@cloudflare/realtimekit-react-native 0.1.4-staging.1 → 0.1.4-staging.10

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 (92) hide show
  1. package/lib/commonjs/AudioSampleHandler.js +61 -0
  2. package/lib/commonjs/AudioSampleHandler.js.map +1 -0
  3. package/lib/commonjs/BackgroundHandler.js +109 -0
  4. package/lib/commonjs/BackgroundHandler.js.map +1 -0
  5. package/lib/commonjs/DeviceInfo.js +37 -0
  6. package/lib/commonjs/DeviceInfo.js.map +1 -0
  7. package/lib/commonjs/LocalMediaError.js +18 -0
  8. package/lib/commonjs/LocalMediaError.js.map +1 -0
  9. package/lib/commonjs/LocalMediaHandler.js +791 -0
  10. package/lib/commonjs/LocalMediaHandler.js.map +1 -0
  11. package/lib/commonjs/LocalMediaInterfaces.js +2 -0
  12. package/lib/commonjs/LocalMediaInterfaces.js.map +1 -0
  13. package/lib/commonjs/LocalMediaUtils.js +298 -0
  14. package/lib/commonjs/LocalMediaUtils.js.map +1 -0
  15. package/lib/commonjs/NativeAudioManager.js +72 -0
  16. package/lib/commonjs/NativeAudioManager.js.map +1 -0
  17. package/lib/commonjs/PermissionHandler.js +157 -0
  18. package/lib/commonjs/PermissionHandler.js.map +1 -0
  19. package/lib/commonjs/ReactContext.js +116 -0
  20. package/lib/commonjs/ReactContext.js.map +1 -0
  21. package/lib/commonjs/ReactHooks.js +99 -0
  22. package/lib/commonjs/ReactHooks.js.map +1 -0
  23. package/lib/commonjs/index.js +95 -0
  24. package/lib/commonjs/index.js.map +1 -0
  25. package/lib/commonjs/utils/constants.js +7 -0
  26. package/lib/commonjs/utils/constants.js.map +1 -0
  27. package/lib/commonjs/utils/crypto.js +76 -0
  28. package/lib/commonjs/utils/crypto.js.map +1 -0
  29. package/lib/commonjs/utils/version.js +8 -0
  30. package/lib/commonjs/utils/version.js.map +1 -0
  31. package/lib/module/AudioSampleHandler.js +54 -0
  32. package/lib/module/AudioSampleHandler.js.map +1 -0
  33. package/lib/module/BackgroundHandler.js +103 -0
  34. package/lib/module/BackgroundHandler.js.map +1 -0
  35. package/lib/module/DeviceInfo.js +31 -0
  36. package/lib/module/DeviceInfo.js.map +1 -0
  37. package/lib/module/LocalMediaError.js +11 -0
  38. package/lib/module/LocalMediaError.js.map +1 -0
  39. package/lib/module/LocalMediaHandler.js +784 -0
  40. package/lib/module/LocalMediaHandler.js.map +1 -0
  41. package/lib/module/LocalMediaInterfaces.js +2 -0
  42. package/lib/module/LocalMediaInterfaces.js.map +1 -0
  43. package/lib/module/LocalMediaUtils.js +290 -0
  44. package/lib/module/LocalMediaUtils.js.map +1 -0
  45. package/lib/module/NativeAudioManager.js +65 -0
  46. package/lib/module/NativeAudioManager.js.map +1 -0
  47. package/lib/module/PermissionHandler.js +149 -0
  48. package/lib/module/PermissionHandler.js.map +1 -0
  49. package/lib/module/ReactContext.js +107 -0
  50. package/lib/module/ReactContext.js.map +1 -0
  51. package/lib/module/ReactHooks.js +75 -0
  52. package/lib/module/ReactHooks.js.map +1 -0
  53. package/lib/{src → module}/index.js +32 -32
  54. package/lib/module/index.js.map +1 -0
  55. package/lib/module/utils/constants.js +5 -0
  56. package/lib/module/utils/constants.js.map +1 -0
  57. package/lib/module/utils/crypto.js +74 -0
  58. package/lib/module/utils/crypto.js.map +1 -0
  59. package/lib/module/utils/version.js +2 -0
  60. package/lib/module/utils/version.js.map +1 -0
  61. package/lib/{src → typescript}/LocalMediaHandler.d.ts +0 -4
  62. package/lib/{src → typescript}/ReactHooks.d.ts +2 -2
  63. package/lib/typescript/utils/constants.d.ts +1 -0
  64. package/lib/typescript/utils/version.d.ts +1 -0
  65. package/package.json +5 -4
  66. package/plugin/build/withRTK.js +43 -17
  67. package/plugin/src/withRTK.ts +55 -25
  68. package/android/src/main/res/values/strings.xml +0 -3
  69. package/lib/package.json +0 -168
  70. package/lib/src/AudioSampleHandler.js +0 -57
  71. package/lib/src/BackgroundHandler.js +0 -100
  72. package/lib/src/DeviceInfo.js +0 -27
  73. package/lib/src/LocalMediaError.js +0 -6
  74. package/lib/src/LocalMediaHandler.js +0 -860
  75. package/lib/src/LocalMediaInterfaces.js +0 -1
  76. package/lib/src/LocalMediaUtils.js +0 -288
  77. package/lib/src/NativeAudioManager.js +0 -93
  78. package/lib/src/PermissionHandler.js +0 -179
  79. package/lib/src/ReactContext.js +0 -90
  80. package/lib/src/ReactHooks.js +0 -80
  81. package/lib/src/utils/crypto.js +0 -82
  82. /package/lib/{src → typescript}/AudioSampleHandler.d.ts +0 -0
  83. /package/lib/{src → typescript}/BackgroundHandler.d.ts +0 -0
  84. /package/lib/{src → typescript}/DeviceInfo.d.ts +0 -0
  85. /package/lib/{src → typescript}/LocalMediaError.d.ts +0 -0
  86. /package/lib/{src → typescript}/LocalMediaInterfaces.d.ts +0 -0
  87. /package/lib/{src → typescript}/LocalMediaUtils.d.ts +0 -0
  88. /package/lib/{src → typescript}/NativeAudioManager.d.ts +0 -0
  89. /package/lib/{src → typescript}/PermissionHandler.d.ts +0 -0
  90. /package/lib/{src → typescript}/ReactContext.d.ts +0 -0
  91. /package/lib/{src → typescript}/index.d.ts +0 -0
  92. /package/lib/{src → typescript}/utils/crypto.d.ts +0 -0
@@ -1,8 +1,8 @@
1
- import RealtimeKitClient from '@cloudflare/realtimekit';
1
+ import RealtimeKitClient, { RealtimeKitClientOptions } from '@cloudflare/realtimekit';
2
2
  /**
3
3
  * Hook which manages a RealtimeKitClient instance
4
4
  */
5
- export declare const useRealtimeKitClient: () => [RealtimeKitClient | undefined, (options: any) => {}];
5
+ export declare const useRealtimeKitClient: () => [RealtimeKitClient | undefined, (options: RealtimeKitClientOptions) => {}];
6
6
  type StateSelector<T extends object, U> = (state: T) => U;
7
7
  /**
8
8
  * @deprecated Use `useRealtimeKitSelector` instead.
@@ -0,0 +1 @@
1
+ export const BASE_SDK_VERSION: "0.1.4";
@@ -0,0 +1 @@
1
+ export declare const SDK_VERSION = "0.1.4-staging.10";
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@cloudflare/realtimekit-react-native",
3
- "version": "0.1.4-staging.1",
3
+ "version": "0.1.4-staging.10",
4
4
  "description": "Cloudflare RealtimeKit SDK for react native",
5
- "main": "lib/index.js",
5
+ "main": "lib/commonjs/index",
6
6
  "author": "Cloudflare",
7
7
  "homepage": "https://realtime.cloudflare.com",
8
- "types": "lib/index.d.ts",
8
+ "module": "lib/module/index",
9
+ "types": "lib/typescript/index.d.ts",
9
10
  "files": [
10
11
  "lib",
11
12
  "android",
@@ -25,7 +26,7 @@
25
26
  },
26
27
  "private": false,
27
28
  "dependencies": {
28
- "@cloudflare/realtimekit": "1.1.7-staging.2",
29
+ "@cloudflare/realtimekit": "1.1.7",
29
30
  "events": "^3.3.0",
30
31
  "fast-base64-decode": "1.0.0",
31
32
  "node-libs-react-native": "^1.2.1",
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config_plugins_1 = require("@expo/config-plugins");
4
4
  const MICROPHONE = 'Allow $(PRODUCT_NAME) to access the microphone';
5
5
  const CAMERA = 'Allow $(PRODUCT_NAME) to access the camera';
6
- const BLUETOOTH = 'Allow $(PRODUCT_NAME) to access the bluetooth';
7
- const BLUETOOTH_ALWAYS = 'Allow $(PRODUCT_NAME) to access the bluetooth';
8
6
  const LIBRARY = 'Allow $(PRODUCT_NAME) to access the files';
9
7
  /**
10
8
  * Adds `NSMicrophoneUsageDescription` and `NSSpeechRecognitionUsageDescription` to the `Info.plist`.
@@ -13,7 +11,7 @@ const LIBRARY = 'Allow $(PRODUCT_NAME) to access the files';
13
11
  * @param props.microphonePermission microphone permission message
14
12
  * @returns
15
13
  */
16
- const withIosPermissions = (c, { microphonePermission, cameraPermission, libraryPermission, bluetoothPermission, bluetoothAlwaysPermission, } = {}) => {
14
+ const withIosPermissions = (c, { microphonePermission, cameraPermission, libraryPermission } = {}) => {
17
15
  return (0, config_plugins_1.withInfoPlist)(c, (config) => {
18
16
  if (microphonePermission !== false) {
19
17
  config.modResults.NSMicrophoneUsageDescription =
@@ -27,18 +25,6 @@ const withIosPermissions = (c, { microphonePermission, cameraPermission, library
27
25
  config.modResults.NSCameraUsageDescription ||
28
26
  CAMERA;
29
27
  }
30
- if (bluetoothPermission !== false) {
31
- config.modResults.NSBluetoothPeripheralUsageDescription =
32
- bluetoothPermission ||
33
- config.modResults.NSBluetoothPeripheralUsageDescription ||
34
- BLUETOOTH;
35
- }
36
- if (bluetoothAlwaysPermission !== false) {
37
- config.modResults.NSBluetoothAlwaysUsageDescription =
38
- bluetoothAlwaysPermission ||
39
- config.modResults.NSBluetoothAlwaysUsageDescription ||
40
- BLUETOOTH_ALWAYS;
41
- }
42
28
  if (libraryPermission !== false) {
43
29
  config.modResults.NSPhotoLibraryUsageDescription =
44
30
  libraryPermission ||
@@ -81,20 +67,60 @@ const withAndroidPermissions = (config) => {
81
67
  'android.permission.SYSTEM_ALERT_WINDOW',
82
68
  'android.permission.WAKE_LOCK',
83
69
  'android.permission.FOREGROUND_SERVICE',
84
- 'android.permission.FOREGROUND_SERVICE_CAMERA',
85
- 'android.permission.FOREGROUND_SERVICE_MICROPHONE',
86
70
  'android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION',
87
71
  'android.permission.WRITE_EXTERNAL_STORAGE',
88
72
  'android.permission.READ_EXTERNAL_STORAGE',
89
73
  'android.permission.MICROPHONE',
90
74
  ]);
91
75
  };
76
+ const withAndroidScreenshare = (config) => {
77
+ return (0, config_plugins_1.withAndroidManifest)(config, (_config) => {
78
+ const manifest = _config.modResults;
79
+ const app = manifest.manifest.application?.[0];
80
+ if (app) {
81
+ // Avoid duplicate entries
82
+ const exists = (app.service || []).some((service) => service.$['android:name'] ===
83
+ 'com.cloudflare.realtimekit.ForegroundService');
84
+ if (!exists) {
85
+ app.service = [
86
+ ...(app.service || []),
87
+ {
88
+ $: {
89
+ 'android:enabled': 'true',
90
+ 'android:foregroundServiceType': 'mediaProjection',
91
+ 'android:name': 'com.cloudflare.realtimekit.ForegroundService',
92
+ },
93
+ },
94
+ ];
95
+ }
96
+ }
97
+ return _config;
98
+ });
99
+ };
100
+ const withAndroidBlobProviderAuthority = (config) => {
101
+ return (0, config_plugins_1.withStringsXml)(config, async (_config) => {
102
+ // Avoid duplicates
103
+ const existing = _config.modResults.resources.string?.find((item) => item.$.name === 'blob_provider_authority');
104
+ if (!existing) {
105
+ _config.modResults.resources.string = [
106
+ ...(_config.modResults.resources.string || []),
107
+ {
108
+ $: { name: 'blob_provider_authority' },
109
+ _: 'com.cloudflare.realtimekit.expo.blobs',
110
+ },
111
+ ];
112
+ }
113
+ return _config;
114
+ });
115
+ };
92
116
  const withVoice = (config, props = {}) => {
93
117
  const _props = props ? props : {};
94
118
  config = withIosPermissions(config, _props);
95
119
  if (_props.microphonePermission !== false) {
96
120
  config = withAndroidPermissions(config);
97
121
  }
122
+ config = withAndroidScreenshare(config);
123
+ config = withAndroidBlobProviderAuthority(config);
98
124
  return config;
99
125
  };
100
126
  exports.default = (0, config_plugins_1.createRunOncePlugin)(withVoice, '@cloudflare/realtimekit-react-native');
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  AndroidConfig,
3
+ AndroidManifest,
3
4
  ConfigPlugin,
4
5
  createRunOncePlugin,
6
+ withAndroidManifest,
5
7
  withInfoPlist,
8
+ withStringsXml,
6
9
  } from '@expo/config-plugins';
7
10
 
8
11
  const MICROPHONE = 'Allow $(PRODUCT_NAME) to access the microphone';
9
12
  const CAMERA = 'Allow $(PRODUCT_NAME) to access the camera';
10
- const BLUETOOTH = 'Allow $(PRODUCT_NAME) to access the bluetooth';
11
- const BLUETOOTH_ALWAYS = 'Allow $(PRODUCT_NAME) to access the bluetooth';
12
13
  const LIBRARY = 'Allow $(PRODUCT_NAME) to access the files';
13
14
 
14
15
  export type Props = {
@@ -47,13 +48,7 @@ export type Props = {
47
48
  */
48
49
  const withIosPermissions: ConfigPlugin<Props> = (
49
50
  c,
50
- {
51
- microphonePermission,
52
- cameraPermission,
53
- libraryPermission,
54
- bluetoothPermission,
55
- bluetoothAlwaysPermission,
56
- } = {}
51
+ { microphonePermission, cameraPermission, libraryPermission } = {}
57
52
  ) => {
58
53
  return withInfoPlist(c, (config) => {
59
54
  if (microphonePermission !== false) {
@@ -70,20 +65,6 @@ const withIosPermissions: ConfigPlugin<Props> = (
70
65
  CAMERA;
71
66
  }
72
67
 
73
- if (bluetoothPermission !== false) {
74
- config.modResults.NSBluetoothPeripheralUsageDescription =
75
- bluetoothPermission ||
76
- config.modResults.NSBluetoothPeripheralUsageDescription ||
77
- BLUETOOTH;
78
- }
79
-
80
- if (bluetoothAlwaysPermission !== false) {
81
- config.modResults.NSBluetoothAlwaysUsageDescription =
82
- bluetoothAlwaysPermission ||
83
- config.modResults.NSBluetoothAlwaysUsageDescription ||
84
- BLUETOOTH_ALWAYS;
85
- }
86
-
87
68
  if (libraryPermission !== false) {
88
69
  config.modResults.NSPhotoLibraryUsageDescription =
89
70
  libraryPermission ||
@@ -129,8 +110,6 @@ const withAndroidPermissions: ConfigPlugin = (config) => {
129
110
  'android.permission.SYSTEM_ALERT_WINDOW',
130
111
  'android.permission.WAKE_LOCK',
131
112
  'android.permission.FOREGROUND_SERVICE',
132
- 'android.permission.FOREGROUND_SERVICE_CAMERA',
133
- 'android.permission.FOREGROUND_SERVICE_MICROPHONE',
134
113
  'android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION',
135
114
  'android.permission.WRITE_EXTERNAL_STORAGE',
136
115
  'android.permission.READ_EXTERNAL_STORAGE',
@@ -138,12 +117,63 @@ const withAndroidPermissions: ConfigPlugin = (config) => {
138
117
  ]);
139
118
  };
140
119
 
120
+ const withAndroidScreenshare: ConfigPlugin = (config) => {
121
+ return withAndroidManifest(config, (_config) => {
122
+ const manifest = _config.modResults as AndroidManifest;
123
+ const app = manifest.manifest.application?.[0];
124
+
125
+ if (app) {
126
+ // Avoid duplicate entries
127
+ const exists = (app.service || []).some(
128
+ (service) =>
129
+ service.$['android:name'] ===
130
+ 'com.cloudflare.realtimekit.ForegroundService'
131
+ );
132
+ if (!exists) {
133
+ app.service = [
134
+ ...(app.service || []),
135
+ {
136
+ $: {
137
+ 'android:enabled': 'true',
138
+ 'android:foregroundServiceType': 'mediaProjection',
139
+ 'android:name': 'com.cloudflare.realtimekit.ForegroundService',
140
+ },
141
+ },
142
+ ];
143
+ }
144
+ }
145
+
146
+ return _config;
147
+ });
148
+ };
149
+
150
+ const withAndroidBlobProviderAuthority: ConfigPlugin = (config) => {
151
+ return withStringsXml(config, async (_config) => {
152
+ // Avoid duplicates
153
+ const existing = _config.modResults.resources.string?.find(
154
+ (item) => item.$.name === 'blob_provider_authority'
155
+ );
156
+ if (!existing) {
157
+ _config.modResults.resources.string = [
158
+ ...(_config.modResults.resources.string || []),
159
+ {
160
+ $: { name: 'blob_provider_authority' },
161
+ _: 'com.cloudflare.realtimekit.expo.blobs',
162
+ },
163
+ ];
164
+ }
165
+ return _config;
166
+ });
167
+ };
168
+
141
169
  const withVoice: ConfigPlugin<Props | void> = (config, props = {}) => {
142
170
  const _props = props ? props : {};
143
171
  config = withIosPermissions(config, _props);
144
172
  if (_props.microphonePermission !== false) {
145
173
  config = withAndroidPermissions(config);
146
174
  }
175
+ config = withAndroidScreenshare(config);
176
+ config = withAndroidBlobProviderAuthority(config);
147
177
  return config;
148
178
  };
149
179
 
@@ -1,3 +0,0 @@
1
- <resources>
2
- <string name="blob_provider_authority">com.cloudflare.realtimekit.blobs</string>
3
- </resources>
package/lib/package.json DELETED
@@ -1,168 +0,0 @@
1
- {
2
- "name": "@cloudflare/realtimekit-react-native",
3
- "version": "1.1.4-staging.1",
4
- "description": "Cloudflare RealtimeKit SDK for react native",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "source": "src/index",
8
- "publishConfig": {
9
- "registry": "https://registry.npmjs.org/",
10
- "access": "public",
11
- "tag": "latest"
12
- },
13
- "files": [
14
- "lib",
15
- "android",
16
- "ios",
17
- "cpp",
18
- "plugin",
19
- "app.plugin.js",
20
- "RealtimeKitCore.podspec",
21
- "!android/build",
22
- "!ios/build",
23
- "!**/__tests__",
24
- "!**/__fixtures__",
25
- "!**/__mocks__"
26
- ],
27
- "scripts": {
28
- "test": "jest",
29
- "typescript": "tsc -p tsconfig.build.json",
30
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
31
- "prepare": "npm run typescript && tsc --build plugin",
32
- "release": "release-it",
33
- "example": "yarn --cwd example",
34
- "pods": "cd example && pod-install --quiet",
35
- "bootstrap": "yarn example && yarn && yarn pods",
36
- "prepublishOnly": "cp package.json package.json.bak && node prepublish.js",
37
- "postpublish": "mv package.json.bak package.json"
38
- },
39
- "keywords": [
40
- "react-native",
41
- "ios",
42
- "android"
43
- ],
44
- "repository": "https://github.com/cloudflare",
45
- "author": "Cloudflare",
46
- "license": "UNLICENSED",
47
- "bugs": {
48
- "url": "https://realtime.cloudflare.com/issues"
49
- },
50
- "homepage": "https://realtime.cloudflare.com",
51
- "dependencies": {
52
- "@cloudflare/realtimekit": "1.1.7-staging.2",
53
- "events": "^3.3.0",
54
- "fast-base64-decode": "1.0.0",
55
- "node-libs-react-native": "^1.2.1",
56
- "react-native-url-polyfill": "1.3.0",
57
- "text-encoding-polyfill": "^0.6.7"
58
- },
59
- "devDependencies": {
60
- "@commitlint/config-conventional": "^11.0.0",
61
- "@cloudflare/react-native-webrtc": "^125.0.1",
62
- "@react-native-community/eslint-config": "3.0.0",
63
- "@release-it/conventional-changelog": "^2.0.0",
64
- "@semantic-release/changelog": "^5.0.1",
65
- "@semantic-release/commit-analyzer": "^8.0.1",
66
- "@semantic-release/exec": "^5.0.0",
67
- "@semantic-release/git": "^9.0.1",
68
- "@semantic-release/npm": "^7.1.3",
69
- "@semantic-release/release-notes-generator": "^9.0.3",
70
- "@types/jest": "^26.0.0",
71
- "@types/react": "18.0.25",
72
- "@types/react-dom": "18.0.9",
73
- "@types/react-native": "0.67.1",
74
- "@typescript-eslint/eslint-plugin": "^6.21.0",
75
- "@typescript-eslint/parser": "^6.21.0",
76
- "babel-plugin-module-resolver": "^5.0.0",
77
- "commitlint": "^11.0.0",
78
- "eslint": "^7.2.0",
79
- "eslint-config-prettier": "^7.0.0",
80
- "eslint-plugin-prettier": "^3.1.3",
81
- "eslint-plugin-react-native": "^4.1.0",
82
- "expo-module-scripts": "^3.1.0",
83
- "husky": "^6.0.0",
84
- "i": "^0.3.7",
85
- "jest": "^26.0.1",
86
- "metro-react-native-babel-preset": "^0.77.0",
87
- "npm": "^9.2.0",
88
- "pod-install": "^0.1.0",
89
- "prettier": "^2.0.5",
90
- "react": "18.2.0",
91
- "react-native": "0.73.2",
92
- "react-native-builder-bob": "^0.18.0",
93
- "typescript": "^5.3.3"
94
- },
95
- "peerDependencies": {
96
- "@cloudflare/react-native-webrtc": "~125.0.1",
97
- "@expo/config-plugins": "*",
98
- "react": "*",
99
- "react-native": "*"
100
- },
101
- "jest": {
102
- "preset": "react-native",
103
- "testEnvironment": "node",
104
- "modulePathIgnorePatterns": [
105
- "<rootDir>/example/node_modules",
106
- "<rootDir>/lib/"
107
- ]
108
- },
109
- "commitlint": {
110
- "extends": [
111
- "@commitlint/config-conventional"
112
- ]
113
- },
114
- "eslintConfig": {
115
- "root": true,
116
- "parser": "@typescript-eslint/parser",
117
- "plugins": [
118
- "@typescript-eslint"
119
- ],
120
- "extends": [
121
- "@react-native-community",
122
- "prettier"
123
- ],
124
- "globals": {
125
- "NodeJS": true,
126
- "React": true,
127
- "JSX": true
128
- },
129
- "rules": {
130
- "prettier/prettier": [
131
- "error",
132
- {
133
- "quoteProps": "consistent",
134
- "singleQuote": true,
135
- "tabWidth": 2,
136
- "trailingComma": "es5",
137
- "useTabs": false
138
- }
139
- ]
140
- }
141
- },
142
- "eslintIgnore": [
143
- "node_modules/",
144
- "lib/",
145
- "plugin/build"
146
- ],
147
- "prettier": {
148
- "quoteProps": "consistent",
149
- "singleQuote": true,
150
- "tabWidth": 2,
151
- "trailingComma": "es5",
152
- "useTabs": false
153
- },
154
- "react-native-builder-bob": {
155
- "source": "src",
156
- "output": "lib",
157
- "targets": [
158
- "commonjs",
159
- "module",
160
- [
161
- "typescript",
162
- {
163
- "project": "tsconfig.build.json"
164
- }
165
- ]
166
- ]
167
- }
168
- }
@@ -1,57 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { NativeEventEmitter, NativeModules, Platform, } from 'react-native';
11
- import { EventEmitter } from 'events';
12
- const { WebRTCModule } = NativeModules;
13
- export default class AudioSampleHandler extends EventEmitter {
14
- constructor() {
15
- super();
16
- this._isListening = false;
17
- this.webRTCModuleEmitter = new NativeEventEmitter(WebRTCModule);
18
- this._audioSampleHandler = this._audioSampleHandler.bind(this);
19
- this._currentSamples = new Float32Array(1024);
20
- this.initialiseSampler();
21
- }
22
- static init() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- return new AudioSampleHandler();
25
- });
26
- }
27
- _audioSampleHandler(audioData) {
28
- this._currentSamples.fill(0);
29
- if (Platform.OS === 'android') {
30
- this._currentSamples.set(audioData);
31
- }
32
- else {
33
- this._currentSamples.set(audioData.samples);
34
- }
35
- }
36
- initialiseSampler() {
37
- this._audioSamplesListener = this.webRTCModuleEmitter.addListener('audioSamples', this._audioSampleHandler);
38
- this._isListening = true;
39
- }
40
- getFloatTimeDomainData(samples) {
41
- if (!this._isListening) {
42
- this.initialiseSampler();
43
- }
44
- samples.set(this._currentSamples);
45
- }
46
- stopListening() {
47
- if (this._audioSamplesListener) {
48
- this._audioSamplesListener.remove();
49
- this._audioSamplesListener = undefined;
50
- this._isListening = false;
51
- this._currentSamples.fill(0);
52
- }
53
- }
54
- destructor() {
55
- this.stopListening();
56
- }
57
- }
@@ -1,100 +0,0 @@
1
- import { DeviceEventEmitter, NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform, } from 'react-native';
2
- const { RTKRNBackgroundTimer } = NativeModules;
3
- const Emitter = new NativeEventEmitter(RTKRNBackgroundTimer);
4
- class BackgroundTimer {
5
- constructor() {
6
- this.uniqueId = 0;
7
- this.callbacks = {};
8
- Emitter.addListener('backgroundTimer.timeout', (id) => {
9
- if (this.callbacks[id]) {
10
- const callbackById = this.callbacks[id];
11
- const { callback } = callbackById;
12
- if (!this.callbacks[id].interval) {
13
- delete this.callbacks[id];
14
- }
15
- else {
16
- Platform.OS === 'android'
17
- ? RTKRNBackgroundTimer.backgroundTimerSetTimeout(id, this.callbacks[id].timeout)
18
- : RTKRNBackgroundTimer.setTimeout(id, this.callbacks[id].timeout);
19
- }
20
- callback();
21
- }
22
- });
23
- }
24
- init() {
25
- return new BackgroundTimer();
26
- }
27
- // Original API
28
- start(delay = 0) {
29
- return Platform.OS === 'android'
30
- ? RTKRNBackgroundTimer.backgroundTimerStart(delay)
31
- : RTKRNBackgroundTimer.start(delay);
32
- }
33
- stop() {
34
- Emitter.removeAllListeners('backgroundTimer.timeout');
35
- return Platform.OS === 'android'
36
- ? RTKRNBackgroundTimer.backgroundTimerStop()
37
- : RTKRNBackgroundTimer.stop();
38
- }
39
- runBackgroundTimer(callback, delay) {
40
- const EventEmitter = Platform.select({
41
- ios: () => NativeAppEventEmitter,
42
- android: () => DeviceEventEmitter,
43
- })();
44
- this.start(0);
45
- this.backgroundListener = EventEmitter.addListener('backgroundTimer', () => {
46
- this.backgroundListener.remove();
47
- this.backgroundClockMethod(callback, delay);
48
- });
49
- }
50
- backgroundClockMethod(callback, delay) {
51
- this.backgroundTimer = this.setTimeout(() => {
52
- callback();
53
- this.backgroundClockMethod(callback, delay);
54
- }, delay);
55
- }
56
- stopBackgroundTimer() {
57
- this.stop();
58
- this.clearTimeout(this.backgroundTimer);
59
- }
60
- // New API, allowing for multiple timers
61
- setTimeout(callback, timeout) {
62
- this.uniqueId += 1;
63
- const timeoutId = this.uniqueId;
64
- this.callbacks[timeoutId] = {
65
- callback,
66
- interval: false,
67
- timeout,
68
- };
69
- Platform.OS === 'android'
70
- ? RTKRNBackgroundTimer.backgroundTimerSetTimeout(timeoutId, timeout)
71
- : RTKRNBackgroundTimer.setTimeout(timeoutId, timeout);
72
- return timeoutId;
73
- }
74
- clearTimeout(timeoutId) {
75
- if (this.callbacks[timeoutId]) {
76
- delete this.callbacks[timeoutId];
77
- // RTKRNBackgroundTimer.clearTimeout(timeoutId);
78
- }
79
- }
80
- setInterval(callback, timeout) {
81
- this.uniqueId += 1;
82
- const intervalId = this.uniqueId;
83
- this.callbacks[intervalId] = {
84
- callback,
85
- interval: true,
86
- timeout,
87
- };
88
- Platform.OS === 'android'
89
- ? RTKRNBackgroundTimer.backgroundTimerSetTimeout(intervalId, timeout)
90
- : RTKRNBackgroundTimer.setTimeout(intervalId, timeout);
91
- return intervalId;
92
- }
93
- clearInterval(intervalId) {
94
- if (this.callbacks[intervalId]) {
95
- delete this.callbacks[intervalId];
96
- // RTKRNBackgroundTimer.clearTimeout(intervalId);
97
- }
98
- }
99
- }
100
- export default new BackgroundTimer();
@@ -1,27 +0,0 @@
1
- import { Platform } from 'react-native';
2
- import sdk_package from '../package.json';
3
- class DeviceInfo {
4
- constructor() {
5
- this.deviceInfo = {
6
- isMobile: true,
7
- isReactNative: true,
8
- osName: Platform.OS,
9
- osVersion: Platform.Version,
10
- reactNativeVersion: this.getReactNativeVersion(),
11
- sdkType: 'realtimekit-react-native',
12
- reactNativeSdkVersion: this.getSdkVersion(),
13
- };
14
- }
15
- getSdkVersion() {
16
- const version = sdk_package.version;
17
- return '0.1.4' + version.slice(5);
18
- }
19
- getReactNativeVersion() {
20
- const version = Platform.constants.reactNativeVersion;
21
- return version.major + '.' + version.minor + '.' + version.patch;
22
- }
23
- getDeviceInfo() {
24
- return this.deviceInfo;
25
- }
26
- }
27
- export default new DeviceInfo();
@@ -1,6 +0,0 @@
1
- export default class LocalMediaError extends Error {
2
- constructor(message, code) {
3
- super(message);
4
- this.code = code;
5
- }
6
- }