@100mslive/react-sdk 0.4.3 → 0.4.4

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 (67) hide show
  1. package/dist/hooks/types.d.ts +6 -0
  2. package/dist/hooks/useAVToggle.d.ts +24 -0
  3. package/dist/hooks/useAVToggle.js +1 -1
  4. package/dist/hooks/useAVToggle.js.map +1 -1
  5. package/dist/hooks/useAudioLevelStyles.d.ts +15 -0
  6. package/dist/hooks/useAudioLevelStyles.js.map +1 -1
  7. package/dist/hooks/useAutoplayError.d.ts +17 -0
  8. package/dist/hooks/useAutoplayError.js +1 -1
  9. package/dist/hooks/useAutoplayError.js.map +1 -1
  10. package/dist/hooks/useCustomEvent.d.ts +58 -0
  11. package/dist/hooks/useCustomEvent.js +1 -1
  12. package/dist/hooks/useCustomEvent.js.map +1 -1
  13. package/dist/hooks/useDevices.d.ts +40 -0
  14. package/dist/hooks/useDevices.js +1 -1
  15. package/dist/hooks/useDevices.js.map +1 -1
  16. package/dist/hooks/useParticipantList.d.ts +13 -0
  17. package/dist/hooks/useParticipantList.js.map +1 -1
  18. package/dist/hooks/useParticipants.d.ts +42 -0
  19. package/dist/hooks/useParticipants.js +1 -1
  20. package/dist/hooks/useParticipants.js.map +1 -1
  21. package/dist/hooks/usePreviewJoin.d.ts +58 -0
  22. package/dist/hooks/usePreviewJoin.js +1 -1
  23. package/dist/hooks/usePreviewJoin.js.map +1 -1
  24. package/dist/hooks/useRecordingStreaming.d.ts +10 -0
  25. package/dist/hooks/useRecordingStreaming.js.map +1 -1
  26. package/dist/hooks/useRemoteAVToggle.d.ts +36 -0
  27. package/dist/hooks/useRemoteAVToggle.js +1 -1
  28. package/dist/hooks/useRemoteAVToggle.js.map +1 -1
  29. package/dist/hooks/useScreenShare.d.ts +40 -0
  30. package/dist/hooks/useScreenShare.js +1 -1
  31. package/dist/hooks/useScreenShare.js.map +1 -1
  32. package/dist/hooks/useVideo.d.ts +27 -0
  33. package/dist/hooks/useVideo.js +1 -1
  34. package/dist/hooks/useVideo.js.map +1 -1
  35. package/dist/hooks/useVideoList.d.ts +68 -0
  36. package/dist/hooks/useVideoList.js.map +1 -1
  37. package/dist/index.cjs.js +1 -1
  38. package/dist/index.cjs.js.map +1 -1
  39. package/dist/index.d.ts +29 -0
  40. package/dist/node_modules/tslib/tslib.es6.js +2 -0
  41. package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
  42. package/dist/{node_modules → packages/react-sdk/node_modules}/zustand/esm/shallow.js +0 -0
  43. package/dist/packages/react-sdk/node_modules/zustand/esm/shallow.js.map +1 -0
  44. package/dist/primitives/HmsRoomProvider.d.ts +49 -0
  45. package/dist/primitives/HmsRoomProvider.js +1 -1
  46. package/dist/primitives/HmsRoomProvider.js.map +1 -1
  47. package/dist/primitives/store.d.ts +15 -0
  48. package/dist/primitives/store.js +1 -1
  49. package/dist/primitives/store.js.map +1 -1
  50. package/dist/primitives/types.d.ts +5 -0
  51. package/dist/utils/commons.d.ts +7 -0
  52. package/dist/utils/commons.js.map +1 -1
  53. package/dist/utils/groupBy.d.ts +15 -0
  54. package/dist/utils/groupBy.js.map +1 -1
  55. package/dist/utils/isBrowser.d.ts +1 -0
  56. package/dist/utils/isBrowser.js.map +1 -1
  57. package/dist/utils/layout.d.ts +116 -0
  58. package/dist/utils/layout.js +1 -1
  59. package/dist/utils/layout.js.map +1 -1
  60. package/dist/utils/logger.d.ts +17 -0
  61. package/dist/utils/logger.js +1 -1
  62. package/dist/utils/logger.js.map +1 -1
  63. package/package.json +3 -4
  64. package/src/primitives/HmsRoomProvider.ts +1 -2
  65. package/dist/node_modules/zustand/esm/shallow.js.map +0 -1
  66. package/dist/package.json.js +0 -2
  67. package/dist/package.json.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ /**
2
+ * use this to control how errors are handled within a function exposed by a hook. By default this
3
+ * only logs the error to the console, and can be overridden for any other behaviour. For e.g.
4
+ * `(err) => throw err;` will ensure that any error is thrown back to the caller when the function is called.
5
+ */
6
+ export declare type hooksErrHandler = (err: Error, method?: string) => void;
@@ -0,0 +1,24 @@
1
+ import { hooksErrHandler } from '../hooks/types';
2
+ export interface useAVToggleResult {
3
+ /**
4
+ * true if unmuted and vice versa
5
+ */
6
+ isLocalAudioEnabled: boolean;
7
+ isLocalVideoEnabled: boolean;
8
+ /**
9
+ * use this function to toggle audio state, the function will only be present if the user
10
+ * has permission to unmute audio
11
+ */
12
+ toggleAudio?: () => void;
13
+ /**
14
+ * use this function to toggle video state, the function will only be present if the user
15
+ * has permission to unmute video
16
+ */
17
+ toggleVideo?: () => void;
18
+ }
19
+ /**
20
+ * Use this hook to implement mute/unmute for audio and video.
21
+ * isAllowedToPublish can be used to decide whether to show the toggle buttons in the UI.
22
+ * @param handleError to handle any error during toggle of audio/video
23
+ */
24
+ export declare const useAVToggle: (handleError?: hooksErrHandler) => useAVToggleResult;
@@ -1,2 +1,2 @@
1
- import{selectIsLocalAudioEnabled as o,selectIsLocalVideoEnabled as i,selectIsAllowedToPublish as t}from"@100mslive/hms-video-store";import{useCallback as e}from"react";import{useHMSStore as d,useHMSActions as a}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as l}from"../utils/commons.js";const r=(r=l)=>{const s=d(o),m=d(i),c=d(t),n=a(),u=e((async()=>{try{await n.setLocalAudioEnabled(!s)}catch(o){r(o,"toggleAudio")}}),[n,s,r]),v=e((async()=>{try{await n.setLocalVideoEnabled(!m)}catch(o){r(o,"toggleVideo")}}),[n,m,r]);return{isLocalAudioEnabled:s,isLocalVideoEnabled:m,toggleAudio:(null==c?void 0:c.audio)?u:void 0,toggleVideo:(null==c?void 0:c.video)?v:void 0}};export{r as useAVToggle};
1
+ import{__awaiter as o}from"../node_modules/tslib/tslib.es6.js";import{selectIsLocalAudioEnabled as i,selectIsLocalVideoEnabled as d,selectIsAllowedToPublish as e}from"@100mslive/hms-video-store";import{useCallback as t}from"react";import{useHMSStore as l,useHMSActions as r}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as s}from"../utils/commons.js";const m=(m=s)=>{const n=l(i),v=l(d),c=l(e),a=r(),u=t((()=>o(void 0,void 0,void 0,(function*(){try{yield a.setLocalAudioEnabled(!n)}catch(o){m(o,"toggleAudio")}}))),[a,n,m]),g=t((()=>o(void 0,void 0,void 0,(function*(){try{yield a.setLocalVideoEnabled(!v)}catch(o){m(o,"toggleVideo")}}))),[a,v,m]);return{isLocalAudioEnabled:n,isLocalVideoEnabled:v,toggleAudio:(null==c?void 0:c.audio)?u:void 0,toggleVideo:(null==c?void 0:c.video)?g:void 0}};export{m as useAVToggle};
2
2
  //# sourceMappingURL=useAVToggle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAVToggle.js","sources":["../../src/hooks/useAVToggle.ts"],"sourcesContent":["import {\n selectIsAllowedToPublish,\n selectIsLocalAudioEnabled,\n selectIsLocalVideoEnabled,\n} from '@100mslive/hms-video-store';\nimport { useCallback } from 'react';\nimport { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';\nimport { logErrorHandler } from '../utils/commons';\nimport { hooksErrHandler } from '../hooks/types';\n\nexport interface useAVToggleResult {\n /**\n * true if unmuted and vice versa\n */\n isLocalAudioEnabled: boolean;\n isLocalVideoEnabled: boolean;\n /**\n * use this function to toggle audio state, the function will only be present if the user\n * has permission to unmute audio\n */\n toggleAudio?: () => void;\n /**\n * use this function to toggle video state, the function will only be present if the user\n * has permission to unmute video\n */\n toggleVideo?: () => void;\n}\n\n/**\n * Use this hook to implement mute/unmute for audio and video.\n * isAllowedToPublish can be used to decide whether to show the toggle buttons in the UI.\n * @param handleError to handle any error during toggle of audio/video\n */\nexport const useAVToggle = (handleError: hooksErrHandler = logErrorHandler): useAVToggleResult => {\n const isLocalAudioEnabled = useHMSStore(selectIsLocalAudioEnabled);\n const isLocalVideoEnabled = useHMSStore(selectIsLocalVideoEnabled);\n const isAllowedToPublish = useHMSStore(selectIsAllowedToPublish);\n const actions = useHMSActions();\n\n const toggleAudio = useCallback(async () => {\n try {\n await actions.setLocalAudioEnabled(!isLocalAudioEnabled);\n } catch (err) {\n handleError(err as Error, 'toggleAudio');\n }\n }, [actions, isLocalAudioEnabled, handleError]);\n\n const toggleVideo = useCallback(async () => {\n try {\n await actions.setLocalVideoEnabled(!isLocalVideoEnabled);\n } catch (err) {\n handleError(err as Error, 'toggleVideo');\n }\n }, [actions, isLocalVideoEnabled, handleError]);\n\n return {\n isLocalAudioEnabled,\n isLocalVideoEnabled,\n toggleAudio: isAllowedToPublish?.audio ? toggleAudio : undefined,\n toggleVideo: isAllowedToPublish?.video ? toggleVideo : undefined,\n };\n};\n"],"names":["useAVToggle","handleError","logErrorHandler","isLocalAudioEnabled","useHMSStore","selectIsLocalAudioEnabled","isLocalVideoEnabled","selectIsLocalVideoEnabled","isAllowedToPublish","selectIsAllowedToPublish","actions","useHMSActions","toggleAudio","useCallback","async","setLocalAudioEnabled","err","toggleVideo","setLocalVideoEnabled","audio","video"],"mappings":"gTAiCa,MAAAA,EAAc,CAACC,EAA+BC,KACzD,MAAMC,EAAsBC,EAAYC,GAClCC,EAAsBF,EAAYG,GAClCC,EAAqBJ,EAAYK,GACjCC,EAAUC,IAEVC,EAAcC,GAAYC,UAC1B,UACIJ,EAAQK,sBAAsBZ,EAEV,CAFU,MAC7Ba,GACPf,EAAYe,EAAc,cAAA,IAE3B,CAACN,EAASP,EAAqBF,IAE5BgB,EAAcJ,GAAYC,UAC1B,UACIJ,EAAQQ,sBAAsBZ,EAEV,CAFU,MAC7BU,GACPf,EAAYe,EAAc,cAAA,IAE3B,CAACN,EAASJ,EAAqBL,IAE3B,MAAA,CACLE,sBACAG,sBACAM,aAAiC,MAAAJ,OAAA,EAAAA,EAAAW,OAAQP,OAAc,EACvDK,aAAiC,MAAAT,OAAA,EAAAA,EAAAY,OAAQH,OAAc,EAAA"}
1
+ {"version":3,"file":"useAVToggle.js","sources":["../../src/hooks/useAVToggle.ts"],"sourcesContent":[null],"names":["useAVToggle","handleError","logErrorHandler","isLocalAudioEnabled","useHMSStore","selectIsLocalAudioEnabled","isLocalVideoEnabled","selectIsLocalVideoEnabled","isAllowedToPublish","selectIsAllowedToPublish","actions","useHMSActions","toggleAudio","useCallback","__awaiter","setLocalAudioEnabled","err","toggleVideo","setLocalVideoEnabled","audio","video"],"mappings":"+WAiCa,MAAAA,EAAc,CAACC,EAA+BC,KACzD,MAAMC,EAAsBC,EAAYC,GAClCC,EAAsBF,EAAYG,GAClCC,EAAqBJ,EAAYK,GACjCC,EAAUC,IAEVC,EAAcC,GAAY,IAAWC,OAAA,OAAA,OAAA,GAAA,YACrC,UACIJ,EAAQK,sBAAsBZ,EAEV,CAFU,MAC7Ba,GACPf,EAAYe,EAAc,cAAA,CAE3B,KAAA,CAACN,EAASP,EAAqBF,IAE5BgB,EAAcJ,GAAY,IAAWC,OAAA,OAAA,OAAA,GAAA,YACrC,UACIJ,EAAQQ,sBAAsBZ,EAEV,CAFU,MAC7BU,GACPf,EAAYe,EAAc,cAAA,CAE3B,KAAA,CAACN,EAASJ,EAAqBL,IAE3B,MAAA,CACLE,sBACAG,sBACAM,4BAAaJ,EAAoBW,OAAQP,OAAc,EACvDK,4BAAaT,EAAoBY,OAAQH,OAAc,EAAA"}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ /**
3
+ * This hook can be used to apply css properties on an element based on the current audio level for the passed in track.
4
+ * It doesn't return the audio level as it's optimised for performance. As audio level could be changing frequently we
5
+ * want to minimise the number of components an audio level change causes to re render.
6
+ * An e.g. use of this hook will be to apply box-shadow on parent tile based on audio level.
7
+ * @param trackId is the audio track id for which audio level needs to be used
8
+ * @param getStyle is a function which can take in current audio level and return the style to apply for the ref
9
+ * @param ref is the ref of the element on which you want the css to apply
10
+ */
11
+ export declare function useAudioLevelStyles({ trackId, getStyle, ref, }: {
12
+ trackId?: string;
13
+ getStyle: (level: number) => Record<string, string>;
14
+ ref: React.RefObject<any>;
15
+ }): void;
@@ -1 +1 @@
1
- {"version":3,"file":"useAudioLevelStyles.js","sources":["../../src/hooks/useAudioLevelStyles.ts"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { selectTrackAudioByID } from '@100mslive/hms-video-store';\nimport { useHMSVanillaStore } from '../primitives/HmsRoomProvider';\n\n/**\n * This hook can be used to apply css properties on an element based on the current audio level for the passed in track.\n * It doesn't return the audio level as it's optimised for performance. As audio level could be changing frequently we\n * want to minimise the number of components an audio level change causes to re render.\n * An e.g. use of this hook will be to apply box-shadow on parent tile based on audio level.\n * @param trackId is the audio track id for which audio level needs to be used\n * @param getStyle is a function which can take in current audio level and return the style to apply for the ref\n * @param ref is the ref of the element on which you want the css to apply\n */\nexport function useAudioLevelStyles({\n trackId,\n getStyle,\n ref,\n}: {\n trackId?: string;\n getStyle: (level: number) => Record<string, string>;\n ref: React.RefObject<any>;\n}) {\n const store = useHMSVanillaStore();\n useEffect(\n () =>\n store.subscribe(level => {\n if (!ref.current) {\n return;\n }\n const styles = getStyle(level);\n for (const key in styles) {\n ref.current.style[key] = styles[key];\n }\n }, selectTrackAudioByID(trackId)),\n [getStyle, ref, store, trackId],\n );\n}\n"],"names":["useAudioLevelStyles","trackId","getStyle","ref","store","useHMSVanillaStore","useEffect","subscribe","level","current","styles","key","style","selectTrackAudioByID"],"mappings":"0KAaO,SAA6BA,GAAAC,QAClCA,EAAAC,SACAA,EAAAC,IACAA,IAMA,MAAMC,EAAQC,IAEZC,GAAA,IACEF,EAAMG,WAAmBC,IACnB,IAACL,EAAIM,QACP,OAEF,MAAMC,EAASR,EAASM,GACxB,IAAA,MAAWG,KAAOD,EACZP,EAAAM,QAAQG,MAAMD,GAAOD,EAAOC,EAAA,GAEjCE,EAAqBZ,KAC1B,CAACC,EAAUC,EAAKC,EAAOH,GAAA"}
1
+ {"version":3,"file":"useAudioLevelStyles.js","sources":["../../src/hooks/useAudioLevelStyles.ts"],"sourcesContent":[null],"names":["useAudioLevelStyles","trackId","getStyle","ref","store","useHMSVanillaStore","useEffect","subscribe","level","current","styles","key","style","selectTrackAudioByID"],"mappings":"0KAaM,SAA8BA,GAAAC,QAClCA,EACAC,SAAAA,EAAAC,IACAA,IAMA,MAAMC,EAAQC,IAEZC,GAAA,IACEF,EAAMG,WAAkBC,IAClB,IAACL,EAAIM,QACP,OAEF,MAAMC,EAASR,EAASM,GACxB,IAAA,MAAWG,KAAOD,EACZP,EAAAM,QAAQG,MAAMD,GAAOD,EAAOC,EAAA,GAEjCE,EAAqBZ,KAC1B,CAACC,EAAUC,EAAKC,EAAOH,GAAA"}
@@ -0,0 +1,17 @@
1
+ export interface useAutoplayErrorResult {
2
+ error: string;
3
+ /**
4
+ * call this method on a UI element click to unblock the blocked audio autoplay.
5
+ */
6
+ unblockAudio: () => Promise<void>;
7
+ /**
8
+ * Call this method to reset(hide) the UI that is rendered when there was an error
9
+ */
10
+ resetError: () => void;
11
+ }
12
+ /**
13
+ * Use this hook to show a UI(modal or a toast) when autoplay is blocked by browser and allow the user to
14
+ * unblock the browser autoplay block
15
+ * @returns {useAutoplayErrorResult}
16
+ */
17
+ export declare const useAutoplayError: () => useAutoplayErrorResult;
@@ -1,2 +1,2 @@
1
- import{useState as o,useCallback as r,useEffect as e}from"react";import{HMSNotificationTypes as i}from"@100mslive/hms-video-store";import{useHMSNotifications as t,useHMSActions as m}from"../primitives/HmsRoomProvider.js";const s=()=>{const s=t(i.ERROR),[a,d]=o(""),n=m(),c=r((async()=>{await n.unblockAudio()}),[n]);return e((()=>{3008===(null==s?void 0:s.data.code)&&d(null==s?void 0:s.data.message)}),[s]),{error:a,unblockAudio:c,resetError:()=>d("")}};export{s as useAutoplayError};
1
+ import{__awaiter as o}from"../node_modules/tslib/tslib.es6.js";import{useState as r,useCallback as i,useEffect as e}from"react";import{HMSNotificationTypes as t}from"@100mslive/hms-video-store";import{useHMSNotifications as s,useHMSActions as d}from"../primitives/HmsRoomProvider.js";const m=()=>{const m=s(t.ERROR),[l,n]=r(""),u=d(),v=i((()=>o(void 0,void 0,void 0,(function*(){yield u.unblockAudio()}))),[u]);return e((()=>{3008===(null==m?void 0:m.data.code)&&n(null==m?void 0:m.data.message)}),[m]),{error:l,unblockAudio:v,resetError:()=>n("")}};export{m as useAutoplayError};
2
2
  //# sourceMappingURL=useAutoplayError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoplayError.js","sources":["../../src/hooks/useAutoplayError.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { HMSNotificationTypes } from '@100mslive/hms-video-store';\nimport { useHMSActions, useHMSNotifications } from '../primitives/HmsRoomProvider';\n\nexport interface useAutoplayErrorResult {\n /*\n * Autoplay error message\n */\n error: string;\n /**\n * call this method on a UI element click to unblock the blocked audio autoplay.\n */\n unblockAudio: () => Promise<void>;\n /**\n * Call this method to reset(hide) the UI that is rendered when there was an error\n */\n resetError: () => void;\n}\n\n/**\n * Use this hook to show a UI(modal or a toast) when autoplay is blocked by browser and allow the user to\n * unblock the browser autoplay block\n * @returns {useAutoplayErrorResult}\n */\nexport const useAutoplayError = (): useAutoplayErrorResult => {\n const notification = useHMSNotifications(HMSNotificationTypes.ERROR);\n const [error, setError] = useState('');\n const actions = useHMSActions();\n\n const unblockAudio = useCallback(async () => {\n await actions.unblockAudio();\n }, [actions]);\n\n useEffect(() => {\n if (notification?.data.code === 3008) {\n setError(notification?.data.message);\n }\n }, [notification]);\n\n return { error, unblockAudio, resetError: () => setError('') };\n};\n"],"names":["useAutoplayError","notification","useHMSNotifications","HMSNotificationTypes","ERROR","error","setError","useState","actions","useHMSActions","unblockAudio","useCallback","async","useEffect","data","code","message","resetError"],"mappings":"6NAwBO,MAAMA,EAAmB,KACxB,MAAAC,EAAeC,EAAoBC,EAAqBC,QACvDC,EAAOC,GAAYC,EAAS,IAC7BC,EAAUC,IAEVC,EAAeC,GAAYC,gBACzBJ,EAAQE,cAAA,GACb,CAACF,IAQJ,OANAK,GAAU,KACwB,QAA5B,MAAAZ,OAAA,EAAAA,EAAca,KAAKC,OACrBT,QAASL,WAAca,KAAKE,QAAA,GAE7B,CAACf,IAEG,CAAEI,QAAOK,eAAcO,WAAY,IAAMX,EAAS,IAAA"}
1
+ {"version":3,"file":"useAutoplayError.js","sources":["../../src/hooks/useAutoplayError.ts"],"sourcesContent":[null],"names":["useAutoplayError","notification","useHMSNotifications","HMSNotificationTypes","ERROR","error","setError","useState","actions","useHMSActions","unblockAudio","useCallback","__awaiter","useEffect","data","code","message","resetError"],"mappings":"4RAwBO,MAAMA,EAAmB,KACxB,MAAAC,EAAeC,EAAoBC,EAAqBC,QACvDC,EAAOC,GAAYC,EAAS,IAC7BC,EAAUC,IAEVC,EAAeC,GAAY,IAAWC,OAAA,OAAA,OAAA,GAAA,kBACpCJ,EAAQE,cAAA,KACb,CAACF,IAQJ,OANAK,GAAU,KACwB,QAA5BZ,aAAA,EAAAA,EAAca,KAAKC,OACrBT,EAASL,aAAY,EAAZA,EAAca,KAAKE,QAAA,GAE7B,CAACf,IAEG,CAAEI,QAAOK,eAAcO,WAAY,IAAMX,EAAS,IAAA"}
@@ -0,0 +1,58 @@
1
+ import { HMSPeerID, HMSRoleName } from '@100mslive/hms-video-store';
2
+ import { hooksErrHandler } from './types';
3
+ export interface useCustomEventInput<T> {
4
+ /**
5
+ * type of the event, e.g. MODERATOR_EVENT, EMOJI_REACTIONS etc.
6
+ */
7
+ type: string;
8
+ /**
9
+ * the handler function for when the custom event comes. It's recommended
10
+ * to use `useCallback` for the function passed in here for performance
11
+ * reasons.
12
+ * The callback is optional in case you want to decouple sending event and
13
+ * handling event in the UI.
14
+ */
15
+ onEvent?: (data: T) => void;
16
+ /**
17
+ * flag to treat event payload as json.
18
+ * If true, the payload will be stringified before sending and
19
+ * parsed before calling the onEvent handler function.
20
+ *
21
+ * Set it to `false` if you want to send/receive only string messages
22
+ *
23
+ * Set it to `true` if you want to send/receive objects
24
+ *
25
+ * default value is true
26
+ */
27
+ json?: boolean;
28
+ /**
29
+ * function to handle errors happening during sending the event
30
+ */
31
+ handleError?: hooksErrHandler;
32
+ }
33
+ export interface EventReceiver {
34
+ peerId?: HMSPeerID;
35
+ roleNames?: HMSRoleName[];
36
+ }
37
+ export interface useCustomEventResult<T> {
38
+ /**
39
+ * sends the event data to others in the room who will receive it in onEvent
40
+ *
41
+ * @example to send message to peers of specific roles
42
+ * ```js
43
+ * sendEvent(data, {roleNames: ['host','guest']})
44
+ * ```
45
+ *
46
+ * @example to send message to single peer
47
+ * ```js
48
+ * sendEvent(data, {peerId})
49
+ * ```
50
+ */
51
+ sendEvent: (data: T, receiver?: EventReceiver) => void;
52
+ }
53
+ /**
54
+ * A generic function to implement [custom events](https://www.100ms.live/docs/javascript/v2/features/chat#custom-events) in your UI.
55
+ * The data to be sent to remote is expected to be a serializable JSON. The serialization
56
+ * and deserialization is taken care of by the hook.
57
+ */
58
+ export declare const useCustomEvent: <T>({ type, json, onEvent, handleError, }: useCustomEventInput<T>) => useCustomEventResult<T>;
@@ -1,2 +1,2 @@
1
- import{useHMSActions as e,useHMSVanillaNotifications as s}from"../primitives/HmsRoomProvider.js";import{useEffect as r,useCallback as t}from"react";import{HMSNotificationTypes as o}from"@100mslive/hms-video-store";import{logErrorHandler as n}from"../utils/commons.js";const a=({type:a,json:i=!0,onEvent:m,handleError:c=n})=>{const d=e(),l=s();r((()=>{d.ignoreMessageTypes([a])}),[d,a]),r((()=>{if(!l)return;return l.onNotification((e=>{const s=e.data;if(s&&s.type===a)try{const e=i?JSON.parse(s.message):s.message;null==m||m(e)}catch(e){c(e,"handleCustomEvent")}}),o.NEW_MESSAGE)}),[l,a,i,m,c]);return{sendEvent:t((async(e,s)=>{try{const r=((e,s)=>s?JSON.stringify(e||""):e)(e,i);s&&Array.isArray(null==s?void 0:s.roleNames)?await d.sendGroupMessage(r,s.roleNames,a):"string"==typeof(null==s?void 0:s.peerId)?await d.sendDirectMessage(r,s.peerId,a):await d.sendBroadcastMessage(r,a),null==m||m(e)}catch(e){c(e,"sendCustomEvent")}}),[d,c,m,a,i])}};export{a as useCustomEvent};
1
+ import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{useHMSActions as s,useHMSVanillaNotifications as o}from"../primitives/HmsRoomProvider.js";import{useEffect as r,useCallback as t}from"react";import{HMSNotificationTypes as i}from"@100mslive/hms-video-store";import{logErrorHandler as n}from"../utils/commons.js";const m=({type:m,json:d=!0,onEvent:a,handleError:l=n})=>{const c=s(),p=o();r((()=>{c.ignoreMessageTypes([m])}),[c,m]),r((()=>{if(!p)return;return p.onNotification((e=>{const s=e.data;if(s&&s.type===m)try{const e=d?JSON.parse(s.message):s.message;null==a||a(e)}catch(e){l(e,"handleCustomEvent")}}),i.NEW_MESSAGE)}),[p,m,d,a,l]);return{sendEvent:t(((s,o)=>e(void 0,void 0,void 0,(function*(){try{const e=((e,s)=>s?JSON.stringify(e||""):e)(s,d);o&&Array.isArray(null==o?void 0:o.roleNames)?yield c.sendGroupMessage(e,o.roleNames,m):"string"==typeof(null==o?void 0:o.peerId)?yield c.sendDirectMessage(e,o.peerId,m):yield c.sendBroadcastMessage(e,m),null==a||a(s)}catch(e){l(e,"sendCustomEvent")}}))),[c,l,a,m,d])}};export{m as useCustomEvent};
2
2
  //# sourceMappingURL=useCustomEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCustomEvent.js","sources":["../../src/hooks/useCustomEvent.ts"],"sourcesContent":["import { useHMSActions, useHMSVanillaNotifications } from '../primitives/HmsRoomProvider';\nimport { useCallback, useEffect } from 'react';\nimport { HMSNotificationTypes, HMSPeerID, HMSRoleName } from '@100mslive/hms-video-store';\nimport { hooksErrHandler } from './types';\nimport { logErrorHandler } from '../utils/commons';\n\nexport interface useCustomEventInput<T> {\n /**\n * type of the event, e.g. MODERATOR_EVENT, EMOJI_REACTIONS etc.\n */\n type: string;\n /**\n * the handler function for when the custom event comes. It's recommended\n * to use `useCallback` for the function passed in here for performance\n * reasons.\n * The callback is optional in case you want to decouple sending event and\n * handling event in the UI.\n */\n onEvent?: (data: T) => void;\n /**\n * flag to treat event payload as json.\n * If true, the payload will be stringified before sending and\n * parsed before calling the onEvent handler function.\n *\n * Set it to `false` if you want to send/receive only string messages\n *\n * Set it to `true` if you want to send/receive objects\n *\n * default value is true\n */\n json?: boolean;\n /**\n * function to handle errors happening during sending the event\n */\n handleError?: hooksErrHandler;\n}\n\nexport interface EventReceiver {\n peerId?: HMSPeerID;\n roleNames?: HMSRoleName[];\n}\n\nexport interface useCustomEventResult<T> {\n /**\n * sends the event data to others in the room who will receive it in onEvent\n *\n * @example to send message to peers of specific roles\n * ```js\n * sendEvent(data, {roleNames: ['host','guest']})\n * ```\n *\n * @example to send message to single peer\n * ```js\n * sendEvent(data, {peerId})\n * ```\n */\n sendEvent: (data: T, receiver?: EventReceiver) => void;\n}\n\nconst stringifyData = <T>(data: T, json: boolean) => (json ? JSON.stringify(data || '') : (data as unknown as string));\n\n/**\n * A generic function to implement [custom events](https://www.100ms.live/docs/javascript/v2/features/chat#custom-events) in your UI.\n * The data to be sent to remote is expected to be a serializable JSON. The serialization\n * and deserialization is taken care of by the hook.\n */\nexport const useCustomEvent = <T>({\n type,\n json = true,\n onEvent,\n handleError = logErrorHandler,\n}: useCustomEventInput<T>): useCustomEventResult<T> => {\n const actions = useHMSActions();\n const notifications = useHMSVanillaNotifications();\n\n useEffect(() => {\n // we don't want these messages to be stored in store reserving that for chat messages\n actions.ignoreMessageTypes([type]);\n }, [actions, type]);\n\n // this is to handle messages from remote peers\n useEffect(() => {\n if (!notifications) {\n return;\n }\n const unsubscribe = notifications.onNotification(notification => {\n const msg = notification.data;\n if (msg && msg.type === type) {\n try {\n const data = json ? JSON.parse(msg.message) : msg.message;\n onEvent?.(data as T);\n } catch (err) {\n handleError(err as Error, 'handleCustomEvent');\n }\n }\n }, HMSNotificationTypes.NEW_MESSAGE);\n return unsubscribe;\n }, [notifications, type, json, onEvent, handleError]);\n\n // this is to send message to remote peers, peers of specific role or single peer, and call onEvent\n const sendEvent = useCallback(\n async (data: T, receiver?: EventReceiver) => {\n try {\n const dataStr = stringifyData<T>(data, json);\n if (receiver && Array.isArray(receiver?.roleNames)) {\n await actions.sendGroupMessage(dataStr, receiver.roleNames, type);\n } else if (typeof receiver?.peerId === 'string') {\n await actions.sendDirectMessage(dataStr, receiver.peerId, type);\n } else {\n await actions.sendBroadcastMessage(dataStr, type);\n }\n onEvent?.(data);\n } catch (err) {\n handleError(err as Error, 'sendCustomEvent');\n }\n },\n [actions, handleError, onEvent, type, json],\n );\n\n return { sendEvent };\n};\n"],"names":["useCustomEvent","type","json","onEvent","handleError","logErrorHandler","actions","useHMSActions","notifications","useHMSVanillaNotifications","useEffect","ignoreMessageTypes","onNotification","notification","msg","data","JSON","parse","message","err","HMSNotificationTypes","NEW_MESSAGE","sendEvent","useCallback","async","receiver","dataStr","stringify","stringifyData","Array","isArray","roleNames","sendGroupMessage","peerId","sendDirectMessage","sendBroadcastMessage"],"mappings":"4QA2DA,MAOaA,EAAiB,EAC5BC,OACAC,QAAO,EACPC,UACAC,cAAcC,MAEd,MAAMC,EAAUC,IACVC,EAAgBC,IAEtBC,GAAU,KAERJ,EAAQK,mBAAmB,CAACV,GAAA,GAC3B,CAACK,EAASL,IAGbS,GAAU,KACR,IAAKF,EACH,OAaK,OAXaA,EAAcI,gBAA+BC,IAC/D,MAAMC,EAAMD,EAAaE,KACrB,GAAAD,GAAOA,EAAIb,OAASA,EAClB,IACF,MAAMc,EAAOb,EAAOc,KAAKC,MAAMH,EAAII,SAAWJ,EAAII,QACxC,MAAAf,GAAAA,EAAAY,EAEgB,CAFhB,MACHI,GACPf,EAAYe,EAAc,oBAAA,CAAA,GAG7BC,EAAqBC,YACjB,GACN,CAACb,EAAeP,EAAMC,EAAMC,EAASC,IAsBxC,MAAO,CAAEkB,UAnBSC,GAChBC,MAAOT,EAASU,KACV,IACI,MAAAC,EA5CQ,EAAIX,EAASb,IAAmBA,EAAOc,KAAKW,UAAUZ,GAAQ,IAAOA,EA4CnEa,CAAiBb,EAAMb,GACnCuB,GAAYI,MAAMC,QAAQ,MAAAL,OAAA,EAAAA,EAAUM,iBAChCzB,EAAQ0B,iBAAiBN,EAASD,EAASM,UAAW9B,GACvB,iBAAX,MAAAwB,OAAA,EAAAA,EAAAQ,cACpB3B,EAAQ4B,kBAAkBR,EAASD,EAASQ,OAAQhC,SAEpDK,EAAQ6B,qBAAqBT,EAASzB,GAEpC,MAAAE,GAAAA,EAAAY,EAEgB,CAFhB,MACHI,GACPf,EAAYe,EAAc,kBAAA,IAG9B,CAACb,EAASF,EAAaD,EAASF,EAAMC,IAG/B"}
1
+ {"version":3,"file":"useCustomEvent.js","sources":["../../src/hooks/useCustomEvent.ts"],"sourcesContent":[null],"names":["useCustomEvent","type","json","onEvent","handleError","logErrorHandler","actions","useHMSActions","notifications","useHMSVanillaNotifications","useEffect","ignoreMessageTypes","onNotification","notification","msg","data","JSON","parse","message","err","HMSNotificationTypes","NEW_MESSAGE","sendEvent","useCallback","receiver","__awaiter","dataStr","stringify","stringifyData","Array","isArray","roleNames","sendGroupMessage","peerId","sendDirectMessage","sendBroadcastMessage"],"mappings":"2UA2DA,MAOaA,EAAiB,EAC5BC,OACAC,QAAO,EACPC,UACAC,cAAcC,MAEd,MAAMC,EAAUC,IACVC,EAAgBC,IAEtBC,GAAU,KAERJ,EAAQK,mBAAmB,CAACV,GAAA,GAC3B,CAACK,EAASL,IAGbS,GAAU,KACR,IAAKF,EACH,OAaK,OAXaA,EAAcI,gBAA8BC,IAC9D,MAAMC,EAAMD,EAAaE,KACrB,GAAAD,GAAOA,EAAIb,OAASA,EAClB,IACF,MAAMc,EAAOb,EAAOc,KAAKC,MAAMH,EAAII,SAAWJ,EAAII,QAClDf,SAAAA,EAAUY,EAEgB,CAFhB,MACHI,GACPf,EAAYe,EAAc,oBAAA,CAAA,GAG7BC,EAAqBC,YACjB,GACN,CAACb,EAAeP,EAAMC,EAAMC,EAASC,IAsBxC,MAAO,CAAEkB,UAnBSC,GAChB,CAAOR,EAASS,IAA4BC,OAAA,OAAA,OAAA,GAAA,YACtC,IACI,MAAAC,EA5CQ,EAAIX,EAASb,IAAmBA,EAAOc,KAAKW,UAAUZ,GAAQ,IAAOA,EA4CnEa,CAAiBb,EAAMb,GACnCsB,GAAYK,MAAMC,QAAQN,aAAA,EAAAA,EAAUO,iBAChCzB,EAAQ0B,iBAAiBN,EAASF,EAASO,UAAW9B,GACvB,8BAAb,EAARuB,EAAUS,cACpB3B,EAAQ4B,kBAAkBR,EAASF,EAASS,OAAQhC,SAEpDK,EAAQ6B,qBAAqBT,EAASzB,GAE9CE,SAAAA,EAAUY,EAEgB,CAFhB,MACHI,GACPf,EAAYe,EAAc,kBAAA,CAAA,KAG9B,CAACb,EAASF,EAAaD,EAASF,EAAMC,IAG/B"}
@@ -0,0 +1,40 @@
1
+ import { hooksErrHandler } from '../hooks/types';
2
+ export declare enum DeviceType {
3
+ videoInput = "videoInput",
4
+ audioInput = "audioInput",
5
+ audioOutput = "audioOutput"
6
+ }
7
+ export declare type DeviceTypeAndInfo<T> = {
8
+ [key in DeviceType]?: T;
9
+ };
10
+ export interface useDevicesResult {
11
+ /**
12
+ * list of all devices by type
13
+ */
14
+ allDevices: DeviceTypeAndInfo<MediaDeviceInfo[]>;
15
+ /**
16
+ * selected device ids for all types
17
+ */
18
+ selectedDeviceIDs: DeviceTypeAndInfo<string>;
19
+ /**
20
+ * function to call to update device
21
+ */
22
+ updateDevice: ({ deviceType, deviceId }: {
23
+ deviceType: DeviceType;
24
+ deviceId: string;
25
+ }) => Promise<void>;
26
+ }
27
+ /**
28
+ * This hook can be used to implement a UI component which allows the user to manually change their
29
+ * audio/video device. It returns the list of all devices as well as the currently selected one. The input
30
+ * devices will be returned based on what the user is allowed to publish, so a audio only user won't get
31
+ * the audioInput field. This can be used to show the UI dropdowns properly.
32
+ *
33
+ * Note:
34
+ * - Browsers give access to the list of devices only if the user has given permission to access them
35
+ * - Changing devices manually work best in combination with remembering the user's selection for the next time, do
36
+ * pass the rememberDeviceSelection flag at time of join for this to happen.
37
+ *
38
+ * @param handleError error handler for any errors during device change
39
+ */
40
+ export declare const useDevices: (handleError?: hooksErrHandler) => useDevicesResult;
@@ -1,2 +1,2 @@
1
- import{selectDevices as t,selectLocalMediaSettings as e,selectIsAllowedToPublish as i}from"@100mslive/hms-video-store";import{useCallback as u}from"react";import{useHMSActions as o,useHMSStore as d}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as a}from"../utils/commons.js";var p,s;(s=p||(p={})).videoInput="videoInput",s.audioInput="audioInput",s.audioOutput="audioOutput";const v=(s=a)=>{const v=o(),c=d(t),n=d(e),I=d(i),r={[p.audioOutput]:n.audioOutputDeviceId},m={[p.audioOutput]:c.audioOutput};I.video&&(m[p.videoInput]=c.videoInput,r[p.videoInput]=n.videoInputDeviceId),I.audio&&(m[p.audioInput]=c.audioInput,r[p.audioInput]=n.audioInputDeviceId);return{allDevices:m,selectedDeviceIDs:r,updateDevice:u((async({deviceType:t,deviceId:e})=>{try{switch(t){case p.audioInput:await v.setAudioSettings({deviceId:e});break;case p.videoInput:await v.setVideoSettings({deviceId:e});break;case p.audioOutput:await v.setAudioOutputDevice(e)}}catch(t){s(t,"updateDevices")}}),[s,v])}};export{p as DeviceType,v as useDevices};
1
+ import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{selectDevices as i,selectLocalMediaSettings as t,selectIsAllowedToPublish as u}from"@100mslive/hms-video-store";import{useCallback as o}from"react";import{useHMSActions as d,useHMSStore as p}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as s}from"../utils/commons.js";var v,a;(a=v||(v={})).videoInput="videoInput",a.audioInput="audioInput",a.audioOutput="audioOutput";const c=(a=s)=>{const c=d(),n=p(i),r=p(t),I=p(u),m={[v.audioOutput]:r.audioOutputDeviceId},l={[v.audioOutput]:n.audioOutput};I.video&&(l[v.videoInput]=n.videoInput,m[v.videoInput]=r.videoInputDeviceId),I.audio&&(l[v.audioInput]=n.audioInput,m[v.audioInput]=r.audioInputDeviceId);return{allDevices:l,selectedDeviceIDs:m,updateDevice:o((({deviceType:i,deviceId:t})=>e(void 0,void 0,void 0,(function*(){try{switch(i){case v.audioInput:yield c.setAudioSettings({deviceId:t});break;case v.videoInput:yield c.setVideoSettings({deviceId:t});break;case v.audioOutput:yield c.setAudioOutputDevice(t)}}catch(e){a(e,"updateDevices")}}))),[a,c])}};export{v as DeviceType,c as useDevices};
2
2
  //# sourceMappingURL=useDevices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDevices.js","sources":["../../src/hooks/useDevices.ts"],"sourcesContent":["import { selectDevices, selectIsAllowedToPublish, selectLocalMediaSettings } from '@100mslive/hms-video-store';\nimport { useCallback } from 'react';\nimport { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';\nimport { logErrorHandler } from '../utils/commons';\nimport { hooksErrHandler } from '../hooks/types';\n\nexport enum DeviceType {\n videoInput = 'videoInput',\n audioInput = 'audioInput',\n audioOutput = 'audioOutput',\n}\n\nexport type DeviceTypeAndInfo<T> = {\n [key in DeviceType]?: T;\n};\n\nexport interface useDevicesResult {\n /**\n * list of all devices by type\n */\n allDevices: DeviceTypeAndInfo<MediaDeviceInfo[]>;\n /**\n * selected device ids for all types\n */\n selectedDeviceIDs: DeviceTypeAndInfo<string>;\n /**\n * function to call to update device\n */\n updateDevice: ({ deviceType, deviceId }: { deviceType: DeviceType; deviceId: string }) => Promise<void>;\n}\n\n/**\n * This hook can be used to implement a UI component which allows the user to manually change their\n * audio/video device. It returns the list of all devices as well as the currently selected one. The input\n * devices will be returned based on what the user is allowed to publish, so a audio only user won't get\n * the audioInput field. This can be used to show the UI dropdowns properly.\n *\n * Note:\n * - Browsers give access to the list of devices only if the user has given permission to access them\n * - Changing devices manually work best in combination with remembering the user's selection for the next time, do\n * pass the rememberDeviceSelection flag at time of join for this to happen.\n *\n * @param handleError error handler for any errors during device change\n */\nexport const useDevices = (handleError: hooksErrHandler = logErrorHandler): useDevicesResult => {\n const actions = useHMSActions();\n const sdkAllDevices: DeviceTypeAndInfo<MediaDeviceInfo[]> = useHMSStore(selectDevices);\n const sdkSelectedDevices = useHMSStore(selectLocalMediaSettings);\n const isAllowedToPublish = useHMSStore(selectIsAllowedToPublish);\n\n const selectedDeviceIDs: DeviceTypeAndInfo<string> = {\n [DeviceType.audioOutput]: sdkSelectedDevices.audioOutputDeviceId,\n };\n const allDevices: DeviceTypeAndInfo<MediaDeviceInfo[]> = {\n [DeviceType.audioOutput]: sdkAllDevices.audioOutput,\n };\n\n if (isAllowedToPublish.video) {\n allDevices[DeviceType.videoInput] = sdkAllDevices.videoInput;\n selectedDeviceIDs[DeviceType.videoInput] = sdkSelectedDevices.videoInputDeviceId;\n }\n if (isAllowedToPublish.audio) {\n allDevices[DeviceType.audioInput] = sdkAllDevices.audioInput;\n selectedDeviceIDs[DeviceType.audioInput] = sdkSelectedDevices.audioInputDeviceId;\n }\n\n const updateDevice = useCallback(\n async ({ deviceType, deviceId }: { deviceType: DeviceType; deviceId: string }) => {\n try {\n switch (deviceType) {\n case DeviceType.audioInput:\n await actions.setAudioSettings({ deviceId });\n break;\n case DeviceType.videoInput:\n await actions.setVideoSettings({ deviceId });\n break;\n case DeviceType.audioOutput:\n await actions.setAudioOutputDevice(deviceId);\n break;\n }\n } catch (err) {\n handleError(err as Error, 'updateDevices');\n }\n },\n [handleError, actions],\n );\n\n return {\n allDevices,\n selectedDeviceIDs,\n updateDevice,\n };\n};\n"],"names":["DeviceType","DeviceType2","useDevices","handleError","logErrorHandler","actions","useHMSActions","sdkAllDevices","useHMSStore","selectDevices","sdkSelectedDevices","selectLocalMediaSettings","isAllowedToPublish","selectIsAllowedToPublish","selectedDeviceIDs","audioOutput","audioOutputDeviceId","allDevices","video","videoInput","videoInputDeviceId","audio","audioInput","audioInputDeviceId","updateDevice","useCallback","async","deviceType","deviceId","setAudioSettings","setVideoSettings","setAudioOutputDevice","err"],"mappings":"mSAMY,IAAAA,EAAAC,KAAAD,IAAAA,EAAA,CAAA,IACG,WAAA,aACAC,EAAA,WAAA,aACCA,EAAA,YAAA,cAmCH,MAAAC,EAAa,CAACC,EAA+BC,KACxD,MAAMC,EAAUC,IACVC,EAAsDC,EAAYC,GAClEC,EAAqBF,EAAYG,GACjCC,EAAqBJ,EAAYK,GAEjCC,EAA+C,CAClD,CAAAd,EAAWe,aAAcL,EAAmBM,qBAEzCC,EAAmD,CACtD,CAAAjB,EAAWe,aAAcR,EAAcQ,aAGtCH,EAAmBM,QACVD,EAAAjB,EAAWmB,YAAcZ,EAAcY,WAChCL,EAAAd,EAAWmB,YAAcT,EAAmBU,oBAE5DR,EAAmBS,QACVJ,EAAAjB,EAAWsB,YAAcf,EAAce,WAChCR,EAAAd,EAAWsB,YAAcZ,EAAmBa,oBAwBzD,MAAA,CACLN,aACAH,oBACAU,aAxBmBC,GACnBC,OAASC,aAAYC,eACf,IACM,OAAAD,GAAA,KACD3B,EAAWsB,iBACRjB,EAAQwB,iBAAiB,CAAED,aACjC,MAAA,KACG5B,EAAWmB,iBACRd,EAAQyB,iBAAiB,CAAEF,aACjC,MAAA,KACG5B,EAAWe,kBACRV,EAAQ0B,qBAAqBH,GAIb,CAHtB,MAEGI,GACP7B,EAAY6B,EAAc,gBAAA,IAG9B,CAAC7B,EAAaE,IAMd"}
1
+ {"version":3,"file":"useDevices.js","sources":["../../src/hooks/useDevices.ts"],"sourcesContent":[null],"names":["DeviceType","DeviceType2","useDevices","handleError","logErrorHandler","actions","useHMSActions","sdkAllDevices","useHMSStore","selectDevices","sdkSelectedDevices","selectLocalMediaSettings","isAllowedToPublish","selectIsAllowedToPublish","selectedDeviceIDs","audioOutput","audioOutputDeviceId","allDevices","video","videoInput","videoInputDeviceId","audio","audioInput","audioInputDeviceId","updateDevice","useCallback","deviceType","deviceId","__awaiter","setAudioSettings","setVideoSettings","setAudioOutputDevice","err"],"mappings":"kWAMY,IAAAA,EAAAC,KAAAD,IAIXA,EAAA,CAAA,IAHC,WAAA,aACAC,EAAA,WAAA,aACAA,EAAA,YAAA,cAmCW,MAAAC,EAAa,CAACC,EAA+BC,KACxD,MAAMC,EAAUC,IACVC,EAAsDC,EAAYC,GAClEC,EAAqBF,EAAYG,GACjCC,EAAqBJ,EAAYK,GAEjCC,EAA+C,CAClD,CAAAd,EAAWe,aAAcL,EAAmBM,qBAEzCC,EAAmD,CACtD,CAAAjB,EAAWe,aAAcR,EAAcQ,aAGtCH,EAAmBM,QACVD,EAAAjB,EAAWmB,YAAcZ,EAAcY,WAChCL,EAAAd,EAAWmB,YAAcT,EAAmBU,oBAE5DR,EAAmBS,QACVJ,EAAAjB,EAAWsB,YAAcf,EAAce,WAChCR,EAAAd,EAAWsB,YAAcZ,EAAmBa,oBAwBzD,MAAA,CACLN,aACAH,oBACAU,aAxBmBC,GACnB,EAASC,aAAYC,cAA4DC,OAAA,OAAA,OAAA,GAAA,YAC3E,IACM,OAAAF,GAAA,KACD1B,EAAWsB,iBACRjB,EAAQwB,iBAAiB,CAAEF,aACjC,MAAA,KACG3B,EAAWmB,iBACRd,EAAQyB,iBAAiB,CAAEH,aACjC,MAAA,KACG3B,EAAWe,kBACRV,EAAQ0B,qBAAqBJ,GAIb,CAHtB,MAEGK,GACP7B,EAAY6B,EAAc,gBAAA,CAAA,KAG9B,CAAC7B,EAAaE,IAMd"}
@@ -0,0 +1,13 @@
1
+ import { HMSPeer, HMSRoleName } from '@100mslive/hms-video-store';
2
+ export interface useParticipantListResult {
3
+ roles: HMSRoleName[];
4
+ participantsByRoles: Record<string, HMSPeer[]>;
5
+ peerCount: number;
6
+ isConnected: boolean;
7
+ }
8
+ export declare const useParticipantList: () => {
9
+ roles: string[];
10
+ participantsByRoles: Record<string, HMSPeer[]>;
11
+ peerCount: number;
12
+ isConnected: boolean | undefined;
13
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"useParticipantList.js","sources":["../../src/hooks/useParticipantList.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n HMSPeer,\n HMSRoleName,\n selectIsConnectedToRoom,\n selectPeerCount,\n selectPeers,\n selectRemotePeers,\n} from '@100mslive/hms-video-store';\nimport { useHMSStore } from '../primitives/HmsRoomProvider';\nimport { groupByRoles } from '../utils/groupBy';\n\nexport interface useParticipantListResult {\n roles: HMSRoleName[];\n participantsByRoles: Record<string, HMSPeer[]>;\n peerCount: number;\n isConnected: boolean;\n}\n\nexport const useParticipantList = () => {\n const isConnected = useHMSStore(selectIsConnectedToRoom);\n const participantList = useHMSStore(isConnected ? selectPeers : selectRemotePeers);\n const peerCount = useHMSStore(selectPeerCount);\n const participantsByRoles = useMemo(() => groupByRoles(participantList), [participantList]);\n const roles = Object.keys(participantsByRoles);\n return { roles, participantsByRoles, peerCount, isConnected };\n};\n"],"names":["useParticipantList","isConnected","useHMSStore","selectIsConnectedToRoom","participantList","selectPeers","selectRemotePeers","peerCount","selectPeerCount","participantsByRoles","useMemo","groupByRoles","roles","Object","keys"],"mappings":"oRAmBO,MAAMA,EAAqB,KAChC,MAAMC,EAAcC,EAAYC,GAC1BC,EAAkBF,EAAYD,EAAcI,EAAcC,GAC1DC,EAAYL,EAAYM,GACxBC,EAAsBC,GAAQ,IAAMC,EAAaP,IAAkB,CAACA,IAEnE,MAAA,CAAEQ,MADKC,OAAOC,KAAKL,GACVA,sBAAqBF,YAAWN,cAAA"}
1
+ {"version":3,"file":"useParticipantList.js","sources":["../../src/hooks/useParticipantList.ts"],"sourcesContent":[null],"names":["useParticipantList","isConnected","useHMSStore","selectIsConnectedToRoom","participantList","selectPeers","selectRemotePeers","peerCount","selectPeerCount","participantsByRoles","useMemo","groupByRoles","roles","Object","keys"],"mappings":"oRAmBO,MAAMA,EAAqB,KAChC,MAAMC,EAAcC,EAAYC,GAC1BC,EAAkBF,EAAYD,EAAcI,EAAcC,GAC1DC,EAAYL,EAAYM,GACxBC,EAAsBC,GAAQ,IAAMC,EAAaP,IAAkB,CAACA,IAEnE,MAAA,CAAEQ,MADKC,OAAOC,KAAKL,GACVA,sBAAqBF,YAAWN,cAAA"}
@@ -0,0 +1,42 @@
1
+ import { HMSPeer, HMSRoleName } from '@100mslive/hms-video-store';
2
+ export interface useParticipantsResult {
3
+ /**
4
+ * list of participants that match the given filters
5
+ */
6
+ participants: HMSPeer[];
7
+ /**
8
+ * Total number of participants in the room
9
+ */
10
+ peerCount: number;
11
+ /**
12
+ * is joined in the room
13
+ */
14
+ isConnected: boolean;
15
+ /**
16
+ * role names with atleast one participant present with that role
17
+ */
18
+ rolesWithParticipants: HMSRoleName[];
19
+ }
20
+ export declare type useParticipantsParams = {
21
+ /** To filter by particular role */
22
+ role: HMSRoleName;
23
+ /**
24
+ * To filter by particular by metadata. only supports { isHandRaised: true } for now
25
+ * @beta
26
+ */
27
+ metadata: Record<string, any>;
28
+ /** To filter by name/role (partial match) */
29
+ search: string;
30
+ };
31
+ /**
32
+ * This can be used to get the total count of participants in the room, participants
33
+ * filtered by role or metadata with isHandRaised or the entire participants if no params are passed
34
+ * @param {useParticipantsParams} params
35
+ * @returns {useParticipantsResult}
36
+ */
37
+ export declare const useParticipants: (params?: useParticipantsParams) => {
38
+ participants: HMSPeer[];
39
+ isConnected: boolean | undefined;
40
+ peerCount: number;
41
+ rolesWithParticipants: (string | undefined)[];
42
+ };
@@ -1,2 +1,2 @@
1
- import{selectIsConnectedToRoom as e,selectPeerCount as r,selectAvailableRoleNames as o,selectPeers as i,selectRemotePeers as t,selectPeerMetadata as s}from"@100mslive/hms-video-store";import{useHMSStore as a,useHMSVanillaStore as l}from"../primitives/HmsRoomProvider.js";const n=n=>{var d;const m=a(e),c=a(r),u=a(o);let v=a(m?i:t);const p=Array.from(new Set(v.map((e=>e.roleName)))),f=l();if((null==(d=null==n?void 0:n.metadata)?void 0:d.isHandRaised)&&(v=v.filter((e=>f.getState(s(e.id)).isHandRaised))),(null==n?void 0:n.role)&&u.includes(n.role)&&(v=v.filter((e=>e.roleName===n.role))),null==n?void 0:n.search){const e=n.search.toLowerCase();v=v.filter((r=>{var o;return(null==(o=r.roleName)?void 0:o.toLowerCase().includes(e))||r.name.toLowerCase().includes(e)}))}return{participants:v,isConnected:m,peerCount:c,rolesWithParticipants:p}};export{n as useParticipants};
1
+ import{selectIsConnectedToRoom as e,selectPeerCount as o,selectAvailableRoleNames as r,selectPeers as i,selectRemotePeers as t,selectPeerMetadata as s}from"@100mslive/hms-video-store";import{useHMSStore as a,useHMSVanillaStore as l}from"../primitives/HmsRoomProvider.js";const n=n=>{var d;const m=a(e),v=a(o),c=a(r);let u=a(m?i:t);const p=Array.from(new Set(u.map((e=>e.roleName)))),f=l();if((null===(d=null==n?void 0:n.metadata)||void 0===d?void 0:d.isHandRaised)&&(u=u.filter((e=>f.getState(s(e.id)).isHandRaised))),(null==n?void 0:n.role)&&c.includes(n.role)&&(u=u.filter((e=>e.roleName===n.role))),null==n?void 0:n.search){const e=n.search.toLowerCase();u=u.filter((o=>{var r;return(null===(r=o.roleName)||void 0===r?void 0:r.toLowerCase().includes(e))||o.name.toLowerCase().includes(e)}))}return{participants:u,isConnected:m,peerCount:v,rolesWithParticipants:p}};export{n as useParticipants};
2
2
  //# sourceMappingURL=useParticipants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useParticipants.js","sources":["../../src/hooks/useParticipants.ts"],"sourcesContent":["import {\n HMSPeer,\n HMSRoleName,\n selectAvailableRoleNames,\n selectIsConnectedToRoom,\n selectPeerCount,\n selectPeerMetadata,\n selectPeers,\n selectRemotePeers,\n} from '@100mslive/hms-video-store';\nimport { useHMSStore, useHMSVanillaStore } from '../primitives/HmsRoomProvider';\n\nexport interface useParticipantsResult {\n /**\n * list of participants that match the given filters\n */\n participants: HMSPeer[];\n /**\n * Total number of participants in the room\n */\n peerCount: number;\n /**\n * is joined in the room\n */\n isConnected: boolean;\n /**\n * role names with atleast one participant present with that role\n */\n rolesWithParticipants: HMSRoleName[];\n}\n\nexport type useParticipantsParams = {\n /** To filter by particular role */\n role: HMSRoleName;\n /**\n * To filter by particular by metadata. only supports { isHandRaised: true } for now\n * @beta\n */\n metadata: Record<string, any>;\n /** To filter by name/role (partial match) */\n search: string;\n};\n\n/**\n * This can be used to get the total count of participants in the room, participants\n * filtered by role or metadata with isHandRaised or the entire participants if no params are passed\n * @param {useParticipantsParams} params\n * @returns {useParticipantsResult}\n */\nexport const useParticipants = (params?: useParticipantsParams) => {\n const isConnected = useHMSStore(selectIsConnectedToRoom);\n const peerCount = useHMSStore(selectPeerCount);\n const availableRoles = useHMSStore(selectAvailableRoleNames);\n let participantList = useHMSStore(isConnected ? selectPeers : selectRemotePeers);\n const rolesWithParticipants = Array.from(new Set(participantList.map(peer => peer.roleName)));\n const vanillaStore = useHMSVanillaStore();\n if (params?.metadata?.isHandRaised) {\n participantList = participantList.filter(peer => {\n return vanillaStore.getState(selectPeerMetadata(peer.id)).isHandRaised;\n });\n }\n if (params?.role && availableRoles.includes(params.role)) {\n participantList = participantList.filter(peer => peer.roleName === params.role);\n }\n if (params?.search) {\n const search = params.search.toLowerCase();\n participantList = participantList.filter(\n peer => peer.roleName?.toLowerCase().includes(search) || peer.name.toLowerCase().includes(search),\n );\n }\n return { participants: participantList, isConnected, peerCount, rolesWithParticipants };\n};\n"],"names":["useParticipants","params","_a","isConnected","useHMSStore","selectIsConnectedToRoom","peerCount","selectPeerCount","availableRoles","selectAvailableRoleNames","participantList","selectPeers","selectRemotePeers","rolesWithParticipants","Array","from","Set","map","peer","roleName","vanillaStore","useHMSVanillaStore","metadata","isHandRaised","filter","getState","selectPeerMetadata","id","role","includes","search","toLowerCase","_a2","name","participants"],"mappings":"+QAiDa,MAAAA,EAAmBC,IAjDhC,IAAAC,EAkDE,MAAMC,EAAcC,EAAYC,GAC1BC,EAAYF,EAAYG,GACxBC,EAAiBJ,EAAYK,GAC/B,IAAAC,EAAkBN,EAAYD,EAAcQ,EAAcC,GACxD,MAAAC,EAAwBC,MAAMC,KAAK,IAAIC,IAAIN,EAAgBO,QAAYC,EAAKC,aAC5EC,EAAeC,IASrB,IARI,OAAAnB,EAAA,MAAAD,OAAA,EAAAA,EAAQqB,eAAR,EAAApB,EAAkBqB,gBACFb,EAAAA,EAAgBc,QAAeN,GACxCE,EAAaK,SAASC,EAAmBR,EAAKS,KAAKJ,iBAGlD,MAAAtB,OAAA,EAAAA,EAAA2B,OAAQpB,EAAeqB,SAAS5B,EAAO2B,QACjDlB,EAAkBA,EAAgBc,QAAeN,GAAAA,EAAKC,WAAalB,EAAO2B,cAExE3B,WAAQ6B,OAAQ,CACZ,MAAAA,EAAS7B,EAAO6B,OAAOC,cACXrB,EAAAA,EAAgBc,QAC3BN,IAnEX,IAAAc,EAmEmB,OAAL,OAAKA,EAAAd,EAAAC,mBAAUY,cAAcF,SAASC,KAAWZ,EAAKe,KAAKF,cAAcF,SAASC,EAAA,GAAA,CAG9F,MAAO,CAAEI,aAAcxB,EAAiBP,cAAaG,YAAWO,wBAAA"}
1
+ {"version":3,"file":"useParticipants.js","sources":["../../src/hooks/useParticipants.ts"],"sourcesContent":[null],"names":["useParticipants","params","isConnected","useHMSStore","selectIsConnectedToRoom","peerCount","selectPeerCount","availableRoles","selectAvailableRoleNames","participantList","selectPeers","selectRemotePeers","rolesWithParticipants","Array","from","Set","map","peer","roleName","vanillaStore","useHMSVanillaStore","_a","metadata","isHandRaised","filter","getState","selectPeerMetadata","id","role","includes","search","toLowerCase","_a2","name","participants"],"mappings":"+QAiDa,MAAAA,EAAmBC,UAC9B,MAAMC,EAAcC,EAAYC,GAC1BC,EAAYF,EAAYG,GACxBC,EAAiBJ,EAAYK,GAC/B,IAAAC,EAAkBN,EAAYD,EAAcQ,EAAcC,GACxD,MAAAC,EAAwBC,MAAMC,KAAK,IAAIC,IAAIN,EAAgBO,QAAYC,EAAKC,aAC5EC,EAAeC,IASrB,IARsB,QAAlBC,EAAApB,aAAM,EAANA,EAAQqB,gBAAU,IAAAD,OAAA,EAAAA,EAAAE,gBACFd,EAAAA,EAAgBe,QAAcP,GACvCE,EAAaM,SAASC,EAAmBT,EAAKU,KAAKJ,iBAG1DtB,aAAM,EAANA,EAAQ2B,OAAQrB,EAAesB,SAAS5B,EAAO2B,QACjDnB,EAAkBA,EAAgBe,QAAeP,GAAAA,EAAKC,WAAajB,EAAO2B,QAExE3B,eAAAA,EAAQ6B,OAAQ,CACZ,MAAAA,EAAS7B,EAAO6B,OAAOC,cACXtB,EAAAA,EAAgBe,QACxBP,IAAA,IAAAe,EAAA,eAAAA,EAAAf,EAAKC,+BAAUa,cAAcF,SAASC,KAAWb,EAAKgB,KAAKF,cAAcF,SAASC,EAAA,GAAA,CAG9F,MAAO,CAAEI,aAAczB,EAAiBP,cAAaG,YAAWO,wBAAA"}
@@ -0,0 +1,58 @@
1
+ import { HMSConfigInitialSettings } from '@100mslive/hms-video-store';
2
+ import { hooksErrHandler } from './types';
3
+ export interface usePreviewInput {
4
+ /**
5
+ * name of user who is joining, this is only required if join is called
6
+ */
7
+ name?: string;
8
+ /**
9
+ * app side authentication token
10
+ */
11
+ token: string;
12
+ /**
13
+ * any extra metadata info for the peer
14
+ */
15
+ metadata?: string;
16
+ /**
17
+ * function to handle errors happening during preview
18
+ */
19
+ handleError?: hooksErrHandler;
20
+ initEndpoint?: string;
21
+ /**
22
+ * initial settings for audio/video and device to be used.
23
+ */
24
+ initialSettings?: HMSConfigInitialSettings;
25
+ /**
26
+ * Enable to get a network quality score while in preview. The score ranges from -1 to 5.
27
+ * -1 when we are not able to connect to 100ms servers within an expected time limit
28
+ * 0 when there is a timeout/failure when measuring the quality
29
+ * 1-5 ranges from poor to good quality.
30
+ */
31
+ captureNetworkQualityInPreview?: boolean;
32
+ }
33
+ export interface usePreviewResult {
34
+ /**
35
+ * enable the join button for the user only when this is true
36
+ */
37
+ enableJoin: boolean;
38
+ /**
39
+ * call this function to join the room
40
+ */
41
+ join: () => Promise<void>;
42
+ /**
43
+ * once the user has joined the room, till leave happens this flag will be true. It can be used
44
+ * to decide to show between preview form and conferencing component/video tiles.
45
+ */
46
+ isConnected: boolean;
47
+ /**
48
+ * call this function to join the room
49
+ */
50
+ preview: () => Promise<void>;
51
+ }
52
+ /**
53
+ * This hook can be used to build a preview UI component, this lets you call preview everytime the passed in
54
+ * token changes. This hook is best used in combination with useDevices for changing devices, useAVToggle for
55
+ * muting/unmuting and useAudioLevelStyles for showing mic audio level to the user.
56
+ * Any device change or mute/unmute will be carried across to join.
57
+ */
58
+ export declare const usePreviewJoin: ({ name, token, metadata, handleError, initEndpoint, initialSettings, captureNetworkQualityInPreview, }: usePreviewInput) => usePreviewResult;
@@ -1,2 +1,2 @@
1
- import{selectRoomState as e,selectIsConnectedToRoom as i,HMSRoomState as t}from"@100mslive/hms-video-store";import{useMemo as r,useCallback as o}from"react";import{useHMSActions as n,useHMSStore as a}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as m}from"../utils/commons.js";const s=({name:s="",token:c,metadata:p,handleError:v=m,initEndpoint:w,initialSettings:l,captureNetworkQualityInPreview:d})=>{const u=n(),f=a(e),y=a(i)||!1,h=f===t.Preview,j=r((()=>({userName:s,authToken:c,metaData:p,rememberDeviceSelection:!0,settings:l,initEndpoint:w,captureNetworkQualityInPreview:d})),[s,c,p,w,l,d]),k=o((async()=>{if(c&&f===t.Disconnected){y&&await u.leave();try{await u.preview(j)}catch(e){v(e,"preview")}}}),[u,v,c,f,j,y]);return{enableJoin:h,join:o((async()=>{if(c)try{await u.join(j)}catch(e){v(e,"join")}}),[u,j,v,c]),isConnected:y,preview:k}};export{s as usePreviewJoin};
1
+ import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{selectRoomState as i,selectIsConnectedToRoom as t,HMSRoomState as o}from"@100mslive/hms-video-store";import{useMemo as r,useCallback as n}from"react";import{useHMSActions as m,useHMSStore as s}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as a}from"../utils/commons.js";const d=({name:d="",token:v,metadata:c,handleError:l=a,initEndpoint:p,initialSettings:u,captureNetworkQualityInPreview:f})=>{const w=m(),y=s(i),j=s(t)||!1,h=y===o.Preview,b=r((()=>({userName:d,authToken:v,metaData:c,rememberDeviceSelection:!0,settings:u,initEndpoint:p,captureNetworkQualityInPreview:f})),[d,v,c,p,u,f]),k=n((()=>e(void 0,void 0,void 0,(function*(){if(v&&y===o.Disconnected){j&&(yield w.leave());try{yield w.preview(b)}catch(e){l(e,"preview")}}}))),[w,l,v,y,b,j]);return{enableJoin:h,join:n((()=>e(void 0,void 0,void 0,(function*(){if(v)try{yield w.join(b)}catch(e){l(e,"join")}}))),[w,b,l,v]),isConnected:j,preview:k}};export{d as usePreviewJoin};
2
2
  //# sourceMappingURL=usePreviewJoin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePreviewJoin.js","sources":["../../src/hooks/usePreviewJoin.ts"],"sourcesContent":["import {\n HMSRoomState,\n selectIsConnectedToRoom,\n selectRoomState,\n HMSConfigInitialSettings,\n} from '@100mslive/hms-video-store';\nimport { useCallback, useMemo } from 'react';\nimport { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';\nimport { hooksErrHandler } from './types';\nimport { logErrorHandler } from '../utils/commons';\nimport { HMSConfig } from '@100mslive/hms-video';\n\nexport interface usePreviewInput {\n /**\n * name of user who is joining, this is only required if join is called\n */\n name?: string;\n /**\n * app side authentication token\n */\n token: string;\n /**\n * any extra metadata info for the peer\n */\n metadata?: string;\n /**\n * function to handle errors happening during preview\n */\n handleError?: hooksErrHandler;\n initEndpoint?: string;\n /**\n * initial settings for audio/video and device to be used.\n */\n initialSettings?: HMSConfigInitialSettings;\n /**\n * Enable to get a network quality score while in preview. The score ranges from -1 to 5.\n * -1 when we are not able to connect to 100ms servers within an expected time limit\n * 0 when there is a timeout/failure when measuring the quality\n * 1-5 ranges from poor to good quality.\n */\n captureNetworkQualityInPreview?: boolean;\n}\n\nexport interface usePreviewResult {\n /**\n * enable the join button for the user only when this is true\n */\n enableJoin: boolean;\n /**\n * call this function to join the room\n */\n join: () => Promise<void>;\n /**\n * once the user has joined the room, till leave happens this flag will be true. It can be used\n * to decide to show between preview form and conferencing component/video tiles.\n */\n isConnected: boolean;\n /**\n * call this function to join the room\n */\n preview: () => Promise<void>;\n}\n\n/**\n * This hook can be used to build a preview UI component, this lets you call preview everytime the passed in\n * token changes. This hook is best used in combination with useDevices for changing devices, useAVToggle for\n * muting/unmuting and useAudioLevelStyles for showing mic audio level to the user.\n * Any device change or mute/unmute will be carried across to join.\n */\nexport const usePreviewJoin = ({\n name = '',\n token,\n metadata,\n handleError = logErrorHandler,\n initEndpoint,\n initialSettings,\n captureNetworkQualityInPreview,\n}: usePreviewInput): usePreviewResult => {\n const actions = useHMSActions();\n const roomState = useHMSStore(selectRoomState);\n const isConnected = useHMSStore(selectIsConnectedToRoom) || false;\n const enableJoin = roomState === HMSRoomState.Preview;\n\n const config: HMSConfig = useMemo(() => {\n return {\n userName: name,\n authToken: token,\n metaData: metadata,\n rememberDeviceSelection: true,\n settings: initialSettings,\n initEndpoint: initEndpoint,\n captureNetworkQualityInPreview,\n };\n }, [name, token, metadata, initEndpoint, initialSettings, captureNetworkQualityInPreview]);\n\n const preview = useCallback(async () => {\n if (!token) {\n return;\n }\n if (roomState !== HMSRoomState.Disconnected) {\n return;\n }\n if (isConnected) {\n await actions.leave();\n }\n try {\n await actions.preview(config);\n } catch (err) {\n handleError(err as Error, 'preview');\n }\n }, [actions, handleError, token, roomState, config, isConnected]);\n\n const join = useCallback(async () => {\n if (!token) {\n return;\n }\n try {\n await actions.join(config);\n } catch (err) {\n handleError(err as Error, 'join');\n }\n }, [actions, config, handleError, token]);\n\n return {\n enableJoin,\n join,\n isConnected,\n preview,\n };\n};\n"],"names":["usePreviewJoin","name","token","metadata","handleError","logErrorHandler","initEndpoint","initialSettings","captureNetworkQualityInPreview","actions","useHMSActions","roomState","useHMSStore","selectRoomState","isConnected","selectIsConnectedToRoom","enableJoin","HMSRoomState","Preview","config","useMemo","userName","authToken","metaData","rememberDeviceSelection","settings","preview","useCallback","async","Disconnected","leave","err","join"],"mappings":"qSAqEO,MAAMA,EAAiB,EAC5BC,OAAO,GACPC,QACAC,WACAC,cAAcC,EACdC,eACAC,kBACAC,qCAEA,MAAMC,EAAUC,IACVC,EAAYC,EAAYC,GACxBC,EAAcF,EAAYG,KAA4B,EACtDC,EAAaL,IAAcM,EAAaC,QAExCC,EAAoBC,GAAQ,KACzB,CACLC,SAAUpB,EACVqB,UAAWpB,EACXqB,SAAUpB,EACVqB,yBAAyB,EACzBC,SAAUlB,EACVD,eACAE,oCAED,CAACP,EAAMC,EAAOC,EAAUG,EAAcC,EAAiBC,IAEpDkB,EAAUC,GAAYC,UAC1B,GAAK1B,GAGDS,IAAcM,EAAaY,aAA3B,CAGAf,SACIL,EAAQqB,QAEZ,UACIrB,EAAQiB,QAAQP,EAEI,CAFJ,MACfY,GACP3B,EAAY2B,EAAc,UAAA,CAR1B,CAQ0B,GAE3B,CAACtB,EAASL,EAAaF,EAAOS,EAAWQ,EAAQL,IAa7C,MAAA,CACLE,aACAgB,KAbWL,GAAYC,UACvB,GAAK1B,EAGD,UACIO,EAAQuB,KAAKb,EAEO,CAFP,MACZY,GACP3B,EAAY2B,EAAc,OAAA,IAE3B,CAACtB,EAASU,EAAQf,EAAaF,IAKhCY,cACAY,UAAA"}
1
+ {"version":3,"file":"usePreviewJoin.js","sources":["../../src/hooks/usePreviewJoin.ts"],"sourcesContent":[null],"names":["usePreviewJoin","name","token","metadata","handleError","logErrorHandler","initEndpoint","initialSettings","captureNetworkQualityInPreview","actions","useHMSActions","roomState","useHMSStore","selectRoomState","isConnected","selectIsConnectedToRoom","enableJoin","HMSRoomState","Preview","config","useMemo","userName","authToken","metaData","rememberDeviceSelection","settings","preview","useCallback","__awaiter","Disconnected","leave","err","join"],"mappings":"oWAqEa,MAAAA,EAAiB,EAC5BC,OAAO,GACPC,QACAC,WACAC,cAAcC,EACdC,eACAC,kBACAC,qCAEA,MAAMC,EAAUC,IACVC,EAAYC,EAAYC,GACxBC,EAAcF,EAAYG,KAA4B,EACtDC,EAAaL,IAAcM,EAAaC,QAExCC,EAAoBC,GAAQ,KACzB,CACLC,SAAUpB,EACVqB,UAAWpB,EACXqB,SAAUpB,EACVqB,yBAAyB,EACzBC,SAAUlB,EACVD,eACAE,oCAED,CAACP,EAAMC,EAAOC,EAAUG,EAAcC,EAAiBC,IAEpDkB,EAAUC,GAAY,IAAWC,OAAA,OAAA,OAAA,GAAA,YACrC,GAAK1B,GAGDS,IAAcM,EAAaY,aAA3B,CAGAf,UACIL,EAAQqB,SAEZ,UACIrB,EAAQiB,QAAQP,EAEI,CAFJ,MACfY,GACP3B,EAAY2B,EAAc,UAAA,CAR1B,CAQ0B,KAE3B,CAACtB,EAASL,EAAaF,EAAOS,EAAWQ,EAAQL,IAa7C,MAAA,CACLE,aACAgB,KAbWL,GAAY,IAAWC,OAAA,OAAA,OAAA,GAAA,YAClC,GAAK1B,EAGD,UACIO,EAAQuB,KAAKb,EAEO,CAFP,MACZY,GACP3B,EAAY2B,EAAc,OAAA,CAAA,KAE3B,CAACtB,EAASU,EAAQf,EAAaF,IAKhCY,cACAY,UAAA"}
@@ -0,0 +1,10 @@
1
+ export interface useRecordingStreamingResult {
2
+ isServerRecordingOn: boolean;
3
+ isBrowserRecordingOn: boolean;
4
+ isHLSRecordingOn: boolean;
5
+ isStreamingOn: boolean;
6
+ isHLSRunning: boolean;
7
+ isRTMPRunning: boolean;
8
+ isRecordingOn: boolean;
9
+ }
10
+ export declare const useRecordingStreaming: () => useRecordingStreamingResult;
@@ -1 +1 @@
1
- {"version":3,"file":"useRecordingStreaming.js","sources":["../../src/hooks/useRecordingStreaming.ts"],"sourcesContent":["import { selectHLSState, selectRecordingState, selectRTMPState } from '@100mslive/hms-video-store';\nimport { useHMSStore } from '../primitives/HmsRoomProvider';\n\nexport interface useRecordingStreamingResult {\n isServerRecordingOn: boolean;\n isBrowserRecordingOn: boolean;\n isHLSRecordingOn: boolean;\n isStreamingOn: boolean;\n isHLSRunning: boolean;\n isRTMPRunning: boolean;\n isRecordingOn: boolean;\n}\n\nexport const useRecordingStreaming = (): useRecordingStreamingResult => {\n const recording = useHMSStore(selectRecordingState);\n const rtmp = useHMSStore(selectRTMPState);\n const hls = useHMSStore(selectHLSState);\n\n const isServerRecordingOn = recording.server.running;\n const isBrowserRecordingOn = recording.browser.running;\n const isHLSRecordingOn = recording.hls.running;\n const isStreamingOn = hls.running || rtmp.running;\n const isRecordingOn = isServerRecordingOn || isBrowserRecordingOn || isHLSRecordingOn;\n\n return {\n isServerRecordingOn,\n isBrowserRecordingOn,\n isHLSRecordingOn,\n isStreamingOn,\n isHLSRunning: hls.running,\n isRTMPRunning: rtmp.running,\n isRecordingOn,\n };\n};\n"],"names":["useRecordingStreaming","recording","useHMSStore","selectRecordingState","rtmp","selectRTMPState","hls","selectHLSState","isServerRecordingOn","server","running","isBrowserRecordingOn","browser","isHLSRecordingOn","isRecordingOn","isStreamingOn","isHLSRunning","isRTMPRunning"],"mappings":"0KAaO,MAAMA,EAAwB,KACnC,MAAMC,EAAYC,EAAYC,GACxBC,EAAOF,EAAYG,GACnBC,EAAMJ,EAAYK,GAElBC,EAAsBP,EAAUQ,OAAOC,QACvCC,EAAuBV,EAAUW,QAAQF,QACzCG,EAAmBZ,EAAUK,IAAII,QAEjCI,EAAgBN,GAAuBG,GAAwBE,EAE9D,MAAA,CACLL,sBACAG,uBACAE,mBACAE,cAPoBT,EAAII,SAAWN,EAAKM,QAQxCM,aAAcV,EAAII,QAClBO,cAAeb,EAAKM,QACpBI,gBAAA"}
1
+ {"version":3,"file":"useRecordingStreaming.js","sources":["../../src/hooks/useRecordingStreaming.ts"],"sourcesContent":[null],"names":["useRecordingStreaming","recording","useHMSStore","selectRecordingState","rtmp","selectRTMPState","hls","selectHLSState","isServerRecordingOn","server","running","isBrowserRecordingOn","browser","isHLSRecordingOn","isRecordingOn","isStreamingOn","isHLSRunning","isRTMPRunning"],"mappings":"0KAaO,MAAMA,EAAwB,KACnC,MAAMC,EAAYC,EAAYC,GACxBC,EAAOF,EAAYG,GACnBC,EAAMJ,EAAYK,GAElBC,EAAsBP,EAAUQ,OAAOC,QACvCC,EAAuBV,EAAUW,QAAQF,QACzCG,EAAmBZ,EAAUK,IAAII,QAEjCI,EAAgBN,GAAuBG,GAAwBE,EAE9D,MAAA,CACLL,sBACAG,uBACAE,mBACAE,cAPoBT,EAAII,SAAWN,EAAKM,QAQxCM,aAAcV,EAAII,QAClBO,cAAeb,EAAKM,QACpBI,gBAAA"}
@@ -0,0 +1,36 @@
1
+ import { HMSTrackID } from '@100mslive/hms-video-store';
2
+ import { hooksErrHandler } from './types';
3
+ export interface useRemoteAVToggleResult {
4
+ /**
5
+ * true if unmuted and vice versa
6
+ */
7
+ isAudioEnabled: boolean;
8
+ isVideoEnabled: boolean;
9
+ /**
10
+ * current volume of the audio track
11
+ */
12
+ volume?: number;
13
+ /**
14
+ * use this function to toggle audio state, the function will only be present if the user
15
+ * has permission to mute/unmute remote audio
16
+ */
17
+ toggleAudio?: () => void;
18
+ /**
19
+ * use this function to toggle video state, the function will only be present if the user
20
+ * has permission to mute/unmute remote video
21
+ */
22
+ toggleVideo?: () => void;
23
+ /**
24
+ * use this function to set the volume of peer's audio track for the local user, the function will
25
+ * only be present if the remote peer has an audio track to change volume for
26
+ */
27
+ setVolume?: (volume: number) => void;
28
+ }
29
+ /**
30
+ * This hook can be used to implement remote mute/unmute + audio volume changer on tile level.
31
+ * @param peerId of the peer whose tracks need to be managed
32
+ * @param audioTrackId of the peer whose tracks need to be managed
33
+ * @param videoTrackId of the peer whose tracks need to be managed
34
+ * @param handleError to handle any error during toggle of audio/video
35
+ */
36
+ export declare const useRemoteAVToggle: (audioTrackId: HMSTrackID, videoTrackId: HMSTrackID, handleError?: hooksErrHandler) => useRemoteAVToggleResult;
@@ -1,2 +1,2 @@
1
- import{selectAudioTrackByID as o,selectVideoTrackByID as e,selectAudioTrackVolume as i,selectPermissions as l}from"@100mslive/hms-video-store";import{useHMSActions as d,useHMSStore as t}from"../primitives/HmsRoomProvider.js";import{useCallback as n}from"react";import{logErrorHandler as u}from"../utils/commons.js";const m=async(o,e,i)=>{if(e)try{await o.setRemoteTrackEnabled(e.id,!e.enabled)}catch(o){i(o,"remoteToggle")}},r=(r,a,s=u)=>{const v=d(),c=t(o(r)),b=t(e(a)),g=t(i(null==c?void 0:c.id)),p=t(l),f=(null==b?void 0:b.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,y=(null==c?void 0:c.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,V=n((async()=>{await m(v,c,s)}),[v,c,s]),w=n((async()=>{await m(v,b,s)}),[v,s,b]),E=n((o=>{c&&v.setVolume(o,c.id)}),[v,c]);return{isAudioEnabled:!!(null==c?void 0:c.enabled),isVideoEnabled:!!(null==b?void 0:b.enabled),volume:g,toggleAudio:c&&y?V:void 0,toggleVideo:"regular"===(null==b?void 0:b.source)&&f?w:void 0,setVolume:c?E:void 0}};export{r as useRemoteAVToggle};
1
+ import{__awaiter as o}from"../node_modules/tslib/tslib.es6.js";import{selectAudioTrackByID as i,selectVideoTrackByID as e,selectAudioTrackVolume as d,selectPermissions as l}from"@100mslive/hms-video-store";import{useHMSActions as n,useHMSStore as t}from"../primitives/HmsRoomProvider.js";import{useCallback as u}from"react";import{logErrorHandler as m}from"../utils/commons.js";const v=(i,e,d)=>o(void 0,void 0,void 0,(function*(){if(e)try{yield i.setRemoteTrackEnabled(e.id,!e.enabled)}catch(o){d(o,"remoteToggle")}})),r=(r,s,a=m)=>{const c=n(),b=t(i(r)),f=t(e(s)),g=t(d(null==b?void 0:b.id)),p=t(l),y=(null==f?void 0:f.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,V=(null==b?void 0:b.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,j=u((()=>o(void 0,void 0,void 0,(function*(){yield v(c,b,a)}))),[c,b,a]),E=u((()=>o(void 0,void 0,void 0,(function*(){yield v(c,f,a)}))),[c,a,f]),h=u((o=>{b&&c.setVolume(o,b.id)}),[c,b]);return{isAudioEnabled:!!(null==b?void 0:b.enabled),isVideoEnabled:!!(null==f?void 0:f.enabled),volume:g,toggleAudio:b&&V?j:void 0,toggleVideo:"regular"===(null==f?void 0:f.source)&&y?E:void 0,setVolume:b?h:void 0}};export{r as useRemoteAVToggle};
2
2
  //# sourceMappingURL=useRemoteAVToggle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRemoteAVToggle.js","sources":["../../src/hooks/useRemoteAVToggle.ts"],"sourcesContent":["/* eslint-disable complexity */\nimport {\n HMSActions,\n HMSTrack,\n HMSTrackID,\n selectAudioTrackVolume,\n selectPermissions,\n selectAudioTrackByID,\n selectVideoTrackByID,\n} from '@100mslive/hms-video-store';\nimport { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';\nimport { useCallback } from 'react';\nimport { hooksErrHandler } from './types';\nimport { logErrorHandler } from '../utils/commons';\n\nexport interface useRemoteAVToggleResult {\n /**\n * true if unmuted and vice versa\n */\n isAudioEnabled: boolean;\n isVideoEnabled: boolean;\n /**\n * current volume of the audio track\n */\n volume?: number;\n /**\n * use this function to toggle audio state, the function will only be present if the user\n * has permission to mute/unmute remote audio\n */\n toggleAudio?: () => void;\n /**\n * use this function to toggle video state, the function will only be present if the user\n * has permission to mute/unmute remote video\n */\n toggleVideo?: () => void;\n /**\n * use this function to set the volume of peer's audio track for the local user, the function will\n * only be present if the remote peer has an audio track to change volume for\n */\n setVolume?: (volume: number) => void;\n}\n\nconst toggleTrackEnabled = async (\n actions: HMSActions,\n track: HMSTrack | undefined | null,\n handleError: hooksErrHandler,\n) => {\n if (track) {\n try {\n await actions.setRemoteTrackEnabled(track.id, !track.enabled);\n } catch (err) {\n handleError(err as Error, 'remoteToggle');\n }\n }\n};\n\n/**\n * This hook can be used to implement remote mute/unmute + audio volume changer on tile level.\n * @param peerId of the peer whose tracks need to be managed\n * @param audioTrackId of the peer whose tracks need to be managed\n * @param videoTrackId of the peer whose tracks need to be managed\n * @param handleError to handle any error during toggle of audio/video\n */\nexport const useRemoteAVToggle = (\n audioTrackId: HMSTrackID,\n videoTrackId: HMSTrackID,\n handleError: hooksErrHandler = logErrorHandler,\n): useRemoteAVToggleResult => {\n const actions = useHMSActions();\n const audioTrack = useHMSStore(selectAudioTrackByID(audioTrackId));\n const videoTrack = useHMSStore(selectVideoTrackByID(videoTrackId));\n const volume = useHMSStore(selectAudioTrackVolume(audioTrack?.id));\n const permissions = useHMSStore(selectPermissions);\n const canToggleVideo = videoTrack?.enabled ? permissions?.mute : permissions?.unmute;\n const canToggleAudio = audioTrack?.enabled ? permissions?.mute : permissions?.unmute;\n\n const toggleAudio = useCallback(async () => {\n await toggleTrackEnabled(actions, audioTrack, handleError);\n }, [actions, audioTrack, handleError]);\n\n const toggleVideo = useCallback(async () => {\n await toggleTrackEnabled(actions, videoTrack, handleError);\n }, [actions, handleError, videoTrack]);\n\n const setVolume = useCallback(\n (volume: number) => {\n if (audioTrack) {\n actions.setVolume(volume, audioTrack.id);\n }\n },\n [actions, audioTrack],\n );\n\n return {\n isAudioEnabled: !!audioTrack?.enabled,\n isVideoEnabled: !!videoTrack?.enabled,\n volume,\n toggleAudio: audioTrack && canToggleAudio ? toggleAudio : undefined,\n toggleVideo: videoTrack?.source === 'regular' && canToggleVideo ? toggleVideo : undefined,\n setVolume: audioTrack ? setVolume : undefined,\n };\n};\n"],"names":["toggleTrackEnabled","async","actions","track","handleError","setRemoteTrackEnabled","id","enabled","err","useRemoteAVToggle","audioTrackId","videoTrackId","logErrorHandler","useHMSActions","audioTrack","useHMSStore","selectAudioTrackByID","videoTrack","selectVideoTrackByID","volume","selectAudioTrackVolume","permissions","selectPermissions","canToggleVideo","mute","unmute","canToggleAudio","toggleAudio","useCallback","toggleVideo","setVolume","volume2","isAudioEnabled","isVideoEnabled","source"],"mappings":"2TA0CA,MAAMA,EAAqBC,MACzBC,EACAC,EACAC,KAEA,GAAID,EACE,UACID,EAAQG,sBAAsBF,EAAMG,IAAKH,EAAMI,QAE3B,CAF2B,MAC9CC,GACPJ,EAAYI,EAAc,eAAA,CAAA,EAYnBC,EAAoB,CAC/BC,EACAC,EACAP,EAA+BQ,KAE/B,MAAMV,EAAUW,IACVC,EAAaC,EAAYC,EAAqBN,IAC9CO,EAAaF,EAAYG,EAAqBP,IAC9CQ,EAASJ,EAAYK,EAAmC,MAAZN,OAAY,EAAAA,EAAAR,KACxDe,EAAcN,EAAYO,GAC1BC,GAAiB,MAAAN,OAAA,EAAAA,EAAYV,SAAU,MAAAc,OAAA,EAAAA,EAAaG,KAAoB,MAAbH,OAAa,EAAAA,EAAAI,OACxEC,GAAiB,MAAAZ,OAAA,EAAAA,EAAYP,SAAU,MAAAc,OAAA,EAAAA,EAAaG,KAAoB,MAAbH,OAAa,EAAAA,EAAAI,OAExEE,EAAcC,GAAY3B,gBACxBD,EAAmBE,EAASY,EAAYV,EAAA,GAC7C,CAACF,EAASY,EAAYV,IAEnByB,EAAcD,GAAY3B,gBACxBD,EAAmBE,EAASe,EAAYb,EAAA,GAC7C,CAACF,EAASE,EAAaa,IAEpBa,EAAYF,GACfG,IACKjB,GACMZ,EAAA4B,UAAUC,EAAQjB,EAAWR,GAAA,GAGzC,CAACJ,EAASY,IAGL,MAAA,CACLkB,kBAA8B,MAAAlB,OAAA,EAAAA,EAAAP,SAC9B0B,kBAA8B,MAAAhB,OAAA,EAAAA,EAAAV,SAC9BY,SACAQ,YAAab,GAAcY,EAAiBC,OAAc,EAC1DE,YAAoC,aAAvB,MAAAZ,OAAA,EAAAA,EAAYiB,SAAwBX,EAAiBM,OAAc,EAChFC,UAAWhB,EAAagB,OAAY,EAAA"}
1
+ {"version":3,"file":"useRemoteAVToggle.js","sources":["../../src/hooks/useRemoteAVToggle.ts"],"sourcesContent":[null],"names":["toggleTrackEnabled","actions","track","handleError","__awaiter","setRemoteTrackEnabled","id","enabled","err","useRemoteAVToggle","audioTrackId","videoTrackId","logErrorHandler","useHMSActions","audioTrack","useHMSStore","selectAudioTrackByID","videoTrack","selectVideoTrackByID","volume","selectAudioTrackVolume","permissions","selectPermissions","canToggleVideo","mute","unmute","canToggleAudio","toggleAudio","useCallback","toggleVideo","setVolume","volume2","isAudioEnabled","isVideoEnabled","source"],"mappings":"0XA0CA,MAAMA,EAAqB,CACzBC,EACAC,EACAC,IACEC,OAAA,OAAA,OAAA,GAAA,YACF,GAAIF,EACE,UACID,EAAQI,sBAAsBH,EAAMI,IAAKJ,EAAMK,QAE3B,CAF2B,MAC9CC,GACPL,EAAYK,EAAc,eAAA,CAAA,IAYnBC,EAAoB,CAC/BC,EACAC,EACAR,EAA+BS,KAE/B,MAAMX,EAAUY,IACVC,EAAaC,EAAYC,EAAqBN,IAC9CO,EAAaF,EAAYG,EAAqBP,IAC9CQ,EAASJ,EAAYK,EAAuBN,eAAAA,EAAYR,KACxDe,EAAcN,EAAYO,GAC1BC,gBAAiB,EAAAN,EAAYV,SAAUc,aAAW,EAAXA,EAAaG,KAAOH,aAAW,EAAXA,EAAaI,OACxEC,gBAAiB,EAAAZ,EAAYP,SAAUc,aAAW,EAAXA,EAAaG,KAAOH,aAAW,EAAXA,EAAaI,OAExEE,EAAcC,GAAY,IAAWxB,OAAA,OAAA,OAAA,GAAA,kBACnCJ,EAAmBC,EAASa,EAAYX,EAC7C,KAAA,CAACF,EAASa,EAAYX,IAEnB0B,EAAcD,GAAY,IAAWxB,OAAA,OAAA,OAAA,GAAA,kBACnCJ,EAAmBC,EAASgB,EAAYd,EAC7C,KAAA,CAACF,EAASE,EAAac,IAEpBa,EAAYF,GACfG,IACKjB,GACMb,EAAA6B,UAAUC,EAAQjB,EAAWR,GAAA,GAGzC,CAACL,EAASa,IAGL,MAAA,CACLkB,kBAAkBlB,aAAA,EAAAA,EAAYP,SAC9B0B,kBAAkBhB,aAAA,EAAAA,EAAYV,SAC9BY,SACAQ,YAAab,GAAcY,EAAiBC,OAAc,EAC1DE,YAAoC,aAAbZ,aAAV,EAAAA,EAAYiB,SAAwBX,EAAiBM,OAAc,EAChFC,UAAWhB,EAAagB,OAAY,EAAA"}