agora-appbuilder-core 2.3.0-beta.9 → 3.0.0
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/Readme.md +11 -6
- package/package.json +1 -1
- package/template/Gulpfile.js +121 -83
- package/template/_gitignore +2 -2
- package/template/_package-lock.json +12959 -13248
- package/template/agora-rn-uikit/src/AgoraUIKit.tsx +2 -2
- package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +2 -0
- package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +3 -3
- package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +4 -5
- package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +3 -1
- package/template/agora-rn-uikit/src/Controls/LocalControls.tsx +2 -2
- package/template/agora-rn-uikit/src/Reducer/LocalMuteAudio.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/LocalMuteVideo.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/RemoteAudioStateChanged.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/RemoteVideoStateChanged.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/UpdateDualStreamMode.ts +4 -4
- package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +7 -5
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteAudio.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteVideo.ts +1 -1
- package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +2 -2
- package/template/agora-rn-uikit/src/Rtc/Create.tsx +88 -43
- package/template/agora-rn-uikit/src/Rtc/Join.tsx +13 -4
- package/template/agora-rn-uikit/src/RtcConfigure.tsx +36 -19
- package/template/agora-rn-uikit/src/Utils/permission.ts +17 -6
- package/template/babel.config.js +9 -9
- package/template/bridge/rtc/webNg/RtcEngine.ts +51 -26
- package/template/customization-api/action-library.ts +22 -0
- package/template/{fpe-api/context.ts → customization-api/app-state.ts} +16 -14
- package/template/customization-api/customEvents.ts +9 -0
- package/template/{fpe-api/install.ts → customization-api/customize.ts} +27 -26
- package/template/{fpe-api → customization-api}/index.ts +11 -6
- package/template/{fpe-api/components.ts → customization-api/sub-components.ts} +22 -3
- package/template/{fpe-api → customization-api}/typeDefinition.ts +13 -14
- package/template/customization-api/utils.ts +30 -0
- package/template/{fpe-implementation → customization-implementation}/createHook.ts +0 -0
- package/template/{fpe-implementation/dummyFpe.ts → customization-implementation/dummyConfig.ts} +4 -4
- package/template/customization-implementation/index.ts +4 -0
- package/template/{fpe-api/useFpe.tsx → customization-implementation/useCustomization.tsx} +12 -12
- package/template/{fpe.config.js → customization.config.js} +11 -11
- package/template/electron/main/index.js +42 -35
- package/template/esbuild.rsdk.go +8 -17
- package/template/global.d.ts +4 -3
- package/template/index.rsdk.tsx +13 -5
- package/template/index.wsdk.tsx +21 -5
- package/template/package.json +3 -0
- package/template/react-native-toast-message/src/index.js +3 -7
- package/template/react-native-toast-message/src/{index.wsdk.js → index.sdk.tsx} +1 -1
- package/template/react-native-toast-message/src/styles.sdk.ts +17 -0
- package/template/src/App.tsx +8 -4
- package/template/src/AppWrapper.tsx +8 -6
- package/template/src/SDKAppWrapper.tsx +28 -21
- package/template/src/app-state/useLocalUserInfo.ts +8 -0
- package/template/src/app-state/useMessages.ts +52 -0
- package/template/src/atoms/PrimaryButton.tsx +2 -2
- package/template/src/atoms/SecondaryButton.tsx +12 -4
- package/template/src/atoms/TextInput.tsx +2 -2
- package/template/src/components/Chat.tsx +22 -11
- package/template/src/components/ChatContext.ts +10 -27
- package/template/src/components/Controls.native.tsx +13 -7
- package/template/src/components/Controls.tsx +15 -24
- package/template/src/components/DeviceConfigure.tsx +4 -3
- package/template/src/components/EventsConfigure.tsx +54 -0
- package/template/src/components/GridVideo.tsx +5 -6
- package/template/src/components/HostControlView.tsx +13 -19
- package/template/src/components/Navbar.tsx +54 -41
- package/template/src/components/NetworkQualityContext.tsx +4 -3
- package/template/src/components/ParticipantsView.tsx +7 -7
- package/template/src/components/PinnedVideo.tsx +3 -4
- package/template/src/components/Precall.native.tsx +3 -3
- package/template/src/components/Precall.tsx +14 -10
- package/template/src/components/RTMConfigure.tsx +61 -219
- package/template/src/components/SettingsView.tsx +6 -3
- package/template/src/components/Share.tsx +24 -18
- package/template/src/components/chat-messages/useChatMessages.tsx +397 -80
- package/template/src/components/chat-notification/useChatNotification.tsx +2 -2
- package/template/src/components/chat-ui/useChatUIControl.tsx +1 -1
- package/template/src/components/common/Logo.tsx +3 -2
- package/template/src/components/contexts/LiveStreamDataContext.tsx +3 -3
- package/template/src/components/contexts/ScreenShareContext.tsx +3 -1
- package/template/src/components/contexts/VideoMeetingDataContext.tsx +85 -0
- package/template/src/components/contexts/WhiteboardContext.tsx +8 -8
- package/template/src/components/livestream/LiveStreamContext.tsx +88 -74
- package/template/src/components/meeting-info/useMeetingInfo.tsx +23 -19
- package/template/src/components/meeting-info/useSetMeetingInfo.tsx +1 -1
- package/template/src/components/participants/AllAudienceParticipants.tsx +2 -2
- package/template/src/components/participants/AllHostParticipants.tsx +4 -4
- package/template/src/components/participants/MeParticipant.tsx +5 -3
- package/template/src/components/participants/ParticipantName.tsx +2 -2
- package/template/src/components/participants/RemoteParticipants.tsx +9 -7
- package/template/src/components/precall/LocalMute.native.tsx +14 -10
- package/template/src/components/precall/LocalMute.tsx +7 -5
- package/template/src/components/precall/VideoPreview.native.tsx +6 -6
- package/template/src/components/precall/VideoPreview.tsx +3 -3
- package/template/src/components/precall/joinCallBtn.tsx +3 -3
- package/template/src/components/precall/meetingTitle.tsx +3 -1
- package/template/src/components/precall/selectDevice.tsx +2 -2
- package/template/src/components/precall/usePreCall.tsx +1 -1
- package/template/src/components/styles.ts +3 -3
- package/template/src/components/useShareLink.tsx +69 -29
- package/template/src/components/useUserPreference.tsx +16 -15
- package/template/src/components/useWakeLock.tsx +3 -3
- package/template/src/language/i18nTypes.ts +1 -1
- package/template/src/language/index.ts +2 -2
- package/template/src/language/useLanguage.tsx +2 -3
- package/template/src/pages/Authenticate.tsx +3 -2
- package/template/src/pages/Create.tsx +18 -20
- package/template/src/pages/Join.tsx +6 -7
- package/template/src/pages/VideoCall.tsx +74 -66
- package/template/src/pages/create/useCreate.tsx +1 -1
- package/template/src/pages/video-call/CustomUserContextHolder.tsx +14 -6
- package/template/src/pages/video-call/DefaultLayouts.ts +8 -8
- package/template/src/pages/video-call/{NameWithMicStatus.tsx → NameWithMicIcon.tsx} +8 -1
- package/template/src/pages/video-call/RenderComponent.tsx +7 -10
- package/template/src/pages/video-call/VideoCallScreen.tsx +31 -22
- package/template/src/pages/video-call/VideoComponent.tsx +13 -15
- package/template/src/pages/video-call/VideoRenderer.tsx +6 -6
- package/template/src/pages/video-call/useLayoutsData.ts +23 -0
- package/template/src/rtm/RTMEngine.ts +13 -0
- package/template/src/rtm-events/EventUtils.ts +20 -20
- package/template/src/rtm-events/EventsQueue.ts +9 -3
- package/template/src/rtm-events/constants.ts +5 -0
- package/template/src/rtm-events/index.tsx +1 -3
- package/template/src/{custom-events/CustomEvents.ts → rtm-events-api/Events.ts} +67 -61
- package/template/src/rtm-events-api/index.tsx +6 -0
- package/template/src/rtm-events-api/types.ts +22 -0
- package/template/src/subComponents/ChatBubble.tsx +24 -8
- package/template/src/subComponents/ChatContainer.tsx +24 -15
- package/template/src/subComponents/ChatInput.tsx +56 -42
- package/template/src/subComponents/LanguageSelector.tsx +2 -2
- package/template/src/subComponents/LayoutIconDropdown.native.tsx +5 -5
- package/template/src/subComponents/LayoutIconDropdown.tsx +7 -7
- package/template/src/subComponents/LocalAudioMute.tsx +3 -4
- package/template/src/subComponents/LocalEndCall.tsx +3 -6
- package/template/src/subComponents/LocalSwitchCamera.tsx +3 -4
- package/template/src/subComponents/LocalVideoMute.tsx +3 -3
- package/template/src/subComponents/NetworkQualityPill.tsx +8 -9
- package/template/src/subComponents/OpenInNativeButton.tsx +2 -3
- package/template/src/subComponents/RemoteAudioMute.tsx +5 -11
- package/template/src/subComponents/RemoteEndCall.tsx +3 -10
- package/template/src/subComponents/RemoteVideoMute.tsx +3 -10
- package/template/src/subComponents/SelectDevice.tsx +1 -1
- package/template/src/subComponents/SelectOAuth.tsx +3 -2
- package/template/src/subComponents/SidePanelButtons.ts +6 -5
- package/template/src/subComponents/TextWithTooltip.tsx +6 -2
- package/template/src/subComponents/{toastConfig.tsx → ToastConfig.tsx} +2 -2
- package/template/src/subComponents/chat/ChatParticipants.tsx +6 -5
- package/template/src/subComponents/livestream/CurrentLiveStreamRequestsView.tsx +2 -2
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamApprovedRequestRecall.tsx +4 -3
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestApprove.tsx +2 -2
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestReject.tsx +2 -4
- package/template/src/subComponents/livestream/index.ts +2 -2
- package/template/src/subComponents/recording/useRecording.tsx +44 -23
- package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +11 -5
- package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +46 -34
- package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +97 -38
- package/template/src/subComponents/screenshare/useScreenshare.tsx +1 -1
- package/template/src/utils/SdkEvents.ts +9 -46
- package/template/src/utils/common.tsx +25 -9
- package/template/src/utils/getUniqueID.ts +5 -0
- package/template/src/utils/isMobileOrTablet.native.ts +2 -2
- package/template/src/utils/isMobileOrTablet.ts +21 -8
- package/template/src/utils/useButtonTemplate.tsx +1 -1
- package/template/src/utils/useCreateMeeting.ts +21 -10
- package/template/src/utils/useGetMeetingPhrase.ts +11 -8
- package/template/src/utils/{IsAttendeeUser.ts → useIsAttendee.ts} +3 -1
- package/template/src/utils/{isAudioEnabled.ts → useIsAudioEnabled.ts} +4 -4
- package/template/src/utils/{isHostUser.ts → useIsHost.ts} +13 -16
- package/template/src/utils/{isPSTNUser.ts → useIsPSTN.ts} +2 -2
- package/template/src/utils/{isScreenShareUser.ts → useIsScreenShare.ts} +0 -0
- package/template/src/utils/{isVideoEnabled.ts → useIsVideoEnabled.ts} +5 -6
- package/template/src/utils/useJoinMeeting.ts +8 -6
- package/template/src/utils/useLayout.tsx +5 -5
- package/template/src/utils/useMutePSTN.ts +5 -3
- package/template/src/utils/useMuteToggleLocal.ts +3 -4
- package/template/src/utils/useRemoteEndCall.ts +11 -10
- package/template/src/utils/useRemoteMute.ts +42 -20
- package/template/src/utils/useSidePanel.tsx +1 -1
- package/template/src/utils/useString.ts +2 -2
- package/template/src/utils/useUserName.ts +11 -0
- package/template/tsconfig_fpeApi.json +8 -9
- package/template/tsconfig_rsdk_index.json +8 -9
- package/template/tsconfig_wsdk_index.json +8 -9
- package/template/webpack.commons.js +9 -9
- package/template/webpack.rsdk.config.js +4 -2
- package/template/webpack.ts.config.js +6 -6
- package/template/webpack.wsdk.config.js +2 -1
- package/template/fpe-api/fpeEvents.ts +0 -9
- package/template/fpe-api/utils.ts +0 -61
- package/template/fpe-implementation/index.ts +0 -1
- package/template/fpe-todo.txt +0 -14
- package/template/src/components/RTMEvents.tsx +0 -84
- package/template/src/custom-events/index.tsx +0 -4
- package/template/src/custom-events/types.ts +0 -51
- package/template/src/pages/video-call/CustomLayout.ts +0 -17
- package/template/src/rtm-events/types.ts +0 -7
- package/template/src/utils/getMeetingInvite.ts +0 -53
- package/template/src/utils/useGroupMessages.ts +0 -24
- package/template/src/utils/useNavParams.ts +0 -6
- package/template/src/utils/useNavigateTo.ts +0 -8
- package/template/src/utils/usePrivateMessages.ts +0 -33
- package/template/src/utils/useSendControlMessage.ts +0 -51
- package/template/src/utils/useSendMessage.ts +0 -40
- package/template/src/utils/useSetUnreadMessageCount.ts +0 -43
- package/template/src/utils/useUnreadMessageCount.ts +0 -50
- package/template/src/utils/useUserList.ts +0 -26
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
information visit https://appbuilder.agora.io.
|
|
10
10
|
*********************************************
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import {EventSource} from '../rtm-events-api/types';
|
|
13
13
|
type TListener = <T>(t: T) => void;
|
|
14
14
|
type TListenerMetaData = {once: boolean; listener: TListener};
|
|
15
15
|
type TEventList = Map<string, TListenerMetaData[]>;
|
|
16
|
-
type TEvents = Record<
|
|
16
|
+
type TEvents = Record<EventSource, TEventList> | Record<string, never>;
|
|
17
17
|
|
|
18
18
|
const EventUtils = (function () {
|
|
19
19
|
'use strict';
|
|
@@ -52,7 +52,7 @@ const EventUtils = (function () {
|
|
|
52
52
|
*/
|
|
53
53
|
const _getListeners = function (
|
|
54
54
|
evt: string,
|
|
55
|
-
source:
|
|
55
|
+
source: EventSource,
|
|
56
56
|
): TListenerMetaData[] | [] {
|
|
57
57
|
let response: TListenerMetaData[] | [];
|
|
58
58
|
if (_events.hasOwnProperty(source)) {
|
|
@@ -75,14 +75,14 @@ const EventUtils = (function () {
|
|
|
75
75
|
* This is mainly for internal use but others may find it useful.
|
|
76
76
|
*
|
|
77
77
|
* @param {String} evt Name of the event to return the listeners from.
|
|
78
|
-
* @param {
|
|
78
|
+
* @param {EventSource} source Name of the bucket to search events from
|
|
79
79
|
* @return {Object} All listener functions for an event in an object.
|
|
80
80
|
* @api private
|
|
81
81
|
* @example : {evt-name: [{once: false, listener: f}, {once: false, listener: f}...so on and so forth]
|
|
82
82
|
*/
|
|
83
83
|
const _getListenersAsObject = function (
|
|
84
84
|
evt: string,
|
|
85
|
-
source:
|
|
85
|
+
source: EventSource,
|
|
86
86
|
): object {
|
|
87
87
|
const listeners = _getListeners(evt, source);
|
|
88
88
|
let response: any;
|
|
@@ -114,7 +114,7 @@ const EventUtils = (function () {
|
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
return {
|
|
117
|
-
getEvents(source:
|
|
117
|
+
getEvents(source: EventSource): TEvents | {} {
|
|
118
118
|
return _events[source] || (_events[source] = new Map());
|
|
119
119
|
},
|
|
120
120
|
/**
|
|
@@ -123,10 +123,10 @@ const EventUtils = (function () {
|
|
|
123
123
|
*
|
|
124
124
|
* @param {String} evt Name of the event to attach the listener to.
|
|
125
125
|
* @param {Function} listener Method to be called when the event is emitted.
|
|
126
|
-
* @param {
|
|
126
|
+
* @param {EventSource} source Name of the bucket to search events from
|
|
127
127
|
* @return {Object} Current instance of EventUtils
|
|
128
128
|
*/
|
|
129
|
-
addListener(evt: string, listener: any, source:
|
|
129
|
+
addListener(evt: string, listener: any, source: EventSource): object {
|
|
130
130
|
if (!_isValidListener(listener)) {
|
|
131
131
|
throw new Error('Listener must be a function');
|
|
132
132
|
}
|
|
@@ -156,13 +156,13 @@ const EventUtils = (function () {
|
|
|
156
156
|
*
|
|
157
157
|
* @param {String} evt Name of the event to remove the listener from.
|
|
158
158
|
* @param {Function} listenerToRemove Method to remove from the event.
|
|
159
|
-
* @param {
|
|
159
|
+
* @param {EventSource} source Name of the bucket to search events from
|
|
160
160
|
* @return {Object} Current instance of EventUtils for chaining.
|
|
161
161
|
*/
|
|
162
162
|
removeListener(
|
|
163
163
|
evt: string,
|
|
164
164
|
listenerToRemove: TListener,
|
|
165
|
-
source:
|
|
165
|
+
source: EventSource,
|
|
166
166
|
): Object {
|
|
167
167
|
let listeners = _getListenersAsObject(evt, source);
|
|
168
168
|
for (let key in listeners) {
|
|
@@ -182,10 +182,10 @@ const EventUtils = (function () {
|
|
|
182
182
|
* That means every event will be emptied.
|
|
183
183
|
*
|
|
184
184
|
* @param {String} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
|
|
185
|
-
* @param {
|
|
185
|
+
* @param {EventSource} source Name of the bucket to search events from
|
|
186
186
|
* @return {Object} Current instance of EventUtils
|
|
187
187
|
*/
|
|
188
|
-
removeAllListeners(evt: string, source:
|
|
188
|
+
removeAllListeners(evt: string, source: EventSource): object {
|
|
189
189
|
let type = typeof evt;
|
|
190
190
|
let events = this.getEvents(source);
|
|
191
191
|
if (type === 'string') {
|
|
@@ -203,7 +203,7 @@ const EventUtils = (function () {
|
|
|
203
203
|
* @param {source} source source Name of the bucket to search events from
|
|
204
204
|
* @return {Object} Current instance of EventUtils
|
|
205
205
|
*/
|
|
206
|
-
removeAll(source:
|
|
206
|
+
removeAll(source: EventSource): object {
|
|
207
207
|
_events[source] = new Map();
|
|
208
208
|
return this;
|
|
209
209
|
},
|
|
@@ -219,11 +219,8 @@ const EventUtils = (function () {
|
|
|
219
219
|
* @param {Array} [args] Optional array of arguments to be passed to each listener.
|
|
220
220
|
* @return {Object} Current instance of EventUtils
|
|
221
221
|
*/
|
|
222
|
-
emitEvent(evt: string, args: any): object {
|
|
223
|
-
let listenersMap = _getListenersAsObject(
|
|
224
|
-
evt,
|
|
225
|
-
args.payload.source || EventSourceEnum.core,
|
|
226
|
-
);
|
|
222
|
+
emitEvent(evt: string, source: EventSource, args: any): object {
|
|
223
|
+
let listenersMap = _getListenersAsObject(evt, source);
|
|
227
224
|
let listeners: TListenerMetaData[];
|
|
228
225
|
let listener: TListenerMetaData;
|
|
229
226
|
for (let key in listenersMap) {
|
|
@@ -235,16 +232,19 @@ const EventUtils = (function () {
|
|
|
235
232
|
listener = listeners[i];
|
|
236
233
|
|
|
237
234
|
if (listener.once === true) {
|
|
238
|
-
this.removeListener(evt,
|
|
235
|
+
this.removeListener(evt, source, listener.listener);
|
|
239
236
|
}
|
|
240
237
|
|
|
241
|
-
const newargs = [].slice.call(arguments,
|
|
238
|
+
const newargs = [].slice.call(arguments, 2);
|
|
242
239
|
listener.listener.apply(this, newargs || []);
|
|
243
240
|
}
|
|
244
241
|
}
|
|
245
242
|
}
|
|
246
243
|
return this;
|
|
247
244
|
},
|
|
245
|
+
clear() {
|
|
246
|
+
_events = {};
|
|
247
|
+
},
|
|
248
248
|
// 1. To add multiple listeners
|
|
249
249
|
// addListeners(evt: string, listeners: any) {
|
|
250
250
|
// if (Array.isArray(listeners)) {
|
|
@@ -27,10 +27,16 @@ const EventsQueue = (function () {
|
|
|
27
27
|
},
|
|
28
28
|
dequeue() {
|
|
29
29
|
if (_eventsQueue.length == 0) return;
|
|
30
|
-
_eventsQueue.
|
|
30
|
+
return _eventsQueue.pop();
|
|
31
31
|
},
|
|
32
|
-
|
|
33
|
-
return _eventsQueue;
|
|
32
|
+
isEmpty() {
|
|
33
|
+
return _eventsQueue.length === 0;
|
|
34
|
+
},
|
|
35
|
+
size() {
|
|
36
|
+
return _eventsQueue.length;
|
|
37
|
+
},
|
|
38
|
+
clear() {
|
|
39
|
+
_eventsQueue = [];
|
|
34
40
|
},
|
|
35
41
|
};
|
|
36
42
|
})();
|
|
@@ -28,6 +28,9 @@ const PUBLIC_CHAT_MESSAGE = 'PUBLIC_CHAT_MESSAGE';
|
|
|
28
28
|
const PRIVATE_CHAT_MESSAGE = 'PRIVATE_CHAT_MESSAGE';
|
|
29
29
|
// 4. NAME ATTRIBUTE
|
|
30
30
|
const NAME_ATTRIBUTE = 'name';
|
|
31
|
+
// 5. VIDEO MEETING ROLE
|
|
32
|
+
const VIDEO_MEETING_HOST = 'VIDEO_MEETING_HOST';
|
|
33
|
+
const VIDEO_MEETING_ATTENDEE = 'VIDEO_MEETING_ATTENDEE';
|
|
31
34
|
const EventNames = {
|
|
32
35
|
RECORDING_ATTRIBUTE,
|
|
33
36
|
RAISED_ATTRIBUTE,
|
|
@@ -36,6 +39,8 @@ const EventNames = {
|
|
|
36
39
|
PRIVATE_CHAT_MESSAGE,
|
|
37
40
|
SCREENSHARE_ATTRIBUTE,
|
|
38
41
|
NAME_ATTRIBUTE,
|
|
42
|
+
VIDEO_MEETING_HOST,
|
|
43
|
+
VIDEO_MEETING_ATTENDEE,
|
|
39
44
|
};
|
|
40
45
|
/** ***** EVENT NAMES ENDS ***** */
|
|
41
46
|
|
|
@@ -13,17 +13,19 @@
|
|
|
13
13
|
('use strict');
|
|
14
14
|
import RtmEngine from 'agora-react-native-rtm';
|
|
15
15
|
import RTMEngine from '../rtm/RTMEngine';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
16
|
+
import {EventUtils} from '../rtm-events';
|
|
17
|
+
import {
|
|
18
|
+
ReceiverUid,
|
|
19
|
+
EventCallback,
|
|
20
|
+
EventSource,
|
|
21
|
+
EventPersistLevel,
|
|
22
|
+
} from './types';
|
|
19
23
|
import {adjustUID} from '../rtm/utils';
|
|
20
24
|
|
|
21
|
-
class
|
|
22
|
-
private
|
|
23
|
-
private source: EventSourceEnum = EventSourceEnum.core;
|
|
25
|
+
class Events {
|
|
26
|
+
private source: EventSource = EventSource.core;
|
|
24
27
|
|
|
25
|
-
constructor(source?:
|
|
26
|
-
this.engine = RTMEngine.getInstance().engine;
|
|
28
|
+
constructor(source?: EventSource) {
|
|
27
29
|
if (source) {
|
|
28
30
|
this.source = source;
|
|
29
31
|
}
|
|
@@ -33,15 +35,15 @@ class CustomEvents {
|
|
|
33
35
|
* Persists the data in the local attributes of the user
|
|
34
36
|
*
|
|
35
37
|
* @param {string} evt to be stored in rtm Attribute key
|
|
36
|
-
* @param {
|
|
38
|
+
* @param {string} payload to be stored in rtm Attribute value
|
|
37
39
|
* @api private
|
|
38
40
|
*/
|
|
39
|
-
private _persist = async (evt: string, payload:
|
|
41
|
+
private _persist = async (evt: string, payload: string) => {
|
|
42
|
+
const rtmEngine: RtmEngine = RTMEngine.getInstance().engine;
|
|
40
43
|
try {
|
|
41
|
-
const
|
|
42
|
-
const rtmAttribute = {key: evt, value: JSON.stringify(payload)};
|
|
44
|
+
const rtmAttribute = {key: evt, value: payload};
|
|
43
45
|
// Step 1: Call RTM API to update local attributes
|
|
44
|
-
await
|
|
46
|
+
await rtmEngine.addOrUpdateLocalUserAttributes([rtmAttribute]);
|
|
45
47
|
} catch (error) {
|
|
46
48
|
console.log(
|
|
47
49
|
'CUSTOM_EVENT_API error occured while updating the value ',
|
|
@@ -65,7 +67,7 @@ class CustomEvents {
|
|
|
65
67
|
return true;
|
|
66
68
|
};
|
|
67
69
|
|
|
68
|
-
private _validateListener = (listener:
|
|
70
|
+
private _validateListener = (listener: EventCallback): boolean => {
|
|
69
71
|
if (typeof listener !== 'function') {
|
|
70
72
|
throw Error(
|
|
71
73
|
`CUSTOM_EVENT_API Function cannot be of type ${typeof listener}`,
|
|
@@ -81,16 +83,14 @@ class CustomEvents {
|
|
|
81
83
|
* If param 'to' is an array of uids is provided then message is sent to all the individual uids in loop.
|
|
82
84
|
*
|
|
83
85
|
* @param {any} rtmPayload payload to be sent across
|
|
84
|
-
* @param {
|
|
86
|
+
* @param {toUid} to uid or uids[] of user
|
|
85
87
|
* @api private
|
|
86
88
|
*/
|
|
87
|
-
private _send = async (rtmPayload: any, toUid?:
|
|
89
|
+
private _send = async (rtmPayload: any, toUid?: ReceiverUid) => {
|
|
88
90
|
const to = typeof toUid == 'string' ? parseInt(toUid) : toUid;
|
|
91
|
+
const rtmEngine: RtmEngine = RTMEngine.getInstance().engine;
|
|
89
92
|
|
|
90
|
-
const text = JSON.stringify(
|
|
91
|
-
type: eventMessageType.CUSTOM_EVENT,
|
|
92
|
-
msg: rtmPayload,
|
|
93
|
-
});
|
|
93
|
+
const text = JSON.stringify(rtmPayload);
|
|
94
94
|
// Case 1: send to channel
|
|
95
95
|
if (
|
|
96
96
|
typeof to === 'undefined' ||
|
|
@@ -100,7 +100,7 @@ class CustomEvents {
|
|
|
100
100
|
console.log('CUSTOM_EVENT_API: case 1 executed');
|
|
101
101
|
try {
|
|
102
102
|
const channelId = RTMEngine.getInstance().channelUid;
|
|
103
|
-
await
|
|
103
|
+
await rtmEngine.sendMessageByChannelId(channelId, text);
|
|
104
104
|
} catch (error) {
|
|
105
105
|
console.log('CUSTOM_EVENT_API: send event case 1 error : ', error);
|
|
106
106
|
throw error;
|
|
@@ -111,7 +111,7 @@ class CustomEvents {
|
|
|
111
111
|
console.log('CUSTOM_EVENT_API: case 2 executed', to);
|
|
112
112
|
const adjustedUID = adjustUID(to);
|
|
113
113
|
try {
|
|
114
|
-
await
|
|
114
|
+
await rtmEngine.sendMessageToPeer({
|
|
115
115
|
peerId: `${adjustedUID}`,
|
|
116
116
|
offline: false,
|
|
117
117
|
text,
|
|
@@ -128,7 +128,7 @@ class CustomEvents {
|
|
|
128
128
|
try {
|
|
129
129
|
for (const uid of to) {
|
|
130
130
|
const adjustedUID = adjustUID(uid);
|
|
131
|
-
await
|
|
131
|
+
await rtmEngine.sendMessageToPeer({
|
|
132
132
|
peerId: `${adjustedUID}`,
|
|
133
133
|
offline: false,
|
|
134
134
|
text,
|
|
@@ -147,41 +147,42 @@ class CustomEvents {
|
|
|
147
147
|
* When the specified event happens, the Events API triggers the callback that you pass.
|
|
148
148
|
* The listener will not be added if it is a duplicate.
|
|
149
149
|
*
|
|
150
|
-
* @param {String}
|
|
150
|
+
* @param {String} eventName Name of the event to attach the listener to.
|
|
151
151
|
* @param {Function} listener Method to be called when the event is emitted.
|
|
152
152
|
* @api public
|
|
153
153
|
*/
|
|
154
|
-
on = (
|
|
154
|
+
on = (eventName: string, listener: EventCallback) => {
|
|
155
155
|
try {
|
|
156
|
-
if (!this._validateEvt(
|
|
157
|
-
|
|
156
|
+
if (!this._validateEvt(eventName) || !this._validateListener(listener))
|
|
157
|
+
return;
|
|
158
|
+
EventUtils.addListener(eventName, listener, this.source);
|
|
159
|
+
return () => {
|
|
160
|
+
EventUtils.removeListener(eventName, listener, this.source);
|
|
161
|
+
};
|
|
158
162
|
} catch (error) {
|
|
159
163
|
console.log('custom-events-on error: ', error);
|
|
160
164
|
}
|
|
161
165
|
};
|
|
162
166
|
|
|
163
167
|
/**
|
|
164
|
-
* Removes a listener function from the specified event if
|
|
168
|
+
* Removes a listener function from the specified event if eventName and listener function both are provided.
|
|
165
169
|
* Removes all listeners from a specified event if listener function is not provided.
|
|
166
170
|
* If you do not specify an event then all listeners will be removed.
|
|
167
171
|
* That means every event will be emptied.
|
|
168
172
|
*
|
|
169
|
-
* @param {String}
|
|
170
|
-
* @param {Function}
|
|
173
|
+
* @param {String} eventName Name of the event to remove the listener from.
|
|
174
|
+
* @param {Function} listener Method to remove from the event.
|
|
171
175
|
* @api public
|
|
172
176
|
*/
|
|
173
|
-
off = (
|
|
177
|
+
off = (eventName?: string, listener?: EventCallback) => {
|
|
174
178
|
try {
|
|
175
|
-
if (
|
|
176
|
-
if (
|
|
177
|
-
this.
|
|
178
|
-
this._validateEvt(evt)
|
|
179
|
-
) {
|
|
180
|
-
EventUtils.removeListener(evt, listenerToRemove, this.source);
|
|
179
|
+
if (listener) {
|
|
180
|
+
if (this._validateListener(listener) && this._validateEvt(eventName)) {
|
|
181
|
+
EventUtils.removeListener(eventName, listener, this.source);
|
|
181
182
|
}
|
|
182
|
-
} else if (
|
|
183
|
-
if (this._validateEvt(
|
|
184
|
-
EventUtils.removeAllListeners(
|
|
183
|
+
} else if (eventName) {
|
|
184
|
+
if (this._validateEvt(eventName)) {
|
|
185
|
+
EventUtils.removeAllListeners(eventName, this.source);
|
|
185
186
|
}
|
|
186
187
|
} else {
|
|
187
188
|
EventUtils.removeAll(this.source);
|
|
@@ -197,42 +198,47 @@ class CustomEvents {
|
|
|
197
198
|
* - If 'to' is empty this method sends channel message.
|
|
198
199
|
*
|
|
199
200
|
*
|
|
200
|
-
* @param {String}
|
|
201
|
-
* @param {
|
|
202
|
-
*
|
|
203
|
-
* - level: 1 | 2 | 3
|
|
204
|
-
* - value: {string}. NOTICE: value bytelength has MAX_SIZE 32kb limit.
|
|
205
|
-
* @param {ToOptions} to uid or uid array. The default mode is to send a message in channel.
|
|
201
|
+
* @param {String} eventName Name of the event to register on which listeners are added
|
|
202
|
+
* @param {String} payload . NOTICE: value bytelength has MAX_SIZE 32kb limit.
|
|
203
|
+
* @param {ReceiverUid} receiver uid or uid array. The default mode is to send a message in channel.
|
|
206
204
|
* @api public
|
|
207
205
|
* */
|
|
208
|
-
send = async (
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
send = async (
|
|
207
|
+
eventName: string = '',
|
|
208
|
+
payload: string = '',
|
|
209
|
+
persistLevel: EventPersistLevel,
|
|
210
|
+
receiver?: ReceiverUid,
|
|
211
|
+
) => {
|
|
212
|
+
if (!this._validateEvt(eventName)) return;
|
|
213
|
+
|
|
214
|
+
const persistValue = JSON.stringify({
|
|
215
|
+
payload,
|
|
216
|
+
persistLevel,
|
|
217
|
+
source: this.source,
|
|
218
|
+
});
|
|
211
219
|
|
|
212
220
|
const rtmPayload = {
|
|
213
|
-
evt:
|
|
214
|
-
|
|
215
|
-
action,
|
|
216
|
-
value,
|
|
217
|
-
level,
|
|
218
|
-
source: this.source,
|
|
219
|
-
},
|
|
221
|
+
evt: eventName,
|
|
222
|
+
value: persistValue,
|
|
220
223
|
};
|
|
221
224
|
|
|
222
|
-
if (
|
|
223
|
-
|
|
225
|
+
if (
|
|
226
|
+
persistLevel === EventPersistLevel.LEVEL2 ||
|
|
227
|
+
persistLevel === EventPersistLevel.LEVEL3
|
|
228
|
+
) {
|
|
229
|
+
console.log('CUSTOM_EVENT_API: Event lifecycle: persist', persistLevel);
|
|
224
230
|
try {
|
|
225
|
-
await this._persist(
|
|
231
|
+
await this._persist(eventName, persistValue);
|
|
226
232
|
} catch (error) {
|
|
227
233
|
console.log('custom-events-persist error: ', error);
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
try {
|
|
231
|
-
await this._send(rtmPayload,
|
|
237
|
+
await this._send(rtmPayload, receiver);
|
|
232
238
|
} catch (error) {
|
|
233
239
|
console.log('CUSTOM_EVENT_API: sending failed. ', error);
|
|
234
240
|
}
|
|
235
241
|
};
|
|
236
242
|
}
|
|
237
243
|
|
|
238
|
-
export default
|
|
244
|
+
export default Events;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {UidType} from '../../agora-rn-uikit';
|
|
2
|
+
|
|
3
|
+
export type ReceiverUid = UidType | UidType[];
|
|
4
|
+
|
|
5
|
+
export type EventPayload = string | Record<string, never>;
|
|
6
|
+
|
|
7
|
+
export enum EventSource {
|
|
8
|
+
core = 'core',
|
|
9
|
+
fpe = 'fpe',
|
|
10
|
+
}
|
|
11
|
+
export enum EventPersistLevel {
|
|
12
|
+
'LEVEL1' = 1,
|
|
13
|
+
'LEVEL2',
|
|
14
|
+
'LEVEL3',
|
|
15
|
+
}
|
|
16
|
+
interface EventCallbackPayload {
|
|
17
|
+
payload: string;
|
|
18
|
+
persistLevel: EventPersistLevel;
|
|
19
|
+
sender: UidType;
|
|
20
|
+
ts: number;
|
|
21
|
+
}
|
|
22
|
+
export type EventCallback = (args: EventCallbackPayload) => void;
|
|
@@ -15,19 +15,27 @@ import Hyperlink from 'react-native-hyperlink';
|
|
|
15
15
|
import {useString} from '../utils/useString';
|
|
16
16
|
import {ChatBubbleProps} from '../components/ChatContext';
|
|
17
17
|
import ColorContext from '../components/ColorContext';
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
18
|
+
import {isWebInternal} from '../utils/common';
|
|
19
|
+
import {useRender} from 'customization-api';
|
|
20
20
|
|
|
21
21
|
const ChatBubble = (props: ChatBubbleProps) => {
|
|
22
|
-
const {renderList} =
|
|
22
|
+
const {renderList} = useRender();
|
|
23
23
|
const {primaryColor} = useContext(ColorContext);
|
|
24
|
-
let {
|
|
24
|
+
let {
|
|
25
|
+
isLocal,
|
|
26
|
+
message,
|
|
27
|
+
createdTimestamp,
|
|
28
|
+
uid,
|
|
29
|
+
isDeleted,
|
|
30
|
+
msgId,
|
|
31
|
+
updatedTimestamp,
|
|
32
|
+
} = props;
|
|
25
33
|
let time =
|
|
26
|
-
new Date(parseInt(
|
|
34
|
+
new Date(parseInt(createdTimestamp)).getHours() +
|
|
27
35
|
':' +
|
|
28
|
-
new Date(parseInt(
|
|
36
|
+
new Date(parseInt(createdTimestamp)).getMinutes();
|
|
29
37
|
const handleUrl = (url: string) => {
|
|
30
|
-
if (
|
|
38
|
+
if (isWebInternal()) {
|
|
31
39
|
window.open(url, '_blank');
|
|
32
40
|
} else {
|
|
33
41
|
Linking.openURL(url);
|
|
@@ -37,7 +45,15 @@ const ChatBubble = (props: ChatBubbleProps) => {
|
|
|
37
45
|
//const remoteUserDefaultLabel = useString('remoteUserDefaultLabel')();
|
|
38
46
|
const remoteUserDefaultLabel = 'User';
|
|
39
47
|
return props?.render ? (
|
|
40
|
-
props.render(
|
|
48
|
+
props.render(
|
|
49
|
+
isLocal,
|
|
50
|
+
message,
|
|
51
|
+
createdTimestamp,
|
|
52
|
+
uid,
|
|
53
|
+
msgId,
|
|
54
|
+
isDeleted,
|
|
55
|
+
updatedTimestamp,
|
|
56
|
+
)
|
|
41
57
|
) : (
|
|
42
58
|
<View>
|
|
43
59
|
<View style={isLocal ? style.chatSenderViewLocal : style.chatSenderView}>
|
|
@@ -25,26 +25,24 @@ import {ChatBubbleProps} from '../components/ChatContext';
|
|
|
25
25
|
import {useLocalUid} from '../../agora-rn-uikit';
|
|
26
26
|
import {ImageIcon} from '../../agora-rn-uikit';
|
|
27
27
|
import TextWithTooltip from './TextWithTooltip';
|
|
28
|
-
import {
|
|
29
|
-
import {isValidReactComponent,
|
|
28
|
+
import {useCustomization} from 'customization-implementation';
|
|
29
|
+
import {isValidReactComponent, isWebInternal} from '../utils/common';
|
|
30
30
|
import {useString} from '../utils/useString';
|
|
31
31
|
import {useChatUIControl} from '../components/chat-ui/useChatUIControl';
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import usePrivateMessages from '../utils/usePrivateMessages';
|
|
32
|
+
import {useRender} from 'customization-api';
|
|
33
|
+
import {useChatMessages} from '../components/chat-messages/useChatMessages';
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* Chat container is the component which renders all the chat messages
|
|
38
37
|
* It retrieves all the messages from the appropriate stores (Message store an provate message store)
|
|
39
38
|
* and maps it to a ChatBubble
|
|
40
39
|
*/
|
|
41
|
-
const ChatContainer = (props
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const privateMessageStore =
|
|
40
|
+
const ChatContainer = (props?: {
|
|
41
|
+
chatBubble?: React.ComponentType<ChatBubbleProps>;
|
|
42
|
+
}) => {
|
|
43
|
+
const {renderList} = useRender();
|
|
44
|
+
const {messageStore, privateMessageStore} = useChatMessages();
|
|
46
45
|
const {height, width} = useWindowDimensions();
|
|
47
|
-
const {selectPrivate} = props;
|
|
48
46
|
const {
|
|
49
47
|
privateActive,
|
|
50
48
|
selectedChatUserId: selectedUserID,
|
|
@@ -56,7 +54,7 @@ const ChatContainer = (props: any) => {
|
|
|
56
54
|
const remoteUserDefaultLabel = 'User';
|
|
57
55
|
const scrollViewRef = useRef<ScrollView>(null);
|
|
58
56
|
|
|
59
|
-
const {ChatBubbleComponent} =
|
|
57
|
+
const {ChatBubbleComponent} = useCustomization((data) => {
|
|
60
58
|
let components: {
|
|
61
59
|
ChatBubbleComponent: React.ComponentType<ChatBubbleProps>;
|
|
62
60
|
} = {
|
|
@@ -80,6 +78,10 @@ const ChatContainer = (props: any) => {
|
|
|
80
78
|
data?.components?.videoCall?.chat?.chatBubble;
|
|
81
79
|
}
|
|
82
80
|
}
|
|
81
|
+
} else {
|
|
82
|
+
if (props?.chatBubble && isValidReactComponent(props?.chatBubble)) {
|
|
83
|
+
components.ChatBubbleComponent = props?.chatBubble;
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
return components;
|
|
85
87
|
});
|
|
@@ -124,9 +126,12 @@ const ChatContainer = (props: any) => {
|
|
|
124
126
|
<ChatBubbleComponent
|
|
125
127
|
isLocal={localUid === message.uid}
|
|
126
128
|
message={message.msg}
|
|
127
|
-
|
|
129
|
+
createdTimestamp={message.createdTimestamp}
|
|
130
|
+
updatedTimestamp={message.updatedTimestamp}
|
|
128
131
|
uid={message.uid}
|
|
129
132
|
key={message.ts}
|
|
133
|
+
msgId={message.msgId}
|
|
134
|
+
isDeleted={message.isDeleted}
|
|
130
135
|
/>
|
|
131
136
|
</>
|
|
132
137
|
))
|
|
@@ -135,9 +140,12 @@ const ChatContainer = (props: any) => {
|
|
|
135
140
|
<ChatBubbleComponent
|
|
136
141
|
isLocal={localUid === message.uid}
|
|
137
142
|
message={message.msg}
|
|
138
|
-
|
|
143
|
+
createdTimestamp={message.createdTimestamp}
|
|
144
|
+
updatedTimestamp={message.updatedTimestamp}
|
|
139
145
|
uid={message.uid}
|
|
140
146
|
key={message.ts}
|
|
147
|
+
msgId={message.msgId}
|
|
148
|
+
isDeleted={message.isDeleted}
|
|
141
149
|
/>
|
|
142
150
|
))
|
|
143
151
|
) : (
|
|
@@ -175,7 +183,7 @@ const style = StyleSheet.create({
|
|
|
175
183
|
alignSelf: 'flex-end',
|
|
176
184
|
},
|
|
177
185
|
name: {
|
|
178
|
-
fontWeight:
|
|
186
|
+
fontWeight: isWebInternal() ? '500' : '700',
|
|
179
187
|
color: $config.PRIMARY_FONT_COLOR,
|
|
180
188
|
textAlign: 'left',
|
|
181
189
|
marginRight: 10,
|
|
@@ -196,4 +204,5 @@ const style = StyleSheet.create({
|
|
|
196
204
|
textAlign: 'center',
|
|
197
205
|
},
|
|
198
206
|
});
|
|
207
|
+
|
|
199
208
|
export default ChatContainer;
|