agora-appbuilder-core 4.0.0-ms.8 → 4.0.0-spl.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/package.json +2 -2
  2. package/template/Gulpfile.js +7 -7
  3. package/template/_package-lock.json +0 -22
  4. package/template/agora-rn-uikit/src/Rtc/Create.tsx +22 -8
  5. package/template/agora-rn-uikit/src/Rtc/Join.tsx +9 -1
  6. package/template/agora-rn-uikit/src/RtcConfigure.tsx +4 -2
  7. package/template/bridge/rtc/webNg/RtcEngine.ts +1 -1
  8. package/template/customization-api/typeDefinition.ts +2 -1
  9. package/template/global.d.ts +1 -3
  10. package/template/index.wsdk.tsx +1 -19
  11. package/template/package.json +0 -2
  12. package/template/src/App.tsx +76 -3
  13. package/template/src/AppWrapper.tsx +13 -16
  14. package/template/src/SDKAppWrapper.tsx +54 -50
  15. package/template/src/atoms/Popup.tsx +1 -3
  16. package/template/src/components/Chat.tsx +9 -8
  17. package/template/src/components/DeviceConfigure.tsx +280 -124
  18. package/template/src/components/GraphQLProvider.tsx +35 -60
  19. package/template/src/components/Navigation.native.tsx +15 -1
  20. package/template/src/components/Navigation.tsx +15 -1
  21. package/template/src/components/OAuth.electron.tsx +41 -0
  22. package/template/src/components/OAuth.native.tsx +55 -0
  23. package/template/src/components/{Navigation.sdk.tsx → OAuth.tsx} +16 -18
  24. package/template/src/components/OAuthConfig.ts +77 -0
  25. package/template/src/components/ParticipantsView.tsx +1 -1
  26. package/template/src/components/Precall.native.tsx +2 -24
  27. package/template/src/components/Precall.tsx +13 -28
  28. package/template/src/components/RTMConfigure.tsx +12 -2
  29. package/template/src/components/Router.electron.ts +0 -1
  30. package/template/src/components/Router.native.ts +0 -1
  31. package/template/src/components/Router.sdk.ts +0 -1
  32. package/template/src/components/Router.ts +0 -1
  33. package/template/src/components/SdkApiContext.tsx +160 -14
  34. package/template/src/components/SdkMuteToggleListener.tsx +92 -0
  35. package/template/src/components/SettingsView.tsx +1 -3
  36. package/template/src/components/Share.tsx +2 -22
  37. package/template/src/components/StorageContext.tsx +4 -20
  38. package/template/src/components/StoreToken.tsx +39 -0
  39. package/template/src/components/ToastComponent.tsx +3 -1
  40. package/template/src/components/popups/InvitePopup.tsx +2 -6
  41. package/template/src/components/precall/PermissionHelper.tsx +28 -3
  42. package/template/src/components/precall/joinCallBtn.native.tsx +1 -3
  43. package/template/src/components/precall/joinCallBtn.tsx +0 -4
  44. package/template/src/components/precall/usePreCall.tsx +6 -5
  45. package/template/src/components/useShareLink.tsx +1 -4
  46. package/template/src/components/useUserPreference.tsx +0 -29
  47. package/template/src/components/useVideoCall.tsx +4 -1
  48. package/template/src/pages/Create.tsx +1 -21
  49. package/template/src/pages/Join.tsx +1 -21
  50. package/template/src/pages/VideoCall.tsx +28 -28
  51. package/template/src/subComponents/LocalEndCall.tsx +0 -1
  52. package/template/src/subComponents/LogoutButton.tsx +1 -1
  53. package/template/src/subComponents/recording/useRecording.tsx +2 -14
  54. package/template/src/utils/SdkEvents.ts +10 -4
  55. package/template/src/utils/SdkMethodEvents.ts +18 -1
  56. package/template/src/utils/common.tsx +5 -22
  57. package/template/src/utils/useCreateMeeting.ts +11 -2
  58. package/template/src/utils/useJoinMeeting.ts +0 -4
  59. package/template/src/utils/useMuteToggleLocal.ts +96 -52
  60. package/template/tsconfig_rsdk_index.json +3 -3
  61. package/template/tsconfig_wsdk_index.json +1 -1
  62. package/template/webpack.web.config.js +3 -7
  63. package/template/src/AppRoutes.tsx +0 -45
  64. package/template/src/auth/AuthProvider.tsx +0 -407
  65. package/template/src/auth/AuthRoute.tsx +0 -86
  66. package/template/src/auth/IDPAuth.electron.tsx +0 -30
  67. package/template/src/auth/IDPAuth.tsx +0 -64
  68. package/template/src/auth/IDPLogoutComponent.tsx +0 -149
  69. package/template/src/auth/UserCancelPopup.tsx +0 -108
  70. package/template/src/auth/config.ts +0 -52
  71. package/template/src/auth/openIDPURL.electron.tsx +0 -38
  72. package/template/src/auth/openIDPURL.native.tsx +0 -51
  73. package/template/src/auth/openIDPURL.tsx +0 -20
  74. package/template/src/auth/useIDPAuth.electron.tsx +0 -62
  75. package/template/src/auth/useIDPAuth.native.tsx +0 -70
  76. package/template/src/auth/useIDPAuth.tsx +0 -59
  77. package/template/src/auth/useTokenAuth.tsx +0 -190
  78. package/template/src/pages/Login.tsx +0 -26
  79. package/template/src/subComponents/Loading.tsx +0 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-appbuilder-core",
3
- "version": "4.0.0-ms.8",
3
+ "version": "4.0.0-spl.10",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "scripts": {
11
11
  "vercel-build": "npm run dev-setup && cd template && npm run web:build && cd .. && npm run copy-vercel",
12
- "uikit": "rm -rf template/agora-rn-uikit && git clone https://github.com/AgoraIO-Community/ReactNative-UIKit.git template/agora-rn-uikit && cd template/agora-rn-uikit && git checkout feature/redesign/ui-kit-v1",
12
+ "uikit": "rm -rf template/agora-rn-uikit && git clone https://github.com/AgoraIO-Community/ReactNative-UIKit.git template/agora-rn-uikit && cd template/agora-rn-uikit && git checkout mavtek-spl-uikit",
13
13
  "deps": "cd template && npm i",
14
14
  "dev-setup": "npm run uikit && npm run deps && node devSetup.js",
15
15
  "web-build": "cd template && npm run web:build && cd .. && npm run copy-vercel",
@@ -460,11 +460,11 @@ module.exports.androidWin = series(
460
460
  );
461
461
 
462
462
  module.exports.test = series(
463
- general.generateNpmPackage,
464
- // general.typescript,
465
- // general.typescriptFix,
466
- // reactSdk.typescript,
467
- // reactSdk.typescriptFix,
468
- // webSdk.typescript,
469
- // webSdk.typescriptFix,
463
+ general.createBuildDirectory,
464
+ general.generateApiTypedefs,
465
+ general.bundleApiTypedefs,
466
+ webSdk.generateSdkTypedefs,
467
+ webSdk.bundleSdkTypedefs,
468
+ general.cleanTempFiles,
469
+ general.genTsDefs,
470
470
  );
@@ -25,7 +25,6 @@
25
25
  "electron-updater": "4.3.9",
26
26
  "exponential-backoff": "3.1.0",
27
27
  "graphql": "15.5.0",
28
- "jwt-decode": "3.1.2",
29
28
  "nanoevents": "7.0.1",
30
29
  "nanoid": "4.0.0",
31
30
  "nosleep.js": "0.12.0",
@@ -34,7 +33,6 @@
34
33
  "react-is": "18.0.0",
35
34
  "react-native": "0.64",
36
35
  "react-native-agora": "3.7.1",
37
- "react-native-exit-app": "1.1.0",
38
36
  "react-native-gesture-handler": "2.8.0",
39
37
  "react-native-hyperlink": "0.0.19",
40
38
  "react-native-inappbrowser-reborn": "3.5.1",
@@ -19421,11 +19419,6 @@
19421
19419
  "integrity": "sha512-qpcRocdkUmf+UTNBYx5w6dexX5J31AKK1OmPwH630a83DdVVUIngk55RSAiIGpQyoH0dlr872VHfPjnQnK1qDQ==",
19422
19420
  "dev": true
19423
19421
  },
19424
- "node_modules/jwt-decode": {
19425
- "version": "3.1.2",
19426
- "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz",
19427
- "integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
19428
- },
19429
19422
  "node_modules/keyv": {
19430
19423
  "version": "3.1.0",
19431
19424
  "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz",
@@ -23560,11 +23553,6 @@
23560
23553
  "nullthrows": "^1.1.1"
23561
23554
  }
23562
23555
  },
23563
- "node_modules/react-native-exit-app": {
23564
- "version": "1.1.0",
23565
- "resolved": "https://registry.npmjs.org/react-native-exit-app/-/react-native-exit-app-1.1.0.tgz",
23566
- "integrity": "sha512-Spne19zfMfJvnUTX909EHUqWMk69rATtLJq9XMBGpNSHhx0M7v5yetx2Z87egBhLOqQm+CWfD/oxWzDG8rbIQA=="
23567
- },
23568
23556
  "node_modules/react-native-gesture-handler": {
23569
23557
  "version": "2.8.0",
23570
23558
  "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.8.0.tgz",
@@ -44628,11 +44616,6 @@
44628
44616
  "integrity": "sha512-qpcRocdkUmf+UTNBYx5w6dexX5J31AKK1OmPwH630a83DdVVUIngk55RSAiIGpQyoH0dlr872VHfPjnQnK1qDQ==",
44629
44617
  "dev": true
44630
44618
  },
44631
- "jwt-decode": {
44632
- "version": "3.1.2",
44633
- "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz",
44634
- "integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
44635
- },
44636
44619
  "keyv": {
44637
44620
  "version": "3.1.0",
44638
44621
  "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz",
@@ -48028,11 +48011,6 @@
48028
48011
  "nullthrows": "^1.1.1"
48029
48012
  }
48030
48013
  },
48031
- "react-native-exit-app": {
48032
- "version": "1.1.0",
48033
- "resolved": "https://registry.npmjs.org/react-native-exit-app/-/react-native-exit-app-1.1.0.tgz",
48034
- "integrity": "sha512-Spne19zfMfJvnUTX909EHUqWMk69rATtLJq9XMBGpNSHhx0M7v5yetx2Z87egBhLOqQm+CWfD/oxWzDG8rbIQA=="
48035
- },
48036
48014
  "react-native-gesture-handler": {
48037
48015
  "version": "2.8.0",
48038
48016
  "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.8.0.tgz",
@@ -21,9 +21,14 @@ const Create = ({
21
21
  children,
22
22
  }: {
23
23
  dispatch: DispatchType;
24
- children: (engine: React.MutableRefObject<RtcEngine>) => JSX.Element;
24
+ children: (
25
+ engine: React.MutableRefObject<RtcEngine>,
26
+ tracksReady: boolean,
27
+ ) => JSX.Element;
25
28
  }) => {
29
+ const mutexLock = useRef(false);
26
30
  const [ready, setReady] = useState(false);
31
+ const [tracksReady, setTracksReady] = useState(false);
27
32
  const {callbacks, rtcProps, mode} = useContext(PropsContext);
28
33
  const {
29
34
  geoFencing = true,
@@ -186,14 +191,15 @@ const Create = ({
186
191
  mode == ChannelProfile.LiveBroadcasting &&
187
192
  rtcProps?.role == ClientRole.Audience
188
193
  ) {
189
- enableVideoAndAudioWithDisabledState();
194
+ await enableVideoAndAudioWithDisabledState();
190
195
  } else {
191
- enableVideoAndAudioWithEnabledState();
196
+ await enableVideoAndAudioWithEnabledState();
192
197
  }
193
198
  };
194
199
 
195
200
  useEffect(() => {
196
201
  async function init() {
202
+ mutexLock.current = true;
197
203
  if (Platform.OS === 'android') {
198
204
  //Request required permissions from Android
199
205
  await requestCameraAndAudioPermission(audioRoom);
@@ -283,8 +289,10 @@ const Create = ({
283
289
  Platform.OS === 'web'
284
290
  )
285
291
  ) {
286
- await enableVideoAndAudioWithInitialStates();
287
- isVideoEnabledRef.current = true;
292
+ enableVideoAndAudioWithInitialStates().then(() => {
293
+ setTracksReady(true);
294
+ isVideoEnabledRef.current = true;
295
+ });
288
296
  }
289
297
 
290
298
  engine.current.addListener(
@@ -375,8 +383,11 @@ const Create = ({
375
383
  } catch (e) {
376
384
  console.error(e);
377
385
  }
386
+ mutexLock.current = false;
387
+ }
388
+ if (!mutexLock.current) {
389
+ init();
378
390
  }
379
- init();
380
391
  return () => {
381
392
  /**
382
393
  * if condition add for websdk issue
@@ -391,7 +402,10 @@ const Create = ({
391
402
 
392
403
  useEffect(() => {
393
404
  const toggleRole = async () => {
394
- if (mode == ChannelProfile.LiveBroadcasting) {
405
+ if (
406
+ mode == ChannelProfile.LiveBroadcasting &&
407
+ engine.current.setClientRole // Check if engine initialized
408
+ ) {
395
409
  if (rtcProps.role == ClientRole.Broadcaster) {
396
410
  await engine.current?.setClientRole(ClientRole.Broadcaster);
397
411
  // isVideoEnabledRef checks if the permission is already taken once
@@ -453,7 +467,7 @@ const Create = ({
453
467
  <>
454
468
  {
455
469
  // Render children once RTCEngine has been initialized
456
- ready && engine ? children(engine) : <></>
470
+ ready && engine ? children(engine, tracksReady) : <></>
457
471
  }
458
472
  </>
459
473
  );
@@ -10,7 +10,8 @@ const Join: React.FC<{
10
10
  engineRef: React.MutableRefObject<RtcEngine>;
11
11
  uidState: RenderStateInterface;
12
12
  dispatch: DispatchType;
13
- }> = ({children, precall, engineRef, uidState, dispatch}) => {
13
+ tracksReady: boolean;
14
+ }> = ({children, precall, engineRef, uidState, dispatch, tracksReady}) => {
14
15
  let joinState = useRef(false);
15
16
  const {rtcProps} = useContext(PropsContext);
16
17
  const {audioRoom = false} = rtcProps;
@@ -19,6 +20,13 @@ const Join: React.FC<{
19
20
  // ? rtcProps.lifecycle.useBeforeJoin()
20
21
  // : null;
21
22
 
23
+ useEffect(() => {
24
+ if (joinState.current && tracksReady && Platform.OS === 'web') {
25
+ //@ts-ignore
26
+ engineRef.current.publish();
27
+ }
28
+ }, [tracksReady]);
29
+
22
30
  useEffect(() => {
23
31
  const engine = engineRef.current;
24
32
  async function leave() {
@@ -332,12 +332,14 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
332
332
 
333
333
  return (
334
334
  <Create dispatch={dispatch}>
335
- {(engineRef) => (
335
+ {(engineRef, tracksReady) => (
336
336
  <Join
337
337
  precall={!rtcProps.callActive}
338
338
  engineRef={engineRef}
339
339
  uidState={uidState}
340
- dispatch={dispatch}>
340
+ dispatch={dispatch}
341
+ tracksReady={tracksReady}
342
+ >
341
343
  <RtcProvider
342
344
  value={{
343
345
  RtcEngine: engineRef.current,
@@ -730,11 +730,11 @@ export default class RtcEngine {
730
730
 
731
731
  async changeSpeaker(speakerId, callback, error) {
732
732
  try {
733
- this.speakerDeviceId = speakerId;
734
733
  // setting sepeaker for all remote stream (previously joined users)
735
734
  this.remoteStreams?.forEach((stream, uid, map) => {
736
735
  stream?.audio?.setPlaybackDevice(speakerId);
737
736
  });
737
+ this.speakerDeviceId = speakerId;
738
738
  callback(speakerId);
739
739
  } catch (e) {
740
740
  error(e);
@@ -101,7 +101,8 @@ export type ComponentsInterface = {
101
101
  */
102
102
  appRoot?: React.ComponentType;
103
103
  // commented for v1 release
104
- //precall?: PreCallInterface | React.ComponentType;
104
+ // precall?: PreCallInterface | React.ComponentType;
105
+ precall?: React.ComponentType;
105
106
  //create?: React.ComponentType;
106
107
  //share?: React.ComponentType;
107
108
  //join?: React.ComponentType;
@@ -98,9 +98,7 @@ interface ConfigInterface {
98
98
  ICON_BG_COLOR: string;
99
99
  TOOLBAR_COLOR: string;
100
100
  ACTIVE_SPEAKER: boolean;
101
- ENABLE_TOKEN_AUTH: boolean;
102
- ENABLE_IDP_AUTH: boolean;
103
- PROJECT_ID: string;
101
+ TOAST_NOTIFICATIONS: boolean;
104
102
  }
105
103
  declare var $config: ConfigInterface;
106
104
  declare module 'customization' {
@@ -3,31 +3,13 @@ import SDKAppWrapper, {
3
3
  AppBuilderSdkApi,
4
4
  AppBuilderSdkApiInterface,
5
5
  } from './src/SDKAppWrapper';
6
- import SDKEvents from './src/utils/SdkEvents';
7
6
  import React from 'react';
8
7
  import * as RN from 'react-native-web';
9
8
  import './src/assets/font-styles.css';
10
9
  export * from 'customization-api';
11
10
  export * from 'customization-implementation';
12
11
 
13
- interface AppBuilderWebSdkInterface extends AppBuilderSdkApiInterface {}
14
-
15
- const clearEvent = {
16
- clear: () => {},
17
- };
18
-
19
- const AppBuilderWebSdkApi: AppBuilderWebSdkInterface = {
20
- ...AppBuilderSdkApi,
21
- // Override customize function for web-sdk
22
- customize: (customization) => {
23
- SDKEvents.emit('addFpe', customization);
24
- clearEvent.clear = SDKEvents.on('addFpeInit', () => {
25
- console.log('addFpeInit called');
26
- SDKEvents.emit('addFpe', customization);
27
- clearEvent.clear();
28
- });
29
- },
30
- };
12
+ const AppBuilderWebSdkApi: AppBuilderSdkApiInterface = AppBuilderSdkApi;
31
13
 
32
14
  // init code
33
15
  class AppBuilder extends HTMLElement {
@@ -65,7 +65,6 @@
65
65
  "electron-updater": "4.3.9",
66
66
  "exponential-backoff": "3.1.0",
67
67
  "graphql": "15.5.0",
68
- "jwt-decode": "3.1.2",
69
68
  "nanoevents": "7.0.1",
70
69
  "nanoid": "4.0.0",
71
70
  "nosleep.js": "0.12.0",
@@ -74,7 +73,6 @@
74
73
  "react-is": "18.0.0",
75
74
  "react-native": "0.64",
76
75
  "react-native-agora": "3.7.1",
77
- "react-native-exit-app": "1.1.0",
78
76
  "react-native-gesture-handler": "2.8.0",
79
77
  "react-native-hyperlink": "0.0.19",
80
78
  "react-native-inappbrowser-reborn": "3.5.1",
@@ -11,7 +11,18 @@
11
11
  */
12
12
  import React, {useState, useContext} from 'react';
13
13
  import {Platform} from 'react-native';
14
+ import Join from './pages/Join';
15
+ import VideoCall from './pages/VideoCall';
16
+ import Create from './pages/Create';
17
+ import {Route, Switch, Redirect} from './components/Router';
18
+ import PrivateRoute from './components/PrivateRoute';
19
+ import OAuth from './components/OAuth';
20
+ import StoreToken from './components/StoreToken';
21
+ import {shouldAuthenticate} from './utils/common';
14
22
  import KeyboardManager from 'react-native-keyboard-manager';
23
+ // commented for v1 release
24
+ //import {CustomRoutesInterface, CUSTOM_ROUTES_PREFIX} from 'customization-api';
25
+ //import {useCustomization} from 'customization-implementation';
15
26
  import AppWrapper from './AppWrapper';
16
27
  import {
17
28
  MeetingInfoContextInterface,
@@ -20,9 +31,9 @@ import {
20
31
  } from './components/meeting-info/useMeetingInfo';
21
32
  import {SetMeetingInfoProvider} from './components/meeting-info/useSetMeetingInfo';
22
33
  import {ShareLinkProvider} from './components/useShareLink';
23
- import AppRoutes from './AppRoutes';
34
+ import Endcall from './pages/Endcall';
24
35
 
25
- // hook can't be used in the outside react function calls. so directly checking the platform.
36
+ //hook can't be used in the outside react function calls. so directly checking the platform.
26
37
  if (Platform.OS === 'ios') {
27
38
  KeyboardManager.setEnable(true);
28
39
  KeyboardManager.setEnableAutoToolbar(false);
@@ -45,6 +56,35 @@ declare module 'agora-rn-uikit' {
45
56
  }
46
57
 
47
58
  const App: React.FC = () => {
59
+ //commented for v1 release
60
+ //const CustomRoutes = useCustomization((data) => data?.customRoutes);
61
+ // const RenderCustomRoutes = () => {
62
+ // try {
63
+ // return (
64
+ // CustomRoutes &&
65
+ // Array.isArray(CustomRoutes) &&
66
+ // CustomRoutes.length &&
67
+ // CustomRoutes?.map((item: CustomRoutesInterface, i: number) => {
68
+ // let RouteComponent = item?.isPrivateRoute ? PrivateRoute : Route;
69
+ // return (
70
+ // <RouteComponent
71
+ // path={CUSTOM_ROUTES_PREFIX + item.path}
72
+ // exact={item.exact}
73
+ // key={i}
74
+ // failureRedirectTo={
75
+ // item.failureRedirectTo ? item.failureRedirectTo : '/'
76
+ // }
77
+ // {...item.routeProps}>
78
+ // <item.component {...item.componentProps} />
79
+ // </RouteComponent>
80
+ // );
81
+ // })
82
+ // );
83
+ // } catch (error) {
84
+ // console.error('Error on rendering the custom routes');
85
+ // return null;
86
+ // }
87
+ // };
48
88
  const [meetingInfo, setMeetingInfo] = useState<MeetingInfoContextInterface>(
49
89
  MeetingInfoDefaultValue,
50
90
  );
@@ -54,7 +94,40 @@ const App: React.FC = () => {
54
94
  <SetMeetingInfoProvider value={{setMeetingInfo}}>
55
95
  <MeetingInfoProvider value={{...meetingInfo}}>
56
96
  <ShareLinkProvider>
57
- <AppRoutes />
97
+ <Switch>
98
+ {/* commented for v1 release */}
99
+ {/* {RenderCustomRoutes()} */}
100
+ <Route exact path={'/'}>
101
+ <Redirect to={'/create'} />
102
+ </Route>
103
+ <Route exact path={'/authenticate'}>
104
+ {shouldAuthenticate ? <OAuth /> : <Redirect to={'/'} />}
105
+ </Route>
106
+ <Route path={'/auth-token/:token'}>
107
+ <StoreToken />
108
+ </Route>
109
+ <Route exact path={'/join'}>
110
+ <Join />
111
+ </Route>
112
+ {/* Will be used in the future
113
+ <Route exact path={'/leave'}>
114
+ <Endcall />
115
+ </Route> */}
116
+ {shouldAuthenticate ? (
117
+ <PrivateRoute
118
+ path={'/create'}
119
+ failureRedirectTo={'/authenticate'}>
120
+ <Create />
121
+ </PrivateRoute>
122
+ ) : (
123
+ <Route path={'/create'}>
124
+ <Create />
125
+ </Route>
126
+ )}
127
+ <Route path={'/:phrase'}>
128
+ <VideoCall />
129
+ </Route>
130
+ </Switch>
58
131
  </ShareLinkProvider>
59
132
  </MeetingInfoProvider>
60
133
  </SetMeetingInfoProvider>
@@ -29,7 +29,6 @@ import Error from './components/common/Error';
29
29
  import {ErrorProvider} from './components/common';
30
30
  import {useCustomization} from 'customization-implementation';
31
31
  import {LanguageProvider} from './language/useLanguage';
32
- import {AuthProvider} from './auth/AuthProvider';
33
32
  import {PropsConsumer} from 'agora-rn-uikit';
34
33
  import ToastComponent from './components/ToastComponent';
35
34
  import {ToastContext, ToastProvider} from './components/useToast';
@@ -100,21 +99,19 @@ const AppWrapper = (props: AppWrapperProps) => {
100
99
  ? `/${SdkJoinState.phrase}`
101
100
  : '',
102
101
  ]}>
103
- <AuthProvider>
104
- <SessionProvider>
105
- <ColorConfigure>
106
- <DimensionProvider>
107
- <LanguageProvider>
108
- <ErrorProvider>
109
- <Error />
110
- <Navigation />
111
- {props.children}
112
- </ErrorProvider>
113
- </LanguageProvider>
114
- </DimensionProvider>
115
- </ColorConfigure>
116
- </SessionProvider>
117
- </AuthProvider>
102
+ <SessionProvider>
103
+ <ColorConfigure>
104
+ <DimensionProvider>
105
+ <LanguageProvider>
106
+ <ErrorProvider>
107
+ <Error />
108
+ <Navigation />
109
+ {props.children}
110
+ </ErrorProvider>
111
+ </LanguageProvider>
112
+ </DimensionProvider>
113
+ </ColorConfigure>
114
+ </SessionProvider>
118
115
  </Router>
119
116
  </GraphQLProvider>
120
117
  </StorageProvider>
@@ -11,68 +11,72 @@ import SDKMethodEventsManager from './utils/SdkMethodEvents';
11
11
  import App from './App';
12
12
  import SdkApiContextProvider from './components/SdkApiContext';
13
13
  import {Unsubscribe} from 'nanoevents';
14
+ import {deviceId} from './components/DeviceConfigure';
14
15
 
15
- // type makeAsync<T extends (...p: any) => void> = (
16
- // ...p: Parameters<T>
17
- // ) => PromiseLike<ReturnType<T>>;
18
- //
19
- // type takeOnlyFirstParam<T extends (...p: any) => void> = (
20
- // p: Parameters<T>[0],
21
- // ) => ReturnType<T>;
16
+ type meetingData = Partial<MeetingInfoContextInterface['data']>;
22
17
 
23
- export interface SdkMethodEvents {
24
- customize: (customization: CustomizationApiInterface) => void;
25
- join(
26
- roomid: string | Partial<MeetingInfoContextInterface['data']>,
27
- skipPrecall?: boolean,
28
- ): MeetingInfoContextInterface['data'];
29
- 'login':(token:string) => Promise<void>
30
- 'logout':() => Promise<void>
18
+ // Hard defined since its an api.
19
+ export interface AppBuilderSdkApiInterface {
20
+ customize: (customization: CustomizationApiInterface) => Promise<void>;
21
+ joinRoom: (roomDetails: string | meetingData) => Promise<meetingData>;
22
+ joinPrecall: (
23
+ roomDetails: string | meetingData,
24
+ ) => Promise<
25
+ [meetingData, () => Promise<MeetingInfoContextInterface['data']>]
26
+ >;
27
+ setMicrophone: (deviceId: deviceId) => Promise<void>;
28
+ setCamera: (deviceId: deviceId) => Promise<void>;
29
+ setSpeaker: (deviceId: deviceId) => Promise<void>;
30
+ muteAudio: (
31
+ mute: boolean | ((currentMute: boolean) => boolean),
32
+ ) => Promise<void>;
33
+ muteVideo: (
34
+ mute: boolean | ((currentMute: boolean) => boolean),
35
+ ) => Promise<void>;
36
+ createCustomization: (
37
+ customization: CustomizationApiInterface,
38
+ ) => CustomizationApiInterface;
39
+ customEvents: typeof customEvents;
40
+ on: <T extends keyof userEventsMapInterface>(
41
+ userEventName: T,
42
+ cb: userEventsMapInterface[T],
43
+ ) => Unsubscribe;
31
44
  }
32
45
 
33
- // interface AppBuilderSdkApiInterface {
34
- // customize: makeAsync<SdkMethodEvents['customize']>;
35
- // joinRoom: makeAsync<takeOnlyFirstParam<SdkMethodEvents['join']>>;
36
- // joinPrecall: makeAsync<takeOnlyFirstParam<SdkMethodEvents['join']>>;
37
- // createCustomization: (
38
- // customization: CustomizationApiInterface,
39
- // ) => CustomizationApiInterface;
40
- // on: <T extends keyof userEventsMapInterface>(
41
- // userEventName: T,
42
- // callBack: userEventsMapInterface[T],
43
- // ) => Unsubscribe;
44
- // }
45
-
46
- export const AppBuilderSdkApi = {
47
- login: async (token: string) => {
48
- return await SDKMethodEventsManager.emit('login', token);
49
- },
50
- logout: async () => {
51
- return await SDKMethodEventsManager.emit('logout');
52
- },
53
- customize: async (customization: CustomizationApiInterface) => {
46
+ export const AppBuilderSdkApi: AppBuilderSdkApiInterface = {
47
+ customize: async (customization) => {
54
48
  return await SDKMethodEventsManager.emit('customize', customization);
55
49
  },
56
50
  customEvents: customEvents,
57
- join: async (roomDetails: string) => {
58
- await SDKMethodEventsManager.emit('join', roomDetails, false);
59
- },
60
- joinRoom: async (
61
- roomDetails: string | Partial<MeetingInfoContextInterface['data']>,
62
- ) => {
51
+ joinRoom: async (roomDetails) => {
63
52
  return await SDKMethodEventsManager.emit('join', roomDetails, true);
64
53
  },
65
- joinPrecall: async (
66
- roomDetails: string | Partial<MeetingInfoContextInterface['data']>,
67
- ) => {
54
+ joinPrecall: async (roomDetails) => {
55
+ if (!$config.PRECALL)
56
+ throw new Error('Precall disabled in config, cant join precall');
68
57
  const t = await SDKMethodEventsManager.emit('join', roomDetails);
69
- return t as unknown as [MeetingInfoContextInterface['data'], () => {}];
58
+ return t as unknown as [
59
+ MeetingInfoContextInterface['data'],
60
+ () => Promise<MeetingInfoContextInterface['data']>,
61
+ ];
62
+ },
63
+ setMicrophone: async (deviceId) => {
64
+ return await SDKMethodEventsManager.emit('microphoneDevice', deviceId);
65
+ },
66
+ setSpeaker: async (deviceId) => {
67
+ return await SDKMethodEventsManager.emit('speakerDevice', deviceId);
68
+ },
69
+ setCamera: async (deviceId) => {
70
+ return await SDKMethodEventsManager.emit('cameraDevice', deviceId);
71
+ },
72
+ muteAudio: async (state) => {
73
+ return await SDKMethodEventsManager.emit('muteAudio', state);
74
+ },
75
+ muteVideo: async (state) => {
76
+ return await SDKMethodEventsManager.emit('muteVideo', state);
70
77
  },
71
78
  createCustomization: customize,
72
- on: <T extends keyof userEventsMapInterface>(
73
- userEventName: T,
74
- cb: userEventsMapInterface[T],
75
- ): Unsubscribe => {
79
+ on: (userEventName, cb) => {
76
80
  console.log('SDKEvents: Event Registered', userEventName);
77
81
  return SDKEvents.on(userEventName, cb);
78
82
  },
@@ -21,7 +21,6 @@ interface PopupProps extends ModalProps {
21
21
  children: React.ReactNode;
22
22
  contentContainerStyle?: ViewStyle;
23
23
  containerStyle?: ViewStyle;
24
- cancelable?: boolean;
25
24
  }
26
25
  const Popup = (props: PopupProps) => {
27
26
  const {
@@ -30,7 +29,6 @@ const Popup = (props: PopupProps) => {
30
29
  setModalVisible,
31
30
  children,
32
31
  showCloseIcon,
33
- cancelable = true,
34
32
  ...otherProps
35
33
  } = props;
36
34
 
@@ -53,7 +51,7 @@ const Popup = (props: PopupProps) => {
53
51
  ]}>
54
52
  <TouchableWithoutFeedback
55
53
  onPress={() => {
56
- cancelable && setModalVisible(false);
54
+ setModalVisible(false);
57
55
  }}>
58
56
  <View style={styles.backDrop} />
59
57
  </TouchableWithoutFeedback>
@@ -81,14 +81,15 @@ const Chat = (props?: ChatProps) => {
81
81
 
82
82
  const {primaryColor} = useContext(ColorContext);
83
83
 
84
- React.useEffect(() => {
85
- return () => {
86
- // reset both the active tabs
87
- setGroupActive(false);
88
- setPrivateActive(false);
89
- setSelectedUser(0);
90
- };
91
- }, []);
84
+ //not need since state are controlled by chatUIControl
85
+ // React.useEffect(() => {
86
+ // return () => {
87
+ // // reset both the active tabs
88
+ // setGroupActive(false);
89
+ // setPrivateActive(false);
90
+ // setSelectedUser(0);
91
+ // };
92
+ // }, []);
92
93
 
93
94
  const selectUser = (userUID: UidType) => {
94
95
  setSelectedUser(userUID);