agora-appbuilder-core 4.0.0-beta.16 → 4.0.0-beta.18

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 (84) hide show
  1. package/package.json +2 -2
  2. package/template/Gulpfile.js +7 -7
  3. package/template/_package-lock.json +22 -0
  4. package/template/agora-rn-uikit/src/Controls/Icons.ts +6 -0
  5. package/template/agora-rn-uikit/src/Rtc/Create.tsx +15 -5
  6. package/template/agora-rn-uikit/src/Rtc/Join.tsx +9 -1
  7. package/template/agora-rn-uikit/src/RtcConfigure.tsx +3 -2
  8. package/template/bridge/rtc/webNg/RtcEngine.ts +1 -1
  9. package/template/customization-api/typeDefinition.ts +2 -1
  10. package/template/global.d.ts +4 -0
  11. package/template/index.wsdk.tsx +1 -19
  12. package/template/package.json +2 -0
  13. package/template/src/App.tsx +3 -76
  14. package/template/src/AppRoutes.tsx +45 -0
  15. package/template/src/AppWrapper.tsx +16 -13
  16. package/template/src/SDKAppWrapper.tsx +79 -43
  17. package/template/src/atoms/Popup.tsx +3 -1
  18. package/template/src/auth/AuthProvider.tsx +502 -0
  19. package/template/src/auth/AuthRoute.tsx +86 -0
  20. package/template/src/auth/IDPAuth.electron.tsx +30 -0
  21. package/template/src/auth/IDPAuth.tsx +59 -0
  22. package/template/src/auth/IDPLogoutComponent.tsx +149 -0
  23. package/template/src/auth/UserCancelPopup.tsx +108 -0
  24. package/template/src/auth/config.ts +52 -0
  25. package/template/src/auth/openIDPURL.electron.tsx +38 -0
  26. package/template/src/auth/openIDPURL.native.tsx +51 -0
  27. package/template/src/auth/openIDPURL.tsx +20 -0
  28. package/template/src/auth/useIDPAuth.electron.tsx +62 -0
  29. package/template/src/auth/useIDPAuth.native.tsx +70 -0
  30. package/template/src/auth/useIDPAuth.tsx +67 -0
  31. package/template/src/auth/useTokenAuth.tsx +192 -0
  32. package/template/src/components/Chat.tsx +9 -8
  33. package/template/src/components/DeviceConfigure.tsx +295 -129
  34. package/template/src/components/EventsConfigure.tsx +17 -0
  35. package/template/src/components/GraphQLProvider.tsx +60 -35
  36. package/template/src/components/Navbar.tsx +12 -1
  37. package/template/src/components/Navigation.native.tsx +1 -15
  38. package/template/src/components/{OAuth.tsx → Navigation.sdk.tsx} +18 -16
  39. package/template/src/components/Navigation.tsx +1 -15
  40. package/template/src/components/Precall.native.tsx +24 -2
  41. package/template/src/components/Precall.tsx +29 -12
  42. package/template/src/components/RTMConfigure.tsx +6 -2
  43. package/template/src/components/Router.electron.ts +1 -0
  44. package/template/src/components/Router.native.ts +1 -0
  45. package/template/src/components/Router.sdk.ts +1 -0
  46. package/template/src/components/Router.ts +1 -0
  47. package/template/src/components/SdkApiContext.tsx +167 -17
  48. package/template/src/components/SdkMuteToggleListener.tsx +92 -0
  49. package/template/src/components/SettingsView.tsx +3 -1
  50. package/template/src/components/Share.tsx +22 -2
  51. package/template/src/components/StorageContext.tsx +20 -4
  52. package/template/src/components/ToastComponent.tsx +3 -0
  53. package/template/src/components/popups/InvitePopup.tsx +6 -2
  54. package/template/src/components/precall/PermissionHelper.tsx +28 -3
  55. package/template/src/components/precall/joinCallBtn.native.tsx +3 -1
  56. package/template/src/components/precall/joinCallBtn.tsx +4 -0
  57. package/template/src/components/precall/usePreCall.tsx +15 -7
  58. package/template/src/components/useShareLink.tsx +3 -1
  59. package/template/src/components/useUserPreference.tsx +29 -0
  60. package/template/src/components/useVideoCall.tsx +9 -1
  61. package/template/src/pages/Create.tsx +23 -2
  62. package/template/src/pages/Join.tsx +21 -1
  63. package/template/src/pages/Login.tsx +26 -0
  64. package/template/src/pages/VideoCall.tsx +47 -41
  65. package/template/src/pages/video-call/ActionSheet.native.tsx +21 -4
  66. package/template/src/subComponents/Loading.tsx +47 -0
  67. package/template/src/subComponents/LocalEndCall.tsx +1 -0
  68. package/template/src/subComponents/LogoutButton.tsx +1 -1
  69. package/template/src/subComponents/recording/useRecording.tsx +14 -2
  70. package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +75 -61
  71. package/template/src/subComponents/screenshare/useScreenshare.tsx +2 -0
  72. package/template/src/utils/SdkEvents.ts +14 -0
  73. package/template/src/utils/SdkMethodEvents.ts +21 -1
  74. package/template/src/utils/common.tsx +22 -5
  75. package/template/src/utils/useCreateMeeting.ts +8 -12
  76. package/template/src/utils/useJoinMeeting.ts +4 -0
  77. package/template/src/utils/useMuteToggleLocal.ts +96 -52
  78. package/template/tsconfig_rsdk_index.json +3 -3
  79. package/template/tsconfig_wsdk_index.json +1 -1
  80. package/template/webpack.web.config.js +7 -3
  81. package/template/src/components/OAuth.electron.tsx +0 -41
  82. package/template/src/components/OAuth.native.tsx +0 -55
  83. package/template/src/components/OAuthConfig.ts +0 -77
  84. package/template/src/components/StoreToken.tsx +0 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-appbuilder-core",
3
- "version": "4.0.0-beta.16",
3
+ "version": "4.0.0-beta.18",
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 mb-with-react18-support",
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,6 +25,7 @@
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",
28
29
  "nanoevents": "7.0.1",
29
30
  "nanoid": "4.0.0",
30
31
  "nosleep.js": "0.12.0",
@@ -33,6 +34,7 @@
33
34
  "react-is": "18.0.0",
34
35
  "react-native": "0.64",
35
36
  "react-native-agora": "3.7.1",
37
+ "react-native-exit-app": "1.1.0",
36
38
  "react-native-gesture-handler": "2.8.0",
37
39
  "react-native-hyperlink": "0.0.19",
38
40
  "react-native-inappbrowser-reborn": "3.5.1",
@@ -19419,6 +19421,11 @@
19419
19421
  "integrity": "sha512-qpcRocdkUmf+UTNBYx5w6dexX5J31AKK1OmPwH630a83DdVVUIngk55RSAiIGpQyoH0dlr872VHfPjnQnK1qDQ==",
19420
19422
  "dev": true
19421
19423
  },
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
+ },
19422
19429
  "node_modules/keyv": {
19423
19430
  "version": "3.1.0",
19424
19431
  "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz",
@@ -23553,6 +23560,11 @@
23553
23560
  "nullthrows": "^1.1.1"
23554
23561
  }
23555
23562
  },
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
+ },
23556
23568
  "node_modules/react-native-gesture-handler": {
23557
23569
  "version": "2.8.0",
23558
23570
  "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.8.0.tgz",
@@ -44616,6 +44628,11 @@
44616
44628
  "integrity": "sha512-qpcRocdkUmf+UTNBYx5w6dexX5J31AKK1OmPwH630a83DdVVUIngk55RSAiIGpQyoH0dlr872VHfPjnQnK1qDQ==",
44617
44629
  "dev": true
44618
44630
  },
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
+ },
44619
44636
  "keyv": {
44620
44637
  "version": "3.1.0",
44621
44638
  "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz",
@@ -48011,6 +48028,11 @@
48011
48028
  "nullthrows": "^1.1.1"
48012
48029
  }
48013
48030
  },
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
+ },
48014
48036
  "react-native-gesture-handler": {
48015
48037
  "version": "2.8.0",
48016
48038
  "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.8.0.tgz",
@@ -9,6 +9,8 @@ export interface IconsInterface {
9
9
  'demote-outlined': string;
10
10
  'lower-hand': string;
11
11
  'raise-hand': string;
12
+ 'turn-off-stt': string;
13
+ 'live-caption-mode': string;
12
14
  }
13
15
 
14
16
  const icons: IconsInterface = {
@@ -32,6 +34,10 @@ const icons: IconsInterface = {
32
34
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADvSURBVHgB5ZRREcIwDIZbB5MQCZOABBxQCUMBSJgEHCBhczAJlTAJITmyo1dW2vTKC/x3ubVZky9JbzPmr4SInmySdcemCR7I7nFQmAhFAcxrAE7ilyBhJ75pBxCu+VxfC3FbpR8Ai2zzI5OEq4wAxAcZgJctmBJxuzFE/GsTQAqy+ZoAJPAggblxVQMAX/LRuHxrwFsnQWIsBtChkcwlACj30icgkEveR9VecV8pCJR0cMMyMeQYQfIAJYR1khj1z08NUUsJGUyNlJCLqVEhZNqDWAXE0QMSr2dr7cyF0Jrv40z70XxD+Px2nPkZPQCoHCglmaLpAgAAAABJRU5ErkJggg==',
33
35
  'raise-hand':
34
36
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADxSURBVHgB5ZTtEYIwDIYD5391gzqBjIAbOIojsIFuoBs4AmyAG+AIblATDSdW+pFSf3g+d+81V0jeNrQA/BVa644EKcGCNapFFfqFQi1IvvxZgEfJ43wwR3HN8cqVnI9N8uoKRx6tXLGc2HbQUjKaLGEiuWVe8ejtcaxBMpIYYCvPqP1XDOjI4rBF7SRJPeUgri2x6oOxWpnNAMKhe/C43RliPpzaosb3QqzBFbVhgyNI0X6o7xdzEgQ7uIGdBp7/p7Ug52MHJ8fqO5ZJeKv0+/EMRYEETKgExSuIIdAk/AZbTOjE0DdpB0U71EHclp/kDilNkhWhg0nUAAAAAElFTkSuQmCC',
37
+ 'turn-off-stt':
38
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAECSURBVHgBzVQLEcIwDE25CZgDhoNJQMJQADiYA4YCcDAsoIA6GChYHQAKSnJLj1LaXvncwbt710/SlyzpCvAP0FrnxBTHFbIPcMs+JfLMLF2NzI6KQ4OskVdPPMVjhTTZkeDRK2g57YUQCt7ECL6MJEFuQhGxF6ZJqRlS3TqeS2vf1K+HoZ5PUbQvE86Qulrzemo6bN2MPFmQ7TXbWxaskBveq3wHooLss0B2+o4DiYecHwSdS906vjt3zyCDMNbW/AKJiAkW9oKbIPHSSxj+ppcF5549ylRGzoQFMZMJhEEPhUYuY4KmTtRJBXGMkSefQdgLFGrA/6kuKPjsk0fkd7gBEy7vamLyRFEAAAAASUVORK5CYII=',
39
+ 'live-caption-mode':
40
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADUSURBVHgB5VPtDYIwEL0S/ssIHYERGEE3qBPoBuIGMgFsAk6iI7hBfadHUpsirZFfvOSlxx333RKtDmoUrLUax4nS8QDPSik+KXMMBqwoHUb4Qu4Z78i0pwRIZ8X4ndGfkVM4q8GhHdWFZwT90amGu+l836kKW0c+gCWCVfS5tJa+AQ412ItsA/YKvAX0PfvOVfgz8ikDso4tbcEdve9b4egNZqhiA/LV0SI38BsQiJfReP/EVRjanryEmmaw6Ay5gtKZUSw0eA0F7MS4oTQM4rtWPAFxAE4MEjNhpQAAAABJRU5ErkJggg==',
35
41
  };
36
42
 
37
43
  export default icons;
@@ -21,10 +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
  }) => {
26
29
  const mutexLock = useRef(false);
27
30
  const [ready, setReady] = useState(false);
31
+ const [tracksReady, setTracksReady] = useState(false);
28
32
  const {callbacks, rtcProps, mode} = useContext(PropsContext);
29
33
  const {
30
34
  geoFencing = true,
@@ -285,8 +289,10 @@ const Create = ({
285
289
  Platform.OS === 'web'
286
290
  )
287
291
  ) {
288
- await enableVideoAndAudioWithInitialStates();
289
- isVideoEnabledRef.current = true;
292
+ enableVideoAndAudioWithInitialStates().then(() => {
293
+ setTracksReady(true);
294
+ isVideoEnabledRef.current = true;
295
+ });
290
296
  }
291
297
 
292
298
  engine.current.addListener(
@@ -304,7 +310,11 @@ const Create = ({
304
310
  },
305
311
  );
306
312
 
307
- engine.current.addListener('UserJoined', (...args) => {
313
+ engine.current.addListener('UserJoined', async (...args) => {
314
+ // preventing STT pusher bot in renderlist
315
+ if (args[0] === 111111) {
316
+ return;
317
+ }
308
318
  //Get current peer IDs
309
319
  dispatch({
310
320
  type: 'UserJoined',
@@ -461,7 +471,7 @@ const Create = ({
461
471
  <>
462
472
  {
463
473
  // Render children once RTCEngine has been initialized
464
- ready && engine ? children(engine) : <></>
474
+ ready && engine ? children(engine, tracksReady) : <></>
465
475
  }
466
476
  </>
467
477
  );
@@ -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,13 @@ 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}>
341
342
  <RtcProvider
342
343
  value={{
343
344
  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,6 +98,10 @@ interface ConfigInterface {
98
98
  ICON_BG_COLOR: string;
99
99
  TOOLBAR_COLOR: string;
100
100
  ACTIVE_SPEAKER: boolean;
101
+ // TOAST_NOTIFICATIONS: boolean;
102
+ ENABLE_TOKEN_AUTH: boolean;
103
+ ENABLE_IDP_AUTH: boolean;
104
+ PROJECT_ID: string;
101
105
  }
102
106
  declare var $config: ConfigInterface;
103
107
  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,6 +65,7 @@
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",
68
69
  "nanoevents": "7.0.1",
69
70
  "nanoid": "4.0.0",
70
71
  "nosleep.js": "0.12.0",
@@ -73,6 +74,7 @@
73
74
  "react-is": "18.0.0",
74
75
  "react-native": "0.64",
75
76
  "react-native-agora": "3.7.1",
77
+ "react-native-exit-app": "1.1.0",
76
78
  "react-native-gesture-handler": "2.8.0",
77
79
  "react-native-hyperlink": "0.0.19",
78
80
  "react-native-inappbrowser-reborn": "3.5.1",
@@ -11,18 +11,7 @@
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';
22
14
  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';
26
15
  import AppWrapper from './AppWrapper';
27
16
  import {
28
17
  MeetingInfoContextInterface,
@@ -31,9 +20,9 @@ import {
31
20
  } from './components/meeting-info/useMeetingInfo';
32
21
  import {SetMeetingInfoProvider} from './components/meeting-info/useSetMeetingInfo';
33
22
  import {ShareLinkProvider} from './components/useShareLink';
34
- import Endcall from './pages/Endcall';
23
+ import AppRoutes from './AppRoutes';
35
24
 
36
- //hook can't be used in the outside react function calls. so directly checking the platform.
25
+ // hook can't be used in the outside react function calls. so directly checking the platform.
37
26
  if (Platform.OS === 'ios') {
38
27
  KeyboardManager.setEnable(true);
39
28
  KeyboardManager.setEnableAutoToolbar(false);
@@ -56,35 +45,6 @@ declare module 'agora-rn-uikit' {
56
45
  }
57
46
 
58
47
  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
- // };
88
48
  const [meetingInfo, setMeetingInfo] = useState<MeetingInfoContextInterface>(
89
49
  MeetingInfoDefaultValue,
90
50
  );
@@ -94,40 +54,7 @@ const App: React.FC = () => {
94
54
  <SetMeetingInfoProvider value={{setMeetingInfo}}>
95
55
  <MeetingInfoProvider value={{...meetingInfo}}>
96
56
  <ShareLinkProvider>
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>
57
+ <AppRoutes />
131
58
  </ShareLinkProvider>
132
59
  </MeetingInfoProvider>
133
60
  </SetMeetingInfoProvider>
@@ -0,0 +1,45 @@
1
+ /*
2
+ ********************************************
3
+ Copyright © 2021 Agora Lab, Inc., all rights reserved.
4
+ AppBuilder and all associated components, source code, APIs, services, and documentation
5
+ (the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
6
+ accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
7
+ Use without a license or in violation of any license terms and conditions (including use for
8
+ any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
9
+ information visit https://appbuilder.agora.io.
10
+ *********************************************
11
+ */
12
+ import React from 'react';
13
+ import Join from './pages/Join';
14
+ import VideoCall from './pages/VideoCall';
15
+ import Create from './pages/Create';
16
+ import {Route, Switch, Redirect} from './components/Router';
17
+ import AuthRoute from './auth/AuthRoute';
18
+ import {IDPAuth} from './auth/IDPAuth';
19
+ import {Text} from 'react-native';
20
+
21
+ function AppRoutes() {
22
+ return (
23
+ <Switch>
24
+ <Route exact path={'/'}>
25
+ <Redirect to={'/create'} />
26
+ </Route>
27
+ <Route exact path={'/authorize/:token?'}>
28
+ <IDPAuth />
29
+ </Route>
30
+ <AuthRoute exact path={'/join'}>
31
+ <Join />
32
+ </AuthRoute>
33
+ <AuthRoute exact path={'/create'}>
34
+ <Create />
35
+ </AuthRoute>
36
+ <AuthRoute path={'/:phrase'}>
37
+ <VideoCall />
38
+ </AuthRoute>
39
+ <Route path="*">
40
+ <Text>Page not found</Text>
41
+ </Route>
42
+ </Switch>
43
+ );
44
+ }
45
+ export default AppRoutes;
@@ -29,6 +29,7 @@ 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';
32
33
  import {PropsConsumer} from 'agora-rn-uikit';
33
34
  import ToastComponent from './components/ToastComponent';
34
35
  import {ToastContext, ToastProvider} from './components/useToast';
@@ -99,19 +100,21 @@ const AppWrapper = (props: AppWrapperProps) => {
99
100
  ? `/${SdkJoinState.phrase}`
100
101
  : '',
101
102
  ]}>
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>
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>
115
118
  </Router>
116
119
  </GraphQLProvider>
117
120
  </StorageProvider>
@@ -11,60 +11,96 @@ 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'];
18
+ export interface AppBuilderSdkApiInterface {
19
+ customize: (customization: CustomizationApiInterface) => Promise<void>;
20
+ joinRoom: (
21
+ roomDetails: string | meetingData,
22
+ userName?: string,
23
+ ) => Promise<meetingData>;
24
+ joinPrecall: (
25
+ roomDetails: string | meetingData,
26
+ userName?: string,
27
+ ) => Promise<
28
+ [
29
+ meetingData,
30
+ (userName?: string) => Promise<MeetingInfoContextInterface['data']>,
31
+ ]
32
+ >;
33
+ setMicrophone: (deviceId: deviceId) => Promise<void>;
34
+ setCamera: (deviceId: deviceId) => Promise<void>;
35
+ setSpeaker: (deviceId: deviceId) => Promise<void>;
36
+ muteAudio: (
37
+ mute: boolean | ((currentMute: boolean) => boolean),
38
+ ) => Promise<void>;
39
+ muteVideo: (
40
+ mute: boolean | ((currentMute: boolean) => boolean),
41
+ ) => Promise<void>;
42
+ createCustomization: (
43
+ customization: CustomizationApiInterface,
44
+ ) => CustomizationApiInterface;
45
+ login: (token: string) => Promise<void>;
46
+ logout: () => Promise<void>;
47
+ customEvents: typeof customEvents;
48
+ on: <T extends keyof userEventsMapInterface>(
49
+ userEventName: T,
50
+ cb: userEventsMapInterface[T],
51
+ ) => Unsubscribe;
29
52
  }
30
53
 
31
- // interface AppBuilderSdkApiInterface {
32
- // customize: makeAsync<SdkMethodEvents['customize']>;
33
- // joinRoom: makeAsync<takeOnlyFirstParam<SdkMethodEvents['join']>>;
34
- // joinPrecall: makeAsync<takeOnlyFirstParam<SdkMethodEvents['join']>>;
35
- // createCustomization: (
36
- // customization: CustomizationApiInterface,
37
- // ) => CustomizationApiInterface;
38
- // on: <T extends keyof userEventsMapInterface>(
39
- // userEventName: T,
40
- // callBack: userEventsMapInterface[T],
41
- // ) => Unsubscribe;
42
- // }
43
-
44
- export const AppBuilderSdkApi = {
45
- customize: async (customization: CustomizationApiInterface) => {
54
+ export const AppBuilderSdkApi: AppBuilderSdkApiInterface = {
55
+ login: async (token: string) => {
56
+ return await SDKMethodEventsManager.emit('login', token);
57
+ },
58
+ logout: async () => {
59
+ return await SDKMethodEventsManager.emit('logout');
60
+ },
61
+ customize: async (customization) => {
46
62
  return await SDKMethodEventsManager.emit('customize', customization);
47
63
  },
48
64
  customEvents: customEvents,
49
- join: async (roomDetails: string) => {
50
- await SDKMethodEventsManager.emit('join', roomDetails, false);
65
+ joinRoom: async (roomDetails, userName) => {
66
+ return await SDKMethodEventsManager.emit(
67
+ 'join',
68
+ roomDetails,
69
+ true,
70
+ userName,
71
+ );
72
+ },
73
+ joinPrecall: async (roomDetails, userName) => {
74
+ if (!$config.PRECALL)
75
+ throw new Error('Precall disabled in config, cant join precall');
76
+ const t = await SDKMethodEventsManager.emit(
77
+ 'join',
78
+ roomDetails,
79
+ false,
80
+ userName,
81
+ );
82
+ return t as unknown as [
83
+ MeetingInfoContextInterface['data'],
84
+ (userName?: string) => Promise<MeetingInfoContextInterface['data']>,
85
+ ];
51
86
  },
52
- joinRoom: async (
53
- roomDetails: string | Partial<MeetingInfoContextInterface['data']>,
54
- ) => {
55
- return await SDKMethodEventsManager.emit('join', roomDetails, true);
87
+ setMicrophone: async (deviceId) => {
88
+ return await SDKMethodEventsManager.emit('microphoneDevice', deviceId);
56
89
  },
57
- joinPrecall: async (
58
- roomDetails: string | Partial<MeetingInfoContextInterface['data']>,
59
- ) => {
60
- const t = await SDKMethodEventsManager.emit('join', roomDetails);
61
- return t as unknown as [MeetingInfoContextInterface['data'], () => {}];
90
+ setSpeaker: async (deviceId) => {
91
+ return await SDKMethodEventsManager.emit('speakerDevice', deviceId);
92
+ },
93
+ setCamera: async (deviceId) => {
94
+ return await SDKMethodEventsManager.emit('cameraDevice', deviceId);
95
+ },
96
+ muteAudio: async (state) => {
97
+ return await SDKMethodEventsManager.emit('muteAudio', state);
98
+ },
99
+ muteVideo: async (state) => {
100
+ return await SDKMethodEventsManager.emit('muteVideo', state);
62
101
  },
63
102
  createCustomization: customize,
64
- on: <T extends keyof userEventsMapInterface>(
65
- userEventName: T,
66
- cb: userEventsMapInterface[T],
67
- ): Unsubscribe => {
103
+ on: (userEventName, cb) => {
68
104
  console.log('SDKEvents: Event Registered', userEventName);
69
105
  return SDKEvents.on(userEventName, cb);
70
106
  },