@cloudflare/realtimekit-react-native 0.0.0 → 0.0.1-staging.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +83 -0
  3. package/RealtimeKitCore.podspec +19 -0
  4. package/android/build.gradle +58 -0
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  7. package/android/gradlew +185 -0
  8. package/android/gradlew.bat +89 -0
  9. package/android/src/main/AndroidManifest.xml +23 -0
  10. package/android/src/main/java/com/reactnativecore/BackgroundTimer/RNBackgroundTimer.java +97 -0
  11. package/android/src/main/java/com/reactnativecore/Constants.java +14 -0
  12. package/android/src/main/java/com/reactnativecore/CoreModule.java +49 -0
  13. package/android/src/main/java/com/reactnativecore/CorePackage.java +34 -0
  14. package/android/src/main/java/com/reactnativecore/DyteHelperModule.java +268 -0
  15. package/android/src/main/java/com/reactnativecore/DyteHolder.java +7 -0
  16. package/android/src/main/java/com/reactnativecore/ForegroundService.java +48 -0
  17. package/android/src/main/java/com/reactnativecore/NotificationHelper.java +127 -0
  18. package/android/src/main/java/com/reactnativecore/RNPermissionsModule.java +226 -0
  19. package/android/src/main/java/com/reactnativecore/incallmanager/AppRTCBluetoothManager.java +637 -0
  20. package/android/src/main/java/com/reactnativecore/incallmanager/AppRTCProximitySensor.java +133 -0
  21. package/android/src/main/java/com/reactnativecore/incallmanager/AppRTCUtils.java +41 -0
  22. package/android/src/main/java/com/reactnativecore/incallmanager/InCallManagerModule.java +1881 -0
  23. package/android/src/main/java/com/reactnativecore/incallmanager/InCallProximityManager.java +162 -0
  24. package/android/src/main/java/com/reactnativecore/incallmanager/InCallWakeLockUtils.java +116 -0
  25. package/android/src/main/java/com/reactnativecore/incallmanager/ThreadUtils.java +39 -0
  26. package/app.plugin.js +1 -0
  27. package/ios/BroadcastEventEmitter.h +11 -0
  28. package/ios/BroadcastEventEmitter.m +72 -0
  29. package/ios/Core.h +5 -0
  30. package/ios/Core.m +28 -0
  31. package/ios/Core.xcodeproj/project.pbxproj +287 -0
  32. package/ios/DyteRNBackgroundTimer.h +22 -0
  33. package/ios/DyteRNBackgroundTimer.m +90 -0
  34. package/ios/DyteRNPermissionHandlerNotifications.h +17 -0
  35. package/ios/DyteRNPermissionHandlerNotifications.m +127 -0
  36. package/ios/DyteRNPermissions.h +50 -0
  37. package/ios/DyteRNPermissions.m +275 -0
  38. package/ios/DyteScreensharePickerView.h +8 -0
  39. package/ios/DyteScreensharePickerView.m +27 -0
  40. package/ios/PrivacyInfo.xcprivacy +60 -0
  41. package/ios/RNInCallManager.h +16 -0
  42. package/ios/RNInCallManager.m +1354 -0
  43. package/ios/permissions/DyteRNPermissionHandlerBluetoothPeripheral.h +4 -0
  44. package/ios/permissions/DyteRNPermissionHandlerBluetoothPeripheral.m +87 -0
  45. package/ios/permissions/DyteRNPermissionHandlerCamera.h +5 -0
  46. package/ios/permissions/DyteRNPermissionHandlerCamera.m +38 -0
  47. package/ios/permissions/DyteRNPermissionHandlerMicrophone.h +5 -0
  48. package/ios/permissions/DyteRNPermissionHandlerMicrophone.m +34 -0
  49. package/ios/permissions/DyteRNPermissionHandlerPhotoLibrary.h +8 -0
  50. package/ios/permissions/DyteRNPermissionHandlerPhotoLibrary.m +70 -0
  51. package/ios/screenshare/DyteDarwinNotificationCenter.swift +21 -0
  52. package/ios/screenshare/DyteScreenshareAtomic.swift +29 -0
  53. package/ios/screenshare/DyteScreenshareHandler.swift +103 -0
  54. package/ios/screenshare/DyteScreenshareUploader.swift +139 -0
  55. package/ios/screenshare/DyteSocketConnection.swift +190 -0
  56. package/lib/BackgroundHandler.d.ts +20 -0
  57. package/lib/BackgroundHandler.js +87 -0
  58. package/lib/LocalMediaError.d.ts +4 -0
  59. package/lib/LocalMediaError.js +6 -0
  60. package/lib/LocalMediaHandler.d.ts +118 -0
  61. package/lib/LocalMediaHandler.js +853 -0
  62. package/lib/LocalMediaInterfaces.d.ts +76 -0
  63. package/lib/LocalMediaInterfaces.js +1 -0
  64. package/lib/LocalMediaUtils.d.ts +93 -0
  65. package/lib/LocalMediaUtils.js +276 -0
  66. package/lib/NativeAudioManager.d.ts +16 -0
  67. package/lib/NativeAudioManager.js +93 -0
  68. package/lib/PermissionHandler.d.ts +34 -0
  69. package/lib/PermissionHandler.js +179 -0
  70. package/lib/ReactContext.d.ts +42 -0
  71. package/lib/ReactContext.js +96 -0
  72. package/lib/ReactHooks.d.ts +11 -0
  73. package/lib/ReactHooks.js +73 -0
  74. package/lib/index.d.ts +10 -0
  75. package/lib/index.js +40 -0
  76. package/lib/utils/crypto.d.ts +17 -0
  77. package/lib/utils/crypto.js +82 -0
  78. package/package.json +51 -4
  79. package/plugin/build/withDyte.d.ts +25 -0
  80. package/plugin/build/withDyte.js +100 -0
  81. package/plugin/src/withDyte.ts +150 -0
  82. package/plugin/tsconfig.json +10 -0
  83. package/plugin/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,133 @@
1
+ /*
2
+ * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license
5
+ * that can be found in the LICENSE file in the root of the source
6
+ * tree. An additional intellectual property rights grant can be found
7
+ * in the file PATENTS. All contributing project authors may
8
+ * be found in the AUTHORS file in the root of the source tree.
9
+ */
10
+ package com.reactnativecore.incallmanager;
11
+ import android.content.Context;
12
+ import android.hardware.Sensor;
13
+ import android.hardware.SensorEvent;
14
+ import android.hardware.SensorEventListener;
15
+ import android.hardware.SensorManager;
16
+ import android.os.Build;
17
+ import android.util.Log;
18
+ import androidx.annotation.Nullable;
19
+ import com.reactnativecore.incallmanager.AppRTCUtils;
20
+ import com.reactnativecore.incallmanager.ThreadUtils;
21
+ /**
22
+ * AppRTCProximitySensor manages functions related to the proximity sensor in
23
+ * the AppRTC demo.
24
+ * On most device, the proximity sensor is implemented as a boolean-sensor.
25
+ * It returns just two values "NEAR" or "FAR". Thresholding is done on the LUX
26
+ * value i.e. the LUX value of the light sensor is compared with a threshold.
27
+ * A LUX-value more than the threshold means the proximity sensor returns "FAR".
28
+ * Anything less than the threshold value and the sensor returns "NEAR".
29
+ */
30
+ public class AppRTCProximitySensor implements SensorEventListener {
31
+ private static final String TAG = "dytesdk:AppRTCProximity";
32
+ // This class should be created, started and stopped on one thread
33
+ // (e.g. the main thread). We use `nonThreadSafe` to ensure that this is
34
+ // the case. Only active when `DEBUG` is set to true.
35
+ private final ThreadUtils.ThreadChecker threadChecker = new ThreadUtils.ThreadChecker();
36
+ private final Runnable onSensorStateListener;
37
+ private final SensorManager sensorManager;
38
+ @Nullable private Sensor proximitySensor;
39
+ private boolean lastStateReportIsNear;
40
+ /** Construction */
41
+ public static AppRTCProximitySensor create(Context context, Runnable sensorStateListener) {
42
+ return new AppRTCProximitySensor(context, sensorStateListener);
43
+ }
44
+ private AppRTCProximitySensor(Context context, Runnable sensorStateListener) {
45
+ onSensorStateListener = sensorStateListener;
46
+ sensorManager = ((SensorManager) context.getSystemService(Context.SENSOR_SERVICE));
47
+ }
48
+ /**
49
+ * Activate the proximity sensor. Also do initialization if called for the
50
+ * first time.
51
+ */
52
+ public boolean start() {
53
+ threadChecker.checkIsOnValidThread();
54
+ if (!initDefaultSensor()) {
55
+ // Proximity sensor is not supported on this device.
56
+ return false;
57
+ }
58
+ sensorManager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_NORMAL);
59
+ return true;
60
+ }
61
+ /** Deactivate the proximity sensor. */
62
+ public void stop() {
63
+ threadChecker.checkIsOnValidThread();
64
+ if (proximitySensor == null) {
65
+ return;
66
+ }
67
+ sensorManager.unregisterListener(this, proximitySensor);
68
+ }
69
+ /** Getter for last reported state. Set to true if "near" is reported. */
70
+ public boolean sensorReportsNearState() {
71
+ threadChecker.checkIsOnValidThread();
72
+ return lastStateReportIsNear;
73
+ }
74
+ @Override
75
+ public final void onAccuracyChanged(Sensor sensor, int accuracy) {
76
+ threadChecker.checkIsOnValidThread();
77
+ AppRTCUtils.assertIsTrue(sensor.getType() == Sensor.TYPE_PROXIMITY);
78
+ if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
79
+ // Log.e(TAG, "The values returned by this sensor cannot be trusted");
80
+ }
81
+ }
82
+ @Override
83
+ public final void onSensorChanged(SensorEvent event) {
84
+ threadChecker.checkIsOnValidThread();
85
+ AppRTCUtils.assertIsTrue(event.sensor.getType() == Sensor.TYPE_PROXIMITY);
86
+ // As a best practice; do as little as possible within this method and
87
+ // avoid blocking.
88
+ float distanceInCentimeters = event.values[0];
89
+ if (distanceInCentimeters < proximitySensor.getMaximumRange()) {
90
+ lastStateReportIsNear = true;
91
+ } else {
92
+ lastStateReportIsNear = false;
93
+ }
94
+ // Report about new state to listening client. Client can then call
95
+ // sensorReportsNearState() to query the current state (NEAR or FAR).
96
+ // if (onSensorStateListener != null) {
97
+ // onSensorStateListener.run();
98
+ // }
99
+ }
100
+ /**
101
+ * Get default proximity sensor if it exists. Tablet devices (e.g. Nexus 7)
102
+ * does not support this type of sensor and false will be returned in such
103
+ * cases.
104
+ */
105
+ private boolean initDefaultSensor() {
106
+ if (proximitySensor != null) {
107
+ return true;
108
+ }
109
+ proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
110
+ if (proximitySensor == null) {
111
+ return false;
112
+ }
113
+ logProximitySensorInfo();
114
+ return true;
115
+ }
116
+ /** Helper method for logging information about the proximity sensor. */
117
+ private void logProximitySensorInfo() {
118
+ if (proximitySensor == null) {
119
+ return;
120
+ }
121
+ StringBuilder info = new StringBuilder("Proximity sensor: ");
122
+ info.append("name=").append(proximitySensor.getName());
123
+ info.append(", vendor: ").append(proximitySensor.getVendor());
124
+ info.append(", power: ").append(proximitySensor.getPower());
125
+ info.append(", resolution: ").append(proximitySensor.getResolution());
126
+ info.append(", max range: ").append(proximitySensor.getMaximumRange());
127
+ info.append(", min delay: ").append(proximitySensor.getMinDelay());
128
+ info.append(", type: ").append(proximitySensor.getStringType());
129
+ info.append(", max delay: ").append(proximitySensor.getMaxDelay());
130
+ info.append(", reporting mode: ").append(proximitySensor.getReportingMode());
131
+ info.append(", isWakeUpSensor: ").append(proximitySensor.isWakeUpSensor());
132
+ }
133
+ }
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license
5
+ * that can be found in the LICENSE file in the root of the source
6
+ * tree. An additional intellectual property rights grant can be found
7
+ * in the file PATENTS. All contributing project authors may
8
+ * be found in the AUTHORS file in the root of the source tree.
9
+ */
10
+ package com.reactnativecore.incallmanager;
11
+ import android.os.Build;
12
+ import android.util.Log;
13
+ /**
14
+ * AppRTCUtils provides helper functions for managing thread safety.
15
+ */
16
+ public final class AppRTCUtils {
17
+ private AppRTCUtils() {}
18
+ /** Helper method which throws an exception when an assertion has failed. */
19
+ public static void assertIsTrue(boolean condition) {
20
+ if (!condition) {
21
+ throw new AssertionError("Expected condition to be true");
22
+ }
23
+ }
24
+ /** Helper method for building a string of thread information.*/
25
+ public static String getThreadInfo() {
26
+ return "@[name=" + Thread.currentThread().getName() + ", id=" + Thread.currentThread().getId()
27
+ + "]";
28
+ }
29
+ /** Information about the current build, taken from system properties. */
30
+ public static void logDeviceInfo(String tag) {
31
+ // Log.d(tag, "Android SDK: " + Build.VERSION.SDK_INT + ", "
32
+ // + "Release: " + Build.VERSION.RELEASE + ", "
33
+ // + "Brand: " + Build.BRAND + ", "
34
+ // + "Device: " + Build.DEVICE + ", "
35
+ // + "Id: " + Build.ID + ", "
36
+ // + "Hardware: " + Build.HARDWARE + ", "
37
+ // + "Manufacturer: " + Build.MANUFACTURER + ", "
38
+ // + "Model: " + Build.MODEL + ", "
39
+ // + "Product: " + Build.PRODUCT);
40
+ }
41
+ }