@maren-sa/react-native-sanarkit 2.5.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 +362 -0
- package/lib/RTCComponent.d.ts +3 -0
- package/lib/RTCComponent.js +1 -0
- package/lib/RtcView.d.ts +19 -0
- package/lib/RtcView.js +1 -0
- package/lib/SanarKit.d.ts +42 -0
- package/lib/SanarKit.js +1 -0
- package/lib/Types.d.ts +23 -0
- package/lib/Types.js +1 -0
- package/lib/common/DotLoader.d.ts +12 -0
- package/lib/common/DotLoader.js +1 -0
- package/lib/common/PermissionModal.d.ts +11 -0
- package/lib/common/PermissionModal.js +1 -0
- package/lib/common/Permissions.d.ts +8 -0
- package/lib/common/Permissions.js +1 -0
- package/lib/common/SanarContext.d.ts +3 -0
- package/lib/common/SanarContext.js +1 -0
- package/lib/common/SanarProvider.d.ts +9 -0
- package/lib/common/SanarProvider.js +1 -0
- package/lib/common/SanarSVG.d.ts +224 -0
- package/lib/common/SanarSVG.js +1 -0
- package/lib/common/ToolTip.d.ts +15 -0
- package/lib/common/ToolTip.js +1 -0
- package/lib/components/Connecting.d.ts +3 -0
- package/lib/components/Connecting.js +1 -0
- package/lib/components/Container.d.ts +8 -0
- package/lib/components/Container.js +1 -0
- package/lib/components/Controls.d.ts +240 -0
- package/lib/components/Controls.js +1 -0
- package/lib/components/Ringer.d.ts +3 -0
- package/lib/components/Ringer.js +1 -0
- package/lib/components/RtcContainer.d.ts +3 -0
- package/lib/components/RtcContainer.js +1 -0
- package/lib/components/SideFrame.d.ts +3 -0
- package/lib/components/SideFrame.js +1 -0
- package/lib/components/SvgIcon.d.ts +12 -0
- package/lib/components/SvgIcon.js +1 -0
- package/lib/components/Timer.d.ts +3 -0
- package/lib/components/Timer.js +1 -0
- package/lib/components/VideoFrames.d.ts +3 -0
- package/lib/components/VideoFrames.js +1 -0
- package/lib/context/SanarContext.d.ts +9 -0
- package/lib/context/SanarContext.js +1 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.js +1 -0
- package/lib/screens/ITCBooking.d.ts +8 -0
- package/lib/screens/ITCBooking.js +18 -0
- package/lib/screens/SKAppointments.d.ts +14 -0
- package/lib/screens/SKAppointments.js +18 -0
- package/lib/screens/SKChat.d.ts +16 -0
- package/lib/screens/SKChat.js +18 -0
- package/lib/screens/SKConsultation.d.ts +2 -0
- package/lib/screens/SKConsultation.js +1 -0
- package/lib/screens/SKDashboard.d.ts +14 -0
- package/lib/screens/SKDashboard.js +36 -0
- package/lib/utils/constants.d.ts +18 -0
- package/lib/utils/constants.js +1 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +1 -0
- package/lib/viewport-units.d.ts +1 -0
- package/lib/viewport-units.js +1 -0
- package/package.json +71 -0
- package/scripts/sanarkit-setup.js +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# SanarKit: react-native-sanarkit
|
|
2
|
+
|
|
3
|
+
A React Native library for integrating Sanar Services seamlessly into your application.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- **SanarKit**: Core SDK for authentication and session management.
|
|
7
|
+
- **SKDashboard**: Module for consolidated dashboard access to all Sanar services.
|
|
8
|
+
- **SKAppointments**: Module for managing healthcare appointments and scheduling.
|
|
9
|
+
- **SKConsultation**: Module for chat-based teleconsultation.
|
|
10
|
+
- **SanarRTC**: Core module for handling real-time video consultations.
|
|
11
|
+
- **ITCBooking** : Module for Instant Consultation booking.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
For complete integration, refer to our [Installation Guide](docs/readme.md).
|
|
15
|
+
|
|
16
|
+
### iOS
|
|
17
|
+
To enable camera and microphone usage, add the following entries to your `Info.plist` file:
|
|
18
|
+
|
|
19
|
+
```xml
|
|
20
|
+
<key>NSCameraUsageDescription</key>
|
|
21
|
+
<string>Your message to user when the camera is accessed for the first time</string>
|
|
22
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
23
|
+
<string>Your message to user when the microphone is accessed for the first time</string>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Android
|
|
27
|
+
To enable camera and microphone usage, add the following permissions to your `AndroidManifest.xml` file:
|
|
28
|
+
|
|
29
|
+
```xml
|
|
30
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
31
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
32
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
33
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
34
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
35
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Initialization
|
|
39
|
+
Before using any Sanar SDK features, initialize the SDK by setting up required configurations to ensure communication with Sanar Services.
|
|
40
|
+
|
|
41
|
+
## SanarKit Properties
|
|
42
|
+
|
|
43
|
+
### Properties
|
|
44
|
+
- `connect`: Method for authentication and session creation with Sanar Services
|
|
45
|
+
- `disconnect`: Method to terminate active sessions
|
|
46
|
+
- `SanarRTC`: Sanar Teleconsultation Module
|
|
47
|
+
- `setEnvironment` : Method to set environment.
|
|
48
|
+
|
|
49
|
+
### Connect
|
|
50
|
+
The `connect` method is used for authentication and session creation with Sanar Services.
|
|
51
|
+
|
|
52
|
+
#### Usage
|
|
53
|
+
```javascript
|
|
54
|
+
import { SanarKit } from '@maren-sa/react-native-sanarkit';
|
|
55
|
+
|
|
56
|
+
SanarKit.connect(
|
|
57
|
+
cid: <sanar-client-access-token>,
|
|
58
|
+
info: <UserInfo>,
|
|
59
|
+
lang: <String>
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
- `cid` (String): Client ID provided by Sanar.
|
|
65
|
+
- `info` (Object): [User details](#userinfo-format) required for session creation.
|
|
66
|
+
- `lang` (String, optional): Language preference (default: English).
|
|
67
|
+
|
|
68
|
+
#### UserInfo Format
|
|
69
|
+
```javascript
|
|
70
|
+
const userInfo = {
|
|
71
|
+
first_name: "John",
|
|
72
|
+
last_name: "Doe",
|
|
73
|
+
dob: "1990-01-01",
|
|
74
|
+
gender: "M",
|
|
75
|
+
nationality: "Saudi Arabia",
|
|
76
|
+
document_id: "2469433220",
|
|
77
|
+
mid: "MG2",
|
|
78
|
+
document_type: 1,
|
|
79
|
+
phone_code: "91",
|
|
80
|
+
phone_no: "81794771111",
|
|
81
|
+
maritalStatus: "0"
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Disconnect
|
|
86
|
+
To terminate the session when it's no longer needed, use the `disconnect` method:
|
|
87
|
+
```javascript
|
|
88
|
+
SanarKit.disconnect();
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
> **Session requirement:** `SKDashboard`, `SKAppointments`, `SKConsultation` and `SanarRTC` all require an active SanarKit session (created via `SanarKit.connect`). Each module validates the session automatically and triggers its `onEndFlow` callback if no valid session is present — so always `connect` before enabling these modules.
|
|
92
|
+
|
|
93
|
+
## SKDashboard Implementation
|
|
94
|
+
`SKDashboard` is a consolidated dashboard module that provides access to all Sanar services through a unified, web-based interface rendered inside your app.
|
|
95
|
+
|
|
96
|
+
#### Usage
|
|
97
|
+
```javascript
|
|
98
|
+
import { useState } from 'react';
|
|
99
|
+
import { SKDashboard } from '@maren-sa/react-native-sanarkit';
|
|
100
|
+
|
|
101
|
+
const [isDashboardEnable, setIsDashboardEnable] = useState(false);
|
|
102
|
+
|
|
103
|
+
// Enable it once you have an active SanarKit session
|
|
104
|
+
<SKDashboard
|
|
105
|
+
enable={isDashboardEnable}
|
|
106
|
+
navigationOption={true}
|
|
107
|
+
onEndFlow={() => setIsDashboardEnable(false)}
|
|
108
|
+
/>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Parameters
|
|
112
|
+
- `enable` (Boolean): Controls whether the dashboard module is active.
|
|
113
|
+
- `onEndFlow` (Function): Callback triggered when the dashboard is closed or navigation returns to home.
|
|
114
|
+
- `navigationOption` (Boolean, optional): Controls navigation-bar visibility within the dashboard (default: `true`). When `false`, the dashboard is rendered without its in-page navigation.
|
|
115
|
+
|
|
116
|
+
#### Features
|
|
117
|
+
- **Unified Access**: Single entry point to all Sanar services.
|
|
118
|
+
- **Service Overview**: Comprehensive view of available healthcare services.
|
|
119
|
+
- **Navigation Control**: Optional navigation bar for seamless embedding.
|
|
120
|
+
- **Session Management**: Automatic session validation and handling.
|
|
121
|
+
|
|
122
|
+
## SKAppointments Implementation
|
|
123
|
+
`SKAppointments` is an appointment-management module for scheduling and managing healthcare appointments, rendered inside your app.
|
|
124
|
+
|
|
125
|
+
#### Usage
|
|
126
|
+
```javascript
|
|
127
|
+
import { useState } from 'react';
|
|
128
|
+
import { SKAppointments } from '@maren-sa/react-native-sanarkit';
|
|
129
|
+
|
|
130
|
+
const [isAppointmentsEnable, setIsAppointmentsEnable] = useState(false);
|
|
131
|
+
|
|
132
|
+
// Enable it once you have an active SanarKit session
|
|
133
|
+
<SKAppointments
|
|
134
|
+
enable={isAppointmentsEnable}
|
|
135
|
+
navigationOption={true}
|
|
136
|
+
onEndFlow={() => setIsAppointmentsEnable(false)}
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Parameters
|
|
141
|
+
- `enable` (Boolean): Controls whether the appointments module is active.
|
|
142
|
+
- `onEndFlow` (Function): Callback triggered when the appointments module is closed or navigation returns to home.
|
|
143
|
+
- `navigationOption` (Boolean, optional): Controls navigation-bar visibility within the appointments interface (default: `true`).
|
|
144
|
+
|
|
145
|
+
#### Features
|
|
146
|
+
- **Appointment Scheduling**: Book new healthcare appointments.
|
|
147
|
+
- **Appointment Management**: View, modify, and cancel existing appointments.
|
|
148
|
+
- **Provider Selection**: Browse and select healthcare providers.
|
|
149
|
+
- **Calendar Integration**: Calendar-based scheduling.
|
|
150
|
+
- **Status Tracking**: Real-time appointment status updates.
|
|
151
|
+
|
|
152
|
+
## SKConsultation Implementation
|
|
153
|
+
`SKConsultation` is a chat-based teleconsultation module, providing real-time communication for users and medical professionals.
|
|
154
|
+
|
|
155
|
+
#### Usage
|
|
156
|
+
```javascript
|
|
157
|
+
import { SKConsultation } from '@maren-sa/react-native-sanarkit';
|
|
158
|
+
|
|
159
|
+
<SKConsultation
|
|
160
|
+
enable={isConsultationEnable}
|
|
161
|
+
appointmentId={appId}
|
|
162
|
+
empId={docId}
|
|
163
|
+
onEndFlow={() => setIsConsultationEnable(false)}
|
|
164
|
+
/>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Parameters
|
|
168
|
+
- `enable` (Boolean): Controls whether consultation module is active.
|
|
169
|
+
- `appointmentId` (String): Unique id for the appointment.
|
|
170
|
+
- `empId` (String): ID of the consulting Doctor.
|
|
171
|
+
- `onEndFlow` (Function): Callback triggered when consultation module is closed on back button.
|
|
172
|
+
|
|
173
|
+
## ITCBooking
|
|
174
|
+
The ITCBooking module provides instant teleconsultation booking functionality with build in interface. It integrates with SanarKit services to enable Instant appointment booking and consultation features.
|
|
175
|
+
|
|
176
|
+
### Installation
|
|
177
|
+
The module is included in the SanarKit SDK package. No additional installation is required.
|
|
178
|
+
|
|
179
|
+
#### Usage
|
|
180
|
+
```typescript
|
|
181
|
+
import { ITCBooking } from '@maren-sa/react-native-sanarkit';
|
|
182
|
+
|
|
183
|
+
// In your component
|
|
184
|
+
<ITCBooking
|
|
185
|
+
enable={boolean}
|
|
186
|
+
onEndFlow={() => void}
|
|
187
|
+
/>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Parameters
|
|
191
|
+
- `enable` (Boolean): Controls whether consultation module is active.
|
|
192
|
+
- `onEndFlow` (Function): Callback triggered when ITCBooking module is closed on back button.
|
|
193
|
+
|
|
194
|
+
For detailed documentation on ITCBooking module, refer to [ITCBooking Documentation](docs/itc_docs.md).
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## SanarRTC
|
|
198
|
+
`SanarRTC` is a teleconsultation module, providing real-time communication for users and Doctors.
|
|
199
|
+
Refer to [SanarRTC Docs](docs/sanarrtc_docs.md) for its integration and usage.
|
|
200
|
+
|
|
201
|
+
## SanarRTC Properties
|
|
202
|
+
- `enable`: Method for enabling and disabling the SanarRTC module.
|
|
203
|
+
- `isFullscreen`: Boolean property to control the video call view size (fullscreen or minimized).
|
|
204
|
+
- `onCallStatusChange`: Callback triggered when the SanarRTC call status changes.
|
|
205
|
+
- `onViewModeChange`: Callback triggered when the video call view changes between fullscreen and minimized.
|
|
206
|
+
|
|
207
|
+
### `onCallStatusChange` Callback
|
|
208
|
+
|
|
209
|
+
The `onCallStatusChange` callback is triggered whenever the SanarRTC call status changes. This allows the application to handle call events accordingly. Below are the possible statuses:
|
|
210
|
+
|
|
211
|
+
| Status | Description |
|
|
212
|
+
|----------------------|-------------|
|
|
213
|
+
| `CALL_INITIATED` | Triggeres when an incoming call request is received from the doctor. |
|
|
214
|
+
| `CALL_ACCEPTED` | Triggeres when the user has accepted the incoming call. |
|
|
215
|
+
| `CALL_REJECTED` | Triggeres when the user has rejected the incoming call. |
|
|
216
|
+
| `CALL_END_USER` | Triggers when the user voluntarily ends the call after the consultation is complete. |
|
|
217
|
+
| `CALL_END_PROVIDER` | Triggers when the doctor ends the call after the consultation is complete. |
|
|
218
|
+
|
|
219
|
+
### `onViewModeChange` Callback
|
|
220
|
+
|
|
221
|
+
The `onViewModeChange` callback is triggered whenever the video call view changes between fullscreen and minimized modes. This allows the application to handle view mode changes accordingly.
|
|
222
|
+
|
|
223
|
+
#### Parameters
|
|
224
|
+
- `mode` (String): The current view mode - either `'fullscreen'` or `'minimized'`
|
|
225
|
+
|
|
226
|
+
#### Usage
|
|
227
|
+
```javascript
|
|
228
|
+
<SanarRTC
|
|
229
|
+
enable={connect}
|
|
230
|
+
onViewModeChange={(mode) => {
|
|
231
|
+
if (mode === 'minimized') {
|
|
232
|
+
console.log('Video call view is now minimized');
|
|
233
|
+
// Handle minimized state
|
|
234
|
+
} else if (mode === 'fullscreen') {
|
|
235
|
+
console.log('Video call view is now fullscreen');
|
|
236
|
+
// Handle fullscreen state
|
|
237
|
+
}
|
|
238
|
+
}}
|
|
239
|
+
/>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Video Call View Control
|
|
243
|
+
|
|
244
|
+
#### Minimize / Maximize Video Call View
|
|
245
|
+
The `isFullscreen` property allows you to control the video call view size from the app level. When set to `true`, the video call view will be displayed in fullscreen mode. When set to `false`, it will be minimized.
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
<SanarRTC
|
|
249
|
+
enable={connect}
|
|
250
|
+
isFullscreen={true} // Controls fullscreen/minimized state
|
|
251
|
+
/>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Global Video Call View
|
|
255
|
+
`SanarRTC` can be rendered at the root level of your application to ensure the video call view is available globally during an active call. This is particularly useful for maintaining the video call interface across different screens and navigation states.
|
|
256
|
+
|
|
257
|
+
#### Usage
|
|
258
|
+
```javascript
|
|
259
|
+
import SanarRTC, { SanarKit } from '@maren-sa/react-native-sanarkit';
|
|
260
|
+
|
|
261
|
+
const App = () => {
|
|
262
|
+
const [connect, setConnect] = useState(false);
|
|
263
|
+
|
|
264
|
+
// ... SanarKit initialization code ...
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<>
|
|
268
|
+
{/* Your app components */}
|
|
269
|
+
<YourAppContent />
|
|
270
|
+
|
|
271
|
+
{/* Global SanarRTC component */}
|
|
272
|
+
<SanarRTC
|
|
273
|
+
enable={connect}
|
|
274
|
+
isFullscreen={true}
|
|
275
|
+
onViewModeChange={(mode) => {
|
|
276
|
+
console.log('View mode changed to:', mode);
|
|
277
|
+
}}
|
|
278
|
+
onCallStatusChange={(status) => {
|
|
279
|
+
console.log('Call status:', status);
|
|
280
|
+
}}
|
|
281
|
+
/>
|
|
282
|
+
</>
|
|
283
|
+
);
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
#### Usage
|
|
288
|
+
```javascript
|
|
289
|
+
import SanarRTC, { SanarKit } from '@maren-sa/react-native-sanarkit';
|
|
290
|
+
|
|
291
|
+
const cID = 'your-client-id';
|
|
292
|
+
const info = {} // UserInfo
|
|
293
|
+
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
const initializeSanar = async () => {
|
|
296
|
+
try {
|
|
297
|
+
const response = await SanarKit.connect(cID, info);
|
|
298
|
+
if (response.status) {
|
|
299
|
+
// enable SanarRTC on successfull connection with SanarKit
|
|
300
|
+
setConnectSanar(true);
|
|
301
|
+
} else {
|
|
302
|
+
console.log('Connection failed with SanarKit:', response.message);
|
|
303
|
+
}
|
|
304
|
+
} catch (error) {
|
|
305
|
+
console.error('Error connecting to SanarKit:', error);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
initializeSanar();
|
|
309
|
+
|
|
310
|
+
return () => {
|
|
311
|
+
SanarKit.disconnect();
|
|
312
|
+
}
|
|
313
|
+
},[]);
|
|
314
|
+
|
|
315
|
+
<SanarRTC
|
|
316
|
+
enable={connect}
|
|
317
|
+
isFullscreen={true}
|
|
318
|
+
onViewModeChange={(mode) => {
|
|
319
|
+
console.log('Video call view mode:', mode);
|
|
320
|
+
}}
|
|
321
|
+
onCallStatusChange={(status) =>{
|
|
322
|
+
switch(status) {
|
|
323
|
+
case 'CALL_INITIATED':
|
|
324
|
+
console.log('Call is being initiated...');
|
|
325
|
+
break;
|
|
326
|
+
case 'CALL_ACCEPTED':
|
|
327
|
+
console.log('Call has been accepted');
|
|
328
|
+
break;
|
|
329
|
+
case 'CALL_REJECTED':
|
|
330
|
+
console.log('Call was rejected');
|
|
331
|
+
break;
|
|
332
|
+
case 'CALL_END_USER':
|
|
333
|
+
console.log('Call ended by user');
|
|
334
|
+
break;
|
|
335
|
+
case 'CALL_END_PROVIDER':
|
|
336
|
+
console.log('Call ended by provider');
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
}}
|
|
340
|
+
/>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## `setEnvironment` Environment Configuration
|
|
344
|
+
SanarKit SDK supports multiple environments for different stages of development and deployment. By default, the SDK is set to the production environment.
|
|
345
|
+
|
|
346
|
+
### Available Environments
|
|
347
|
+
- `production`: Default environment for live/production applications
|
|
348
|
+
- `staging`: Environment for pre-production testing
|
|
349
|
+
- `development`: Environment for development and debugging
|
|
350
|
+
|
|
351
|
+
### Usage
|
|
352
|
+
To set the environment, add the following code to your application's root file (e.g., `App.tsx` or `index.js`):
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
import { SanarKit } from '@maren-sa/react-native-sanarkit';
|
|
356
|
+
|
|
357
|
+
// Set environment before initializing SanarKit
|
|
358
|
+
SanarKit.setEnvironment('production'); // or 'staging' or 'development'
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Example Repository
|
|
362
|
+
For detailed implementation and usage, check the [Example Repository](exampleapp).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _Types=require("./Types");var _Ringer=_interopRequireDefault(require("./components/Ringer"));var _RtcView=_interopRequireDefault(require("./RtcView"));var _SanarContext=_interopRequireDefault(require("./common/SanarContext"));var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Volumes/MarenExt/sdk/medgulf/ReactNative/rn-sanarkit-dev/src/RTCComponent.js";var Rtc=function Rtc(){var _React$useContext=_react.default.useContext(_SanarContext.default),ringing=_React$useContext.ringing,status=_React$useContext.status,isMinimized=_React$useContext.isMinimized;var isConnected=status===_Types.CONNECTION_STATUS.CONNECTED;if(!ringing&&!isConnected)return null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:isMinimized?styles.minimizedContainer:styles.container,children:[ringing&&(0,_jsxRuntime.jsx)(_Ringer.default,{}),isConnected&&(0,_jsxRuntime.jsx)(_RtcView.default,{})]});};var _default=exports.default=Rtc;var styles=_reactNative.StyleSheet.create({container:Object.assign({},_reactNative.StyleSheet.absoluteFillObject,{zIndex:999}),minimizedContainer:Object.assign({},_reactNative.StyleSheet.absoluteFillObject,{width:0,height:0,zIndex:999})});
|
package/lib/RtcView.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default class RtcView extends React.Component<any, any, any> {
|
|
2
|
+
static contextType: React.Context<any>;
|
|
3
|
+
constructor(props: any);
|
|
4
|
+
state: {
|
|
5
|
+
peerIds: never[];
|
|
6
|
+
joined: boolean;
|
|
7
|
+
connecting: boolean;
|
|
8
|
+
duration: string;
|
|
9
|
+
time: number;
|
|
10
|
+
};
|
|
11
|
+
componentWillUnmount(): Promise<void>;
|
|
12
|
+
_handleAppStateChange: (nextAppState: any) => Promise<void>;
|
|
13
|
+
removeDisconnectionTimeout(): void;
|
|
14
|
+
setCallDuartion(timerValue: any): void;
|
|
15
|
+
componentDidMount(): Promise<void>;
|
|
16
|
+
timer: NodeJS.Timeout | undefined;
|
|
17
|
+
render(): React.JSX.Element | null;
|
|
18
|
+
}
|
|
19
|
+
import React from 'react';
|
package/lib/RtcView.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _RtcContainer=_interopRequireDefault(require("./components/RtcContainer"));var _reactNativeAgora=require("react-native-agora");var _VideoFrames=_interopRequireDefault(require("./components/VideoFrames"));var _SanarContext=_interopRequireDefault(require("./common/SanarContext"));var _Connecting=_interopRequireDefault(require("./components/Connecting"));var _moment=_interopRequireDefault(require("moment"));var _SKConsultation=_interopRequireDefault(require("./screens/SKConsultation"));var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/Volumes/MarenExt/sdk/medgulf/ReactNative/rn-sanarkit-dev/src/RtcView.js";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}function _callSuper(t,o,e){return o=(0,_getPrototypeOf2.default)(o),(0,_possibleConstructorReturn2.default)(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2.default)(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var backgroundTime=null;var RtcView=exports.default=function(_Component){function RtcView(props){var _this;(0,_classCallCheck2.default)(this,RtcView);_this=_callSuper(this,RtcView,[props]);_this._handleAppStateChange=function(){var _ref=(0,_asyncToGenerator2.default)(function*(nextAppState){if(nextAppState=='background'){backgroundTime=(0,_moment.default)();}else{var activeTime=(0,_moment.default)();var newData=activeTime.diff(backgroundTime,'seconds');if(_reactNative.Platform.OS!=='ios'&&backgroundTime!==null){_this.setCallDuartion(newData);backgroundTime=null;}}if(nextAppState=='background'){_this.context._engineRef.enableLocalVideo(false);_this.context._engineRef.stopPreview();}else if(nextAppState=='active'){_this.context._engineRef.enableLocalVideo(true);_this.context._engineRef.startPreview();}});return function(_x){return _ref.apply(this,arguments);};}();_this.state={peerIds:[],joined:false,connecting:true,duration:(0,_moment.default)().hour(0).minute(0).second(0).format('H : mm : ss'),time:0};return _this;}(0,_inherits2.default)(RtcView,_Component);return(0,_createClass2.default)(RtcView,[{key:"componentWillUnmount",value:function(){var _componentWillUnmount=(0,_asyncToGenerator2.default)(function*(){var _engineRef=this.context._engineRef;clearInterval(this.timer);if(_engineRef){yield _engineRef.leaveChannel();_engineRef.unregisterEventHandler();_engineRef.release();}this.removeDisconnectionTimeout();});function componentWillUnmount(){return _componentWillUnmount.apply(this,arguments);}return componentWillUnmount;}()},{key:"removeDisconnectionTimeout",value:function removeDisconnectionTimeout(){if(this.noResponseDisconnect){clearInterval(this.noResponseDisconnect);}}},{key:"setCallDuartion",value:function setCallDuartion(timerValue){var _this2=this;var _this$state=this.state,time=_this$state.time,duration=_this$state.duration;this.setState({time:time+timerValue},function(){_this2.setState({duration:(0,_moment.default)().hour(0).minute(0).second(time).format('H : mm : ss')});});}},{key:"componentDidMount",value:function(){var _componentDidMount=(0,_asyncToGenerator2.default)(function*(){var _this3=this;_reactNative.AppState.addEventListener('change',this._handleAppStateChange);var _this$context=this.context,notification=_this$context.notification,setPeerIds=_this$context.setPeerIds,setEngineRef=_this$context.setEngineRef,setVideoPaused=_this$context.setVideoPaused;var _engine=(0,_reactNativeAgora.createAgoraRtcEngine)();yield _engine.initialize({appId:notification.providerId});yield _engine.setChannelProfile(_reactNativeAgora.ChannelProfileType.ChannelProfileLiveBroadcasting);setEngineRef(_engine);yield _engine.enableVideo();_engine.setVideoEncoderConfiguration({dimensions:{width:720,height:1280},frameRate:15,bitrate:0,orientationMode:_reactNativeAgora.OrientationMode.OrientationModeAdaptive,degradationPreference:_reactNativeAgora.DegradationPreference.MaintainQuality,mirrorMode:_reactNativeAgora.VideoMirrorModeType.VideoMirrorModeAuto});_engine.registerEventHandler({onWarning:function onWarning(warn){console.log('Warning',warn);},onError:function onError(err){console.log('Error',err);},onRemoteVideoStateChanged:function onRemoteVideoStateChanged(connection,uid,state,reason,elapsed){if(reason===5){setVideoPaused(true);}else if(reason===6){setVideoPaused(false);}},onUserJoined:function onUserJoined(connection,uid,elapsed){console.log("UserJoined : ",uid,elapsed);if(_this3.state.peerIds.indexOf(uid)===-1){var updatedPeerIds=[].concat((0,_toConsumableArray2.default)(_this3.state.peerIds),[uid]);_this3.setState({peerIds:updatedPeerIds},function(){setPeerIds(updatedPeerIds);});}_this3.setState({connecting:false});if(!_this3.timer){_this3.timer=setInterval(function(){_this3.setCallDuartion(1);},1000);}},onUserOffline:function onUserOffline(connection,uid,reason){console.log("UserOffline : ",uid,reason);var setIsMinimized=_this3.context.setIsMinimized;var updatedPeerIds=_this3.state.peerIds.filter(function(id){return id!==uid;});_this3.setState({peerIds:updatedPeerIds},function(){setPeerIds(updatedPeerIds);});setIsMinimized(false);},onJoinChannelSuccess:function onJoinChannelSuccess(connection,elapsed){_this3.context.pauseLocalVideo(false);_this3.setState({joined:true});}});yield _engine.setClientRole(_reactNativeAgora.ClientRoleType.ClientRoleBroadcaster);yield _engine.startPreview();setTimeout(function(){_engine==null?void 0:_engine.joinChannel(notification.token,notification.roomName,0,{clientRoleType:_reactNativeAgora.ClientRoleType.ClientRoleBroadcaster,publishMicrophoneTrack:true,publishCameraTrack:true,autoSubscribeAudio:true,autoSubscribeVideo:true});},1000);});function componentDidMount(){return _componentDidMount.apply(this,arguments);}return componentDidMount;}()},{key:"render",value:function render(){var _this$context2=this.context,intialFrame=_this$context2.intialFrame,isChatOpen=_this$context2.isChatOpen,notification=_this$context2.notification,closeChatPage=_this$context2.closeChatPage;var _this$state2=this.state,joined=_this$state2.joined,connecting=_this$state2.connecting;if(joined){return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(0,_jsxRuntime.jsx)(_reactNative.View,{children:connecting?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute"},children:(0,_jsxRuntime.jsx)(_Connecting.default,{})}):(0,_jsxRuntime.jsx)(_RtcContainer.default,{duration:this.state.duration,children:(0,_jsxRuntime.jsx)(_VideoFrames.default,{isLocal:intialFrame})})})});}else{return null;}}}]);}(_react.Component);RtcView.contextType=_SanarContext.default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type ConnectResponse = {
|
|
2
|
+
message: string;
|
|
3
|
+
status: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type Environment = 'production' | 'staging' | 'development';
|
|
6
|
+
export interface SanarKitInterface {
|
|
7
|
+
connect(cid: string, info: any, lang?: string): Promise<ConnectResponse>;
|
|
8
|
+
disconnect(): void;
|
|
9
|
+
connected: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type UserInfo = {
|
|
12
|
+
first_name: string;
|
|
13
|
+
last_name: string;
|
|
14
|
+
dob: string;
|
|
15
|
+
gender: string;
|
|
16
|
+
nationality: string;
|
|
17
|
+
document_id: string;
|
|
18
|
+
mid: string;
|
|
19
|
+
document_type: number;
|
|
20
|
+
phone_code: string;
|
|
21
|
+
phone_no: string;
|
|
22
|
+
maritalStatus: string;
|
|
23
|
+
};
|
|
24
|
+
declare class SanarKit implements SanarKitInterface {
|
|
25
|
+
eventListner: any;
|
|
26
|
+
session: any;
|
|
27
|
+
info: UserInfo | null;
|
|
28
|
+
connected: boolean;
|
|
29
|
+
private _environment;
|
|
30
|
+
private _isChatEnabled;
|
|
31
|
+
get isChatEnabled(): boolean;
|
|
32
|
+
setIsChatEnabled(value: boolean): void;
|
|
33
|
+
get environment(): Environment;
|
|
34
|
+
setEnvironment(value: Environment): void;
|
|
35
|
+
connect(cid: string, info: any, lang?: string): Promise<{
|
|
36
|
+
message: any;
|
|
37
|
+
status: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
disconnect(): void;
|
|
40
|
+
}
|
|
41
|
+
declare const _default: SanarKit;
|
|
42
|
+
export default _default;
|
package/lib/SanarKit.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _socket=_interopRequireDefault(require("socket.io-client"));var _reactNativeDeviceInfo=_interopRequireDefault(require("react-native-device-info"));var _utils=require("./utils");var SanarKit=function(){function SanarKit(){(0,_classCallCheck2.default)(this,SanarKit);this.info=null;this.connected=false;this._environment='production';this._isChatEnabled=false;}return(0,_createClass2.default)(SanarKit,[{key:"isChatEnabled",get:function get(){return this._isChatEnabled;}},{key:"setIsChatEnabled",value:function setIsChatEnabled(value){this._isChatEnabled=value;}},{key:"environment",get:function get(){return this._environment;}},{key:"setEnvironment",value:function setEnvironment(value){this._environment=value;}},{key:"connect",value:function(){var _connect=(0,_asyncToGenerator2.default)(function*(cid,info,lang){try{var did=yield _reactNativeDeviceInfo.default.getUniqueId();var _yield$getInfo=yield(0,_utils.getInfo)(cid,info,lang!=null?lang:'en',this.environment),status=_yield$getInfo.status,data=_yield$getInfo.data,message=_yield$getInfo.message,error_message=_yield$getInfo.error_message;if(status==1000){this.eventListner=(0,_socket.default)(data.messagingUrl,{query:`uid=${data.uid}&did=${did}`,transports:['websocket']});this.session=data;this.info=info;this.connected=true;console.log('Connected successfully : ',this.connected);return{message:message,status:true};}else{this.connected=false;console.log('Connected failed : ',this.connected);return{message:error_message,status:false};};}catch(error){this.connected=false;console.log('Connected failed : ',this.connected);throw error;}});function connect(_x,_x2,_x3){return _connect.apply(this,arguments);}return connect;}()},{key:"disconnect",value:function disconnect(){if(this.eventListner){this.eventListner.disconnect();console.log("Disconnected with Sanar");}this.session=null;this.info=null;this.connected=false;}}]);}();;var _default=exports.default=new SanarKit();
|
package/lib/Types.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare enum SANAR_EVENT_TYPE {
|
|
2
|
+
Connect = "connect",
|
|
3
|
+
Disconnect = "disconnect",
|
|
4
|
+
Telecall = "VIDEO_CALL",
|
|
5
|
+
Message = "INCOMING_MESSAGE",
|
|
6
|
+
ConnectError = "connect_error",
|
|
7
|
+
CALL_INITIATED = "CALL_INITIATED",
|
|
8
|
+
CALL_ACCEPTED = "CALL_ACCEPTED",
|
|
9
|
+
CALL_REJECTED = "CALL_REJECTED",
|
|
10
|
+
CALL_END_USER = "CALL_END_USER",
|
|
11
|
+
CALL_END_PROVIDER = "CALL_END_PROVIDER"
|
|
12
|
+
}
|
|
13
|
+
export declare enum CONNECTION_STATUS {
|
|
14
|
+
RINGING = 0,
|
|
15
|
+
CONNECTED = 1,
|
|
16
|
+
DISCONNECTED = 2
|
|
17
|
+
}
|
|
18
|
+
export type RTCViewStatus = 'minimized' | 'fullscreen';
|
|
19
|
+
export type SanarTelemedicine = {
|
|
20
|
+
uniqueId: string | number;
|
|
21
|
+
uid: string | number;
|
|
22
|
+
url: string;
|
|
23
|
+
};
|
package/lib/Types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.SANAR_EVENT_TYPE=exports.CONNECTION_STATUS=void 0;var SANAR_EVENT_TYPE=exports.SANAR_EVENT_TYPE=function(SANAR_EVENT_TYPE){SANAR_EVENT_TYPE["Connect"]="connect";SANAR_EVENT_TYPE["Disconnect"]="disconnect";SANAR_EVENT_TYPE["Telecall"]="VIDEO_CALL";SANAR_EVENT_TYPE["Message"]="INCOMING_MESSAGE";SANAR_EVENT_TYPE["ConnectError"]="connect_error";SANAR_EVENT_TYPE["CALL_INITIATED"]="CALL_INITIATED";SANAR_EVENT_TYPE["CALL_ACCEPTED"]="CALL_ACCEPTED";SANAR_EVENT_TYPE["CALL_REJECTED"]="CALL_REJECTED";SANAR_EVENT_TYPE["CALL_END_USER"]="CALL_END_USER";SANAR_EVENT_TYPE["CALL_END_PROVIDER"]="CALL_END_PROVIDER";return SANAR_EVENT_TYPE;}({});var CONNECTION_STATUS=exports.CONNECTION_STATUS=function(CONNECTION_STATUS){CONNECTION_STATUS[CONNECTION_STATUS["RINGING"]=0]="RINGING";CONNECTION_STATUS[CONNECTION_STATUS["CONNECTED"]=1]="CONNECTED";CONNECTION_STATUS[CONNECTION_STATUS["DISCONNECTED"]=2]="DISCONNECTED";return CONNECTION_STATUS;}({});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default class DotLoader extends React.Component<any, any, any> {
|
|
2
|
+
constructor(props: any);
|
|
3
|
+
constructor(props: any, context: any);
|
|
4
|
+
state: {
|
|
5
|
+
active: number;
|
|
6
|
+
};
|
|
7
|
+
componentDidMount(): void;
|
|
8
|
+
interval: NodeJS.Timeout | undefined;
|
|
9
|
+
componentWillUnmount(): void;
|
|
10
|
+
render(): React.JSX.Element;
|
|
11
|
+
}
|
|
12
|
+
import React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/Volumes/MarenExt/sdk/medgulf/ReactNative/rn-sanarkit-dev/src/common/DotLoader.js";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}function _callSuper(t,o,e){return o=(0,_getPrototypeOf2.default)(o),(0,_possibleConstructorReturn2.default)(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2.default)(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}var SIZE=7;var MARGIN=5;var BG='rgba(6, 111, 140,0.7)';var ACTIVE_BG='rgba(6, 111, 140,0.5)';var dots=[1,2,3];var INTERVAL=300;var ANIMATION_DURATION=400;var ANIMATION_SCALE=1.8;var DotLoader=exports.default=function(_React$Component){function DotLoader(){var _this;(0,_classCallCheck2.default)(this,DotLoader);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_callSuper(this,DotLoader,[].concat(args));_this.state={active:1};return _this;}(0,_inherits2.default)(DotLoader,_React$Component);return(0,_createClass2.default)(DotLoader,[{key:"componentDidMount",value:function componentDidMount(){var _this2=this;this.interval=setInterval(function(){var active=_this2.state.active;_this2.setState({active:active>2?1:active+1});},INTERVAL);}},{key:"componentWillUnmount",value:function componentWillUnmount(){clearInterval(this.interval);}},{key:"render",value:function render(){var _this3=this;var active=this.state.active;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.main,children:dots.map(function(i){return(0,_react.createElement)(Dot,Object.assign({},_this3.props,{active:i===active,key:i.toString(),__self:_this3,__source:{fileName:_jsxFileName,lineNumber:32,columnNumber:32}}));})});}}]);}(_react.default.Component);var Dot=function(_React$Component2){function Dot(props){var _this4;(0,_classCallCheck2.default)(this,Dot);_this4=_callSuper(this,Dot,[props]);_this4.scaleDown=function(){_reactNative.Animated.timing(_this4.scale,{toValue:1,duration:_this4.props.animationDuration,useNativeDriver:false}).start();};_this4.scaleUp=function(){_reactNative.Animated.timing(_this4.scale,{toValue:_this4.props.animationScale,duration:_this4.props.animationDuration,useNativeDriver:false}).start();};_this4.scale=new _reactNative.Animated.Value(1);return _this4;}(0,_inherits2.default)(Dot,_React$Component2);return(0,_createClass2.default)(Dot,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.active)this.scaleUp();}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(prevProps.active&&!this.props.active){this.scaleDown();}if(!prevProps.active&&this.props.active){this.scaleUp();}}},{key:"render",value:function render(){var _this$props=this.props,active=_this$props.active,size=_this$props.size,background=_this$props.background,activeBackground=_this$props.activeBackground,dotMargin=_this$props.dotMargin;var style={height:size,width:size,borderRadius:size/2,marginHorizontal:dotMargin,backgroundColor:active?activeBackground:background};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[style,{transform:[{scale:this.scale}]}]});}}]);}(_react.default.Component);Dot.defaultProps={size:SIZE,background:BG,activeBackground:ACTIVE_BG,dotMargin:MARGIN,animationDuration:ANIMATION_DURATION,animationScale:ANIMATION_SCALE};var styles=_reactNative.StyleSheet.create({main:{flexDirection:'row',justifyContent:'center',alignItems:'center'}});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default PermissionModal;
|
|
2
|
+
declare function PermissionModal(props: any): React.JSX.Element;
|
|
3
|
+
declare namespace PermissionModal {
|
|
4
|
+
namespace defaultProps {
|
|
5
|
+
let isVisible: boolean;
|
|
6
|
+
let camera: boolean;
|
|
7
|
+
let microphone: boolean;
|
|
8
|
+
let bluetooth: boolean;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
import React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Volumes/MarenExt/sdk/medgulf/ReactNative/rn-sanarkit-dev/src/common/PermissionModal.js";var PermissionModal=function PermissionModal(props){var isVisible=props.isVisible,camera=props.camera,microphone=props.microphone,bluetooth=props.bluetooth,closeModal=props.closeModal;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{animationType:"fade",visible:isVisible,transparent:true,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.modalContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.text,children:"Please enable required permission in settings"}),!camera&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.permission,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.icon,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{children:"Icon"})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.permissionText,children:"Camera"})]}),!microphone&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.permission,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.icon,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{children:"Icon"})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.permissionText,children:"Microphone"})]}),!bluetooth&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.permission,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.icon,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{children:"Icon"})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.permissionText,children:"Bluetooth"})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",marginTop:10},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.actionsContainer,children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.button,onPress:function onPress(){return _reactNative.Linking.openSettings();},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.buttonText,children:"Settings"})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.actionsContainer,{marginLeft:20}],children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.button,onPress:closeModal,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.buttonText,children:"Cancel"})})})]})]})})});};PermissionModal.defaultProps={isVisible:true,camera:true,microphone:true,bluetooth:true};var styles=_reactNative.StyleSheet.create({main:{flex:1,backgroundColor:'red'},container:{flex:1,alignItems:'center',justifyContent:'center',paddingHorizontal:50,backgroundColor:'rgba(0,0,0,0.4)'},modalContainer:{paddingVertical:20,paddingHorizontal:30,borderRadius:20,alignItems:'center',justifyContent:'center',borderWidth:1,backgroundColor:'white',borderColor:'rgba(0,0,0,0.4)'},text:{fontSize:16,fontWeight:'500',textAlign:'center',paddingVertical:5,color:'#39404f'},actionsContainer:{flex:1,alignItems:'center',justifyContent:'center',flexDirection:'row',backgroundColor:'#066f8c',padding:10,borderRadius:5},button:{flex:1,alignItems:'center',justifyContent:'center'},buttonText:{fontSize:15,fontWeight:'500',color:'white'},permission:{flexDirection:'row',alignItems:'center',paddingVertical:2,width:120},icon:{width:30,height:30,marginRight:10,alignItems:'center',justifyContent:'center'},permissionText:{fontSize:14,fontWeight:'400',color:'#999999'}});var _default=exports.default=PermissionModal;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function checkPermissions(): Promise<{
|
|
2
|
+
cameraPermission: any;
|
|
3
|
+
microphonePermission: any;
|
|
4
|
+
bluetoothPermission: any;
|
|
5
|
+
}>;
|
|
6
|
+
export function validatePermission(value: any): Promise<any>;
|
|
7
|
+
export function checkPermissionValue(value: any, status: any): Promise<any>;
|
|
8
|
+
export function requestPermission(value: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.checkPermissionValue=checkPermissionValue;exports.checkPermissions=checkPermissions;exports.requestPermission=requestPermission;exports.validatePermission=validatePermission;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _reactNative=require("react-native");var _reactNativePermissions=require("react-native-permissions");var alreadyCheckediOS,alreadyCheckedAndroid=false;function checkPermissions(){var cameraPermissionValues=_reactNative.Platform.OS=='ios'?_reactNativePermissions.PERMISSIONS.IOS.CAMERA:_reactNativePermissions.PERMISSIONS.ANDROID.CAMERA;var microphonePermissionValues=_reactNative.Platform.OS=='ios'?_reactNativePermissions.PERMISSIONS.IOS.MICROPHONE:_reactNativePermissions.PERMISSIONS.ANDROID.RECORD_AUDIO;var bluetoothPermissionValues=_reactNativePermissions.PERMISSIONS.ANDROID.BLUETOOTH_CONNECT;return validatePermission(cameraPermissionValues).then(function(result){var permissionCamera=result;return validatePermission(microphonePermissionValues).then(function(result1){var permissionMicroPhone=result1;if(_reactNative.Platform.OS=='android'){return validatePermission(bluetoothPermissionValues).then(function(result3){var permissionBluetooth=result3;return{cameraPermission:permissionCamera,microphonePermission:permissionMicroPhone,bluetoothPermission:permissionBluetooth};});}else{return{cameraPermission:permissionCamera,microphonePermission:permissionMicroPhone,bluetoothPermission:true};}});});}function validatePermission(_x){return _validatePermission.apply(this,arguments);}function _validatePermission(){_validatePermission=(0,_asyncToGenerator2.default)(function*(value){try{return(0,_reactNativePermissions.check)(value).then(function(statuses){return checkPermissionValue(value,statuses);});}catch(err){}});return _validatePermission.apply(this,arguments);}function checkPermissionValue(_x2,_x3){return _checkPermissionValue.apply(this,arguments);}function _checkPermissionValue(){_checkPermissionValue=(0,_asyncToGenerator2.default)(function*(value,status){switch(status){case _reactNativePermissions.RESULTS.DENIED:return yield requestPermission(value).then(function(result){return result;});break;case _reactNativePermissions.RESULTS.BLOCKED:return false;break;default:return true;break;}});return _checkPermissionValue.apply(this,arguments);}function requestPermission(_x4){return _requestPermission.apply(this,arguments);}function _requestPermission(){_requestPermission=(0,_asyncToGenerator2.default)(function*(value){return(0,_reactNativePermissions.request)(value).then(function(){var _ref=(0,_asyncToGenerator2.default)(function*(result){if(result==='blocked'){if(_reactNative.Platform.OS=="ios"){alreadyCheckediOS=true;}else{alreadyCheckedAndroid=true;}return false;}else if(result==='denied'){return yield requestPermission(value).then(function(result){return result;});}else{return true;}});return function(_x5){return _ref.apply(this,arguments);};}());});return _requestPermission.apply(this,arguments);}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var SanarContext=_react.default.createContext();var _default=exports.default=SanarContext;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default SanarProvider;
|
|
2
|
+
declare function SanarProvider({ children, enable, onCallStatusChange, isFullscreen, onViewModeChange }: {
|
|
3
|
+
children: any;
|
|
4
|
+
enable: any;
|
|
5
|
+
onCallStatusChange: any;
|
|
6
|
+
isFullscreen: any;
|
|
7
|
+
onViewModeChange: any;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
import React from "react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _Types=require("../Types");var _constants=require("../utils/constants");var _reactNativeAgora=require("react-native-agora");var _SanarKit=_interopRequireDefault(require("../SanarKit"));var _SanarContext=_interopRequireDefault(require("./SanarContext"));var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Volumes/MarenExt/sdk/medgulf/ReactNative/rn-sanarkit-dev/src/common/SanarProvider.js";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var SanarProvider=function SanarProvider(_ref){var children=_ref.children,enable=_ref.enable,onCallStatusChange=_ref.onCallStatusChange,isFullscreen=_ref.isFullscreen,onViewModeChange=_ref.onViewModeChange;var initialState={notification:null,message:false,ringing:false,status:_Types.CONNECTION_STATUS.DISCONNECTED};var reducer=function reducer(state,action){switch(action.type){case _constants.TELECALL:return Object.assign({},state,{ringing:action.value});case _constants.NOTIFICATION_PAYLOAD:return Object.assign({},state,{notification:action.value});case _constants.MESSAGE:return Object.assign({},state,{message:action.value});case _constants.ACCEPT_CALL:return Object.assign({},state,{status:action.value});case _constants.END_CALL:return Object.assign({},state,{status:action.value});default:return initialState;}};var _useReducer=(0,_react.useReducer)(reducer,initialState),_useReducer2=(0,_slicedToArray2.default)(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];(0,_react.useEffect)(function(){if(enable&&store.status==_Types.CONNECTION_STATUS.DISCONNECTED){if(_SanarKit.default.session){_SanarKit.default.eventListner.on(_Types.SANAR_EVENT_TYPE.Connect,function(){console.log('Connected with Sanar');});_SanarKit.default.eventListner.on(_Types.SANAR_EVENT_TYPE.Disconnect,function(){console.log('disconnected');onCallStatusChange(_Types.SANAR_EVENT_TYPE.Disconnect);});_SanarKit.default.eventListner.on(_Types.SANAR_EVENT_TYPE.Telecall,function(e){dispatch({type:_constants.NOTIFICATION_PAYLOAD,value:e});dispatch({type:_constants.TELECALL,value:true});onCallStatusChange(_Types.SANAR_EVENT_TYPE.CALL_INITIATED);});_SanarKit.default.eventListner.on(_Types.SANAR_EVENT_TYPE.ConnectError,function(){dispatch({type:_constants.END_CALL,value:_Types.CONNECTION_STATUS.DISCONNECTED});});_SanarKit.default.eventListner.on('CALL_REJECTED',function(e){store.setIsMinimized(false);store.resetStore();dispatch({type:""});onCallStatusChange(_Types.SANAR_EVENT_TYPE.CALL_END_PROVIDER);});}}else{dispatch({type:""});store.resetStore();_SanarKit.default.disconnect();}},[enable]);(0,_react.useEffect)(function(){if(isFullscreen&&store.isMinimized){store.setToggleFrame(isFullscreen);}},[isFullscreen]);var onDecline=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(){var _state$notification,_state$notification2;_SanarKit.default.eventListner.emit(_constants.REJECT_CALL,JSON.stringify({did:_SanarKit.default.info.did,headerToken:decodeURIComponent(_SanarKit.default.session.token),dsid:(_state$notification=state.notification)==null?void 0:_state$notification.sid,roomName:(_state$notification2=state.notification)==null?void 0:_state$notification2.roomName}));dispatch({type:_constants.TELECALL,value:false});dispatch({type:_constants.END_CALL,value:_Types.CONNECTION_STATUS.DISCONNECTED});store.setIsMinimized(false);if(store._engineRef){try{yield store._engineRef.leaveChannel();}catch(error){console.log('Error leaving channel on decline:',error);}}onCallStatusChange(_Types.SANAR_EVENT_TYPE.CALL_REJECTED);});return function onDecline(){return _ref2.apply(this,arguments);};}();var onAccept=function onAccept(){var _state$notification3,_state$notification4;dispatch({type:_constants.TELECALL,value:false});dispatch({type:_constants.ACCEPT_CALL,value:_Types.CONNECTION_STATUS.CONNECTED});_SanarKit.default.eventListner.emit(_constants.ACCEPT_CALL,JSON.stringify({did:_SanarKit.default.info.did,headerToken:decodeURIComponent(_SanarKit.default.session.token),dsid:(_state$notification3=state.notification)==null?void 0:_state$notification3.sid,roomName:(_state$notification4=state.notification)==null?void 0:_state$notification4.roomName}));onCallStatusChange(_Types.SANAR_EVENT_TYPE.CALL_ACCEPTED);};var onEnd=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(duration){var _state$notification5,_state$notification6;_SanarKit.default.eventListner.emit(_constants.REJECT_CALL,JSON.stringify({did:_SanarKit.default.info.did,headerToken:decodeURIComponent(_SanarKit.default.session.token),dsid:(_state$notification5=state.notification)==null?void 0:_state$notification5.sid,roomName:(_state$notification6=state.notification)==null?void 0:_state$notification6.roomName,duration:duration}));dispatch({type:_constants.END_CALL,value:_Types.CONNECTION_STATUS.DISCONNECTED});if(store._engineRef){yield store._engineRef.leaveChannel();}});return function onEnd(_x){return _ref3.apply(this,arguments);};}();var _toggleAudio=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(action){if(store._engineRef){yield store._engineRef.setEnableSpeakerphone(action);}});return function _toggleAudio(_x2){return _ref4.apply(this,arguments);};}();var _toggleVideo=function _toggleVideo(action){if(!store._engineRef)return;if(!action){setIsLocalVideo(false);store._engineRef.enableLocalVideo(false);store._engineRef.stopPreview();}else{setIsLocalVideo(true);store._engineRef.enableLocalVideo(true);store._engineRef.startPreview();}};var _toggleMute=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(action){if(!store._engineRef)return;if(!action){yield store._engineRef.muteLocalAudioStream(true);}else{yield store._engineRef.muteLocalAudioStream(false);}});return function _toggleMute(_x3){return _ref5.apply(this,arguments);};}();var _toggleCamera=function _toggleCamera(action){if(store._engineRef){store._engineRef.switchCamera();}};var _toggleWhiteBg=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(action){if(!store._engineRef)return;var source={backgroundSourceType:_reactNativeAgora.VirtualBackgroundSourceType.BackgroundColor,color:0xFFFFFF};if(!action){var segprop=new _reactNativeAgora.SegmentationProperty();segprop.modelType=1;segprop.greenCapacity=0.5;store._engineRef.enableVirtualBackground(true,source,segprop);}else{store._engineRef.enableVirtualBackground(false,source,new _reactNativeAgora.SegmentationProperty());}});return function _toggleWhiteBg(_x4){return _ref6.apply(this,arguments);};}();var _toggleBlurBg=function _toggleBlurBg(action){if(!store._engineRef)return;var source={backgroundSourceType:_reactNativeAgora.VirtualBackgroundSourceType.BackgroundBlur,blurDegree:_reactNativeAgora.BlurDegree.BlurDegreeMedium};if(!action){var segprop=new _reactNativeAgora.SegmentationProperty();segprop.modelType=1;segprop.greenCapacity=0.5;store._engineRef.enableVirtualBackground(true,source,segprop);}else{store._engineRef.enableVirtualBackground(false,source,new _reactNativeAgora.SegmentationProperty());}};var _useState=(0,_react.useState)(null),_useState2=(0,_slicedToArray2.default)(_useState,2),_engine=_useState2[0],set_Engine=_useState2[1];var _useState3=(0,_react.useState)([]),_useState4=(0,_slicedToArray2.default)(_useState3,2),_peerIds=_useState4[0],_setPeerIds=_useState4[1];var _useState5=(0,_react.useState)(false),_useState6=(0,_slicedToArray2.default)(_useState5,2),_intialFrame=_useState6[0],set_IntialFrame=_useState6[1];var _useState7=(0,_react.useState)(false),_useState8=(0,_slicedToArray2.default)(_useState7,2),_isPaused=_useState8[0],set_IsPaused=_useState8[1];var _useState9=(0,_react.useState)(false),_useState10=(0,_slicedToArray2.default)(_useState9,2),_openChat=_useState10[0],set_OpenChat=_useState10[1];var _useState11=(0,_react.useState)(false),_useState12=(0,_slicedToArray2.default)(_useState11,2),_isMinimized=_useState12[0],set_IsMinimized=_useState12[1];var _useState13=(0,_react.useState)(false),_useState14=(0,_slicedToArray2.default)(_useState13,2),shouldToggleFrame=_useState14[0],setShouldToggleFrame=_useState14[1];var _useState15=(0,_react.useState)(false),_useState16=(0,_slicedToArray2.default)(_useState15,2),isLocalVideo=_useState16[0],setIsLocalVideo=_useState16[1];var store={notification:state.notification,ringing:state.ringing,status:state.status,isChatOpen:_openChat,newMessage:state.message,brandLogo:true,_engineRef:_engine,_peerIds:_peerIds,intialFrame:_intialFrame,isPaused:_isPaused,isMinimized:_isMinimized,shouldToggleFrame:shouldToggleFrame,isLocalVideoPaused:isLocalVideo,acceptCall:function acceptCall(){onAccept();},pauseLocalVideo:function pauseLocalVideo(action){_toggleVideo(action);},disconnectCall:function disconnectCall(){onDecline();},endCall:function endCall(duration){onCallStatusChange(_Types.SANAR_EVENT_TYPE.CALL_END_USER);onEnd(duration);},setEngineRef:function setEngineRef(ref){set_Engine(ref);},setPeerIds:function setPeerIds(data){_setPeerIds(data);},switchFrame:function switchFrame(){set_IntialFrame(!_intialFrame);},setVideoPaused:function setVideoPaused(state){set_IsPaused(state);},openChatPage:function openChatPage(){set_OpenChat(true);},closeChatPage:function closeChatPage(){set_OpenChat(false);},resetStore:function resetStore(){set_OpenChat(false);_setPeerIds([]);set_IntialFrame(false);set_IsPaused(false);dispatch({type:""});},onClickControl:function onClickControl(type,value){switch(type){case"CAMERA":_toggleCamera(value);break;case"AUDIO":_toggleAudio(value);break;case"MUTE":_toggleMute(value);break;case"VIDEO":_toggleVideo(value);break;case"WHITE_BG":_toggleWhiteBg(value);break;case"BLUR_BG":_toggleBlurBg(value);break;default:break;}},setIsMinimized:function setIsMinimized(val){return set_IsMinimized(val);},setToggleFrame:function setToggleFrame(val){return setShouldToggleFrame(val);}};(0,_react.useEffect)(function(){onViewModeChange(store.isMinimized?"minimized":"fullscreen");},[_isMinimized]);return(0,_jsxRuntime.jsx)(_SanarContext.default.Provider,{value:store,children:children});};var _default=exports.default=SanarProvider;
|