agora-appbuilder-core 2.3.0-beta.2 → 2.3.0-beta.22

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 (78) hide show
  1. package/Readme.md +11 -6
  2. package/package.json +2 -2
  3. package/template/Gulpfile.js +112 -13
  4. package/template/_package-lock.json +13011 -13288
  5. package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +2 -0
  6. package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +4 -5
  7. package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +3 -1
  8. package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +3 -1
  9. package/template/agora-rn-uikit/src/Rtc/Create.tsx +64 -33
  10. package/template/agora-rn-uikit/src/Rtc/Join.tsx +11 -2
  11. package/template/agora-rn-uikit/src/RtcConfigure.tsx +23 -4
  12. package/template/agora-rn-uikit/src/Utils/permission.ts +17 -6
  13. package/template/bridge/rtc/webNg/RtcEngine.ts +51 -26
  14. package/template/esbuild.rsdk.go +20 -6
  15. package/template/fpe-api/components.ts +15 -0
  16. package/template/fpe-api/context.ts +2 -3
  17. package/template/fpe-api/install.ts +19 -9
  18. package/template/fpe-api/typeDefinition.ts +7 -6
  19. package/template/fpe-api/utils.ts +32 -25
  20. package/template/global.d.ts +3 -2
  21. package/template/index.rsdk.tsx +15 -4
  22. package/template/index.wsdk.tsx +13 -3
  23. package/template/package.json +4 -2
  24. package/template/react-native-toast-message/src/index.js +3 -7
  25. package/template/react-native-toast-message/src/{index.wsdk.js → index.sdk.tsx} +1 -1
  26. package/template/react-native-toast-message/src/styles.sdk.ts +17 -0
  27. package/template/src/SDKAppWrapper.tsx +1 -1
  28. package/template/src/components/Chat.tsx +23 -5
  29. package/template/src/components/ChatContext.ts +15 -4
  30. package/template/src/components/Controls.native.tsx +10 -6
  31. package/template/src/components/Controls.tsx +6 -4
  32. package/template/src/components/HostControlView.tsx +5 -3
  33. package/template/src/components/Navbar.tsx +15 -13
  34. package/template/src/components/RTMConfigure.tsx +20 -50
  35. package/template/src/components/chat-messages/useChatMessages.tsx +369 -70
  36. package/template/src/components/contexts/LiveStreamDataContext.tsx +3 -3
  37. package/template/src/components/contexts/ScreenShareContext.tsx +2 -0
  38. package/template/src/components/livestream/LiveStreamContext.tsx +9 -6
  39. package/template/src/components/participants/MeParticipant.tsx +5 -3
  40. package/template/src/components/participants/RemoteParticipants.tsx +9 -7
  41. package/template/src/components/precall/LocalMute.native.tsx +12 -8
  42. package/template/src/components/precall/LocalMute.tsx +5 -3
  43. package/template/src/components/precall/textInput.tsx +1 -1
  44. package/template/src/components/useShareLink.tsx +37 -39
  45. package/template/src/components/useUserPreference.tsx +125 -0
  46. package/template/src/custom-events/CustomEvents.ts +39 -23
  47. package/template/src/custom-events/types.ts +3 -3
  48. package/template/src/language/default-labels/videoCallScreenLabels.ts +4 -2
  49. package/template/src/pages/Create.tsx +10 -3
  50. package/template/src/pages/Join.tsx +4 -1
  51. package/template/src/pages/VideoCall.tsx +61 -56
  52. package/template/src/pages/video-call/CustomUserContextHolder.tsx +13 -5
  53. package/template/src/pages/video-call/VideoCallScreen.tsx +18 -15
  54. package/template/src/rtm/RTMEngine.ts +13 -0
  55. package/template/src/rtm/utils.ts +1 -1
  56. package/template/src/rtm-events/EventUtils.ts +3 -0
  57. package/template/src/rtm-events/EventsQueue.ts +9 -3
  58. package/template/src/rtm-events/constants.ts +3 -1
  59. package/template/src/subComponents/ChatBubble.tsx +22 -4
  60. package/template/src/subComponents/ChatContainer.tsx +30 -19
  61. package/template/src/subComponents/ChatInput.tsx +38 -26
  62. package/template/src/subComponents/SelectDevice.tsx +1 -1
  63. package/template/src/subComponents/recording/useRecording.tsx +15 -4
  64. package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +11 -5
  65. package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +35 -26
  66. package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +83 -33
  67. package/template/src/utils/SdkEvents.ts +3 -3
  68. package/template/src/utils/getMeetingInvite.ts +38 -15
  69. package/template/src/utils/getUniqueID.ts +5 -0
  70. package/template/src/utils/useDeleteMessage.ts +36 -0
  71. package/template/src/utils/useEditMessage.ts +41 -0
  72. package/template/src/utils/useGetName.ts +2 -3
  73. package/template/src/utils/useJoinMeeting.ts +22 -14
  74. package/template/src/utils/useLocalShareScreenUid.ts +19 -0
  75. package/template/src/utils/useSendMessage.ts +4 -5
  76. package/template/src/utils/useSetName.ts +2 -4
  77. package/template/webpack.rsdk.config.js +3 -2
  78. package/template/webpack.wsdk.config.js +0 -1
@@ -11,7 +11,7 @@
11
11
  */
12
12
  // @ts-nocheck
13
13
  import React, {useState, useContext, useEffect, useRef} from 'react';
14
- import RtmEngine, {RtmAttribute} from 'agora-react-native-rtm';
14
+ import RtmEngine from 'agora-react-native-rtm';
15
15
  import {PropsContext, useLocalUid} from '../../agora-rn-uikit';
16
16
  import ChatContext, {controlMessageEnum} from './ChatContext';
17
17
  import {RtcContext} from '../../agora-rn-uikit';
@@ -20,7 +20,6 @@ import {Platform} from 'react-native';
20
20
  import {backOff} from 'exponential-backoff';
21
21
  import {useString} from '../utils/useString';
22
22
  import {isAndroid, isWeb} from '../utils/common';
23
- import StorageContext from './StorageContext';
24
23
  import {useRenderContext} from 'fpe-api';
25
24
  import {
26
25
  safeJsonParse,
@@ -33,6 +32,7 @@ import {
33
32
  import {EventUtils, EventsQueue, eventMessageType} from '../rtm-events';
34
33
  import RTMEngine from '../rtm/RTMEngine';
35
34
  import {filterObject} from '../utils';
35
+ import useLocalScreenShareUid from '../utils/useLocalShareScreenUid';
36
36
 
37
37
  export enum UserType {
38
38
  ScreenShare = 'screenshare',
@@ -56,6 +56,7 @@ const parsePayload = (data: string) => {
56
56
 
57
57
  const RtmConfigure = (props: any) => {
58
58
  const localUid = useLocalUid();
59
+ const screenShareUid = useLocalScreenShareUid();
59
60
  const {callActive} = props;
60
61
  const {rtcProps} = useContext(PropsContext);
61
62
  const {RtcEngine, dispatch} = useContext(RtcContext);
@@ -75,21 +76,6 @@ const RtmConfigure = (props: any) => {
75
76
  renderListRef.current.renderList = renderList;
76
77
  }, [renderList]);
77
78
 
78
- const {store, setStore} = useContext(StorageContext);
79
- const getInitialUsername = () =>
80
- store?.displayName ? store.displayName : '';
81
- const [displayName, setDisplayName] = useState(getInitialUsername());
82
-
83
- //Update the store displayName value if the state is changed
84
- useEffect(() => {
85
- setStore((prevState) => {
86
- return {
87
- ...prevState,
88
- displayName,
89
- };
90
- });
91
- }, [displayName]);
92
-
93
79
  const [login, setLogin] = useState<boolean>(false);
94
80
 
95
81
  const [hasUserJoinedRTM, setHasUserJoinedRTM] = useState<boolean>(false);
@@ -145,13 +131,14 @@ const RtmConfigure = (props: any) => {
145
131
 
146
132
  const setAttribute = async () => {
147
133
  const rtmAttributes = [
148
- {key: 'name', value: displayName || userText},
149
134
  {key: 'screenUid', value: String(rtcProps.screenShareUid)},
150
135
  ];
151
136
  try {
152
137
  await engine.current.setLocalUserAttributes(rtmAttributes);
153
138
  timerValueRef.current = 5;
154
- joinChannel();
139
+ await joinChannel();
140
+ setHasUserJoinedRTM(true);
141
+ await runQueuedCustomEvents();
155
142
  } catch (error) {
156
143
  setTimeout(async () => {
157
144
  timerValueRef.current = timerValueRef.current + timerValueRef.current;
@@ -165,8 +152,6 @@ const RtmConfigure = (props: any) => {
165
152
  await engine.current.joinChannel(rtcProps.channel);
166
153
  timerValueRef.current = 5;
167
154
  await getMembers();
168
- setHasUserJoinedRTM(true);
169
- await runQueuedCustomEvents();
170
155
  } catch (error) {
171
156
  setTimeout(async () => {
172
157
  timerValueRef.current = timerValueRef.current + timerValueRef.current;
@@ -194,6 +179,9 @@ const RtmConfigure = (props: any) => {
194
179
  const attr = await engine.current.getUserAttributesByUid(
195
180
  member.uid,
196
181
  );
182
+ if (!attr || !attr.attributes) {
183
+ throw attr;
184
+ }
197
185
  for (const key in attr.attributes) {
198
186
  if (
199
187
  attr.attributes.hasOwnProperty(key) &&
@@ -224,10 +212,6 @@ const RtmConfigure = (props: any) => {
224
212
  const screenUid = parseInt(attr?.attributes?.screenUid);
225
213
  //start - updating user data in rtc
226
214
  const userData = {
227
- name:
228
- String(member.uid)[0] === '1'
229
- ? pstnUserLabel
230
- : attr?.attributes?.name || userText,
231
215
  screenUid: screenUid,
232
216
  //below thing for livestreaming
233
217
  type: 'rtc',
@@ -237,7 +221,6 @@ const RtmConfigure = (props: any) => {
237
221
 
238
222
  //start - updating screenshare data in rtc
239
223
  const screenShareUser = {
240
- name: getScreenShareName(attr?.attributes?.name || userText),
241
224
  type: UserType.ScreenShare,
242
225
  };
243
226
  updateRenderListState(screenUid, screenShareUser);
@@ -297,6 +280,9 @@ const RtmConfigure = (props: any) => {
297
280
  const backoffAttributes = backOff(
298
281
  async () => {
299
282
  const attr = await engine.current.getUserAttributesByUid(data.uid);
283
+ if (!attr || !attr.attributes) {
284
+ throw attr;
285
+ }
300
286
  for (const key in attr.attributes) {
301
287
  if (attr.attributes.hasOwnProperty(key) && attr.attributes[key]) {
302
288
  return attr;
@@ -323,10 +309,6 @@ const RtmConfigure = (props: any) => {
323
309
  const screenUid = parseInt(attr?.attributes?.screenUid);
324
310
  //start - updating user data in rtc
325
311
  const userData = {
326
- name:
327
- String(data.uid)[0] === '1'
328
- ? pstnUserLabel
329
- : attr?.attributes?.name || userText,
330
312
  screenUid: screenUid,
331
313
  //below thing for livestreaming
332
314
  type: 'rtc',
@@ -336,7 +318,6 @@ const RtmConfigure = (props: any) => {
336
318
 
337
319
  //start - updating screenshare data in rtc
338
320
  const screenShareUser = {
339
- name: getScreenShareName(attr?.attributes?.name || userText),
340
321
  type: UserType.ScreenShare,
341
322
  };
342
323
  updateRenderListState(screenUid, screenShareUser);
@@ -462,22 +443,12 @@ const RtmConfigure = (props: any) => {
462
443
 
463
444
  const runQueuedCustomEvents = async () => {
464
445
  try {
465
- const eventsInQueue = EventsQueue.printQueue();
466
- if (eventsInQueue.length !== 0) {
467
- for (const queuedEvents of eventsInQueue) {
468
- await customEventDispatcher(
469
- queuedEvents.data,
470
- queuedEvents.uid,
471
- queuedEvents.ts,
472
- );
473
- EventsQueue.dequeue();
474
- }
446
+ while (!EventsQueue.isEmpty()) {
447
+ const currEvt = EventsQueue.dequeue();
448
+ await customEventDispatcher(currEvt.data, currEvt.uid, currEvt.ts);
475
449
  }
476
450
  } catch (error) {
477
- throw Error(
478
- 'CUSTOM_EVENTS_API: error while running queued events ',
479
- error,
480
- );
451
+ console.log('CUSTOM_EVENT_API: error while running queue events', error);
481
452
  }
482
453
  };
483
454
 
@@ -502,7 +473,7 @@ const RtmConfigure = (props: any) => {
502
473
  }
503
474
  // Step 2: Emit the event
504
475
  try {
505
- console.log('CUSTOM_EVENT_API: emiting event: ');
476
+ console.log('CUSTOM_EVENT_API: emiting event..: ');
506
477
  EventUtils.emitEvent(evt, {payload, sender, ts});
507
478
  } catch (error) {
508
479
  console.log('CUSTOM_EVENT_API: error while emiting event: ', error);
@@ -570,8 +541,9 @@ const RtmConfigure = (props: any) => {
570
541
 
571
542
  const end = async () => {
572
543
  callActive
573
- ? (await (engine.current as RtmEngine).logout(),
574
- await (engine.current as RtmEngine).destroyClient(),
544
+ ? (RTMEngine.getInstance().destroy(),
545
+ EventUtils.clear(),
546
+ setHasUserJoinedRTM(false),
575
547
  // setLogin(false),
576
548
  console.log('RTM cleanup done'))
577
549
  : {};
@@ -596,8 +568,6 @@ const RtmConfigure = (props: any) => {
596
568
  engine: engine.current,
597
569
  localUid: localUid,
598
570
  onlineUsersCount,
599
- setDisplayName,
600
- displayName,
601
571
  }}>
602
572
  {login ? props.children : <></>}
603
573
  </ChatContext.Provider>