@fishjam-cloud/react-native-client 0.23.0 → 0.25.0-rc.1

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 (262) hide show
  1. package/README.md +56 -15
  2. package/dist/index.d.ts +13 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +19 -0
  5. package/dist/overrides/RTCPeerConnection.d.ts +8 -0
  6. package/dist/overrides/RTCPeerConnection.d.ts.map +1 -0
  7. package/dist/overrides/RTCPeerConnection.js +16 -0
  8. package/dist/overrides/RTCView.d.ts +11 -0
  9. package/dist/overrides/RTCView.d.ts.map +1 -0
  10. package/dist/overrides/RTCView.js +21 -0
  11. package/dist/polyfills/local-storage.d.ts +10 -0
  12. package/dist/polyfills/local-storage.d.ts.map +1 -0
  13. package/dist/polyfills/local-storage.js +24 -0
  14. package/{build/hooks → dist}/useForegroundService.d.ts +10 -10
  15. package/dist/useForegroundService.d.ts.map +1 -0
  16. package/dist/useForegroundService.js +10 -0
  17. package/dist/webrtc-polyfill.d.ts +2 -0
  18. package/dist/webrtc-polyfill.d.ts.map +1 -0
  19. package/dist/webrtc-polyfill.js +14 -0
  20. package/package.json +44 -92
  21. package/plugin/broadcastExtensionFiles/Atomic.swift +37 -0
  22. package/plugin/broadcastExtensionFiles/DarwinNotificationCenter.swift +29 -0
  23. package/plugin/broadcastExtensionFiles/Info.plist +2 -2
  24. package/plugin/broadcastExtensionFiles/SampleHandler.swift +104 -0
  25. package/plugin/broadcastExtensionFiles/SampleUploader.swift +146 -0
  26. package/plugin/broadcastExtensionFiles/SocketConnection.swift +198 -0
  27. package/plugin/build/types.d.ts +5 -3
  28. package/plugin/build/withFishjam.d.ts +31 -2
  29. package/plugin/build/withFishjam.js +32 -6
  30. package/plugin/build/withFishjamAndroid.d.ts +2 -2
  31. package/plugin/build/withFishjamAndroid.js +60 -13
  32. package/plugin/build/withFishjamIos.d.ts +3 -8
  33. package/plugin/build/withFishjamIos.js +54 -69
  34. package/plugin/src/types.ts +19 -0
  35. package/plugin/src/withFishjam.ts +42 -0
  36. package/plugin/src/withFishjamAndroid.ts +112 -0
  37. package/plugin/src/withFishjamIos.ts +336 -0
  38. package/plugin/tsconfig.json +9 -0
  39. package/plugin/tsconfig.tsbuildinfo +1 -0
  40. package/LICENSE.txt +0 -201
  41. package/android/build.gradle +0 -95
  42. package/android/src/main/AndroidManifest.xml +0 -2
  43. package/android/src/main/java/io/fishjam/reactnative/AudioDeviceKind.kt +0 -34
  44. package/android/src/main/java/io/fishjam/reactnative/AudioSwitchManager.kt +0 -61
  45. package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +0 -126
  46. package/android/src/main/java/io/fishjam/reactnative/Errors.kt +0 -31
  47. package/android/src/main/java/io/fishjam/reactnative/PipContainerView.kt +0 -282
  48. package/android/src/main/java/io/fishjam/reactnative/PipContainerViewModule.kt +0 -41
  49. package/android/src/main/java/io/fishjam/reactnative/PipTrackSelector.kt +0 -98
  50. package/android/src/main/java/io/fishjam/reactnative/PipViewFactory.kt +0 -186
  51. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +0 -1001
  52. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +0 -358
  53. package/android/src/main/java/io/fishjam/reactnative/Utils.kt +0 -11
  54. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +0 -40
  55. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewViewModule.kt +0 -22
  56. package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +0 -76
  57. package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +0 -33
  58. package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +0 -257
  59. package/android/src/main/java/io/fishjam/reactnative/extensions/CaptureDevice.kt +0 -17
  60. package/android/src/main/java/io/fishjam/reactnative/foregroundService/FishjamForegroundService.kt +0 -101
  61. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceManager.kt +0 -118
  62. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceState.kt +0 -46
  63. package/android/src/main/java/io/fishjam/reactnative/helpers/PictureInPictureHelperFragment.kt +0 -20
  64. package/android/src/main/java/io/fishjam/reactnative/managers/ListenerManager.kt +0 -24
  65. package/android/src/main/java/io/fishjam/reactnative/managers/LocalCameraTracksChangedListenersManager.kt +0 -8
  66. package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt +0 -17
  67. package/android/src/main/java/io/fishjam/reactnative/managers/TracksUpdateListenersManager.kt +0 -7
  68. package/android/src/main/java/io/fishjam/reactnative/utils/PermissionUtils.kt +0 -45
  69. package/build/RNFishjamClientModule.d.ts +0 -106
  70. package/build/RNFishjamClientModule.d.ts.map +0 -1
  71. package/build/RNFishjamClientModule.js +0 -21
  72. package/build/RNFishjamClientModule.js.map +0 -1
  73. package/build/common/metadata.d.ts +0 -9
  74. package/build/common/metadata.d.ts.map +0 -1
  75. package/build/common/metadata.js +0 -11
  76. package/build/common/metadata.js.map +0 -1
  77. package/build/components/FishjamRoom/GridTrackItem.d.ts +0 -12
  78. package/build/components/FishjamRoom/GridTrackItem.d.ts.map +0 -1
  79. package/build/components/FishjamRoom/GridTrackItem.js +0 -56
  80. package/build/components/FishjamRoom/GridTrackItem.js.map +0 -1
  81. package/build/components/FishjamRoom/VideosGrid.d.ts +0 -3
  82. package/build/components/FishjamRoom/VideosGrid.d.ts.map +0 -1
  83. package/build/components/FishjamRoom/VideosGrid.js +0 -20
  84. package/build/components/FishjamRoom/VideosGrid.js.map +0 -1
  85. package/build/components/FishjamRoom/index.d.ts +0 -33
  86. package/build/components/FishjamRoom/index.d.ts.map +0 -1
  87. package/build/components/FishjamRoom/index.js +0 -53
  88. package/build/components/FishjamRoom/index.js.map +0 -1
  89. package/build/components/FishjamRoom/parsePeersToTracks.d.ts +0 -4
  90. package/build/components/FishjamRoom/parsePeersToTracks.d.ts.map +0 -1
  91. package/build/components/FishjamRoom/parsePeersToTracks.js +0 -37
  92. package/build/components/FishjamRoom/parsePeersToTracks.js.map +0 -1
  93. package/build/components/PipContainerView.d.ts +0 -48
  94. package/build/components/PipContainerView.d.ts.map +0 -1
  95. package/build/components/PipContainerView.js +0 -34
  96. package/build/components/PipContainerView.js.map +0 -1
  97. package/build/components/VideoPreviewView.d.ts +0 -28
  98. package/build/components/VideoPreviewView.d.ts.map +0 -1
  99. package/build/components/VideoPreviewView.js +0 -17
  100. package/build/components/VideoPreviewView.js.map +0 -1
  101. package/build/components/VideoRendererView.d.ts +0 -39
  102. package/build/components/VideoRendererView.d.ts.map +0 -1
  103. package/build/components/VideoRendererView.js +0 -25
  104. package/build/components/VideoRendererView.js.map +0 -1
  105. package/build/consts/index.d.ts +0 -5
  106. package/build/consts/index.d.ts.map +0 -1
  107. package/build/consts/index.js +0 -8
  108. package/build/consts/index.js.map +0 -1
  109. package/build/debug/common/webRTC.d.ts +0 -9
  110. package/build/debug/common/webRTC.d.ts.map +0 -1
  111. package/build/debug/common/webRTC.js +0 -11
  112. package/build/debug/common/webRTC.js.map +0 -1
  113. package/build/debug/index.d.ts +0 -4
  114. package/build/debug/index.d.ts.map +0 -1
  115. package/build/debug/index.js +0 -3
  116. package/build/debug/index.js.map +0 -1
  117. package/build/debug/stats/types.d.ts +0 -55
  118. package/build/debug/stats/types.d.ts.map +0 -1
  119. package/build/debug/stats/types.js +0 -2
  120. package/build/debug/stats/types.js.map +0 -1
  121. package/build/debug/stats/useRTCStatistics.d.ts +0 -9
  122. package/build/debug/stats/useRTCStatistics.d.ts.map +0 -1
  123. package/build/debug/stats/useRTCStatistics.js +0 -79
  124. package/build/debug/stats/useRTCStatistics.js.map +0 -1
  125. package/build/hooks/internal/useFishjamEvent.d.ts +0 -4
  126. package/build/hooks/internal/useFishjamEvent.d.ts.map +0 -1
  127. package/build/hooks/internal/useFishjamEvent.js +0 -38
  128. package/build/hooks/internal/useFishjamEvent.js.map +0 -1
  129. package/build/hooks/internal/useFishjamEventState.d.ts +0 -3
  130. package/build/hooks/internal/useFishjamEventState.d.ts.map +0 -1
  131. package/build/hooks/internal/useFishjamEventState.js +0 -18
  132. package/build/hooks/internal/useFishjamEventState.js.map +0 -1
  133. package/build/hooks/useAppScreenShare.d.ts +0 -20
  134. package/build/hooks/useAppScreenShare.d.ts.map +0 -1
  135. package/build/hooks/useAppScreenShare.js +0 -54
  136. package/build/hooks/useAppScreenShare.js.map +0 -1
  137. package/build/hooks/useAudioSettings.d.ts +0 -49
  138. package/build/hooks/useAudioSettings.d.ts.map +0 -1
  139. package/build/hooks/useAudioSettings.js +0 -70
  140. package/build/hooks/useAudioSettings.js.map +0 -1
  141. package/build/hooks/useBandwidthEstimation.d.ts +0 -14
  142. package/build/hooks/useBandwidthEstimation.d.ts.map +0 -1
  143. package/build/hooks/useBandwidthEstimation.js +0 -19
  144. package/build/hooks/useBandwidthEstimation.js.map +0 -1
  145. package/build/hooks/useCallKit.d.ts +0 -121
  146. package/build/hooks/useCallKit.d.ts.map +0 -1
  147. package/build/hooks/useCallKit.js +0 -142
  148. package/build/hooks/useCallKit.js.map +0 -1
  149. package/build/hooks/useCamera.d.ts +0 -113
  150. package/build/hooks/useCamera.d.ts.map +0 -1
  151. package/build/hooks/useCamera.js +0 -95
  152. package/build/hooks/useCamera.js.map +0 -1
  153. package/build/hooks/useConnection.d.ts +0 -73
  154. package/build/hooks/useConnection.d.ts.map +0 -1
  155. package/build/hooks/useConnection.js +0 -46
  156. package/build/hooks/useConnection.js.map +0 -1
  157. package/build/hooks/useForegroundService.d.ts.map +0 -1
  158. package/build/hooks/useForegroundService.js +0 -66
  159. package/build/hooks/useForegroundService.js.map +0 -1
  160. package/build/hooks/useMicrophone.d.ts +0 -16
  161. package/build/hooks/useMicrophone.d.ts.map +0 -1
  162. package/build/hooks/useMicrophone.js +0 -31
  163. package/build/hooks/useMicrophone.js.map +0 -1
  164. package/build/hooks/usePeerStatus.d.ts +0 -10
  165. package/build/hooks/usePeerStatus.d.ts.map +0 -1
  166. package/build/hooks/usePeerStatus.js +0 -13
  167. package/build/hooks/usePeerStatus.js.map +0 -1
  168. package/build/hooks/usePeers.d.ts +0 -98
  169. package/build/hooks/usePeers.d.ts.map +0 -1
  170. package/build/hooks/usePeers.js +0 -81
  171. package/build/hooks/usePeers.js.map +0 -1
  172. package/build/hooks/usePermissions.d.ts +0 -24
  173. package/build/hooks/usePermissions.d.ts.map +0 -1
  174. package/build/hooks/usePermissions.js +0 -61
  175. package/build/hooks/usePermissions.js.map +0 -1
  176. package/build/hooks/useReconnection.d.ts +0 -11
  177. package/build/hooks/useReconnection.d.ts.map +0 -1
  178. package/build/hooks/useReconnection.js +0 -14
  179. package/build/hooks/useReconnection.js.map +0 -1
  180. package/build/hooks/useSandbox.d.ts +0 -20
  181. package/build/hooks/useSandbox.d.ts.map +0 -1
  182. package/build/hooks/useSandbox.js +0 -54
  183. package/build/hooks/useSandbox.js.map +0 -1
  184. package/build/hooks/useScreenShare.d.ts +0 -37
  185. package/build/hooks/useScreenShare.d.ts.map +0 -1
  186. package/build/hooks/useScreenShare.js +0 -52
  187. package/build/hooks/useScreenShare.js.map +0 -1
  188. package/build/hooks/useUpdatePeerMetadata.d.ts +0 -15
  189. package/build/hooks/useUpdatePeerMetadata.d.ts.map +0 -1
  190. package/build/hooks/useUpdatePeerMetadata.js +0 -21
  191. package/build/hooks/useUpdatePeerMetadata.js.map +0 -1
  192. package/build/index.d.ts +0 -36
  193. package/build/index.d.ts.map +0 -1
  194. package/build/index.js +0 -30
  195. package/build/index.js.map +0 -1
  196. package/build/livestream/components/LivestreamStreamer.d.ts +0 -24
  197. package/build/livestream/components/LivestreamStreamer.d.ts.map +0 -1
  198. package/build/livestream/components/LivestreamStreamer.js +0 -12
  199. package/build/livestream/components/LivestreamStreamer.js.map +0 -1
  200. package/build/livestream/components/LivestreamViewer.d.ts +0 -46
  201. package/build/livestream/components/LivestreamViewer.d.ts.map +0 -1
  202. package/build/livestream/components/LivestreamViewer.js +0 -10
  203. package/build/livestream/components/LivestreamViewer.js.map +0 -1
  204. package/build/livestream/hooks/useLivestreamStreamer.d.ts +0 -65
  205. package/build/livestream/hooks/useLivestreamStreamer.d.ts.map +0 -1
  206. package/build/livestream/hooks/useLivestreamStreamer.js +0 -72
  207. package/build/livestream/hooks/useLivestreamStreamer.js.map +0 -1
  208. package/build/livestream/hooks/useLivestreamViewer.d.ts +0 -36
  209. package/build/livestream/hooks/useLivestreamViewer.d.ts.map +0 -1
  210. package/build/livestream/hooks/useLivestreamViewer.js +0 -73
  211. package/build/livestream/hooks/useLivestreamViewer.js.map +0 -1
  212. package/build/livestream/index.d.ts +0 -11
  213. package/build/livestream/index.d.ts.map +0 -1
  214. package/build/livestream/index.js +0 -6
  215. package/build/livestream/index.js.map +0 -1
  216. package/build/protos/fishjam/peer_notifications.d.ts +0 -63
  217. package/build/protos/fishjam/peer_notifications.d.ts.map +0 -1
  218. package/build/protos/fishjam/peer_notifications.js +0 -235
  219. package/build/protos/fishjam/peer_notifications.js.map +0 -1
  220. package/build/types.d.ts +0 -34
  221. package/build/types.d.ts.map +0 -1
  222. package/build/types.js +0 -2
  223. package/build/types.js.map +0 -1
  224. package/build/utils/config.d.ts +0 -6
  225. package/build/utils/config.d.ts.map +0 -1
  226. package/build/utils/config.js +0 -10
  227. package/build/utils/config.js.map +0 -1
  228. package/build/utils/errorListener.d.ts +0 -2
  229. package/build/utils/errorListener.d.ts.map +0 -1
  230. package/build/utils/errorListener.js +0 -15
  231. package/build/utils/errorListener.js.map +0 -1
  232. package/build/utils/eventPayloadValidator.d.ts +0 -3
  233. package/build/utils/eventPayloadValidator.d.ts.map +0 -1
  234. package/build/utils/eventPayloadValidator.js +0 -86
  235. package/build/utils/eventPayloadValidator.js.map +0 -1
  236. package/build/utils/getFishjamUrl.d.ts +0 -2
  237. package/build/utils/getFishjamUrl.d.ts.map +0 -1
  238. package/build/utils/getFishjamUrl.js +0 -10
  239. package/build/utils/getFishjamUrl.js.map +0 -1
  240. package/debug/package.json +0 -4
  241. package/expo-module.config.json +0 -19
  242. package/ios/CameraPermissionsRequester.swift +0 -117
  243. package/ios/Events.swift +0 -152
  244. package/ios/PictureInPictureManager.swift +0 -215
  245. package/ios/PipContainerView.swift +0 -56
  246. package/ios/PipContainerViewModule.swift +0 -48
  247. package/ios/RNFishjamClient.podspec +0 -30
  248. package/ios/RNFishjamClient.swift +0 -995
  249. package/ios/RNFishjamClientModule.swift +0 -289
  250. package/ios/RNFishjamProxy.swift +0 -12
  251. package/ios/Utils/PermissionUtils.swift +0 -16
  252. package/ios/Utils.swift +0 -23
  253. package/ios/VideoPreviewView.swift +0 -54
  254. package/ios/VideoPreviewViewModule.swift +0 -21
  255. package/ios/VideoRendererView.swift +0 -98
  256. package/ios/VideoRendererViewModule.swift +0 -23
  257. package/ios/extensions/AVCaptureDevice.swift +0 -20
  258. package/ios/managers/LocalCameraTracksChangedListenersManager.swift +0 -23
  259. package/ios/managers/TracksUpdateListenersManager.swift +0 -21
  260. package/livestream/package.json +0 -4
  261. package/plugin/broadcastExtensionFiles/FishjamBroadcastSampleHandler.swift +0 -50
  262. /package/plugin/broadcastExtensionFiles/{FishjamScreenBroadcastExtension.entitlements → ScreenBroadcastExtension.entitlements} +0 -0
@@ -0,0 +1,336 @@
1
+ import type { ConfigPlugin } from '@expo/config-plugins';
2
+ import { withEntitlementsPlist, withInfoPlist, withPodfileProperties, withXcodeProject } from '@expo/config-plugins';
3
+ import * as path from 'path';
4
+ import * as fs from 'promise-fs';
5
+
6
+ import type { FishjamPluginOptions } from './types';
7
+
8
+ function getSbeTargetName(props: FishjamPluginOptions) {
9
+ return props?.ios?.broadcastExtensionTargetName || 'ScreenBroadcastExtension';
10
+ }
11
+
12
+ function getSbeDisplayName(props: FishjamPluginOptions) {
13
+ return props?.ios?.broadcastExtensionDisplayName || 'ScreenBroadcast';
14
+ }
15
+
16
+ const TARGETED_DEVICE_FAMILY = `"1,2"`;
17
+ const IPHONEOS_DEPLOYMENT_TARGET = '15.1';
18
+ const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
19
+ const BUNDLE_IDENTIFIER_TEMPLATE_REGEX = /{{BUNDLE_IDENTIFIER}}/gm;
20
+ const DISPLAY_NAME_TEMPLATE_REGEX = /{{DISPLAY_NAME}}/gm;
21
+
22
+ /**
23
+ * A helper function for updating a value in a file for given regex
24
+ */
25
+ async function updateFileWithRegex(
26
+ iosPath: string,
27
+ fileName: string,
28
+ regex: RegExp,
29
+ value: string,
30
+ props: FishjamPluginOptions,
31
+ ) {
32
+ const targetName = getSbeTargetName(props);
33
+ const filePath = `${iosPath}/${targetName}/${fileName}`;
34
+ let file = await fs.readFile(filePath, { encoding: 'utf-8' });
35
+ file = file.replace(regex, value);
36
+ await fs.writeFile(filePath, file);
37
+ }
38
+
39
+ /**
40
+ * Adds "App Group" permission
41
+ * App Group allows your app and the ScreenBroadcastExtension to communicate with each other.
42
+ */
43
+ const withAppGroupPermissions: ConfigPlugin<FishjamPluginOptions> = (config, props) => {
44
+ const APP_GROUP_KEY = 'com.apple.security.application-groups';
45
+ const bundleIdentifier = config.ios?.bundleIdentifier || '';
46
+ const groupIdentifier = props?.ios?.appGroupContainerId || `group.${bundleIdentifier}`;
47
+ const mainTarget = props?.ios?.mainTargetName || '';
48
+
49
+ config.ios ??= {};
50
+ config.ios.entitlements ??= {};
51
+ config.ios.entitlements[APP_GROUP_KEY] ??= [];
52
+
53
+ const entitlementsArray = config.ios.entitlements[APP_GROUP_KEY] as string[];
54
+ if (!entitlementsArray.includes(groupIdentifier)) {
55
+ entitlementsArray.push(groupIdentifier);
56
+ }
57
+
58
+ config = withEntitlementsPlist(config, (newConfig) => {
59
+ const modResultsArray = (newConfig.modResults[APP_GROUP_KEY] as string[]) || [];
60
+ if (!modResultsArray.includes(groupIdentifier)) {
61
+ modResultsArray.push(groupIdentifier);
62
+ }
63
+ newConfig.modResults[APP_GROUP_KEY] = modResultsArray;
64
+ return newConfig;
65
+ });
66
+
67
+ // eslint-disable-next-line no-shadow
68
+ config = withXcodeProject(config, (props) => {
69
+ const xcodeProject = props.modResults;
70
+ const targets = xcodeProject.getFirstTarget();
71
+ const project = xcodeProject.getFirstProject();
72
+
73
+ if (!targets || !project) {
74
+ return props;
75
+ }
76
+
77
+ const targetUuid = targets.uuid;
78
+ const projectUuid = project.uuid;
79
+
80
+ const projectObj = xcodeProject.hash.project.objects.PBXProject[projectUuid];
81
+ projectObj.attributes ??= {};
82
+ projectObj.attributes.TargetAttributes ??= {};
83
+ projectObj.attributes.TargetAttributes[targetUuid] ??= {};
84
+ projectObj.attributes.TargetAttributes[targetUuid].SystemCapabilities ??= {};
85
+
86
+ projectObj.attributes.TargetAttributes[targetUuid].SystemCapabilities['com.apple.ApplicationGroups.iOS'] = {
87
+ enabled: 1,
88
+ };
89
+
90
+ const mainTargetName = mainTarget || props.modRequest.projectName;
91
+ const entitlementsFilePath = `${mainTargetName}/${mainTargetName}.entitlements`;
92
+ const configurations = xcodeProject.pbxXCBuildConfigurationSection();
93
+
94
+ Object.keys(configurations).forEach((key) => {
95
+ // eslint-disable-next-line no-shadow
96
+ const config = configurations[key];
97
+ if (config.buildSettings?.PRODUCT_NAME?.includes(mainTargetName)) {
98
+ if (!config.buildSettings.CODE_SIGN_ENTITLEMENTS) {
99
+ config.buildSettings.CODE_SIGN_ENTITLEMENTS = entitlementsFilePath;
100
+ }
101
+ }
102
+ });
103
+
104
+ return props;
105
+ });
106
+
107
+ return config;
108
+ };
109
+
110
+ /**
111
+ * Adds constants to Info.plist
112
+ * In order to dynamically retrieve extension's bundleId and group name we need to store it in Info.plist.
113
+ */
114
+ const withInfoPlistConstants: ConfigPlugin<FishjamPluginOptions> = (config, props) =>
115
+ withInfoPlist(config, (configuration) => {
116
+ const bundleIdentifier = configuration.ios?.bundleIdentifier || '';
117
+ const groupIdentifier = props?.ios?.appGroupContainerId || `group.${bundleIdentifier}`;
118
+ configuration.modResults['RTCScreenSharingExtension'] = `${bundleIdentifier}.${getSbeTargetName(props)}`;
119
+ configuration.modResults['RTCAppGroupIdentifier'] = groupIdentifier;
120
+ return configuration;
121
+ });
122
+
123
+ /**
124
+ * Updates and copies required extension files.
125
+ * Our extension needs to be properly setup inside the Xcode project. In order to do that we need to copy the files and update the pbxproj.
126
+ */
127
+ const withFishjamSBE: ConfigPlugin<FishjamPluginOptions> = (config, options) =>
128
+ withXcodeProject(config, async (props) => {
129
+ const appName = props.modRequest.projectName || '';
130
+ const iosPath = props.modRequest.platformProjectRoot;
131
+ const bundleIdentifier = props.ios?.bundleIdentifier;
132
+ const groupIdentifier = options?.ios?.appGroupContainerId || `group.${bundleIdentifier}`;
133
+ const xcodeProject = props.modResults;
134
+ const targetName = getSbeTargetName(options);
135
+
136
+ const pluginDir = require.resolve('@fishjam-cloud/react-native-client/package.json');
137
+ const extensionSourceDir = path.join(pluginDir, '../plugin/broadcastExtensionFiles/');
138
+
139
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
140
+ const templateTargetName = 'ScreenBroadcastExtension';
141
+
142
+ const extFiles = [
143
+ 'SampleHandler.swift',
144
+ 'SampleUploader.swift',
145
+ `${templateTargetName}.entitlements`,
146
+ `Info.plist`,
147
+ 'SocketConnection.swift',
148
+ 'DarwinNotificationCenter.swift',
149
+ 'Atomic.swift',
150
+ ];
151
+
152
+ const destFiles = [
153
+ 'SampleHandler.swift',
154
+ 'SampleUploader.swift',
155
+ `${targetName}.entitlements`,
156
+ `Info.plist`,
157
+ 'SocketConnection.swift',
158
+ 'DarwinNotificationCenter.swift',
159
+ 'Atomic.swift',
160
+ ];
161
+
162
+ await xcodeProject.parse(async function (err: Error) {
163
+ if (err) {
164
+ console.error(`Error parsing iOS project: ${JSON.stringify(err)}`);
165
+ return;
166
+ }
167
+ if (xcodeProject.pbxTargetByName(targetName)) {
168
+ // eslint-disable-next-line no-console
169
+ console.log(`${targetName} already exists in project. Skipping...`);
170
+ return;
171
+ }
172
+ try {
173
+ await fs.mkdir(`${iosPath}/${targetName}`, { recursive: true });
174
+ for (let i = 0; i < extFiles.length; i++) {
175
+ const srcFile = `${extensionSourceDir}${extFiles[i]}`;
176
+ const destFile = `${iosPath}/${targetName}/${destFiles[i]}`;
177
+ await fs.copyFile(srcFile, destFile);
178
+ }
179
+ } catch (e) {
180
+ console.error('Error copying extension files: ', e);
181
+ throw e;
182
+ }
183
+
184
+ try {
185
+ await updateFileWithRegex(
186
+ iosPath,
187
+ `${targetName}.entitlements`,
188
+ GROUP_IDENTIFIER_TEMPLATE_REGEX,
189
+ groupIdentifier,
190
+ options,
191
+ );
192
+ await updateFileWithRegex(
193
+ iosPath,
194
+ 'SampleHandler.swift',
195
+ GROUP_IDENTIFIER_TEMPLATE_REGEX,
196
+ groupIdentifier,
197
+ options,
198
+ );
199
+ await updateFileWithRegex(
200
+ iosPath,
201
+ 'SampleUploader.swift',
202
+ BUNDLE_IDENTIFIER_TEMPLATE_REGEX,
203
+ bundleIdentifier || '',
204
+ options,
205
+ );
206
+ await updateFileWithRegex(
207
+ iosPath,
208
+ 'Info.plist',
209
+ DISPLAY_NAME_TEMPLATE_REGEX,
210
+ getSbeDisplayName(options),
211
+ options,
212
+ );
213
+ } catch (e) {
214
+ console.error('Error updating extension files: ', e);
215
+ }
216
+
217
+ // Create new PBXGroup for the extension
218
+ const extGroup = xcodeProject.addPbxGroup(extFiles, targetName, targetName);
219
+
220
+ // Add the new PBXGroup to the top level group. This makes the
221
+ // files / folder appear in the file explorer in Xcode.
222
+ const groups = xcodeProject.hash.project.objects['PBXGroup'];
223
+ Object.keys(groups).forEach(function (key) {
224
+ if (groups[key].name === undefined) {
225
+ xcodeProject.addToPbxGroup(extGroup.uuid, key);
226
+ }
227
+ });
228
+
229
+ // WORK AROUND for codeProject.addTarget BUG
230
+ // Xcode projects don't contain these if there is only one target
231
+ // An upstream fix should be made to the code referenced in this link:
232
+ // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
233
+ const projObjects = xcodeProject.hash.project.objects;
234
+ projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
235
+ projObjects['PBXContainerItemProxy'] = projObjects['PBXContainerItemProxy'] || {};
236
+
237
+ // Add the SBE target
238
+ // This adds PBXTargetDependency and PBXContainerItemProxy for you
239
+ const sbeTarget = xcodeProject.addTarget(
240
+ targetName,
241
+ 'app_extension',
242
+ targetName,
243
+ `${bundleIdentifier}.${targetName}`,
244
+ );
245
+
246
+ // Add build phases to the new target
247
+ xcodeProject.addBuildPhase(
248
+ [
249
+ 'SampleHandler.swift',
250
+ 'SampleUploader.swift',
251
+ 'SocketConnection.swift',
252
+ 'DarwinNotificationCenter.swift',
253
+ 'Atomic.swift',
254
+ ],
255
+ 'PBXSourcesBuildPhase',
256
+ 'Sources',
257
+ sbeTarget.uuid,
258
+ );
259
+ xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', sbeTarget.uuid);
260
+
261
+ xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', sbeTarget.uuid);
262
+
263
+ xcodeProject.addFramework('ReplayKit.framework', {
264
+ target: sbeTarget.uuid,
265
+ });
266
+
267
+ // Edit the Deployment info of the new Target, only IphoneOS and Targeted Device Family
268
+ // However, can be more
269
+ const configurations = xcodeProject.pbxXCBuildConfigurationSection();
270
+ for (const key in configurations) {
271
+ if (
272
+ typeof configurations[key].buildSettings !== 'undefined' &&
273
+ configurations[key].buildSettings.PRODUCT_NAME === `"${targetName}"`
274
+ ) {
275
+ const buildSettingsObj = configurations[key].buildSettings;
276
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
277
+ options?.ios?.iphoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET;
278
+ buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
279
+ buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${targetName}/${targetName}.entitlements`;
280
+ buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
281
+ buildSettingsObj.INFOPLIST_FILE = `${targetName}/Info.plist`;
282
+ buildSettingsObj.SWIFT_VERSION = '5.0';
283
+ buildSettingsObj.MARKETING_VERSION = '1.0.0';
284
+ buildSettingsObj.CURRENT_PROJECT_VERSION = '1';
285
+ buildSettingsObj.ENABLE_BITCODE = 'NO';
286
+ }
287
+ }
288
+
289
+ await fs.writeFile(projPath, xcodeProject.writeSync());
290
+ });
291
+
292
+ return props;
293
+ });
294
+
295
+ /**
296
+ * Adds iOS VoIP background mode to keep the app running during calls
297
+ */
298
+ const withFishjamVoIPBackgroundMode: ConfigPlugin<FishjamPluginOptions> = (config, props) =>
299
+ withInfoPlist(config, (configuration) => {
300
+ if (props?.ios?.enableVoIPBackgroundMode) {
301
+ const backgroundModes = new Set(configuration.modResults.UIBackgroundModes ?? []);
302
+ backgroundModes.add('voip');
303
+
304
+ configuration.modResults.UIBackgroundModes = Array.from(backgroundModes);
305
+ }
306
+
307
+ return configuration;
308
+ });
309
+
310
+ const withFishjamPictureInPicture: ConfigPlugin<FishjamPluginOptions> = (config, props) =>
311
+ withInfoPlist(config, (configuration) => {
312
+ if (props?.ios?.supportsPictureInPicture) {
313
+ const backgroundModes = new Set(configuration.modResults.UIBackgroundModes ?? []);
314
+ backgroundModes.add('audio');
315
+ configuration.modResults.UIBackgroundModes = Array.from(backgroundModes);
316
+ }
317
+
318
+ return configuration;
319
+ });
320
+
321
+ const withFishjamIos: ConfigPlugin<FishjamPluginOptions> = (config, props) => {
322
+ if (props?.ios?.enableScreensharing) {
323
+ config = withAppGroupPermissions(config, props);
324
+ config = withInfoPlistConstants(config, props);
325
+ config = withFishjamSBE(config, props);
326
+ }
327
+ config = withPodfileProperties(config, (configuration) => {
328
+ configuration.modResults['ios.deploymentTarget'] = props?.ios?.iphoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET;
329
+ return configuration;
330
+ });
331
+ config = withFishjamPictureInPicture(config, props);
332
+ config = withFishjamVoIPBackgroundMode(config, props);
333
+ return config;
334
+ };
335
+
336
+ export { withFishjamIos };
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "expo-module-scripts/tsconfig.plugin",
3
+ "compilerOptions": {
4
+ "outDir": "build",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
+ }
@@ -0,0 +1 @@
1
+ {"root":["./src/types.ts","./src/withFishjam.ts","./src/withFishjamAndroid.ts","./src/withFishjamIos.ts"],"version":"5.8.3"}
package/LICENSE.txt DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2023 Software Mansion
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
@@ -1,95 +0,0 @@
1
- import groovy.json.JsonSlurper
2
-
3
- apply plugin: 'com.android.library'
4
- apply plugin: 'kotlin-android'
5
- apply plugin: 'maven-publish'
6
-
7
- def inputFile = new File("$projectDir/../package.json")
8
- def packageJson = new JsonSlurper().parseText(inputFile.text)
9
- def packageVersion = packageJson["version"]
10
-
11
- group = 'io.fishjam.reactnative'
12
- version = "${packageVersion}"
13
-
14
- buildscript {
15
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
16
- if (expoModulesCorePlugin.exists()) {
17
- apply from: expoModulesCorePlugin
18
- applyKotlinExpoModulesCorePlugin()
19
- }
20
-
21
- // Simple helper that allows the root project to override versions declared by this library.
22
- ext.safeExtGet = { prop, fallback ->
23
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
24
- }
25
-
26
- // Ensures backward compatibility
27
- ext.getKotlinVersion = {
28
- if (ext.has("kotlinVersion")) {
29
- ext.kotlinVersion()
30
- } else {
31
- ext.safeExtGet("kotlinVersion", "1.6.10")
32
- }
33
- }
34
-
35
- repositories {
36
- mavenLocal()
37
- mavenCentral()
38
- }
39
-
40
- dependencies {
41
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
42
- }
43
- }
44
-
45
- afterEvaluate {
46
- publishing {
47
- publications {
48
- release(MavenPublication) {
49
- from components.release
50
- }
51
- }
52
- repositories {
53
- maven {
54
- url = mavenLocal().url
55
- }
56
- }
57
- }
58
- }
59
-
60
- android {
61
- namespace = "io.fishjam.reactnative"
62
- compileSdk(34)
63
-
64
- defaultConfig {
65
- minSdkVersion safeExtGet("minSdkVersion", 21)
66
- targetSdkVersion safeExtGet("targetSdkVersion", 34)
67
- versionCode 1
68
- versionName "${packageVersion}"
69
- }
70
-
71
- lintOptions {
72
- abortOnError false
73
- }
74
- publishing {
75
- singleVariant("release") {
76
- withSourcesJar()
77
- }
78
- }
79
- }
80
-
81
- repositories {
82
- mavenCentral()
83
- }
84
-
85
- dependencies {
86
- implementation project(':expo-modules-core')
87
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
88
- if (findProject(':fishjam-cloud-android-client')) {
89
- implementation project(':fishjam-cloud-android-client')
90
- } else {
91
- implementation "com.github.fishjam-cloud:mobile-client-sdk:${packageVersion}"
92
- }
93
- implementation 'com.twilio:audioswitch:1.2.0'
94
- implementation 'androidx.appcompat:appcompat:1.6.1'
95
- }
@@ -1,2 +0,0 @@
1
- <manifest>
2
- </manifest>
@@ -1,34 +0,0 @@
1
- package io.fishjam.reactnative
2
-
3
- import com.twilio.audioswitch.AudioDevice
4
-
5
- enum class AudioDeviceKind(
6
- val typeName: String,
7
- val audioDeviceClass: Class<out AudioDevice>
8
- ) {
9
- BLUETOOTH("bluetooth", AudioDevice.BluetoothHeadset::class.java),
10
- WIRED_HEADSET("headset", AudioDevice.WiredHeadset::class.java),
11
- SPEAKER("speaker", AudioDevice.Speakerphone::class.java),
12
- EARPIECE("earpiece", AudioDevice.Earpiece::class.java)
13
- ;
14
-
15
- companion object {
16
- fun fromAudioDevice(audioDevice: AudioDevice): AudioDeviceKind? {
17
- for (kind in values()) {
18
- if (kind.audioDeviceClass == audioDevice.javaClass) {
19
- return kind
20
- }
21
- }
22
- return null
23
- }
24
-
25
- fun fromTypeName(typeName: String): AudioDeviceKind? {
26
- for (kind in values()) {
27
- if (kind.typeName == typeName) {
28
- return kind
29
- }
30
- }
31
- return null
32
- }
33
- }
34
- }