@apirtc/react-lib 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENCE.md +21 -0
- package/README.md +111 -0
- package/dist/components/VideoStream/VideoStream.d.ts +8 -0
- package/dist/components/VideoStream/index.d.ts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/esm/components/VideoStream/VideoStream.d.ts +8 -0
- package/dist/esm/components/VideoStream/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/hooks/getDisplayMedia.mock.d.ts +0 -0
- package/dist/esm/hooks/index.d.ts +9 -0
- package/dist/esm/hooks/useCameraStream.d.ts +4 -0
- package/dist/esm/hooks/useCameraStream.spec.d.ts +1 -0
- package/dist/esm/hooks/useConversation.d.ts +11 -0
- package/dist/esm/hooks/useConversation.spec.d.ts +1 -0
- package/dist/esm/hooks/useConversationMessages.d.ts +5 -0
- package/dist/esm/hooks/useConversationMessages.spec.d.ts +1 -0
- package/dist/esm/hooks/useConversationModeration.d.ts +4 -0
- package/dist/esm/hooks/useConversationModeration.spec.d.ts +1 -0
- package/dist/esm/hooks/useConversationStreams.d.ts +13 -0
- package/dist/esm/hooks/useConversationStreams.spec.d.ts +1 -0
- package/dist/esm/hooks/usePresence.d.ts +4 -0
- package/dist/esm/hooks/usePresence.spec.d.ts +1 -0
- package/dist/esm/hooks/useSession.d.ts +20 -0
- package/dist/esm/hooks/useSession.spec.d.ts +1 -0
- package/dist/esm/hooks/useStreamApplyVideoProcessor.d.ts +16 -0
- package/dist/esm/hooks/useStreamApplyVideoProcessor.spec.d.ts +1 -0
- package/dist/esm/hooks/useUserMediaDevices.d.ts +4 -0
- package/dist/esm/hooks/useUserMediaDevices.spec.d.ts +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/hooks/getDisplayMedia.mock.d.ts +0 -0
- package/dist/hooks/index.d.ts +9 -0
- package/dist/hooks/useCameraStream.d.ts +4 -0
- package/dist/hooks/useCameraStream.spec.d.ts +1 -0
- package/dist/hooks/useConversation.d.ts +11 -0
- package/dist/hooks/useConversation.spec.d.ts +1 -0
- package/dist/hooks/useConversationMessages.d.ts +5 -0
- package/dist/hooks/useConversationMessages.spec.d.ts +1 -0
- package/dist/hooks/useConversationModeration.d.ts +4 -0
- package/dist/hooks/useConversationModeration.spec.d.ts +1 -0
- package/dist/hooks/useConversationStreams.d.ts +13 -0
- package/dist/hooks/useConversationStreams.spec.d.ts +1 -0
- package/dist/hooks/usePresence.d.ts +4 -0
- package/dist/hooks/usePresence.spec.d.ts +1 -0
- package/dist/hooks/useSession.d.ts +20 -0
- package/dist/hooks/useSession.spec.d.ts +1 -0
- package/dist/hooks/useStreamApplyVideoProcessor.d.ts +16 -0
- package/dist/hooks/useStreamApplyVideoProcessor.spec.d.ts +1 -0
- package/dist/hooks/useUserMediaDevices.d.ts +4 -0
- package/dist/hooks/useUserMediaDevices.spec.d.ts +1 -0
- package/dist/index.d.ts +103 -0
- package/dist/react-lib.production.min.js +2 -0
- package/dist/react-lib.production.min.js.map +1 -0
- package/package.json +42 -0
package/LICENCE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 ApiRTC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# react-lib
|
|
2
|
+
|
|
3
|
+
This library offers React **ApiRTC** high order components. Theses are mostly hooks to fasten your **ApiRTC** integration.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
`npm install @apirtc/react-lib`
|
|
8
|
+
|
|
9
|
+
requires to have @apirtc/apirtc peer dependency installed too:
|
|
10
|
+
|
|
11
|
+
`npm install @apirtc/apirtc`
|
|
12
|
+
|
|
13
|
+
## Hooks
|
|
14
|
+
|
|
15
|
+
### useSession
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
import { useSession } from '@apirtc/react-lib'
|
|
19
|
+
const { session } = useSession({ apiKey: 'your_api_key' });
|
|
20
|
+
```
|
|
21
|
+
### useUserMediaDevices
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
import { useUserMediaDevices } from '@apirtc/react-lib'
|
|
25
|
+
const { userMediaDevices } = useUserMediaDevices(session);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### useCameraStream
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
import { useCameraStream } from '@apirtc/react-lib'
|
|
32
|
+
const { stream } = useCameraStream(session);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### useStreamApplyVideoProcessor
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
import { useStreamApplyVideoProcessor } from '@apirtc/react-lib'
|
|
39
|
+
const { stream: localStream } = useStreamApplyVideoProcessor(stream, 'blur');
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### usePresence
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
import { usePresence } from '@apirtc/react-lib'
|
|
46
|
+
const { contactsByGroup } = usePresence(session, ['groupName1', 'groupName2']);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### useConversation
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
import { useConversation } from '@apirtc/react-lib'
|
|
53
|
+
const { conversation } = useConversation(session, 'conversationName', undefined, true);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### useConversationModeration
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
import { useConversationModeration } from '@apirtc/react-lib'
|
|
60
|
+
const { candidates } = useConversationModeration(conversation);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### useConversationMessages
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
import { useConversationMessages } from '@apirtc/react-lib'
|
|
67
|
+
const { messages, sendMessage } = useConversationMessages(conversation);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### useConversationStreams
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
import { useConversationStreams } from '@apirtc/react-lib'
|
|
74
|
+
const { publishedStreams, subscribedStreams } = useConversationStreams(
|
|
75
|
+
conversation, stream ? [{ stream: stream }] : []);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Components
|
|
79
|
+
|
|
80
|
+
### VideoStream
|
|
81
|
+
|
|
82
|
+
Use it to display any **ApiRTC** **Stream**.
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
import { VideoStream } from '@apirtc/react-lib'
|
|
86
|
+
|
|
87
|
+
<VideoStream stream={stream} muted={false}></VideoStream>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Configure log level
|
|
91
|
+
|
|
92
|
+
Available log levels:
|
|
93
|
+
|
|
94
|
+
* **debug**
|
|
95
|
+
* **info**
|
|
96
|
+
* **warn**
|
|
97
|
+
* **error**
|
|
98
|
+
|
|
99
|
+
from web app code:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
import { setLogLevel } from '@apirtc/react-lib'
|
|
103
|
+
|
|
104
|
+
setLogLevel('warn')
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
from console:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
setApirtcReactLibLogLevel('debug')
|
|
111
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./VideoStream";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as VideoStream } from "./VideoStream";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./VideoStream";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as VideoStream } from "./VideoStream";
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as useCameraStream } from "./useCameraStream";
|
|
2
|
+
export { default as useConversation } from "./useConversation";
|
|
3
|
+
export { default as useConversationMessages } from "./useConversationMessages";
|
|
4
|
+
export { default as useConversationModeration } from "./useConversationModeration";
|
|
5
|
+
export { default as useConversationStreams } from "./useConversationStreams";
|
|
6
|
+
export { default as usePresence } from "./usePresence";
|
|
7
|
+
export { default as useSession, Credentials } from "./useSession";
|
|
8
|
+
export { default as useStreamApplyVideoProcessor } from './useStreamApplyVideoProcessor';
|
|
9
|
+
export { default as useUserMediaDevices } from "./useUserMediaDevices";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Conversation, GetOrCreateConversationOptions, Session } from '@apirtc/apirtc';
|
|
2
|
+
/**
|
|
3
|
+
* Please note that the hook won't react on autoJoin change
|
|
4
|
+
*/
|
|
5
|
+
export default function useConversation(session: Session | undefined, name: string | undefined, options?: GetOrCreateConversationOptions, join?: boolean): {
|
|
6
|
+
conversation: Conversation | undefined;
|
|
7
|
+
joining: boolean;
|
|
8
|
+
joined: boolean;
|
|
9
|
+
join: () => Promise<void>;
|
|
10
|
+
leave: () => Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Contact, Conversation, ConversationMessage } from '@apirtc/apirtc';
|
|
2
|
+
export default function useConversationMessages(conversation: Conversation | undefined): {
|
|
3
|
+
messages: ConversationMessage[];
|
|
4
|
+
sendMessage: (msgContent: string, sender: Contact) => Promise<void>;
|
|
5
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Conversation, PublishOptions, Stream } from '@apirtc/apirtc';
|
|
2
|
+
export default function useConversationStreams(conversation: Conversation | undefined,
|
|
3
|
+
/** fully managed list of Stream(s) to publish, with associated publish options */
|
|
4
|
+
streamsToPublish?: Array<{
|
|
5
|
+
stream: Stream;
|
|
6
|
+
options?: PublishOptions;
|
|
7
|
+
} | undefined | null>, errorCallback?: (error: any) => void): {
|
|
8
|
+
publishedStreams: Stream[];
|
|
9
|
+
subscribedStreams: Stream[];
|
|
10
|
+
publish: (localStream: Stream, options?: PublishOptions) => Promise<Stream>;
|
|
11
|
+
unpublish: (localStream: Stream) => void;
|
|
12
|
+
replacePublishedStream: (oldStream: Stream, newStream: Stream, options?: PublishOptions) => Promise<Stream>;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Session, RegisterInformation } from '@apirtc/apirtc';
|
|
2
|
+
type LoginPassword = {
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
};
|
|
6
|
+
type ApiKey = {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
};
|
|
9
|
+
type Token = {
|
|
10
|
+
token: string;
|
|
11
|
+
};
|
|
12
|
+
export type Credentials = LoginPassword | ApiKey | Token;
|
|
13
|
+
export default function useSession(credentials?: Credentials, options?: RegisterInformation): {
|
|
14
|
+
session: Session | undefined;
|
|
15
|
+
connecting: boolean;
|
|
16
|
+
connect: (credentials: Credentials | undefined, options?: RegisterInformation) => Promise<void>;
|
|
17
|
+
disconnect: () => void;
|
|
18
|
+
error: any;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Stream, VideoProcessorOptions } from '@apirtc/apirtc';
|
|
2
|
+
/**
|
|
3
|
+
* This hook takes stream passed as parameter, and
|
|
4
|
+
* returns either this stream or a stream with video processor applied.
|
|
5
|
+
* This is controlled by the videoProcessorType input attribute.
|
|
6
|
+
* By default the output stream is the input stream.
|
|
7
|
+
* The hook fully manages the output stream (applies 'none' if input stream is set to undefined).
|
|
8
|
+
* The hook never releases the input stream.
|
|
9
|
+
*
|
|
10
|
+
* @param stream
|
|
11
|
+
* @returns stream blurred or not, toggle method, boolean blurred state.
|
|
12
|
+
*/
|
|
13
|
+
export default function useStreamApplyVideoProcessor(stream: Stream | undefined, videoProcessorType: 'none' | 'blur' | 'backgroundImage', options?: VideoProcessorOptions, errorCallback?: (error: any) => void): {
|
|
14
|
+
stream: Stream | undefined;
|
|
15
|
+
applied: "none" | "blur" | "backgroundImage";
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './hooks';
|
|
3
|
+
type LogLevel = {
|
|
4
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
5
|
+
isDebugEnabled: boolean;
|
|
6
|
+
isInfoEnabled: boolean;
|
|
7
|
+
isWarnEnabled: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare global {
|
|
10
|
+
var apirtcReactLibLogLevel: LogLevel;
|
|
11
|
+
var setApirtcReactLibLogLevel: Function;
|
|
12
|
+
}
|
|
13
|
+
export declare function setLogLevel(logLevelText: 'debug' | 'info' | 'warn' | 'error' | string): LogLevel;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e,{useRef as o,useEffect as n,useState as t,useCallback as i}from"react";import{UserAgent as a}from"@apirtc/apirtc";function s(t){const{autoPlay:i=!0}=t,a=o(null);return n((()=>{const e=a.current;if(e&&t.stream)return t.stream.attachToElement(e),()=>{e.src=""}}),[t.stream]),e.createElement("video",{id:t.stream.getId(),style:{maxWidth:"100%"},ref:a,autoPlay:i,muted:t.muted})}const r="useCameraStream";function l(e,o={}){const[i,a]=t();return n((()=>{if(e){e.getUserAgent().createStream(o).then((e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(r+"|createStream",o,e),a(e)})).catch((e=>{console.error(r+"|createStream",o,e),a(void 0)}))}else a(void 0)}),[e,JSON.stringify(o)]),n((()=>()=>{i&&(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(r+"|release stream",i),i.release())}),[i]),{stream:i}}const c="useConversation";function b(e,o,a,s=!1){const[r,l]=t(),[b,g]=t(!1),[d,u]=t(!1),L=i((()=>(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(c+"|join",r),new Promise(((e,o)=>{r?r.isJoined()?o(c+"|join|conversation already joined"):(u(!0),r.join().then((()=>{g(!0),e()})).catch((e=>{o(e)})).finally((()=>{u(!1)}))):o(c+"|join|conversation not defined")})))),[r]),f=i((()=>(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(c+"|leave",r),new Promise(((e,o)=>{r?r.isJoined()?r.leave().then((()=>{g(!1),e()})).catch((e=>{o(e)})):o(c+"|leave|conversation is not joined"):o(c+"|leave|conversation not defined")})))),[r]);return n((()=>{if(e&&o){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(c+"|getOrCreateConversation",o,a,s);const n=e.getOrCreateConversation(o,a);return l(n),()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(c+"|useEffect cleanup",o,a,s),n.isJoined()?n.leave().then((()=>{})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(c+"|useEffect conversation.leave()",e)})).finally((()=>{n.destroy(),l(void 0),g(!1)})):(n.destroy(),l(void 0))}}}),[e,o,JSON.stringify(a)]),n((()=>{if(r&&s){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(c+"|useEffect",r,s);const e=r,o=s;return o&&(u(!0),e.join().then((()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(c+"|joined",e),g(!0)})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(c+"|useEffect conversation.join()",e)})).finally((()=>{u(!1)}))),()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(c+"|useEffect cleanup",e,o),e.isJoined()&&e.leave().then((()=>{g(!1)})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(c+"|useEffect conversation.leave()",e)}))}}}),[r,s]),{conversation:r,joining:d,joined:b,join:L,leave:f}}const g="useConversationMessages";function d(e){const[o]=t(new Array),[a,s]=t(new Array);n((()=>{if(e){const n=n=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(g+"|on:message:",e.getName(),n),o.push(n),s(Array.from(o))};return e.on("message",n),()=>{e.removeListener("message",n),o.length=0,s(new Array)}}}),[e]);return{messages:a,sendMessage:i(((n,t)=>new Promise(((i,a)=>{null==e||e.sendMessage(n).then((a=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(g+"|sentMessage",e.getName(),a,n),o.push({content:n,sender:t,time:new Date}),s(Array.from(o)),i()})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(g+"|sendMessage error",e),a(e)}))}))),[e])}}const u="useConversationModeration";function L(e,o,i){const[a,s]=t(new Set);return n((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(u+"|useEffect conversation",e),e){const n=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(u+"|on:contactJoinedWaitingRoom",e),a.add(e),s(new Set(a))},t=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(u+"|on:contactLeftWaitingRoom",e),a.delete(e),s(new Set(a))},r=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(u+"|on:participantEjected",e),!0===e.self?(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(u+"|Self participant was ejected"),i&&i()):o&&o(e.contact)};return e.on("contactJoinedWaitingRoom",n).on("contactLeftWaitingRoom",t).on("participantEjected",r),()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(u+"|conversation clear",e),e.removeListener("contactJoinedWaitingRoom",n).removeListener("contactLeftWaitingRoom",t).removeListener("participantEjected",r),s(new Set)}}}),[e]),{candidates:a}}function f(e){return null!=e}const p="useConversationStreams";function h(e,o=[],a){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${p}|hook`);const[s,r]=t([]),[l]=t(new Array),[c,b]=t(new Array),[g]=t(new Array),[d,u]=t(new Array),L=i(((o,n)=>new Promise(((t,i)=>{e&&(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${p}|publish|${e.getName()}`,o,n),e.publish(o,n).then((o=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(`${p}|published|${e.getName()}`,o),l.push(o),b(Array.from(l)),t(o)})).catch((e=>{i(e)})))}))),[e]),h=i(((o,n,t)=>new Promise(((i,a)=>{if(e){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${p}|replacePublishedStream|${e.getName()}|${o.getId()} -> ${n.getId()}(${JSON.stringify(t)})`);const s=e.getConversationCall(o);s&&s.replacePublishedStream(n,void 0,t).then((n=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(`${p}|stream replaced|${e.getName()}`,o,n,t);const a=l.indexOf(o);a>=0&&(l.splice(a,1,n),b(Array.from(l))),i(n)})).catch((e=>{a(e)}))}}))),[e]),v=i((o=>{if(e){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${p}|unpublish|${e.getName()}`,o),e.unpublish(o);const n=l.indexOf(o);n>=0&&(l.splice(n,1),b(Array.from(l)))}}),[e]),m=i((()=>{const n=Math.max(s.length,o.length);globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(p+"|doHandlePublication",o,JSON.stringify(s.map((e=>null==e?void 0:e.stream.getId()))),n);const t=[...o];r(t);const i=new Set(o.filter(f).map((e=>e.stream)));for(let r=0;r<n;r++){const n=s[r],l=o[r];if(n&&l){const o=()=>{h(n.stream,l.stream,l.options).catch((e=>{t.splice(r,1,null),a?a(e):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(`${p}|replacePublishedStream|error`,e)}))};n.stream===l.stream?JSON.stringify(n.options)!==JSON.stringify(l.options)&&o():i.has(n.stream)?e&&!e.isPublishedStream(l.stream)&&L(l.stream,l.options).catch((e=>{t.splice(r,1,null),a?a(e):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(`${p}|publish|error`,e)})):e&&!e.isPublishedStream(l.stream)?o():v(n.stream)}else n&&!l?i.has(n.stream)||v(n.stream):!n&&l&&e&&!e.isPublishedStream(l.stream)&&L(l.stream,l.options).catch((e=>{t.splice(r,1,null),a?a(e):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(`${p}|publish|error`,e)}))}}),[e,o,s,L,v,h]);n((()=>{if(e){const o=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(p+"|on_streamAdded",e),g.push(e),u(Array.from(g))},n=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(p+"|on_streamRemoved",e);const o=g.indexOf(e);o>=0&&(g.splice(o,1),u(Array.from(g)))},t=o=>{const n=String(o.streamId);!0===o.isRemote&&("added"===o.listEventType?e.subscribeToStream(n):"removed"===o.listEventType&&e.unsubscribeToStream(n))};return e.on("streamAdded",o),e.on("streamRemoved",n),e.on("streamListChanged",t),()=>{e.removeListener("streamListChanged",t),e.removeListener("streamRemoved",n),e.removeListener("streamAdded",o)}}}),[e]);const E=e=>{l.forEach((o=>{e.unpublish(o)})),l.length=0,r([]),g.forEach((o=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(p+"|unsubscribeToStream stream",e,o),e.unsubscribeToStream(o.getId())})),g.length=0,b(new Array),u(new Array)};return n((()=>{if(e){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(p+"|useEffect doHandlePublication",e.getName());const n=()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(p+"|on_joined",e.getName(),o),m()},t=()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(p+"|on_left",e.getName()),E(e)};return e.on("joined",n),e.on("left",t),()=>{e.removeListener("joined",n),e.removeListener("left",t)}}}),[m]),n((()=>{if(e)return globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${p}|conversation|${e.getName()}`,e),e.getAvailableStreamList().forEach((o=>{const n=String(o.streamId);!0===o.isRemote&&e.subscribeToStream(n)})),()=>{E(e)}}),[e]),n((()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${p}|streamsToPublish`,JSON.stringify(o.map((e=>(null==e?void 0:e.stream.getId())+"-"+JSON.stringify(null==e?void 0:e.options))))),e&&e.isJoined()&&m()}),[JSON.stringify(o.map((e=>(null==e?void 0:e.stream.getId())+"-"+JSON.stringify(null==e?void 0:e.options))))]),{publishedStreams:c,subscribedStreams:d,publish:L,unpublish:v,replacePublishedStream:h}}const v="usePresence";function m(e,o){const[i]=t(new Set),[a]=t(new Map),[s,r]=t(new Map);n((()=>{if(e)return()=>{a.clear(),r(new Map(a)),i.clear()}}),[e]);const l=e=>{var o;const n=null!==(o=a.get(e))&&void 0!==o?o:new Set;return a.has(e)||a.set(e,n),n};return n((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(v+"|useEffect session, groups",o),e){const n=e,t=new Set(o);t.forEach((e=>{i.has(e)||(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(v+"|subscribeToGroup",e),i.add(e),n.subscribeToGroup(e))}));let s=!1;if(i.forEach((e=>{t.has(e)||(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(v+"|unsubscribeToGroup",e),n.unsubscribeToGroup(e),i.delete(e),a.delete(e),s=!0)})),s&&r(new Map(a)),o.length>0){const e=e=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(v+"|contactListUpdate",e);let o=!1;for(const n of Object.keys(e.joinedGroup))if(t.has(n)){const t=l(n);for(const i of e.joinedGroup[n])t.add(i),o=!0}for(const n of Object.keys(e.leftGroup))if(t.has(n)){const t=l(n);for(const i of e.leftGroup[n])t.delete(i),o=!0,0===t.size&&a.delete(n)}for(const n of e.userDataChanged)for(const e of a.values())if(e.has(n)){o=!0;break}o&&r(new Map(a))};return n.on("contactListUpdate",e),()=>{n.removeListener("contactListUpdate",e)}}}}),[e,JSON.stringify(o)]),{contactsByGroup:s}}const E="useSession";function T(e,o){const[i,s]=t(),[r,l]=t(!1),[c,b]=t();n((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(E+"|useEffect credentials, options",e,o),e){let n=!0;return g(e,o).catch((e=>{console.error(E+"|connection failed",e,n),s(void 0),n&&b(e)})),()=>{n=!1,s(void 0),l(!1),b(void 0)}}}),[JSON.stringify(e),JSON.stringify(o)]),n((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(E+"|useEffect session",i),i){const e=i;return()=>{e.disconnect().then((()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(E+"|disconnected",e)})).catch((e=>{console.error(E+"|disconnect",e)}))}}}),[i]);const g=(e,o)=>new Promise(((n,t)=>{const i=o||{cloudUrl:"https://cloud.apirtc.com"};let r;if("object"==typeof(c=e)&&"username"in c)i.password=e.password,r=new a({uri:"apirtc:"+e.username});else if(function(e){return"object"==typeof e&&"apiKey"in e}(e))r=new a({uri:`apiKey:${e.apiKey}`});else{if(!function(e){return"object"==typeof e&&"token"in e}(e))return void t("credentials not recognized");r=new a({uri:`token:${e.token}`})}var c;l(!0),r.register(i).then((e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(E+"|connected",e),s(e),n()})).catch((e=>{t(e)})).finally((()=>{l(!1)}))}));return{session:i,connecting:r,connect:g,disconnect:()=>{s(void 0)},error:c}}const R="useStreamApplyVideoProcessor";function y(e,o,a,s){const[r,l]=t(e),[c,b]=t("none");n((()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(R+"|useEffect",e,o,a),e&&"none"!==o?e.applyVideoProcessor(o,a).then((e=>{l(e),b(o)})).catch((n=>{l(e),s?s(n):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(R+"|useEffect",e,o,a,n),b((e=>e))})):(l(e),b("none"))}),[e,o,a]);const g=i((()=>{r&&r!==e&&(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(R+"|releasing outStream",r),r.release())}),[e,r]);return n((()=>()=>{g()}),[r]),{stream:r,applied:c}}const S={audioinput:{},audiooutput:{},videoinput:{}};function w(e){const[o,i]=t(S);return n((()=>{if(e){const o=e.getUserAgent(),n=()=>{const e=o.getUserMediaDevices();globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info("useUserMediaDevices|mediaDeviceChanged",e),i(e)};return o.on("mediaDeviceChanged",n),()=>{o.removeListener("mediaDeviceChanged",n),i(S)}}}),[e]),{userMediaDevices:o}}const D={level:"info",isDebugEnabled:!1,isInfoEnabled:!0,isWarnEnabled:!0};function I(e){switch(e){case"debug":globalThis.apirtcReactLibLogLevel={level:"debug",isDebugEnabled:!0,isInfoEnabled:!0,isWarnEnabled:!0};break;case"info":default:globalThis.apirtcReactLibLogLevel=D;break;case"warn":globalThis.apirtcReactLibLogLevel={level:"warn",isDebugEnabled:!1,isInfoEnabled:!1,isWarnEnabled:!0};break;case"error":globalThis.apirtcReactLibLogLevel={level:"error",isDebugEnabled:!1,isInfoEnabled:!1,isWarnEnabled:!1}}return globalThis.apirtcReactLibLogLevel}globalThis.apirtcReactLibLogLevel=D,globalThis.setApirtcReactLibLogLevel=I;export{s as VideoStream,I as setLogLevel,l as useCameraStream,b as useConversation,d as useConversationMessages,L as useConversationModeration,h as useConversationStreams,m as usePresence,T as useSession,y as useStreamApplyVideoProcessor,w as useUserMediaDevices};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/components/VideoStream/VideoStream.tsx","../../src/hooks/useCameraStream.ts","../../src/hooks/useConversation.ts","../../src/hooks/useConversationMessages.ts","../../src/hooks/useConversationModeration.ts","../../src/hooks/useConversationStreams.ts","../../src/hooks/usePresence.ts","../../src/hooks/useSession.ts","../../src/hooks/useStreamApplyVideoProcessor.ts","../../src/hooks/useUserMediaDevices.ts","../../src/index.ts"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport { Stream } from '@apirtc/apirtc'\n\n// tried const Video = styled.video`\n// max-width: 100%;\n// `\n// or\n// /* override other styles to make responsive */\n// width: 100% !important;\n// height: auto !important;\n// or\n// return <video width=\"100%\" ...\n//\n// but for all there is a problem then in react display...\n\nexport interface VideoStreamProps {\n stream: Stream,\n autoPlay?: boolean,\n muted?: boolean\n}\nexport default function VideoStream(props: VideoStreamProps) {\n\n // default autoPlay\n const { autoPlay = true } = props;\n\n const videoRef = useRef<HTMLVideoElement>(null)\n\n useEffect(() => {\n const ref = videoRef.current;\n if (ref && props.stream) {\n props.stream.attachToElement(ref)\n return () => {\n ref.src = \"\";\n }\n }\n }, [props.stream])\n // No need to put videoRef.current because useRef does not trigger rerender anyways\n\n return <video id={props.stream.getId()} style={{ maxWidth: '100%' }}\n ref={videoRef}\n autoPlay={autoPlay}\n muted={props.muted}></video>\n}","import { useState, useEffect } from 'react'\nimport { CreateStreamOptions, Session, Stream, UserAgent } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useCameraStream\";\nexport default function useCameraStream(\n session: Session | undefined,\n options: CreateStreamOptions = {}\n) {\n const [stream, setStream] = useState<Stream>();\n\n useEffect(() => {\n if (session) {\n const userAgent: UserAgent = session.getUserAgent();\n userAgent.createStream(options).then((localStream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|createStream\", options, localStream)\n }\n setStream(localStream)\n }).catch((error: any) => {\n console.error(HOOK_NAME + \"|createStream\", options, error)\n setStream(undefined)\n })\n\n // DO NOT set out stream to undefined in the return, to prevent unnecessary refreshes\n // of other components with undefined stream, whereas we are expecting to change it\n // to another instance..\n // return () => { setStream(undefined) } // DON'T\n } else {\n setStream(undefined)\n }\n\n }, [session, JSON.stringify(options)])\n\n useEffect(() => {\n return () => {\n if (stream) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|release stream\", stream)\n }\n stream.release()\n }\n }\n }, [stream])\n\n return {\n stream\n }\n}","import { useState, useEffect, useCallback } from 'react'\nimport { Conversation, GetOrCreateConversationOptions, Session } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useConversation\";\n/**\n * Please note that the hook won't react on autoJoin change\n */\nexport default function useConversation(\n session: Session | undefined,\n name: string | undefined,\n options?: GetOrCreateConversationOptions,\n join: boolean = false\n) {\n const [conversation, setConversation] = useState<Conversation>();\n const [joined, setJoined] = useState<boolean>(false);\n const [joining, setJoining] = useState<boolean>(false);\n\n // Callbacks\n //\n // Offering Promised join/leave methods allows developer to act on then/catch\n //\n const o_join = useCallback(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|join\", conversation)\n //JSON.stringify((apiRTC as any).session.apiCCWebRTCClient.webRTCClient.MCUClient.sessionMCUs))\n }\n return new Promise<void>((resolve, reject) => {\n if (!conversation) {\n reject(HOOK_NAME + \"|join|conversation not defined\")\n return\n }\n if (!conversation.isJoined()) {\n setJoining(true)\n conversation.join().then(() => {\n // successfully joined the conversation.\n setJoined(true)\n resolve()\n }).catch((error: any) => {\n // could not join the conversation.\n reject(error)\n }).finally(() => {\n setJoining(false)\n })\n } else {\n reject(HOOK_NAME + \"|join|conversation already joined\")\n }\n })\n }, [conversation]);\n\n const o_leave = useCallback(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|leave\", conversation)\n }\n return new Promise<void>((resolve, reject) => {\n if (!conversation) {\n reject(HOOK_NAME + \"|leave|conversation not defined\")\n return\n }\n if (conversation.isJoined()) {\n conversation.leave().then(() => {\n // local user successfully left the conversation.\n setJoined(false)\n resolve()\n }).catch((error: any) => {\n reject(error)\n })\n } else {\n reject(HOOK_NAME + \"|leave|conversation is not joined\")\n }\n })\n }, [conversation]);\n\n // Effects\n //\n useEffect(() => {\n if (session && name) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|getOrCreateConversation\", name, options, join)\n }\n const l_conversation = session.getOrCreateConversation(name, options);\n setConversation(l_conversation)\n return () => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect cleanup\", name, options, join)\n }\n if (l_conversation.isJoined()) {\n l_conversation.leave()\n .then(() => { })\n .catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect conversation.leave()\", error)\n }\n })\n .finally(() => {\n l_conversation.destroy()\n setConversation(undefined)\n setJoined(false)\n })\n } else {\n // It is important to destroy the conversation.\n // Otherwise subsequent getOrCreateConversation with same name would get\n // previous handle, regardless of the potentially new options.\n // This also allows to cleanup memory\n l_conversation.destroy()\n setConversation(undefined)\n }\n }\n }\n }, [session, name, JSON.stringify(options)])\n\n useEffect(() => {\n if (conversation && join) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect\", conversation, join)\n }\n const l_conversation = conversation;\n const l_join = join;\n if (l_join) {\n setJoining(true)\n l_conversation.join().then(() => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|joined\", l_conversation)\n }\n setJoined(true)\n }).catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect conversation.join()\", error)\n }\n }).finally(() => {\n setJoining(false)\n })\n }\n return () => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect cleanup\", l_conversation, l_join)\n }\n if (l_conversation.isJoined()) {\n l_conversation.leave().then(() => {\n setJoined(false)\n }).catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect conversation.leave()\", error)\n }\n })\n }\n }\n }\n }, [conversation, join])\n\n return {\n conversation,\n joining,\n joined,\n join: o_join,\n leave: o_leave\n }\n}","import { useState, useEffect, useCallback } from 'react'\nimport { Contact, Conversation, ConversationMessage } from '@apirtc/apirtc'\n\n// TODO : get and handle with pagination messages history\n// TODO : ask apirtc to include the uuid in ConversationMessage so that we can store it\n// into ConversationMessage when creating the local one, and we get it from conversation on:message\n// the uuid shall be the value used as a react child key when displaying list of messages\n\nconst HOOK_NAME = \"useConversationMessages\";\nexport default function useConversationMessages(\n conversation: Conversation | undefined,\n) {\n // Use an internal array which will always be the same object as far as React knows\n // This will avoid the need for adding it as a dependency for each callback\n const [messages] = useState<Array<ConversationMessage>>(new Array<ConversationMessage>());\n // And use a copy as output array so that client code will react upon change\n // (only a new instance of array is detected by React)\n const [o_messages, setO_Messages] = useState<Array<ConversationMessage>>(new Array<ConversationMessage>());\n\n useEffect(() => {\n if (conversation) {\n const onMessage = (message: ConversationMessage) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:message:\", conversation.getName(), message)\n }\n messages.push(message)\n setO_Messages(Array.from(messages))\n };\n conversation.on('message', onMessage)\n\n return () => {\n conversation.removeListener('message', onMessage)\n messages.length = 0;\n setO_Messages(new Array<any>())\n }\n }\n }, [conversation])\n\n const sendMessage = useCallback((msgContent: string, sender: Contact) => {\n return new Promise<void>((resolve, reject) => {\n conversation?.sendMessage(msgContent)\n .then((uuid: number) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|sentMessage\", conversation.getName(), uuid, msgContent)\n }\n messages.push({ content: msgContent, sender: sender, time: new Date() })\n setO_Messages(Array.from(messages))\n resolve()\n })\n .catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|sendMessage error\", error)\n }\n reject(error)\n })\n })\n }, [conversation]);\n\n return {\n messages: o_messages,\n sendMessage\n }\n}","import { useState, useEffect } from 'react'\nimport { Contact, Conversation } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useConversationModeration\";\nexport default function useConversationModeration(\n conversation: Conversation | undefined,\n onEjected?: (contact: Contact) => void,\n onEjectedSelf?: () => void) {\n\n const [candidates, setCandidates] = useState<Set<Contact>>(new Set<Contact>());\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect conversation\", conversation)\n }\n\n if (conversation) {\n const on_contactJoinedWaitingRoom = (contact: Contact) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:contactJoinedWaitingRoom\", contact)\n }\n // A candidate joined the waiting room.\n candidates.add(contact)\n setCandidates(new Set(candidates))\n };\n const on_contactLeftWaitingRoom = (contact: Contact) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:contactLeftWaitingRoom\", contact)\n }\n // A candidate left the waiting room.\n candidates.delete(contact)\n setCandidates(new Set(candidates))\n };\n // TODO make apirtc.d.ts update to replace 'any'\n const on_participantEjected = (data: any) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:participantEjected\", data)\n }\n if (data.self === true) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|Self participant was ejected\")\n }\n if (onEjectedSelf) {\n onEjectedSelf()\n }\n } else {\n if (onEjected) {\n onEjected(data.contact)\n }\n }\n };\n\n conversation\n .on('contactJoinedWaitingRoom', on_contactJoinedWaitingRoom)\n .on('contactLeftWaitingRoom', on_contactLeftWaitingRoom)\n .on('participantEjected', on_participantEjected)\n\n return () => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|conversation clear\", conversation)\n }\n // remove listeners\n conversation\n .removeListener('contactJoinedWaitingRoom', on_contactJoinedWaitingRoom)\n .removeListener('contactLeftWaitingRoom', on_contactLeftWaitingRoom)\n .removeListener('participantEjected', on_participantEjected)\n setCandidates(new Set())\n }\n }\n }, [conversation])\n\n return {\n candidates\n }\n}","import { useState, useEffect, useCallback } from 'react'\nimport { Conversation, PublishOptions, Stream, StreamInfo } from '@apirtc/apirtc'\n\n// TODO?: add pagination ?\n// interface Options {\n// streamsSubscribePageSize: number\n// }\n\nfunction notEmpty<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined;\n}\n\nconst HOOK_NAME = \"useConversationStreams\";\nexport default function useConversationStreams(\n conversation: Conversation | undefined,\n /** fully managed list of Stream(s) to publish, with associated publish options */\n streamsToPublish: Array<{ stream: Stream, options?: PublishOptions } | undefined | null> = [],\n errorCallback?: (error: any) => void\n) {\n\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|hook`)\n }\n\n // A cache to handle publication differences\n const [publishedStreamsCache, setPublishedStreamsCache] =\n useState<Array<{ stream: Stream, options?: PublishOptions } | undefined | null>>([]);\n\n // Use an internal array which will always be the same object as far as React knows\n // This will avoid the need for adding it as a dependency for each callback\n const [publishedStreams] = useState<Array<Stream>>(new Array<Stream>());\n // And use a copy as output array so that client code will react upon change\n // (only a new instance of array is detected by React)\n const [o_publishedStreams, setO_PublishedStreams] = useState<Array<Stream>>(new Array<Stream>());\n\n const [subscribedStreams] = useState<Array<Stream>>(new Array<Stream>());\n const [o_subscribedStreams, setO_SubscribedStreams] = useState<Array<Stream>>(new Array<Stream>());\n\n const publish: (localStream: Stream, options?: PublishOptions) => Promise<Stream> =\n useCallback((localStream: Stream, options?: PublishOptions) => {\n return new Promise<Stream>((resolve, reject) => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|publish|${conversation.getName()}`, localStream, options)\n }\n conversation.publish(localStream, options).then((stream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(`${HOOK_NAME}|published|${conversation.getName()}`, stream)\n }\n //console.log(`PUSHING ${stream.getId()} to publishedStreams`, JSON.stringify(publishedStreams.map(s => s.getId())))\n publishedStreams.push(stream)\n // Returning a new array makes lets React detect changes\n setO_PublishedStreams(Array.from(publishedStreams))\n resolve(stream)\n }).catch((error: any) => {\n reject(error)\n })\n }\n })\n }, [conversation]);\n\n const replacePublishedStream = useCallback((oldStream: Stream, newStream: Stream, options?: PublishOptions) => {\n return new Promise<Stream>((resolve, reject) => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|replacePublishedStream|${conversation.getName()}|${oldStream.getId()} -> ${newStream.getId()}(${JSON.stringify(options)})`)\n }\n const conversationCall = conversation.getConversationCall(oldStream);\n if (conversationCall) {\n conversationCall.replacePublishedStream(newStream, undefined, options)\n .then((stream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(`${HOOK_NAME}|stream replaced|${conversation.getName()}`, oldStream, stream, options)\n }\n const index = publishedStreams.indexOf(oldStream);\n if (index >= 0) {\n publishedStreams.splice(index, 1, stream)\n setO_PublishedStreams(Array.from(publishedStreams))\n }\n resolve(stream)\n }).catch((error: any) => {\n reject(error)\n })\n }\n }\n })\n }, [conversation]);\n\n const unpublish: (localStream: Stream) => void = useCallback((localStream: Stream) => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|unpublish|${conversation.getName()}`, localStream)\n }\n conversation.unpublish(localStream)\n const index = publishedStreams.indexOf(localStream);\n if (index >= 0) {\n publishedStreams.splice(index, 1)\n setO_PublishedStreams(Array.from(publishedStreams))\n }\n }\n }, [conversation]);\n\n const doHandlePublication = useCallback(() => {\n const maxLength = Math.max(publishedStreamsCache.length, streamsToPublish.length);\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|doHandlePublication\", streamsToPublish,\n JSON.stringify(publishedStreamsCache.map(l_s => l_s?.stream.getId())), maxLength)\n }\n\n // Strategy for published streams cache is to initialize it as it should be\n // and remove items if publication fails.\n const newPublishedStreamsCache = [...streamsToPublish];\n setPublishedStreamsCache(newPublishedStreamsCache)\n\n // Prepare a set for Streams to publish, for further optimized check\n const streamsToPublishSet = new Set(streamsToPublish.filter(notEmpty).map((item) => item.stream));\n\n // Loop on arrays index to publish new streams, or replace if necessary\n for (let i = 0; i < maxLength; i++) {\n const previous = publishedStreamsCache[i];\n const next = streamsToPublish[i];\n\n if (previous && next) {\n const doReplacePublishedStream = () => {\n replacePublishedStream(previous.stream, next.stream, next.options)\n .catch((error: Error) => {\n newPublishedStreamsCache.splice(i, 1, null)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(`${HOOK_NAME}|replacePublishedStream|error`, error)\n }\n })\n }\n if (previous.stream === next.stream) {\n // Streams are the same, only replace if options are different\n if (JSON.stringify(previous.options) !== JSON.stringify(next.options)) {\n doReplacePublishedStream()\n }\n } else {\n // If position in both new and cached list are defined but are different:\n // replace if and only if stream to unpublish shall not be published (at other position)\n if (streamsToPublishSet.has(previous.stream)) { // previous shall be published\n // Previous shall actually be published (at another position), so don't do anything about it\n // But then we still have to publish new stream (if not already published)\n if (conversation && !conversation.isPublishedStream(next.stream)) {\n publish(next.stream, next.options).catch((error: Error) => {\n newPublishedStreamsCache.splice(i, 1, null)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(`${HOOK_NAME}|publish|error`, error)\n }\n })\n }\n } else {\n if (conversation && !conversation.isPublishedStream(next.stream)) {\n doReplacePublishedStream()\n } else { // new stream is already published\n // So we shall not replace another stream by it, but we need to unpublish the previous\n unpublish(previous.stream)\n }\n }\n }\n } else if (previous && !next) {\n // If position in new list is now undefined(or null) while it was in cache:\n // unpublish if and only if stream to unpublish shall not be published (at other position)\n if (!streamsToPublishSet.has(previous.stream)) {\n unpublish(previous.stream)\n }\n } else if (!previous && next) {\n // If position in new list is valid : publish it whatever the position in cache.\n // Depending on the case the stream might be already published, or it might be not\n // (can happen if the cache was set while Conversation was not joined yet).\n // Note that we could try to publish without checking isPublishedStream, the call would\n // reject with a console error but this would not affect the behavior.\n if (conversation && !conversation.isPublishedStream(next.stream)) {\n publish(next.stream, next.options).catch((error: Error) => {\n newPublishedStreamsCache.splice(i, 1, null)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(`${HOOK_NAME}|publish|error`, error)\n }\n })\n }\n }\n }\n }, [conversation,\n streamsToPublish,\n publishedStreamsCache,\n publish, unpublish, replacePublishedStream]);\n\n // --------------------------------------------------------------------------\n // useEffect(s) - Order is important\n //\n useEffect(() => {\n if (conversation) {\n const on_streamAdded = (remoteStream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_streamAdded\", remoteStream)\n }\n subscribedStreams.push(remoteStream)\n setO_SubscribedStreams(Array.from(subscribedStreams))\n };\n const on_streamRemoved = (remoteStream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_streamRemoved\", remoteStream)\n }\n const index = subscribedStreams.indexOf(remoteStream);\n if (index >= 0) {\n subscribedStreams.splice(index, 1)\n setO_SubscribedStreams(Array.from(subscribedStreams))\n }\n };\n const on_streamListChanged = (streamInfo: StreamInfo) => {\n const streamId = String(streamInfo.streamId);\n if (streamInfo.isRemote === true) {\n if (streamInfo.listEventType === 'added') {\n // a remote stream was published\n conversation.subscribeToStream(streamId)\n } else if (streamInfo.listEventType === 'removed') {\n // a remote stream is not published anymore\n conversation.unsubscribeToStream(streamId)\n }\n }\n };\n // Subscribe to incoming streams\n conversation.on('streamAdded', on_streamAdded)\n conversation.on('streamRemoved', on_streamRemoved)\n conversation.on('streamListChanged', on_streamListChanged)\n\n return () => {\n // remove listeners\n conversation.removeListener('streamListChanged', on_streamListChanged)\n conversation.removeListener('streamRemoved', on_streamRemoved)\n conversation.removeListener('streamAdded', on_streamAdded)\n }\n }\n }, [conversation])\n\n const unpublishAndUnsubscribeAll = (i_conversation: Conversation) => {\n publishedStreams.forEach(stream => {\n i_conversation.unpublish(stream)\n })\n // Clear internal array\n publishedStreams.length = 0;\n\n // Clear cache\n setPublishedStreamsCache([])\n\n subscribedStreams.forEach(stream => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|unsubscribeToStream stream\", i_conversation, stream)\n }\n i_conversation.unsubscribeToStream(stream.getId())\n })\n // Clear internal array\n subscribedStreams.length = 0;\n\n // Clear output arrays with new array so that parent gets notified of a change.\n // Simply setting length to 0 is not detected by react.\n setO_PublishedStreams(new Array<Stream>())\n setO_SubscribedStreams(new Array<Stream>())\n };\n\n useEffect(() => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect doHandlePublication\", conversation.getName())\n }\n\n const on_joined = () => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_joined\", conversation.getName(), streamsToPublish)\n }\n doHandlePublication()\n };\n const on_left = () => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_left\", conversation.getName())\n }\n // Forcing unpublish will allow to republish if joining again\n unpublishAndUnsubscribeAll(conversation)\n };\n\n conversation.on('joined', on_joined)\n conversation.on('left', on_left)\n\n return () => {\n conversation.removeListener('joined', on_joined)\n conversation.removeListener('left', on_left)\n }\n }\n }, [doHandlePublication]) // Don't add 'conversation' in here because\n // doHandlePublication already changes on conversation change\n\n // subscribeToStream(s) after having set listeners\n //\n useEffect(() => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|conversation|${conversation.getName()}`, conversation)\n }\n // Subscribe to existing remote streams\n conversation.getAvailableStreamList().forEach((streamInfo: StreamInfo) => {\n const streamId = String(streamInfo.streamId);\n if (streamInfo.isRemote === true) {\n conversation.subscribeToStream(streamId)\n }\n })\n return () => {\n unpublishAndUnsubscribeAll(conversation)\n }\n }\n }, [conversation])\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|streamsToPublish`,\n JSON.stringify(streamsToPublish.map(l_s => l_s?.stream.getId() + '-' + JSON.stringify(l_s?.options))))\n }\n if (conversation && conversation.isJoined()) {\n doHandlePublication()\n }\n }, [JSON.stringify(streamsToPublish.map(l_s => l_s?.stream.getId() + '-' + JSON.stringify(l_s?.options)))])\n\n return {\n publishedStreams: o_publishedStreams,\n subscribedStreams: o_subscribedStreams,\n publish,\n unpublish,\n replacePublishedStream\n }\n}\n","import { useState, useEffect } from 'react'\nimport { Session, Contact } from '@apirtc/apirtc'\n\n/**\n * Subscribe to groups and returns contactsByGroup (of theses groups only) when updated.\n * If input groups list is updated, this hooks works diff with the previous set in order\n * to make as little as possible unsubscribe/subscribe calls.\n */\n\nconst HOOK_NAME = \"usePresence\";\nexport default function usePresence(session: Session | undefined, groups: Array<string>) {\n\n const [groupsCache] = useState<Set<string>>(new Set());\n\n const [m_contactsByGroup] = useState<Map<string, Set<Contact>>>(new Map());\n\n const [contactsByGroup, setContactsByGroup] = useState<Map<string, Set<Contact>>>(new Map());\n\n useEffect(() => {\n if (session) {\n return () => {\n m_contactsByGroup.clear()\n setContactsByGroup(new Map(m_contactsByGroup))\n groupsCache.clear()\n }\n }\n }, [session])\n\n const getOrCreateGroupSet = (group: string) => {\n const o_set = m_contactsByGroup.get(group) ?? new Set();\n if (!m_contactsByGroup.has(group)) {\n m_contactsByGroup.set(group, o_set)\n }\n return o_set\n };\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect session, groups\", groups)\n }\n if (session) {\n const l_session = session;\n const l_groupsSet = new Set(groups);\n\n // Diff update subscription to groups\n //\n l_groupsSet.forEach(group => {\n if (!groupsCache.has(group)) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|subscribeToGroup\", group)\n }\n groupsCache.add(group)\n l_session.subscribeToGroup(group)\n }\n })\n\n let needsRefresh = false;\n groupsCache.forEach(group => {\n if (!l_groupsSet.has(group)) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|unsubscribeToGroup\", group)\n }\n l_session.unsubscribeToGroup(group)\n groupsCache.delete(group)\n m_contactsByGroup.delete(group)\n needsRefresh = true;\n }\n })\n\n if (needsRefresh) {\n // contactsByGroup is exposed, so change the Map object to let client code detect a change.\n setContactsByGroup(new Map(m_contactsByGroup))\n }\n\n if (groups.length > 0) {\n const onContactListUpdate = (updatedContacts: any) => {\n\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|contactListUpdate\", updatedContacts)\n }\n\n let needsRefresh = false;\n\n // Maintain Map of Contacts per Group\n //\n for (const group of Object.keys(updatedContacts.joinedGroup)) {\n if (l_groupsSet.has(group)) {\n const l_set = getOrCreateGroupSet(group);\n for (const contact of updatedContacts.joinedGroup[group]) {\n l_set.add(contact)\n needsRefresh = true;\n }\n }\n }\n for (const group of Object.keys(updatedContacts.leftGroup)) {\n if (l_groupsSet.has(group)) {\n const l_set = getOrCreateGroupSet(group);\n for (const contact of updatedContacts.leftGroup[group]) {\n l_set.delete(contact)\n needsRefresh = true;\n\n // if set is empty, no need to keep the group as key in the map\n if (l_set.size === 0) {\n m_contactsByGroup.delete(group)\n }\n }\n }\n }\n\n // For data updates, trigger a refresh if and only if contact is part of managed groups\n for (const contact of updatedContacts.userDataChanged as Contact[]) {\n for (const l_contacts of m_contactsByGroup.values()) {\n if (l_contacts.has(contact)) {\n needsRefresh = true;\n break;\n }\n }\n }\n\n if (needsRefresh) {\n // contactsByGroup is exposed, so change the Map object to let client code detect a change.\n setContactsByGroup(new Map(m_contactsByGroup))\n }\n };\n l_session.on('contactListUpdate', onContactListUpdate)\n return () => {\n l_session.removeListener('contactListUpdate', onContactListUpdate)\n }\n }\n }\n }, [session, JSON.stringify(groups)])\n\n return {\n contactsByGroup\n }\n}","import { useEffect, useState } from 'react'\nimport { Session, UserAgent, RegisterInformation } from '@apirtc/apirtc'\n\ntype LoginPassword = {\n username: string\n password: string\n};\n\nfunction isInstanceOfLoginPassword(object: any): object is LoginPassword {\n if (typeof object !== 'object') return false;\n return 'username' in object;\n}\n\ntype ApiKey = { apiKey: string };\nfunction isInstanceOfApiKey(object: any): object is ApiKey {\n if (typeof object !== 'object') return false;\n return 'apiKey' in object;\n}\n\ntype Token = { token: string };\nfunction isInstanceOfToken(object: any): object is Token {\n if (typeof object !== 'object') return false;\n return 'token' in object;\n}\n\nexport type Credentials = LoginPassword | ApiKey | Token;\n\nconst HOOK_NAME = \"useSession\";\nexport default function useSession(credentials?: Credentials, options?: RegisterInformation) {\n\n const [session, setSession] = useState<Session | undefined>()\n const [connecting, setConnecting] = useState<boolean>(false)\n const [error, setError] = useState<any>()\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect credentials, options\", credentials, options)\n }\n if (credentials) {\n // To fix errors like \"Warning: Can't perform a React state update on an unmounted component\"\n // https://stackoverflow.com/questions/53949393/cant-perform-a-react-state-update-on-an-unmounted-component\n let isMounted = true;\n connect(credentials, options).catch((error: any) => {\n console.error(HOOK_NAME + \"|connection failed\", error, isMounted)\n setSession(undefined)\n if (isMounted) {\n setError(error)\n }\n })\n return () => {\n isMounted = false;\n setSession(undefined)\n // Even though connecting is managed in connect(),\n // mark connecting to false when credentials are changed\n // as this shall be way to connect elsewhere or connect to\n // with other credentials. Note that to be perfect we should\n // cancel the potentially running connect : Is that possible with ApiRTC ?\n setConnecting(false)\n setError(undefined)\n }\n }\n }, [JSON.stringify(credentials), JSON.stringify(options)])\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect session\", session)\n }\n if (session) {\n const l_session = session;\n return () => {\n l_session.disconnect().then(() => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|disconnected\", l_session)\n }\n }).catch((error: any) => {\n console.error(HOOK_NAME + \"|disconnect\", error)\n })\n }\n }\n }, [session])\n\n const connect = (credentials: Credentials | undefined, options?: RegisterInformation) => {\n return new Promise<void>((resolve, reject) => {\n const registerInformation: RegisterInformation = options ? options : {\n cloudUrl: 'https://cloud.apirtc.com',\n };\n\n let l_userAgent;\n\n if (isInstanceOfLoginPassword(credentials)) {\n registerInformation.password = credentials.password;\n l_userAgent = new UserAgent({\n uri: 'apirtc:' + credentials.username\n });\n } else if (isInstanceOfApiKey(credentials)) {\n l_userAgent = new UserAgent({\n uri: `apiKey:${credentials.apiKey}`\n });\n } else if (isInstanceOfToken(credentials)) {\n l_userAgent = new UserAgent({\n uri: `token:${credentials.token}`\n });\n } else {\n reject(\"credentials not recognized\")\n return\n }\n\n setConnecting(true)\n l_userAgent.register(registerInformation).then(l_session => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|connected\", l_session)\n }\n setSession(l_session)\n resolve()\n }).catch((error: any) => {\n reject(error)\n }).finally(() => {\n setConnecting(false)\n })\n })\n }\n\n // const disconnect = useCallback(() => {\n // return new Promise<void>((resolve, reject) => {\n // if (session) {\n // const l_session = session;\n // l_session.disconnect().then(() => {\n // console.log(HOOK_NAME + \"|disconnected\", l_session)\n // setSession(undefined)\n // resolve()\n // }).catch((error: any) => {\n // console.error(HOOK_NAME + \"|disconnect\", error)\n // reject(error)\n // })\n // } else {\n // resolve()\n // }\n // })\n // }, [session])\n\n const disconnect = () => {\n setSession(undefined)\n };\n\n return {\n //userAgent: userAgent, // can get it from session\n session: session,\n connecting,\n connect,\n disconnect,\n error\n }\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { Stream, VideoProcessorOptions } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useStreamApplyVideoProcessor\";\n/**\n * This hook takes stream passed as parameter, and\n * returns either this stream or a stream with video processor applied.\n * This is controlled by the videoProcessorType input attribute.\n * By default the output stream is the input stream.\n * The hook fully manages the output stream (applies 'none' if input stream is set to undefined).\n * The hook never releases the input stream.\n * \n * @param stream \n * @returns stream blurred or not, toggle method, boolean blurred state.\n */\nexport default function useStreamApplyVideoProcessor(\n stream: Stream | undefined,\n videoProcessorType: 'none' | 'blur' | 'backgroundImage', options?: VideoProcessorOptions,\n errorCallback?: (error: any) => void) {\n //\n const [outStream, setOutStream] = useState(stream);\n const [applied, setApplied] = useState<'none' | 'blur' | 'backgroundImage'>('none')\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect\", stream, videoProcessorType, options)\n }\n if (stream && videoProcessorType !== 'none') {\n stream.applyVideoProcessor(videoProcessorType, options).then(l_stream => {\n setOutStream(l_stream)\n setApplied(videoProcessorType)\n }).catch(error => {\n setOutStream(stream)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect\", stream, videoProcessorType, options, error)\n }\n setApplied(previousValue => previousValue)\n })\n } else {\n setOutStream(stream)\n setApplied('none')\n }\n }, [stream, videoProcessorType, options])\n\n const doCheckAndReleaseOutStream = useCallback(() => {\n if (outStream && (outStream !== stream)) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|releasing outStream\", outStream)\n }\n // stream?.applyVideoProcessor('none').catch(error => {\n // if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n // console.warn(HOOK_NAME + \"|doCheckAndReleaseOutStream\", stream, outStream)\n // }\n // })\n outStream.release()\n }\n }, [stream, outStream])\n\n useEffect(() => {\n return () => {\n doCheckAndReleaseOutStream()\n }\n }, [outStream])\n\n return {\n stream: outStream,\n applied\n }\n}","import { useState, useEffect } from 'react'\nimport { MediaDeviceList, Session, UserAgent } from '@apirtc/apirtc'\n\nconst EMPTY_LIST: MediaDeviceList = { audioinput: {}, audiooutput: {}, videoinput: {} }\n\nconst HOOK_NAME = \"useUserMediaDevices\";\nexport default function useUserMediaDevices(\n session: Session | undefined\n) {\n const [userMediaDevices, setUserMediaDevices] = useState<MediaDeviceList>(EMPTY_LIST)\n\n useEffect(() => {\n if (session) {\n const userAgent: UserAgent = session.getUserAgent();\n\n const on_mediaDeviceChanged = () => {\n const mediaDevices: MediaDeviceList = userAgent.getUserMediaDevices()\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|mediaDeviceChanged\", mediaDevices)\n }\n setUserMediaDevices(mediaDevices)\n };\n userAgent.on(\"mediaDeviceChanged\", on_mediaDeviceChanged)\n\n return () => {\n userAgent.removeListener('mediaDeviceChanged', on_mediaDeviceChanged)\n setUserMediaDevices(EMPTY_LIST)\n }\n }\n }, [session])\n\n return {\n userMediaDevices\n }\n}","export * from './components'\nexport * from './hooks'\n\ntype LogLevel = {\n level: 'debug' | 'info' | 'warn' | 'error'\n isDebugEnabled: boolean\n isInfoEnabled: boolean\n isWarnEnabled: boolean\n}\n\nconst INFO: LogLevel = { level: 'info', isDebugEnabled: false, isInfoEnabled: true, isWarnEnabled: true };\n\ndeclare global {\n var apirtcReactLibLogLevel: LogLevel;\n var setApirtcReactLibLogLevel: Function;\n}\n\n// a default value MUST be set in case application using the library does not override it\nglobalThis.apirtcReactLibLogLevel = INFO;\n\nexport function setLogLevel(logLevelText: 'debug' | 'info' | 'warn' | 'error' | string) {\n switch (logLevelText) {\n case 'debug':\n globalThis.apirtcReactLibLogLevel = { level: 'debug', isDebugEnabled: true, isInfoEnabled: true, isWarnEnabled: true };\n break\n case 'info':\n globalThis.apirtcReactLibLogLevel = INFO;\n break\n case 'warn':\n globalThis.apirtcReactLibLogLevel = { level: 'warn', isDebugEnabled: false, isInfoEnabled: false, isWarnEnabled: true };\n break\n case 'error':\n globalThis.apirtcReactLibLogLevel = { level: 'error', isDebugEnabled: false, isInfoEnabled: false, isWarnEnabled: false };\n break\n default:\n // in case null is passed as input, default to 'info'\n globalThis.apirtcReactLibLogLevel = INFO;\n }\n return globalThis.apirtcReactLibLogLevel\n}\n\nglobalThis.setApirtcReactLibLogLevel = setLogLevel;\n"],"names":["VideoStream","props","autoPlay","videoRef","useRef","useEffect","ref","current","stream","attachToElement","src","React","createElement","id","getId","style","maxWidth","muted","HOOK_NAME","useCameraStream","session","options","setStream","useState","getUserAgent","createStream","then","localStream","globalThis","apirtcReactLibLogLevel","isInfoEnabled","console","info","catch","error","undefined","JSON","stringify","release","useConversation","name","join","conversation","setConversation","joined","setJoined","joining","setJoining","o_join","useCallback","isDebugEnabled","debug","Promise","resolve","reject","isJoined","finally","o_leave","leave","l_conversation","getOrCreateConversation","isWarnEnabled","warn","destroy","l_join","useConversationMessages","messages","Array","o_messages","setO_Messages","onMessage","message","getName","push","from","on","removeListener","length","sendMessage","msgContent","sender","uuid","content","time","Date","useConversationModeration","onEjected","onEjectedSelf","candidates","setCandidates","Set","on_contactJoinedWaitingRoom","contact","add","on_contactLeftWaitingRoom","delete","on_participantEjected","data","self","notEmpty","value","useConversationStreams","streamsToPublish","errorCallback","publishedStreamsCache","setPublishedStreamsCache","publishedStreams","o_publishedStreams","setO_PublishedStreams","subscribedStreams","o_subscribedStreams","setO_SubscribedStreams","publish","replacePublishedStream","oldStream","newStream","conversationCall","getConversationCall","index","indexOf","splice","unpublish","doHandlePublication","maxLength","Math","max","map","l_s","newPublishedStreamsCache","streamsToPublishSet","filter","item","i","previous","next","doReplacePublishedStream","has","isPublishedStream","on_streamAdded","remoteStream","on_streamRemoved","on_streamListChanged","streamInfo","streamId","String","isRemote","listEventType","subscribeToStream","unsubscribeToStream","unpublishAndUnsubscribeAll","i_conversation","forEach","on_joined","on_left","getAvailableStreamList","usePresence","groups","groupsCache","m_contactsByGroup","Map","contactsByGroup","setContactsByGroup","clear","getOrCreateGroupSet","group","o_set","_a","get","set","l_session","l_groupsSet","subscribeToGroup","needsRefresh","unsubscribeToGroup","onContactListUpdate","updatedContacts","Object","keys","joinedGroup","l_set","leftGroup","size","userDataChanged","l_contacts","values","useSession","credentials","setSession","connecting","setConnecting","setError","isMounted","connect","disconnect","registerInformation","cloudUrl","l_userAgent","object","password","UserAgent","uri","username","isInstanceOfApiKey","apiKey","isInstanceOfToken","token","register","useStreamApplyVideoProcessor","videoProcessorType","outStream","setOutStream","applied","setApplied","applyVideoProcessor","l_stream","previousValue","doCheckAndReleaseOutStream","EMPTY_LIST","audioinput","audiooutput","videoinput","useUserMediaDevices","userMediaDevices","setUserMediaDevices","userAgent","on_mediaDeviceChanged","mediaDevices","getUserMediaDevices","INFO","level","setLogLevel","logLevelText","setApirtcReactLibLogLevel"],"mappings":"2HAoBwB,SAAAA,EAAYC,GAGhC,MAAMC,SAAEA,GAAW,GAASD,EAEtBE,EAAWC,EAAyB,MAa1C,OAXAC,GAAU,KACN,MAAMC,EAAMH,EAASI,QACrB,GAAID,GAAOL,EAAMO,OAEb,OADAP,EAAMO,OAAOC,gBAAgBH,GACtB,KACHA,EAAII,IAAM,EAAE,CAEnB,GACF,CAACT,EAAMO,SAGHG,EAAOC,cAAA,QAAA,CAAAC,GAAIZ,EAAMO,OAAOM,QAASC,MAAO,CAAEC,SAAU,QACvDV,IAAKH,EACLD,SAAUA,EACVe,MAAOhB,EAAMgB,OACrB,CCvCA,MAAMC,EAAY,kBACM,SAAAC,EACpBC,EACAC,EAA+B,IAE/B,MAAOb,EAAQc,GAAaC,IAoC5B,OAlCAlB,GAAU,KACN,GAAIe,EAAS,CACoBA,EAAQI,eAC3BC,aAAaJ,GAASK,MAAMC,IAC9BC,WAAWC,uBAAuBC,eAClCC,QAAQC,KAAKd,EAAY,gBAAiBG,EAASM,GAEvDL,EAAUK,EAAY,IACvBM,OAAOC,IACNH,QAAQG,MAAMhB,EAAY,gBAAiBG,EAASa,GACpDZ,OAAUa,EAAU,GAO3B,MACGb,OAAUa,EACb,GAEF,CAACf,EAASgB,KAAKC,UAAUhB,KAE5BhB,GAAU,IACC,KACCG,IAC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,uBAAuBC,eAClCC,QAAQC,KAAKd,yCAAmCgN,GAEpDH,EAAoBG,EAAa,EAIrC,OAFAF,EAAUrJ,GAAG,qBAAsBsJ,GAE5B,KACHD,EAAUpJ,eAAe,qBAAsBqJ,GAC/CF,EAAoBN,EAAW,CAEtC,IACF,CAACrM,IAEG,CACH0M,mBAER,CCxBA,MAAMM,EAAiB,CAAEC,MAAO,OAAQnL,gBAAgB,EAAOpB,eAAe,EAAM+B,eAAe,GAU7F,SAAUyK,EAAYC,GACxB,OAAQA,GACJ,IAAK,QACD3M,WAAWC,uBAAyB,CAAEwM,MAAO,QAASnL,gBAAgB,EAAMpB,eAAe,EAAM+B,eAAe,GAChH,MACJ,IAAK,OASL,QAEIjC,WAAWC,uBAAyBuM,QARxC,IAAK,OACDxM,WAAWC,uBAAyB,CAAEwM,MAAO,OAAQnL,gBAAgB,EAAOpB,eAAe,EAAO+B,eAAe,GACjH,MACJ,IAAK,QACDjC,WAAWC,uBAAyB,CAAEwM,MAAO,QAASnL,gBAAgB,EAAOpB,eAAe,EAAO+B,eAAe,GAM1H,OAAOjC,WAAWC,sBACtB,CArBAD,WAAWC,uBAAyBuM,EAuBpCxM,WAAW4M,0BAA4BF"}
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as useCameraStream } from "./useCameraStream";
|
|
2
|
+
export { default as useConversation } from "./useConversation";
|
|
3
|
+
export { default as useConversationMessages } from "./useConversationMessages";
|
|
4
|
+
export { default as useConversationModeration } from "./useConversationModeration";
|
|
5
|
+
export { default as useConversationStreams } from "./useConversationStreams";
|
|
6
|
+
export { default as usePresence } from "./usePresence";
|
|
7
|
+
export { default as useSession, Credentials } from "./useSession";
|
|
8
|
+
export { default as useStreamApplyVideoProcessor } from './useStreamApplyVideoProcessor';
|
|
9
|
+
export { default as useUserMediaDevices } from "./useUserMediaDevices";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Conversation, GetOrCreateConversationOptions, Session } from '@apirtc/apirtc';
|
|
2
|
+
/**
|
|
3
|
+
* Please note that the hook won't react on autoJoin change
|
|
4
|
+
*/
|
|
5
|
+
export default function useConversation(session: Session | undefined, name: string | undefined, options?: GetOrCreateConversationOptions, join?: boolean): {
|
|
6
|
+
conversation: Conversation | undefined;
|
|
7
|
+
joining: boolean;
|
|
8
|
+
joined: boolean;
|
|
9
|
+
join: () => Promise<void>;
|
|
10
|
+
leave: () => Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Contact, Conversation, ConversationMessage } from '@apirtc/apirtc';
|
|
2
|
+
export default function useConversationMessages(conversation: Conversation | undefined): {
|
|
3
|
+
messages: ConversationMessage[];
|
|
4
|
+
sendMessage: (msgContent: string, sender: Contact) => Promise<void>;
|
|
5
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Conversation, PublishOptions, Stream } from '@apirtc/apirtc';
|
|
2
|
+
export default function useConversationStreams(conversation: Conversation | undefined,
|
|
3
|
+
/** fully managed list of Stream(s) to publish, with associated publish options */
|
|
4
|
+
streamsToPublish?: Array<{
|
|
5
|
+
stream: Stream;
|
|
6
|
+
options?: PublishOptions;
|
|
7
|
+
} | undefined | null>, errorCallback?: (error: any) => void): {
|
|
8
|
+
publishedStreams: Stream[];
|
|
9
|
+
subscribedStreams: Stream[];
|
|
10
|
+
publish: (localStream: Stream, options?: PublishOptions) => Promise<Stream>;
|
|
11
|
+
unpublish: (localStream: Stream) => void;
|
|
12
|
+
replacePublishedStream: (oldStream: Stream, newStream: Stream, options?: PublishOptions) => Promise<Stream>;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Session, RegisterInformation } from '@apirtc/apirtc';
|
|
2
|
+
type LoginPassword = {
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
};
|
|
6
|
+
type ApiKey = {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
};
|
|
9
|
+
type Token = {
|
|
10
|
+
token: string;
|
|
11
|
+
};
|
|
12
|
+
export type Credentials = LoginPassword | ApiKey | Token;
|
|
13
|
+
export default function useSession(credentials?: Credentials, options?: RegisterInformation): {
|
|
14
|
+
session: Session | undefined;
|
|
15
|
+
connecting: boolean;
|
|
16
|
+
connect: (credentials: Credentials | undefined, options?: RegisterInformation) => Promise<void>;
|
|
17
|
+
disconnect: () => void;
|
|
18
|
+
error: any;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Stream, VideoProcessorOptions } from '@apirtc/apirtc';
|
|
2
|
+
/**
|
|
3
|
+
* This hook takes stream passed as parameter, and
|
|
4
|
+
* returns either this stream or a stream with video processor applied.
|
|
5
|
+
* This is controlled by the videoProcessorType input attribute.
|
|
6
|
+
* By default the output stream is the input stream.
|
|
7
|
+
* The hook fully manages the output stream (applies 'none' if input stream is set to undefined).
|
|
8
|
+
* The hook never releases the input stream.
|
|
9
|
+
*
|
|
10
|
+
* @param stream
|
|
11
|
+
* @returns stream blurred or not, toggle method, boolean blurred state.
|
|
12
|
+
*/
|
|
13
|
+
export default function useStreamApplyVideoProcessor(stream: Stream | undefined, videoProcessorType: 'none' | 'blur' | 'backgroundImage', options?: VideoProcessorOptions, errorCallback?: (error: any) => void): {
|
|
14
|
+
stream: Stream | undefined;
|
|
15
|
+
applied: "none" | "blur" | "backgroundImage";
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './getDisplayMedia.mock';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Stream, Session, CreateStreamOptions, GetOrCreateConversationOptions, Conversation, ConversationMessage, Contact, PublishOptions, RegisterInformation, VideoProcessorOptions, MediaDeviceList } from '@apirtc/apirtc';
|
|
3
|
+
|
|
4
|
+
interface VideoStreamProps {
|
|
5
|
+
stream: Stream;
|
|
6
|
+
autoPlay?: boolean;
|
|
7
|
+
muted?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare function VideoStream(props: VideoStreamProps): JSX.Element;
|
|
10
|
+
|
|
11
|
+
declare function useCameraStream(session: Session | undefined, options?: CreateStreamOptions): {
|
|
12
|
+
stream: Stream | undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Please note that the hook won't react on autoJoin change
|
|
17
|
+
*/
|
|
18
|
+
declare function useConversation(session: Session | undefined, name: string | undefined, options?: GetOrCreateConversationOptions, join?: boolean): {
|
|
19
|
+
conversation: Conversation | undefined;
|
|
20
|
+
joining: boolean;
|
|
21
|
+
joined: boolean;
|
|
22
|
+
join: () => Promise<void>;
|
|
23
|
+
leave: () => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
declare function useConversationMessages(conversation: Conversation | undefined): {
|
|
27
|
+
messages: ConversationMessage[];
|
|
28
|
+
sendMessage: (msgContent: string, sender: Contact) => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
declare function useConversationModeration(conversation: Conversation | undefined, onEjected?: (contact: Contact) => void, onEjectedSelf?: () => void): {
|
|
32
|
+
candidates: Set<Contact>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
declare function useConversationStreams(conversation: Conversation | undefined,
|
|
36
|
+
/** fully managed list of Stream(s) to publish, with associated publish options */
|
|
37
|
+
streamsToPublish?: Array<{
|
|
38
|
+
stream: Stream;
|
|
39
|
+
options?: PublishOptions;
|
|
40
|
+
} | undefined | null>, errorCallback?: (error: any) => void): {
|
|
41
|
+
publishedStreams: Stream[];
|
|
42
|
+
subscribedStreams: Stream[];
|
|
43
|
+
publish: (localStream: Stream, options?: PublishOptions) => Promise<Stream>;
|
|
44
|
+
unpublish: (localStream: Stream) => void;
|
|
45
|
+
replacePublishedStream: (oldStream: Stream, newStream: Stream, options?: PublishOptions) => Promise<Stream>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
declare function usePresence(session: Session | undefined, groups: Array<string>): {
|
|
49
|
+
contactsByGroup: Map<string, Set<Contact>>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type LoginPassword = {
|
|
53
|
+
username: string;
|
|
54
|
+
password: string;
|
|
55
|
+
};
|
|
56
|
+
type ApiKey = {
|
|
57
|
+
apiKey: string;
|
|
58
|
+
};
|
|
59
|
+
type Token = {
|
|
60
|
+
token: string;
|
|
61
|
+
};
|
|
62
|
+
type Credentials = LoginPassword | ApiKey | Token;
|
|
63
|
+
declare function useSession(credentials?: Credentials, options?: RegisterInformation): {
|
|
64
|
+
session: Session | undefined;
|
|
65
|
+
connecting: boolean;
|
|
66
|
+
connect: (credentials: Credentials | undefined, options?: RegisterInformation) => Promise<void>;
|
|
67
|
+
disconnect: () => void;
|
|
68
|
+
error: any;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* This hook takes stream passed as parameter, and
|
|
73
|
+
* returns either this stream or a stream with video processor applied.
|
|
74
|
+
* This is controlled by the videoProcessorType input attribute.
|
|
75
|
+
* By default the output stream is the input stream.
|
|
76
|
+
* The hook fully manages the output stream (applies 'none' if input stream is set to undefined).
|
|
77
|
+
* The hook never releases the input stream.
|
|
78
|
+
*
|
|
79
|
+
* @param stream
|
|
80
|
+
* @returns stream blurred or not, toggle method, boolean blurred state.
|
|
81
|
+
*/
|
|
82
|
+
declare function useStreamApplyVideoProcessor(stream: Stream | undefined, videoProcessorType: 'none' | 'blur' | 'backgroundImage', options?: VideoProcessorOptions, errorCallback?: (error: any) => void): {
|
|
83
|
+
stream: Stream | undefined;
|
|
84
|
+
applied: "none" | "blur" | "backgroundImage";
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
declare function useUserMediaDevices(session: Session | undefined): {
|
|
88
|
+
userMediaDevices: MediaDeviceList;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type LogLevel = {
|
|
92
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
93
|
+
isDebugEnabled: boolean;
|
|
94
|
+
isInfoEnabled: boolean;
|
|
95
|
+
isWarnEnabled: boolean;
|
|
96
|
+
};
|
|
97
|
+
declare global {
|
|
98
|
+
var apirtcReactLibLogLevel: LogLevel;
|
|
99
|
+
var setApirtcReactLibLogLevel: Function;
|
|
100
|
+
}
|
|
101
|
+
declare function setLogLevel(logLevelText: 'debug' | 'info' | 'warn' | 'error' | string): LogLevel;
|
|
102
|
+
|
|
103
|
+
export { Credentials, VideoStream, setLogLevel, useCameraStream, useConversation, useConversationMessages, useConversationModeration, useConversationStreams, usePresence, useSession, useStreamApplyVideoProcessor, useUserMediaDevices };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@apirtc/apirtc")):"function"==typeof define&&define.amd?define(["exports","react","@apirtc/apirtc"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ApiRtcReactLib={},e.React,e.apiRTC)}(this,(function(e,t,o){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(t);const s="useCameraStream";const i="useConversation";const l="useConversationMessages";const r="useConversationModeration";function c(e){return null!=e}const b="useConversationStreams";const u="usePresence";const d="useSession";const g="useStreamApplyVideoProcessor";const f={audioinput:{},audiooutput:{},videoinput:{}};const L={level:"info",isDebugEnabled:!1,isInfoEnabled:!0,isWarnEnabled:!0};function p(e){switch(e){case"debug":globalThis.apirtcReactLibLogLevel={level:"debug",isDebugEnabled:!0,isInfoEnabled:!0,isWarnEnabled:!0};break;case"info":default:globalThis.apirtcReactLibLogLevel=L;break;case"warn":globalThis.apirtcReactLibLogLevel={level:"warn",isDebugEnabled:!1,isInfoEnabled:!1,isWarnEnabled:!0};break;case"error":globalThis.apirtcReactLibLogLevel={level:"error",isDebugEnabled:!1,isInfoEnabled:!1,isWarnEnabled:!1}}return globalThis.apirtcReactLibLogLevel}globalThis.apirtcReactLibLogLevel=L,globalThis.setApirtcReactLibLogLevel=p,e.VideoStream=function(e){const{autoPlay:o=!0}=e,n=t.useRef(null);return t.useEffect((()=>{const t=n.current;if(t&&e.stream)return e.stream.attachToElement(t),()=>{t.src=""}}),[e.stream]),a.default.createElement("video",{id:e.stream.getId(),style:{maxWidth:"100%"},ref:n,autoPlay:o,muted:e.muted})},e.setLogLevel=p,e.useCameraStream=function(e,o={}){const[n,a]=t.useState();return t.useEffect((()=>{if(e){e.getUserAgent().createStream(o).then((e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(s+"|createStream",o,e),a(e)})).catch((e=>{console.error(s+"|createStream",o,e),a(void 0)}))}else a(void 0)}),[e,JSON.stringify(o)]),t.useEffect((()=>()=>{n&&(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(s+"|release stream",n),n.release())}),[n]),{stream:n}},e.useConversation=function(e,o,n,a=!1){const[s,l]=t.useState(),[r,c]=t.useState(!1),[b,u]=t.useState(!1),d=t.useCallback((()=>(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(i+"|join",s),new Promise(((e,t)=>{s?s.isJoined()?t(i+"|join|conversation already joined"):(u(!0),s.join().then((()=>{c(!0),e()})).catch((e=>{t(e)})).finally((()=>{u(!1)}))):t(i+"|join|conversation not defined")})))),[s]),g=t.useCallback((()=>(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(i+"|leave",s),new Promise(((e,t)=>{s?s.isJoined()?s.leave().then((()=>{c(!1),e()})).catch((e=>{t(e)})):t(i+"|leave|conversation is not joined"):t(i+"|leave|conversation not defined")})))),[s]);return t.useEffect((()=>{if(e&&o){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(i+"|getOrCreateConversation",o,n,a);const t=e.getOrCreateConversation(o,n);return l(t),()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(i+"|useEffect cleanup",o,n,a),t.isJoined()?t.leave().then((()=>{})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(i+"|useEffect conversation.leave()",e)})).finally((()=>{t.destroy(),l(void 0),c(!1)})):(t.destroy(),l(void 0))}}}),[e,o,JSON.stringify(n)]),t.useEffect((()=>{if(s&&a){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(i+"|useEffect",s,a);const e=s,t=a;return t&&(u(!0),e.join().then((()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(i+"|joined",e),c(!0)})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(i+"|useEffect conversation.join()",e)})).finally((()=>{u(!1)}))),()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(i+"|useEffect cleanup",e,t),e.isJoined()&&e.leave().then((()=>{c(!1)})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(i+"|useEffect conversation.leave()",e)}))}}}),[s,a]),{conversation:s,joining:b,joined:r,join:d,leave:g}},e.useConversationMessages=function(e){const[o]=t.useState(new Array),[n,a]=t.useState(new Array);return t.useEffect((()=>{if(e){const t=t=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(l+"|on:message:",e.getName(),t),o.push(t),a(Array.from(o))};return e.on("message",t),()=>{e.removeListener("message",t),o.length=0,a(new Array)}}}),[e]),{messages:n,sendMessage:t.useCallback(((t,n)=>new Promise(((s,i)=>{null==e||e.sendMessage(t).then((i=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(l+"|sentMessage",e.getName(),i,t),o.push({content:t,sender:n,time:new Date}),a(Array.from(o)),s()})).catch((e=>{globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(l+"|sendMessage error",e),i(e)}))}))),[e])}},e.useConversationModeration=function(e,o,n){const[a,s]=t.useState(new Set);return t.useEffect((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(r+"|useEffect conversation",e),e){const t=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(r+"|on:contactJoinedWaitingRoom",e),a.add(e),s(new Set(a))},i=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(r+"|on:contactLeftWaitingRoom",e),a.delete(e),s(new Set(a))},l=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(r+"|on:participantEjected",e),!0===e.self?(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(r+"|Self participant was ejected"),n&&n()):o&&o(e.contact)};return e.on("contactJoinedWaitingRoom",t).on("contactLeftWaitingRoom",i).on("participantEjected",l),()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(r+"|conversation clear",e),e.removeListener("contactJoinedWaitingRoom",t).removeListener("contactLeftWaitingRoom",i).removeListener("participantEjected",l),s(new Set)}}}),[e]),{candidates:a}},e.useConversationStreams=function(e,o=[],n){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${b}|hook`);const[a,s]=t.useState([]),[i]=t.useState(new Array),[l,r]=t.useState(new Array),[u]=t.useState(new Array),[d,g]=t.useState(new Array),f=t.useCallback(((t,o)=>new Promise(((n,a)=>{e&&(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${b}|publish|${e.getName()}`,t,o),e.publish(t,o).then((t=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(`${b}|published|${e.getName()}`,t),i.push(t),r(Array.from(i)),n(t)})).catch((e=>{a(e)})))}))),[e]),L=t.useCallback(((t,o,n)=>new Promise(((a,s)=>{if(e){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${b}|replacePublishedStream|${e.getName()}|${t.getId()} -> ${o.getId()}(${JSON.stringify(n)})`);const l=e.getConversationCall(t);l&&l.replacePublishedStream(o,void 0,n).then((o=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(`${b}|stream replaced|${e.getName()}`,t,o,n);const s=i.indexOf(t);s>=0&&(i.splice(s,1,o),r(Array.from(i))),a(o)})).catch((e=>{s(e)}))}}))),[e]),p=t.useCallback((t=>{if(e){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${b}|unpublish|${e.getName()}`,t),e.unpublish(t);const o=i.indexOf(t);o>=0&&(i.splice(o,1),r(Array.from(i)))}}),[e]),h=t.useCallback((()=>{const t=Math.max(a.length,o.length);globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(b+"|doHandlePublication",o,JSON.stringify(a.map((e=>null==e?void 0:e.stream.getId()))),t);const i=[...o];s(i);const l=new Set(o.filter(c).map((e=>e.stream)));for(let s=0;s<t;s++){const t=a[s],r=o[s];if(t&&r){const o=()=>{L(t.stream,r.stream,r.options).catch((e=>{i.splice(s,1,null),n?n(e):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(`${b}|replacePublishedStream|error`,e)}))};t.stream===r.stream?JSON.stringify(t.options)!==JSON.stringify(r.options)&&o():l.has(t.stream)?e&&!e.isPublishedStream(r.stream)&&f(r.stream,r.options).catch((e=>{i.splice(s,1,null),n?n(e):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(`${b}|publish|error`,e)})):e&&!e.isPublishedStream(r.stream)?o():p(t.stream)}else t&&!r?l.has(t.stream)||p(t.stream):!t&&r&&e&&!e.isPublishedStream(r.stream)&&f(r.stream,r.options).catch((e=>{i.splice(s,1,null),n?n(e):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(`${b}|publish|error`,e)}))}}),[e,o,a,f,p,L]);t.useEffect((()=>{if(e){const t=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(b+"|on_streamAdded",e),u.push(e),g(Array.from(u))},o=e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(b+"|on_streamRemoved",e);const t=u.indexOf(e);t>=0&&(u.splice(t,1),g(Array.from(u)))},n=t=>{const o=String(t.streamId);!0===t.isRemote&&("added"===t.listEventType?e.subscribeToStream(o):"removed"===t.listEventType&&e.unsubscribeToStream(o))};return e.on("streamAdded",t),e.on("streamRemoved",o),e.on("streamListChanged",n),()=>{e.removeListener("streamListChanged",n),e.removeListener("streamRemoved",o),e.removeListener("streamAdded",t)}}}),[e]);const v=e=>{i.forEach((t=>{e.unpublish(t)})),i.length=0,s([]),u.forEach((t=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(b+"|unsubscribeToStream stream",e,t),e.unsubscribeToStream(t.getId())})),u.length=0,r(new Array),g(new Array)};return t.useEffect((()=>{if(e){globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(b+"|useEffect doHandlePublication",e.getName());const t=()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(b+"|on_joined",e.getName(),o),h()},n=()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(b+"|on_left",e.getName()),v(e)};return e.on("joined",t),e.on("left",n),()=>{e.removeListener("joined",t),e.removeListener("left",n)}}}),[h]),t.useEffect((()=>{if(e)return globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${b}|conversation|${e.getName()}`,e),e.getAvailableStreamList().forEach((t=>{const o=String(t.streamId);!0===t.isRemote&&e.subscribeToStream(o)})),()=>{v(e)}}),[e]),t.useEffect((()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(`${b}|streamsToPublish`,JSON.stringify(o.map((e=>(null==e?void 0:e.stream.getId())+"-"+JSON.stringify(null==e?void 0:e.options))))),e&&e.isJoined()&&h()}),[JSON.stringify(o.map((e=>(null==e?void 0:e.stream.getId())+"-"+JSON.stringify(null==e?void 0:e.options))))]),{publishedStreams:l,subscribedStreams:d,publish:f,unpublish:p,replacePublishedStream:L}},e.usePresence=function(e,o){const[n]=t.useState(new Set),[a]=t.useState(new Map),[s,i]=t.useState(new Map);t.useEffect((()=>{if(e)return()=>{a.clear(),i(new Map(a)),n.clear()}}),[e]);const l=e=>{var t;const o=null!==(t=a.get(e))&&void 0!==t?t:new Set;return a.has(e)||a.set(e,o),o};return t.useEffect((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(u+"|useEffect session, groups",o),e){const t=e,s=new Set(o);s.forEach((e=>{n.has(e)||(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(u+"|subscribeToGroup",e),n.add(e),t.subscribeToGroup(e))}));let r=!1;if(n.forEach((e=>{s.has(e)||(globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(u+"|unsubscribeToGroup",e),t.unsubscribeToGroup(e),n.delete(e),a.delete(e),r=!0)})),r&&i(new Map(a)),o.length>0){const e=e=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(u+"|contactListUpdate",e);let t=!1;for(const o of Object.keys(e.joinedGroup))if(s.has(o)){const n=l(o);for(const a of e.joinedGroup[o])n.add(a),t=!0}for(const o of Object.keys(e.leftGroup))if(s.has(o)){const n=l(o);for(const s of e.leftGroup[o])n.delete(s),t=!0,0===n.size&&a.delete(o)}for(const o of e.userDataChanged)for(const e of a.values())if(e.has(o)){t=!0;break}t&&i(new Map(a))};return t.on("contactListUpdate",e),()=>{t.removeListener("contactListUpdate",e)}}}}),[e,JSON.stringify(o)]),{contactsByGroup:s}},e.useSession=function(e,n){const[a,s]=t.useState(),[i,l]=t.useState(!1),[r,c]=t.useState();t.useEffect((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(d+"|useEffect credentials, options",e,n),e){let t=!0;return b(e,n).catch((e=>{console.error(d+"|connection failed",e,t),s(void 0),t&&c(e)})),()=>{t=!1,s(void 0),l(!1),c(void 0)}}}),[JSON.stringify(e),JSON.stringify(n)]),t.useEffect((()=>{if(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(d+"|useEffect session",a),a){const e=a;return()=>{e.disconnect().then((()=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(d+"|disconnected",e)})).catch((e=>{console.error(d+"|disconnect",e)}))}}}),[a]);const b=(e,t)=>new Promise(((n,a)=>{const i=t||{cloudUrl:"https://cloud.apirtc.com"};let r;if("object"==typeof(c=e)&&"username"in c)i.password=e.password,r=new o.UserAgent({uri:"apirtc:"+e.username});else if(function(e){return"object"==typeof e&&"apiKey"in e}(e))r=new o.UserAgent({uri:`apiKey:${e.apiKey}`});else{if(!function(e){return"object"==typeof e&&"token"in e}(e))return void a("credentials not recognized");r=new o.UserAgent({uri:`token:${e.token}`})}var c;l(!0),r.register(i).then((e=>{globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info(d+"|connected",e),s(e),n()})).catch((e=>{a(e)})).finally((()=>{l(!1)}))}));return{session:a,connecting:i,connect:b,disconnect:()=>{s(void 0)},error:r}},e.useStreamApplyVideoProcessor=function(e,o,n,a){const[s,i]=t.useState(e),[l,r]=t.useState("none");t.useEffect((()=>{globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(g+"|useEffect",e,o,n),e&&"none"!==o?e.applyVideoProcessor(o,n).then((e=>{i(e),r(o)})).catch((t=>{i(e),a?a(t):globalThis.apirtcReactLibLogLevel.isWarnEnabled&&console.warn(g+"|useEffect",e,o,n,t),r((e=>e))})):(i(e),r("none"))}),[e,o,n]);const c=t.useCallback((()=>{s&&s!==e&&(globalThis.apirtcReactLibLogLevel.isDebugEnabled&&console.debug(g+"|releasing outStream",s),s.release())}),[e,s]);return t.useEffect((()=>()=>{c()}),[s]),{stream:s,applied:l}},e.useUserMediaDevices=function(e){const[o,n]=t.useState(f);return t.useEffect((()=>{if(e){const t=e.getUserAgent(),o=()=>{const e=t.getUserMediaDevices();globalThis.apirtcReactLibLogLevel.isInfoEnabled&&console.info("useUserMediaDevices|mediaDeviceChanged",e),n(e)};return t.on("mediaDeviceChanged",o),()=>{t.removeListener("mediaDeviceChanged",o),n(f)}}}),[e]),{userMediaDevices:o}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=react-lib.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-lib.production.min.js","sources":["../src/hooks/useCameraStream.ts","../src/hooks/useConversation.ts","../src/hooks/useConversationMessages.ts","../src/hooks/useConversationModeration.ts","../src/hooks/useConversationStreams.ts","../src/hooks/usePresence.ts","../src/hooks/useSession.ts","../src/hooks/useStreamApplyVideoProcessor.ts","../src/hooks/useUserMediaDevices.ts","../src/index.ts","../src/components/VideoStream/VideoStream.tsx"],"sourcesContent":["import { useState, useEffect } from 'react'\nimport { CreateStreamOptions, Session, Stream, UserAgent } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useCameraStream\";\nexport default function useCameraStream(\n session: Session | undefined,\n options: CreateStreamOptions = {}\n) {\n const [stream, setStream] = useState<Stream>();\n\n useEffect(() => {\n if (session) {\n const userAgent: UserAgent = session.getUserAgent();\n userAgent.createStream(options).then((localStream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|createStream\", options, localStream)\n }\n setStream(localStream)\n }).catch((error: any) => {\n console.error(HOOK_NAME + \"|createStream\", options, error)\n setStream(undefined)\n })\n\n // DO NOT set out stream to undefined in the return, to prevent unnecessary refreshes\n // of other components with undefined stream, whereas we are expecting to change it\n // to another instance..\n // return () => { setStream(undefined) } // DON'T\n } else {\n setStream(undefined)\n }\n\n }, [session, JSON.stringify(options)])\n\n useEffect(() => {\n return () => {\n if (stream) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|release stream\", stream)\n }\n stream.release()\n }\n }\n }, [stream])\n\n return {\n stream\n }\n}","import { useState, useEffect, useCallback } from 'react'\nimport { Conversation, GetOrCreateConversationOptions, Session } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useConversation\";\n/**\n * Please note that the hook won't react on autoJoin change\n */\nexport default function useConversation(\n session: Session | undefined,\n name: string | undefined,\n options?: GetOrCreateConversationOptions,\n join: boolean = false\n) {\n const [conversation, setConversation] = useState<Conversation>();\n const [joined, setJoined] = useState<boolean>(false);\n const [joining, setJoining] = useState<boolean>(false);\n\n // Callbacks\n //\n // Offering Promised join/leave methods allows developer to act on then/catch\n //\n const o_join = useCallback(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|join\", conversation)\n //JSON.stringify((apiRTC as any).session.apiCCWebRTCClient.webRTCClient.MCUClient.sessionMCUs))\n }\n return new Promise<void>((resolve, reject) => {\n if (!conversation) {\n reject(HOOK_NAME + \"|join|conversation not defined\")\n return\n }\n if (!conversation.isJoined()) {\n setJoining(true)\n conversation.join().then(() => {\n // successfully joined the conversation.\n setJoined(true)\n resolve()\n }).catch((error: any) => {\n // could not join the conversation.\n reject(error)\n }).finally(() => {\n setJoining(false)\n })\n } else {\n reject(HOOK_NAME + \"|join|conversation already joined\")\n }\n })\n }, [conversation]);\n\n const o_leave = useCallback(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|leave\", conversation)\n }\n return new Promise<void>((resolve, reject) => {\n if (!conversation) {\n reject(HOOK_NAME + \"|leave|conversation not defined\")\n return\n }\n if (conversation.isJoined()) {\n conversation.leave().then(() => {\n // local user successfully left the conversation.\n setJoined(false)\n resolve()\n }).catch((error: any) => {\n reject(error)\n })\n } else {\n reject(HOOK_NAME + \"|leave|conversation is not joined\")\n }\n })\n }, [conversation]);\n\n // Effects\n //\n useEffect(() => {\n if (session && name) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|getOrCreateConversation\", name, options, join)\n }\n const l_conversation = session.getOrCreateConversation(name, options);\n setConversation(l_conversation)\n return () => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect cleanup\", name, options, join)\n }\n if (l_conversation.isJoined()) {\n l_conversation.leave()\n .then(() => { })\n .catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect conversation.leave()\", error)\n }\n })\n .finally(() => {\n l_conversation.destroy()\n setConversation(undefined)\n setJoined(false)\n })\n } else {\n // It is important to destroy the conversation.\n // Otherwise subsequent getOrCreateConversation with same name would get\n // previous handle, regardless of the potentially new options.\n // This also allows to cleanup memory\n l_conversation.destroy()\n setConversation(undefined)\n }\n }\n }\n }, [session, name, JSON.stringify(options)])\n\n useEffect(() => {\n if (conversation && join) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect\", conversation, join)\n }\n const l_conversation = conversation;\n const l_join = join;\n if (l_join) {\n setJoining(true)\n l_conversation.join().then(() => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|joined\", l_conversation)\n }\n setJoined(true)\n }).catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect conversation.join()\", error)\n }\n }).finally(() => {\n setJoining(false)\n })\n }\n return () => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect cleanup\", l_conversation, l_join)\n }\n if (l_conversation.isJoined()) {\n l_conversation.leave().then(() => {\n setJoined(false)\n }).catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect conversation.leave()\", error)\n }\n })\n }\n }\n }\n }, [conversation, join])\n\n return {\n conversation,\n joining,\n joined,\n join: o_join,\n leave: o_leave\n }\n}","import { useState, useEffect, useCallback } from 'react'\nimport { Contact, Conversation, ConversationMessage } from '@apirtc/apirtc'\n\n// TODO : get and handle with pagination messages history\n// TODO : ask apirtc to include the uuid in ConversationMessage so that we can store it\n// into ConversationMessage when creating the local one, and we get it from conversation on:message\n// the uuid shall be the value used as a react child key when displaying list of messages\n\nconst HOOK_NAME = \"useConversationMessages\";\nexport default function useConversationMessages(\n conversation: Conversation | undefined,\n) {\n // Use an internal array which will always be the same object as far as React knows\n // This will avoid the need for adding it as a dependency for each callback\n const [messages] = useState<Array<ConversationMessage>>(new Array<ConversationMessage>());\n // And use a copy as output array so that client code will react upon change\n // (only a new instance of array is detected by React)\n const [o_messages, setO_Messages] = useState<Array<ConversationMessage>>(new Array<ConversationMessage>());\n\n useEffect(() => {\n if (conversation) {\n const onMessage = (message: ConversationMessage) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:message:\", conversation.getName(), message)\n }\n messages.push(message)\n setO_Messages(Array.from(messages))\n };\n conversation.on('message', onMessage)\n\n return () => {\n conversation.removeListener('message', onMessage)\n messages.length = 0;\n setO_Messages(new Array<any>())\n }\n }\n }, [conversation])\n\n const sendMessage = useCallback((msgContent: string, sender: Contact) => {\n return new Promise<void>((resolve, reject) => {\n conversation?.sendMessage(msgContent)\n .then((uuid: number) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|sentMessage\", conversation.getName(), uuid, msgContent)\n }\n messages.push({ content: msgContent, sender: sender, time: new Date() })\n setO_Messages(Array.from(messages))\n resolve()\n })\n .catch((error: any) => {\n if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|sendMessage error\", error)\n }\n reject(error)\n })\n })\n }, [conversation]);\n\n return {\n messages: o_messages,\n sendMessage\n }\n}","import { useState, useEffect } from 'react'\nimport { Contact, Conversation } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useConversationModeration\";\nexport default function useConversationModeration(\n conversation: Conversation | undefined,\n onEjected?: (contact: Contact) => void,\n onEjectedSelf?: () => void) {\n\n const [candidates, setCandidates] = useState<Set<Contact>>(new Set<Contact>());\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect conversation\", conversation)\n }\n\n if (conversation) {\n const on_contactJoinedWaitingRoom = (contact: Contact) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:contactJoinedWaitingRoom\", contact)\n }\n // A candidate joined the waiting room.\n candidates.add(contact)\n setCandidates(new Set(candidates))\n };\n const on_contactLeftWaitingRoom = (contact: Contact) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:contactLeftWaitingRoom\", contact)\n }\n // A candidate left the waiting room.\n candidates.delete(contact)\n setCandidates(new Set(candidates))\n };\n // TODO make apirtc.d.ts update to replace 'any'\n const on_participantEjected = (data: any) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on:participantEjected\", data)\n }\n if (data.self === true) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|Self participant was ejected\")\n }\n if (onEjectedSelf) {\n onEjectedSelf()\n }\n } else {\n if (onEjected) {\n onEjected(data.contact)\n }\n }\n };\n\n conversation\n .on('contactJoinedWaitingRoom', on_contactJoinedWaitingRoom)\n .on('contactLeftWaitingRoom', on_contactLeftWaitingRoom)\n .on('participantEjected', on_participantEjected)\n\n return () => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|conversation clear\", conversation)\n }\n // remove listeners\n conversation\n .removeListener('contactJoinedWaitingRoom', on_contactJoinedWaitingRoom)\n .removeListener('contactLeftWaitingRoom', on_contactLeftWaitingRoom)\n .removeListener('participantEjected', on_participantEjected)\n setCandidates(new Set())\n }\n }\n }, [conversation])\n\n return {\n candidates\n }\n}","import { useState, useEffect, useCallback } from 'react'\nimport { Conversation, PublishOptions, Stream, StreamInfo } from '@apirtc/apirtc'\n\n// TODO?: add pagination ?\n// interface Options {\n// streamsSubscribePageSize: number\n// }\n\nfunction notEmpty<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined;\n}\n\nconst HOOK_NAME = \"useConversationStreams\";\nexport default function useConversationStreams(\n conversation: Conversation | undefined,\n /** fully managed list of Stream(s) to publish, with associated publish options */\n streamsToPublish: Array<{ stream: Stream, options?: PublishOptions } | undefined | null> = [],\n errorCallback?: (error: any) => void\n) {\n\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|hook`)\n }\n\n // A cache to handle publication differences\n const [publishedStreamsCache, setPublishedStreamsCache] =\n useState<Array<{ stream: Stream, options?: PublishOptions } | undefined | null>>([]);\n\n // Use an internal array which will always be the same object as far as React knows\n // This will avoid the need for adding it as a dependency for each callback\n const [publishedStreams] = useState<Array<Stream>>(new Array<Stream>());\n // And use a copy as output array so that client code will react upon change\n // (only a new instance of array is detected by React)\n const [o_publishedStreams, setO_PublishedStreams] = useState<Array<Stream>>(new Array<Stream>());\n\n const [subscribedStreams] = useState<Array<Stream>>(new Array<Stream>());\n const [o_subscribedStreams, setO_SubscribedStreams] = useState<Array<Stream>>(new Array<Stream>());\n\n const publish: (localStream: Stream, options?: PublishOptions) => Promise<Stream> =\n useCallback((localStream: Stream, options?: PublishOptions) => {\n return new Promise<Stream>((resolve, reject) => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|publish|${conversation.getName()}`, localStream, options)\n }\n conversation.publish(localStream, options).then((stream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(`${HOOK_NAME}|published|${conversation.getName()}`, stream)\n }\n //console.log(`PUSHING ${stream.getId()} to publishedStreams`, JSON.stringify(publishedStreams.map(s => s.getId())))\n publishedStreams.push(stream)\n // Returning a new array makes lets React detect changes\n setO_PublishedStreams(Array.from(publishedStreams))\n resolve(stream)\n }).catch((error: any) => {\n reject(error)\n })\n }\n })\n }, [conversation]);\n\n const replacePublishedStream = useCallback((oldStream: Stream, newStream: Stream, options?: PublishOptions) => {\n return new Promise<Stream>((resolve, reject) => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|replacePublishedStream|${conversation.getName()}|${oldStream.getId()} -> ${newStream.getId()}(${JSON.stringify(options)})`)\n }\n const conversationCall = conversation.getConversationCall(oldStream);\n if (conversationCall) {\n conversationCall.replacePublishedStream(newStream, undefined, options)\n .then((stream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(`${HOOK_NAME}|stream replaced|${conversation.getName()}`, oldStream, stream, options)\n }\n const index = publishedStreams.indexOf(oldStream);\n if (index >= 0) {\n publishedStreams.splice(index, 1, stream)\n setO_PublishedStreams(Array.from(publishedStreams))\n }\n resolve(stream)\n }).catch((error: any) => {\n reject(error)\n })\n }\n }\n })\n }, [conversation]);\n\n const unpublish: (localStream: Stream) => void = useCallback((localStream: Stream) => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|unpublish|${conversation.getName()}`, localStream)\n }\n conversation.unpublish(localStream)\n const index = publishedStreams.indexOf(localStream);\n if (index >= 0) {\n publishedStreams.splice(index, 1)\n setO_PublishedStreams(Array.from(publishedStreams))\n }\n }\n }, [conversation]);\n\n const doHandlePublication = useCallback(() => {\n const maxLength = Math.max(publishedStreamsCache.length, streamsToPublish.length);\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|doHandlePublication\", streamsToPublish,\n JSON.stringify(publishedStreamsCache.map(l_s => l_s?.stream.getId())), maxLength)\n }\n\n // Strategy for published streams cache is to initialize it as it should be\n // and remove items if publication fails.\n const newPublishedStreamsCache = [...streamsToPublish];\n setPublishedStreamsCache(newPublishedStreamsCache)\n\n // Prepare a set for Streams to publish, for further optimized check\n const streamsToPublishSet = new Set(streamsToPublish.filter(notEmpty).map((item) => item.stream));\n\n // Loop on arrays index to publish new streams, or replace if necessary\n for (let i = 0; i < maxLength; i++) {\n const previous = publishedStreamsCache[i];\n const next = streamsToPublish[i];\n\n if (previous && next) {\n const doReplacePublishedStream = () => {\n replacePublishedStream(previous.stream, next.stream, next.options)\n .catch((error: Error) => {\n newPublishedStreamsCache.splice(i, 1, null)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(`${HOOK_NAME}|replacePublishedStream|error`, error)\n }\n })\n }\n if (previous.stream === next.stream) {\n // Streams are the same, only replace if options are different\n if (JSON.stringify(previous.options) !== JSON.stringify(next.options)) {\n doReplacePublishedStream()\n }\n } else {\n // If position in both new and cached list are defined but are different:\n // replace if and only if stream to unpublish shall not be published (at other position)\n if (streamsToPublishSet.has(previous.stream)) { // previous shall be published\n // Previous shall actually be published (at another position), so don't do anything about it\n // But then we still have to publish new stream (if not already published)\n if (conversation && !conversation.isPublishedStream(next.stream)) {\n publish(next.stream, next.options).catch((error: Error) => {\n newPublishedStreamsCache.splice(i, 1, null)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(`${HOOK_NAME}|publish|error`, error)\n }\n })\n }\n } else {\n if (conversation && !conversation.isPublishedStream(next.stream)) {\n doReplacePublishedStream()\n } else { // new stream is already published\n // So we shall not replace another stream by it, but we need to unpublish the previous\n unpublish(previous.stream)\n }\n }\n }\n } else if (previous && !next) {\n // If position in new list is now undefined(or null) while it was in cache:\n // unpublish if and only if stream to unpublish shall not be published (at other position)\n if (!streamsToPublishSet.has(previous.stream)) {\n unpublish(previous.stream)\n }\n } else if (!previous && next) {\n // If position in new list is valid : publish it whatever the position in cache.\n // Depending on the case the stream might be already published, or it might be not\n // (can happen if the cache was set while Conversation was not joined yet).\n // Note that we could try to publish without checking isPublishedStream, the call would\n // reject with a console error but this would not affect the behavior.\n if (conversation && !conversation.isPublishedStream(next.stream)) {\n publish(next.stream, next.options).catch((error: Error) => {\n newPublishedStreamsCache.splice(i, 1, null)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(`${HOOK_NAME}|publish|error`, error)\n }\n })\n }\n }\n }\n }, [conversation,\n streamsToPublish,\n publishedStreamsCache,\n publish, unpublish, replacePublishedStream]);\n\n // --------------------------------------------------------------------------\n // useEffect(s) - Order is important\n //\n useEffect(() => {\n if (conversation) {\n const on_streamAdded = (remoteStream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_streamAdded\", remoteStream)\n }\n subscribedStreams.push(remoteStream)\n setO_SubscribedStreams(Array.from(subscribedStreams))\n };\n const on_streamRemoved = (remoteStream: Stream) => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_streamRemoved\", remoteStream)\n }\n const index = subscribedStreams.indexOf(remoteStream);\n if (index >= 0) {\n subscribedStreams.splice(index, 1)\n setO_SubscribedStreams(Array.from(subscribedStreams))\n }\n };\n const on_streamListChanged = (streamInfo: StreamInfo) => {\n const streamId = String(streamInfo.streamId);\n if (streamInfo.isRemote === true) {\n if (streamInfo.listEventType === 'added') {\n // a remote stream was published\n conversation.subscribeToStream(streamId)\n } else if (streamInfo.listEventType === 'removed') {\n // a remote stream is not published anymore\n conversation.unsubscribeToStream(streamId)\n }\n }\n };\n // Subscribe to incoming streams\n conversation.on('streamAdded', on_streamAdded)\n conversation.on('streamRemoved', on_streamRemoved)\n conversation.on('streamListChanged', on_streamListChanged)\n\n return () => {\n // remove listeners\n conversation.removeListener('streamListChanged', on_streamListChanged)\n conversation.removeListener('streamRemoved', on_streamRemoved)\n conversation.removeListener('streamAdded', on_streamAdded)\n }\n }\n }, [conversation])\n\n const unpublishAndUnsubscribeAll = (i_conversation: Conversation) => {\n publishedStreams.forEach(stream => {\n i_conversation.unpublish(stream)\n })\n // Clear internal array\n publishedStreams.length = 0;\n\n // Clear cache\n setPublishedStreamsCache([])\n\n subscribedStreams.forEach(stream => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|unsubscribeToStream stream\", i_conversation, stream)\n }\n i_conversation.unsubscribeToStream(stream.getId())\n })\n // Clear internal array\n subscribedStreams.length = 0;\n\n // Clear output arrays with new array so that parent gets notified of a change.\n // Simply setting length to 0 is not detected by react.\n setO_PublishedStreams(new Array<Stream>())\n setO_SubscribedStreams(new Array<Stream>())\n };\n\n useEffect(() => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect doHandlePublication\", conversation.getName())\n }\n\n const on_joined = () => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_joined\", conversation.getName(), streamsToPublish)\n }\n doHandlePublication()\n };\n const on_left = () => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|on_left\", conversation.getName())\n }\n // Forcing unpublish will allow to republish if joining again\n unpublishAndUnsubscribeAll(conversation)\n };\n\n conversation.on('joined', on_joined)\n conversation.on('left', on_left)\n\n return () => {\n conversation.removeListener('joined', on_joined)\n conversation.removeListener('left', on_left)\n }\n }\n }, [doHandlePublication]) // Don't add 'conversation' in here because\n // doHandlePublication already changes on conversation change\n\n // subscribeToStream(s) after having set listeners\n //\n useEffect(() => {\n if (conversation) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|conversation|${conversation.getName()}`, conversation)\n }\n // Subscribe to existing remote streams\n conversation.getAvailableStreamList().forEach((streamInfo: StreamInfo) => {\n const streamId = String(streamInfo.streamId);\n if (streamInfo.isRemote === true) {\n conversation.subscribeToStream(streamId)\n }\n })\n return () => {\n unpublishAndUnsubscribeAll(conversation)\n }\n }\n }, [conversation])\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(`${HOOK_NAME}|streamsToPublish`,\n JSON.stringify(streamsToPublish.map(l_s => l_s?.stream.getId() + '-' + JSON.stringify(l_s?.options))))\n }\n if (conversation && conversation.isJoined()) {\n doHandlePublication()\n }\n }, [JSON.stringify(streamsToPublish.map(l_s => l_s?.stream.getId() + '-' + JSON.stringify(l_s?.options)))])\n\n return {\n publishedStreams: o_publishedStreams,\n subscribedStreams: o_subscribedStreams,\n publish,\n unpublish,\n replacePublishedStream\n }\n}\n","import { useState, useEffect } from 'react'\nimport { Session, Contact } from '@apirtc/apirtc'\n\n/**\n * Subscribe to groups and returns contactsByGroup (of theses groups only) when updated.\n * If input groups list is updated, this hooks works diff with the previous set in order\n * to make as little as possible unsubscribe/subscribe calls.\n */\n\nconst HOOK_NAME = \"usePresence\";\nexport default function usePresence(session: Session | undefined, groups: Array<string>) {\n\n const [groupsCache] = useState<Set<string>>(new Set());\n\n const [m_contactsByGroup] = useState<Map<string, Set<Contact>>>(new Map());\n\n const [contactsByGroup, setContactsByGroup] = useState<Map<string, Set<Contact>>>(new Map());\n\n useEffect(() => {\n if (session) {\n return () => {\n m_contactsByGroup.clear()\n setContactsByGroup(new Map(m_contactsByGroup))\n groupsCache.clear()\n }\n }\n }, [session])\n\n const getOrCreateGroupSet = (group: string) => {\n const o_set = m_contactsByGroup.get(group) ?? new Set();\n if (!m_contactsByGroup.has(group)) {\n m_contactsByGroup.set(group, o_set)\n }\n return o_set\n };\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect session, groups\", groups)\n }\n if (session) {\n const l_session = session;\n const l_groupsSet = new Set(groups);\n\n // Diff update subscription to groups\n //\n l_groupsSet.forEach(group => {\n if (!groupsCache.has(group)) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|subscribeToGroup\", group)\n }\n groupsCache.add(group)\n l_session.subscribeToGroup(group)\n }\n })\n\n let needsRefresh = false;\n groupsCache.forEach(group => {\n if (!l_groupsSet.has(group)) {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|unsubscribeToGroup\", group)\n }\n l_session.unsubscribeToGroup(group)\n groupsCache.delete(group)\n m_contactsByGroup.delete(group)\n needsRefresh = true;\n }\n })\n\n if (needsRefresh) {\n // contactsByGroup is exposed, so change the Map object to let client code detect a change.\n setContactsByGroup(new Map(m_contactsByGroup))\n }\n\n if (groups.length > 0) {\n const onContactListUpdate = (updatedContacts: any) => {\n\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|contactListUpdate\", updatedContacts)\n }\n\n let needsRefresh = false;\n\n // Maintain Map of Contacts per Group\n //\n for (const group of Object.keys(updatedContacts.joinedGroup)) {\n if (l_groupsSet.has(group)) {\n const l_set = getOrCreateGroupSet(group);\n for (const contact of updatedContacts.joinedGroup[group]) {\n l_set.add(contact)\n needsRefresh = true;\n }\n }\n }\n for (const group of Object.keys(updatedContacts.leftGroup)) {\n if (l_groupsSet.has(group)) {\n const l_set = getOrCreateGroupSet(group);\n for (const contact of updatedContacts.leftGroup[group]) {\n l_set.delete(contact)\n needsRefresh = true;\n\n // if set is empty, no need to keep the group as key in the map\n if (l_set.size === 0) {\n m_contactsByGroup.delete(group)\n }\n }\n }\n }\n\n // For data updates, trigger a refresh if and only if contact is part of managed groups\n for (const contact of updatedContacts.userDataChanged as Contact[]) {\n for (const l_contacts of m_contactsByGroup.values()) {\n if (l_contacts.has(contact)) {\n needsRefresh = true;\n break;\n }\n }\n }\n\n if (needsRefresh) {\n // contactsByGroup is exposed, so change the Map object to let client code detect a change.\n setContactsByGroup(new Map(m_contactsByGroup))\n }\n };\n l_session.on('contactListUpdate', onContactListUpdate)\n return () => {\n l_session.removeListener('contactListUpdate', onContactListUpdate)\n }\n }\n }\n }, [session, JSON.stringify(groups)])\n\n return {\n contactsByGroup\n }\n}","import { useEffect, useState } from 'react'\nimport { Session, UserAgent, RegisterInformation } from '@apirtc/apirtc'\n\ntype LoginPassword = {\n username: string\n password: string\n};\n\nfunction isInstanceOfLoginPassword(object: any): object is LoginPassword {\n if (typeof object !== 'object') return false;\n return 'username' in object;\n}\n\ntype ApiKey = { apiKey: string };\nfunction isInstanceOfApiKey(object: any): object is ApiKey {\n if (typeof object !== 'object') return false;\n return 'apiKey' in object;\n}\n\ntype Token = { token: string };\nfunction isInstanceOfToken(object: any): object is Token {\n if (typeof object !== 'object') return false;\n return 'token' in object;\n}\n\nexport type Credentials = LoginPassword | ApiKey | Token;\n\nconst HOOK_NAME = \"useSession\";\nexport default function useSession(credentials?: Credentials, options?: RegisterInformation) {\n\n const [session, setSession] = useState<Session | undefined>()\n const [connecting, setConnecting] = useState<boolean>(false)\n const [error, setError] = useState<any>()\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect credentials, options\", credentials, options)\n }\n if (credentials) {\n // To fix errors like \"Warning: Can't perform a React state update on an unmounted component\"\n // https://stackoverflow.com/questions/53949393/cant-perform-a-react-state-update-on-an-unmounted-component\n let isMounted = true;\n connect(credentials, options).catch((error: any) => {\n console.error(HOOK_NAME + \"|connection failed\", error, isMounted)\n setSession(undefined)\n if (isMounted) {\n setError(error)\n }\n })\n return () => {\n isMounted = false;\n setSession(undefined)\n // Even though connecting is managed in connect(),\n // mark connecting to false when credentials are changed\n // as this shall be way to connect elsewhere or connect to\n // with other credentials. Note that to be perfect we should\n // cancel the potentially running connect : Is that possible with ApiRTC ?\n setConnecting(false)\n setError(undefined)\n }\n }\n }, [JSON.stringify(credentials), JSON.stringify(options)])\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect session\", session)\n }\n if (session) {\n const l_session = session;\n return () => {\n l_session.disconnect().then(() => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|disconnected\", l_session)\n }\n }).catch((error: any) => {\n console.error(HOOK_NAME + \"|disconnect\", error)\n })\n }\n }\n }, [session])\n\n const connect = (credentials: Credentials | undefined, options?: RegisterInformation) => {\n return new Promise<void>((resolve, reject) => {\n const registerInformation: RegisterInformation = options ? options : {\n cloudUrl: 'https://cloud.apirtc.com',\n };\n\n let l_userAgent;\n\n if (isInstanceOfLoginPassword(credentials)) {\n registerInformation.password = credentials.password;\n l_userAgent = new UserAgent({\n uri: 'apirtc:' + credentials.username\n });\n } else if (isInstanceOfApiKey(credentials)) {\n l_userAgent = new UserAgent({\n uri: `apiKey:${credentials.apiKey}`\n });\n } else if (isInstanceOfToken(credentials)) {\n l_userAgent = new UserAgent({\n uri: `token:${credentials.token}`\n });\n } else {\n reject(\"credentials not recognized\")\n return\n }\n\n setConnecting(true)\n l_userAgent.register(registerInformation).then(l_session => {\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|connected\", l_session)\n }\n setSession(l_session)\n resolve()\n }).catch((error: any) => {\n reject(error)\n }).finally(() => {\n setConnecting(false)\n })\n })\n }\n\n // const disconnect = useCallback(() => {\n // return new Promise<void>((resolve, reject) => {\n // if (session) {\n // const l_session = session;\n // l_session.disconnect().then(() => {\n // console.log(HOOK_NAME + \"|disconnected\", l_session)\n // setSession(undefined)\n // resolve()\n // }).catch((error: any) => {\n // console.error(HOOK_NAME + \"|disconnect\", error)\n // reject(error)\n // })\n // } else {\n // resolve()\n // }\n // })\n // }, [session])\n\n const disconnect = () => {\n setSession(undefined)\n };\n\n return {\n //userAgent: userAgent, // can get it from session\n session: session,\n connecting,\n connect,\n disconnect,\n error\n }\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { Stream, VideoProcessorOptions } from '@apirtc/apirtc'\n\nconst HOOK_NAME = \"useStreamApplyVideoProcessor\";\n/**\n * This hook takes stream passed as parameter, and\n * returns either this stream or a stream with video processor applied.\n * This is controlled by the videoProcessorType input attribute.\n * By default the output stream is the input stream.\n * The hook fully manages the output stream (applies 'none' if input stream is set to undefined).\n * The hook never releases the input stream.\n * \n * @param stream \n * @returns stream blurred or not, toggle method, boolean blurred state.\n */\nexport default function useStreamApplyVideoProcessor(\n stream: Stream | undefined,\n videoProcessorType: 'none' | 'blur' | 'backgroundImage', options?: VideoProcessorOptions,\n errorCallback?: (error: any) => void) {\n //\n const [outStream, setOutStream] = useState(stream);\n const [applied, setApplied] = useState<'none' | 'blur' | 'backgroundImage'>('none')\n\n useEffect(() => {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|useEffect\", stream, videoProcessorType, options)\n }\n if (stream && videoProcessorType !== 'none') {\n stream.applyVideoProcessor(videoProcessorType, options).then(l_stream => {\n setOutStream(l_stream)\n setApplied(videoProcessorType)\n }).catch(error => {\n setOutStream(stream)\n if (errorCallback) {\n errorCallback(error)\n } else if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n console.warn(HOOK_NAME + \"|useEffect\", stream, videoProcessorType, options, error)\n }\n setApplied(previousValue => previousValue)\n })\n } else {\n setOutStream(stream)\n setApplied('none')\n }\n }, [stream, videoProcessorType, options])\n\n const doCheckAndReleaseOutStream = useCallback(() => {\n if (outStream && (outStream !== stream)) {\n if (globalThis.apirtcReactLibLogLevel.isDebugEnabled) {\n console.debug(HOOK_NAME + \"|releasing outStream\", outStream)\n }\n // stream?.applyVideoProcessor('none').catch(error => {\n // if (globalThis.apirtcReactLibLogLevel.isWarnEnabled) {\n // console.warn(HOOK_NAME + \"|doCheckAndReleaseOutStream\", stream, outStream)\n // }\n // })\n outStream.release()\n }\n }, [stream, outStream])\n\n useEffect(() => {\n return () => {\n doCheckAndReleaseOutStream()\n }\n }, [outStream])\n\n return {\n stream: outStream,\n applied\n }\n}","import { useState, useEffect } from 'react'\nimport { MediaDeviceList, Session, UserAgent } from '@apirtc/apirtc'\n\nconst EMPTY_LIST: MediaDeviceList = { audioinput: {}, audiooutput: {}, videoinput: {} }\n\nconst HOOK_NAME = \"useUserMediaDevices\";\nexport default function useUserMediaDevices(\n session: Session | undefined\n) {\n const [userMediaDevices, setUserMediaDevices] = useState<MediaDeviceList>(EMPTY_LIST)\n\n useEffect(() => {\n if (session) {\n const userAgent: UserAgent = session.getUserAgent();\n\n const on_mediaDeviceChanged = () => {\n const mediaDevices: MediaDeviceList = userAgent.getUserMediaDevices()\n if (globalThis.apirtcReactLibLogLevel.isInfoEnabled) {\n console.info(HOOK_NAME + \"|mediaDeviceChanged\", mediaDevices)\n }\n setUserMediaDevices(mediaDevices)\n };\n userAgent.on(\"mediaDeviceChanged\", on_mediaDeviceChanged)\n\n return () => {\n userAgent.removeListener('mediaDeviceChanged', on_mediaDeviceChanged)\n setUserMediaDevices(EMPTY_LIST)\n }\n }\n }, [session])\n\n return {\n userMediaDevices\n }\n}","export * from './components'\nexport * from './hooks'\n\ntype LogLevel = {\n level: 'debug' | 'info' | 'warn' | 'error'\n isDebugEnabled: boolean\n isInfoEnabled: boolean\n isWarnEnabled: boolean\n}\n\nconst INFO: LogLevel = { level: 'info', isDebugEnabled: false, isInfoEnabled: true, isWarnEnabled: true };\n\ndeclare global {\n var apirtcReactLibLogLevel: LogLevel;\n var setApirtcReactLibLogLevel: Function;\n}\n\n// a default value MUST be set in case application using the library does not override it\nglobalThis.apirtcReactLibLogLevel = INFO;\n\nexport function setLogLevel(logLevelText: 'debug' | 'info' | 'warn' | 'error' | string) {\n switch (logLevelText) {\n case 'debug':\n globalThis.apirtcReactLibLogLevel = { level: 'debug', isDebugEnabled: true, isInfoEnabled: true, isWarnEnabled: true };\n break\n case 'info':\n globalThis.apirtcReactLibLogLevel = INFO;\n break\n case 'warn':\n globalThis.apirtcReactLibLogLevel = { level: 'warn', isDebugEnabled: false, isInfoEnabled: false, isWarnEnabled: true };\n break\n case 'error':\n globalThis.apirtcReactLibLogLevel = { level: 'error', isDebugEnabled: false, isInfoEnabled: false, isWarnEnabled: false };\n break\n default:\n // in case null is passed as input, default to 'info'\n globalThis.apirtcReactLibLogLevel = INFO;\n }\n return globalThis.apirtcReactLibLogLevel\n}\n\nglobalThis.setApirtcReactLibLogLevel = setLogLevel;\n","import React, { useEffect, useRef } from 'react'\nimport { Stream } from '@apirtc/apirtc'\n\n// tried const Video = styled.video`\n// max-width: 100%;\n// `\n// or\n// /* override other styles to make responsive */\n// width: 100% !important;\n// height: auto !important;\n// or\n// return <video width=\"100%\" ...\n//\n// but for all there is a problem then in react display...\n\nexport interface VideoStreamProps {\n stream: Stream,\n autoPlay?: boolean,\n muted?: boolean\n}\nexport default function VideoStream(props: VideoStreamProps) {\n\n // default autoPlay\n const { autoPlay = true } = props;\n\n const videoRef = useRef<HTMLVideoElement>(null)\n\n useEffect(() => {\n const ref = videoRef.current;\n if (ref && props.stream) {\n props.stream.attachToElement(ref)\n return () => {\n ref.src = \"\";\n }\n }\n }, [props.stream])\n // No need to put videoRef.current because useRef does not trigger rerender anyways\n\n return <video id={props.stream.getId()} style={{ maxWidth: '100%' }}\n ref={videoRef}\n autoPlay={autoPlay}\n muted={props.muted}></video>\n}"],"names":["HOOK_NAME","notEmpty","value","EMPTY_LIST","audioinput","audiooutput","videoinput","INFO","level","isDebugEnabled","isInfoEnabled","isWarnEnabled","setLogLevel","logLevelText","globalThis","apirtcReactLibLogLevel","setApirtcReactLibLogLevel","props","autoPlay","videoRef","useRef","useEffect","ref","current","stream","attachToElement","src","React","createElement","id","getId","style","maxWidth","muted","session","options","setStream","useState","getUserAgent","createStream","then","localStream","console","info","catch","error","undefined","JSON","stringify","release","name","join","conversation","setConversation","joined","setJoined","joining","setJoining","o_join","useCallback","debug","Promise","resolve","reject","isJoined","finally","o_leave","leave","l_conversation","getOrCreateConversation","warn","destroy","l_join","messages","Array","o_messages","setO_Messages","onMessage","message","getName","push","from","on","removeListener","length","sendMessage","msgContent","sender","uuid","content","time","Date","onEjected","onEjectedSelf","candidates","setCandidates","Set","on_contactJoinedWaitingRoom","contact","add","on_contactLeftWaitingRoom","delete","on_participantEjected","data","self","streamsToPublish","errorCallback","publishedStreamsCache","setPublishedStreamsCache","publishedStreams","o_publishedStreams","setO_PublishedStreams","subscribedStreams","o_subscribedStreams","setO_SubscribedStreams","publish","replacePublishedStream","oldStream","newStream","conversationCall","getConversationCall","index","indexOf","splice","unpublish","doHandlePublication","maxLength","Math","max","map","l_s","newPublishedStreamsCache","streamsToPublishSet","filter","item","i","previous","next","doReplacePublishedStream","has","isPublishedStream","on_streamAdded","remoteStream","on_streamRemoved","on_streamListChanged","streamInfo","streamId","String","isRemote","listEventType","subscribeToStream","unsubscribeToStream","unpublishAndUnsubscribeAll","i_conversation","forEach","on_joined","on_left","getAvailableStreamList","groups","groupsCache","m_contactsByGroup","Map","contactsByGroup","setContactsByGroup","clear","getOrCreateGroupSet","group","o_set","_a","get","set","l_session","l_groupsSet","subscribeToGroup","needsRefresh","unsubscribeToGroup","onContactListUpdate","updatedContacts","Object","keys","joinedGroup","l_set","leftGroup","size","userDataChanged","l_contacts","values","credentials","setSession","connecting","setConnecting","setError","isMounted","connect","disconnect","registerInformation","cloudUrl","l_userAgent","object","password","UserAgent","uri","username","isInstanceOfApiKey","apiKey","isInstanceOfToken","token","register","videoProcessorType","outStream","setOutStream","applied","setApplied","applyVideoProcessor","l_stream","previousValue","doCheckAndReleaseOutStream","userMediaDevices","setUserMediaDevices","userAgent","on_mediaDeviceChanged","mediaDevices","getUserMediaDevices"],"mappings":"kaAGA,MAAMA,EA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MAAM5D,EAAY,uBAAwBiN,GAOtDA,EAAUhK,UACb,GACF,CAACzB,EAAQyL,IAQZ,OANA5L,EAAAA,WAAU,IACC,KACHmM,GAA4B,GAEjC,CAACP,IAEG,CACHzL,OAAQyL,EACRE,UAER,wBChEwB,SACpBjL,GAEA,MAAOuL,EAAkBC,GAAuBrL,EAAQA,SAAkBlC,GAsB1E,OApBAkB,EAAAA,WAAU,KACN,GAAIa,EAAS,CACT,MAAMyL,EAAuBzL,EAAQI,eAE/BsL,EAAwB,KAC1B,MAAMC,EAAgCF,EAAUG,sBAC5ChN,WAAWC,uBAAuBL,eAClCgC,QAAQC,KAAK3C,yCAAmC6N,GAEpDH,EAAoBG,EAAa,EAIrC,OAFAF,EAAUzI,GAAG,qBAAsB0I,GAE5B,KACHD,EAAUxI,eAAe,qBAAsByI,GAC/CF,EAAoBvN,EAAW,CAEtC,IACF,CAAC+B,IAEG,CACHuL,mBAER"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apirtc/react-lib",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "react library for apirtc",
|
|
5
|
+
"main": "dist/esm/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rollup -c",
|
|
13
|
+
"test": "jest --coverage"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"apirtc",
|
|
17
|
+
"react"
|
|
18
|
+
],
|
|
19
|
+
"author": "Kevin Moyse",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@apirtc/apirtc": "^4.7.8",
|
|
23
|
+
"react": "^17"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@rollup/plugin-commonjs": "^21.0.3",
|
|
27
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
28
|
+
"@testing-library/react-hooks": "^8.0.0",
|
|
29
|
+
"@types/jest": "^27.5.0",
|
|
30
|
+
"@types/react": "^17",
|
|
31
|
+
"jest": "^28.1.0",
|
|
32
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
33
|
+
"react-dom": "^17",
|
|
34
|
+
"rollup": "^2.70.1",
|
|
35
|
+
"rollup-plugin-dts": "^4.2.0",
|
|
36
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
37
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
38
|
+
"rollup-plugin-typescript2": "^0.31.2",
|
|
39
|
+
"ts-jest": "^28.0.2",
|
|
40
|
+
"typescript": "^4.6.3"
|
|
41
|
+
}
|
|
42
|
+
}
|