@fishjam-cloud/react-native-client 0.3.0 → 0.4.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.
- package/README.md +2 -2
- package/android/build.gradle +2 -2
- package/android/src/main/java/io/fishjam/reactnative/Errors.kt +1 -2
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +52 -27
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +40 -79
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +4 -3
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewViewModule.kt +5 -0
- package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +4 -3
- package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +2 -0
- package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +3 -2
- package/android/src/main/java/io/fishjam/reactnative/{FishjamForegroundService.kt → foregroundService/FishjamForegroundService.kt} +7 -2
- package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceManager.kt +147 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/LocalCameraTracksChangedListenersManager.kt +21 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt +27 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/TracksUpdateListenersManager.kt +21 -0
- package/android/src/main/java/io/fishjam/reactnative/utils/PermissionUtils.kt +45 -0
- package/build/RNFishjamClientModule.d.ts +6 -2
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/hooks/useAppScreenShare.d.ts +11 -0
- package/build/hooks/useAppScreenShare.d.ts.map +1 -0
- package/build/hooks/useAppScreenShare.js +54 -0
- package/build/hooks/useAppScreenShare.js.map +1 -0
- package/build/hooks/useFishjamEvent.d.ts +1 -0
- package/build/hooks/useFishjamEvent.d.ts.map +1 -1
- package/build/hooks/useFishjamEvent.js +1 -0
- package/build/hooks/useFishjamEvent.js.map +1 -1
- package/build/hooks/useForegroundService.d.ts +44 -0
- package/build/hooks/useForegroundService.d.ts.map +1 -0
- package/build/hooks/useForegroundService.js +57 -0
- package/build/hooks/useForegroundService.js.map +1 -0
- package/build/hooks/useMicrophone.d.ts +1 -1
- package/build/hooks/useMicrophone.js +1 -1
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/useScreenShare.d.ts +1 -0
- package/build/hooks/useScreenShare.d.ts.map +1 -1
- package/build/hooks/useScreenShare.js +20 -13
- package/build/hooks/useScreenShare.js.map +1 -1
- package/build/index.d.ts +4 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/types.d.ts +0 -25
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -10
- package/build/types.js.map +1 -1
- package/ios/Events.swift +1 -0
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +144 -57
- package/ios/RNFishjamClientModule.swift +32 -24
- package/ios/Utils/PermissionUtils.swift +16 -0
- package/ios/VideoPreviewView.swift +6 -10
- package/ios/VideoRendererView.swift +5 -14
- package/ios/managers/LocalCameraTracksChangedListenersManager.swift +23 -0
- package/ios/managers/TracksUpdateListenersManager.swift +21 -0
- package/package.json +7 -7
- package/plugin/build/withFishjamAndroid.js +1 -1
- package/build/utils/foregroundService.d.ts +0 -32
- package/build/utils/foregroundService.d.ts.map +0 -1
- package/build/utils/foregroundService.js +0 -43
- package/build/utils/foregroundService.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AVFoundation
|
|
2
|
+
|
|
3
|
+
class PermissionUtils {
|
|
4
|
+
static func requestCameraPermission() async -> Bool { await requestAccessIfNeeded(for: .video) }
|
|
5
|
+
static func requestMicrophonePermission() async -> Bool { await requestAccessIfNeeded(for: .audio) }
|
|
6
|
+
|
|
7
|
+
private static func requestAccessIfNeeded(for mediaType: AVMediaType) async -> Bool {
|
|
8
|
+
let status = AVCaptureDevice.authorizationStatus(for: mediaType)
|
|
9
|
+
|
|
10
|
+
return if status == .notDetermined {
|
|
11
|
+
await AVCaptureDevice.requestAccess(for: mediaType)
|
|
12
|
+
} else {
|
|
13
|
+
status == .authorized
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
import FishjamCloudClient
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
func onLocalCameraTrackChanged()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
class VideoPreviewView: ExpoView, OnLocalCameraTrackChangedListener {
|
|
4
|
+
class VideoPreviewView: ExpoView, LocalCameraTrackChangedListener {
|
|
9
5
|
var videoView: VideoView? = nil
|
|
10
|
-
private var localVideoTrack:
|
|
6
|
+
private var localVideoTrack: LocalCameraTrack? = nil
|
|
11
7
|
|
|
12
8
|
required init(appContext: AppContext? = nil) {
|
|
13
9
|
super.init(appContext: appContext)
|
|
@@ -30,8 +26,8 @@ class VideoPreviewView: ExpoView, OnLocalCameraTrackChangedListener {
|
|
|
30
26
|
|
|
31
27
|
self.localVideoTrack =
|
|
32
28
|
tracks.first(where: { (key, track) in
|
|
33
|
-
track is
|
|
34
|
-
})?.value as?
|
|
29
|
+
track is LocalCameraTrack
|
|
30
|
+
})?.value as? LocalCameraTrack
|
|
35
31
|
self.localVideoTrack?.start()
|
|
36
32
|
self.videoView?.track = self.localVideoTrack
|
|
37
33
|
}
|
|
@@ -40,10 +36,10 @@ class VideoPreviewView: ExpoView, OnLocalCameraTrackChangedListener {
|
|
|
40
36
|
override func willMove(toSuperview newSuperview: UIView?) {
|
|
41
37
|
super.willMove(toSuperview: newSuperview)
|
|
42
38
|
if newSuperview == nil {
|
|
43
|
-
RNFishjamClient.
|
|
39
|
+
RNFishjamClient.localCameraTracksChangedListenersManager.remove(self)
|
|
44
40
|
localVideoTrack?.stop()
|
|
45
41
|
} else {
|
|
46
|
-
RNFishjamClient.
|
|
42
|
+
RNFishjamClient.localCameraTracksChangedListenersManager.add(self)
|
|
47
43
|
trySetLocalCameraTrack()
|
|
48
44
|
}
|
|
49
45
|
}
|
|
@@ -2,17 +2,13 @@ import Combine
|
|
|
2
2
|
import ExpoModulesCore
|
|
3
3
|
import FishjamCloudClient
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
func onTrackUpdate()
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
class VideoRendererView: ExpoView, OnTrackUpdateListener {
|
|
5
|
+
class VideoRendererView: ExpoView, TrackUpdateListener {
|
|
10
6
|
var videoView: VideoView? = nil
|
|
11
7
|
var cancellableEndpoints: Cancellable? = nil
|
|
12
8
|
|
|
13
9
|
required init(appContext: AppContext? = nil) {
|
|
14
10
|
super.init(appContext: appContext)
|
|
15
|
-
RNFishjamClient.
|
|
11
|
+
RNFishjamClient.tracksUpdateListenersManager.add(self)
|
|
16
12
|
videoView = VideoView()
|
|
17
13
|
videoView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
18
14
|
videoView?.clipsToBounds = true
|
|
@@ -20,12 +16,7 @@ class VideoRendererView: ExpoView, OnTrackUpdateListener {
|
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
deinit {
|
|
23
|
-
RNFishjamClient.
|
|
24
|
-
if let view = $0 as? VideoRendererView {
|
|
25
|
-
return view === self
|
|
26
|
-
}
|
|
27
|
-
return false
|
|
28
|
-
})
|
|
19
|
+
RNFishjamClient.tracksUpdateListenersManager.remove(self)
|
|
29
20
|
}
|
|
30
21
|
|
|
31
22
|
override func willMove(toSuperview newSuperview: UIView?) {
|
|
@@ -41,7 +32,7 @@ class VideoRendererView: ExpoView, OnTrackUpdateListener {
|
|
|
41
32
|
if self.superview != nil {
|
|
42
33
|
for endpoint in RNFishjamClient.getLocalAndRemoteEndpoints() {
|
|
43
34
|
if let track = endpoint.tracks[self.trackId] as? VideoTrack {
|
|
44
|
-
if let track = track as?
|
|
35
|
+
if let track = track as? LocalCameraTrack {
|
|
45
36
|
self.mirrorVideo = track.isFrontCamera
|
|
46
37
|
}
|
|
47
38
|
self.videoView?.track = track
|
|
@@ -52,7 +43,7 @@ class VideoRendererView: ExpoView, OnTrackUpdateListener {
|
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
45
|
|
|
55
|
-
func
|
|
46
|
+
func onTracksUpdate() {
|
|
56
47
|
updateVideoTrack()
|
|
57
48
|
}
|
|
58
49
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
protocol LocalCameraTrackChangedListener: AnyObject {
|
|
4
|
+
func onLocalCameraTrackChanged()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class LocalCameraTracksChangedListenersManager {
|
|
8
|
+
private var listeners: [LocalCameraTrackChangedListener] = []
|
|
9
|
+
|
|
10
|
+
func add(_ listener: LocalCameraTrackChangedListener) {
|
|
11
|
+
listeners.append(listener)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
func remove(_ listener: LocalCameraTrackChangedListener) {
|
|
15
|
+
listeners.removeAll { $0 === listener }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func notifyListeners() {
|
|
19
|
+
for listener in listeners {
|
|
20
|
+
listener.onLocalCameraTrackChanged()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
protocol TrackUpdateListener: AnyObject {
|
|
2
|
+
func onTracksUpdate()
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class TracksUpdateListenersManager {
|
|
6
|
+
private var listeners: [TrackUpdateListener] = []
|
|
7
|
+
|
|
8
|
+
func add(_ listener: TrackUpdateListener) {
|
|
9
|
+
listeners.append(listener)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
func remove(_ listener: TrackUpdateListener) {
|
|
13
|
+
listeners.removeAll { $0 === listener }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func notifyListeners() {
|
|
17
|
+
for listener in listeners {
|
|
18
|
+
listener.onTracksUpdate()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/react-native-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A React Native client for Fishjam Cloud",
|
|
5
5
|
"author": "Fishjam Cloud Team",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@testing-library/react": "^15.0.7",
|
|
48
|
-
"@types/lodash": "^4.17.
|
|
48
|
+
"@types/lodash": "^4.17.10",
|
|
49
49
|
"@types/phoenix": "^1.6.5",
|
|
50
50
|
"@types/promise-fs": "^2.1.2",
|
|
51
|
-
"@types/react": "^18.3.
|
|
51
|
+
"@types/react": "^18.3.11",
|
|
52
52
|
"expo": "^51.0.32",
|
|
53
53
|
"expo-module-scripts": "^3.5.2",
|
|
54
54
|
"expo-modules-core": "^1.12.24",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.3.1",
|
|
63
63
|
"react-native": "^0.75.2",
|
|
64
|
-
"ts-proto": "^2.
|
|
65
|
-
"typedoc": "^0.26.
|
|
64
|
+
"ts-proto": "^2.2.3",
|
|
65
|
+
"typedoc": "^0.26.8",
|
|
66
66
|
"typedoc-plugin-mark-react-functional-components": "^0.2.2",
|
|
67
|
-
"typescript": "^5.
|
|
67
|
+
"typescript": "^5.6.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"expo": "*",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"debug",
|
|
85
85
|
"android/build.gradle",
|
|
86
86
|
"android/src/**",
|
|
87
|
-
"ios
|
|
87
|
+
"ios/**/*.swift",
|
|
88
88
|
"ios/RNFishjamClient.podspec",
|
|
89
89
|
"plugin/build/**",
|
|
90
90
|
"plugin/broadcastExtensionFiles/**",
|
|
@@ -9,7 +9,7 @@ const withFishjamForegroundService = (config) => {
|
|
|
9
9
|
mainApplication.service = mainApplication.service || [];
|
|
10
10
|
const newService = {
|
|
11
11
|
$: {
|
|
12
|
-
'android:name': 'io.fishjam.reactnative.FishjamForegroundService',
|
|
12
|
+
'android:name': 'io.fishjam.reactnative.foregroundService.FishjamForegroundService',
|
|
13
13
|
'android:foregroundServiceType': 'camera|microphone|mediaProjection',
|
|
14
14
|
},
|
|
15
15
|
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ForegroundServiceOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Launches a foreground service on Android.
|
|
4
|
-
* Does nothing on other platforms.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* You must have have the following permissions enabled before calling this function:
|
|
8
|
-
* @example
|
|
9
|
-
```
|
|
10
|
-
"android.permission.FOREGROUND_SERVICE"
|
|
11
|
-
"android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"
|
|
12
|
-
"android.permission.FOREGROUND_SERVICE_CAMERA"
|
|
13
|
-
"android.permission.FOREGROUND_SERVICE_MICROPHONE"
|
|
14
|
-
"android.permission.POST_NOTIFICATIONS"
|
|
15
|
-
*```
|
|
16
|
-
* as well as FishjamForegroundService in your AndroidManifest:
|
|
17
|
-
* @example
|
|
18
|
-
```
|
|
19
|
-
<service android:name="io.fishjam.reactnative.FishjamForegroundService" android:foregroundServiceType="camera|microphone|mediaProjection"/>
|
|
20
|
-
```
|
|
21
|
-
* @category Screenshare
|
|
22
|
-
*/
|
|
23
|
-
export declare const startForegroundService: (options: ForegroundServiceOptions) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Stops previously launched Android foreground service.
|
|
26
|
-
* @see {@link startForegroundService} for further information.
|
|
27
|
-
*
|
|
28
|
-
* Does nothing on other platforms.
|
|
29
|
-
* @category Screenshare
|
|
30
|
-
*/
|
|
31
|
-
export declare const stopForegroundService: () => void;
|
|
32
|
-
//# sourceMappingURL=foregroundService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"foregroundService.d.ts","sourceRoot":"","sources":["../../src/utils/foregroundService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;MAoBM;AACN,eAAO,MAAM,sBAAsB,YAAa,wBAAwB,SAKvE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,YAKjC,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
3
|
-
/**
|
|
4
|
-
* Launches a foreground service on Android.
|
|
5
|
-
* Does nothing on other platforms.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* You must have have the following permissions enabled before calling this function:
|
|
9
|
-
* @example
|
|
10
|
-
```
|
|
11
|
-
"android.permission.FOREGROUND_SERVICE"
|
|
12
|
-
"android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"
|
|
13
|
-
"android.permission.FOREGROUND_SERVICE_CAMERA"
|
|
14
|
-
"android.permission.FOREGROUND_SERVICE_MICROPHONE"
|
|
15
|
-
"android.permission.POST_NOTIFICATIONS"
|
|
16
|
-
*```
|
|
17
|
-
* as well as FishjamForegroundService in your AndroidManifest:
|
|
18
|
-
* @example
|
|
19
|
-
```
|
|
20
|
-
<service android:name="io.fishjam.reactnative.FishjamForegroundService" android:foregroundServiceType="camera|microphone|mediaProjection"/>
|
|
21
|
-
```
|
|
22
|
-
* @category Screenshare
|
|
23
|
-
*/
|
|
24
|
-
export const startForegroundService = (options) => {
|
|
25
|
-
if (Platform.OS !== 'android') {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
RNFishjamClientModule.startForegroundService(options);
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Stops previously launched Android foreground service.
|
|
32
|
-
* @see {@link startForegroundService} for further information.
|
|
33
|
-
*
|
|
34
|
-
* Does nothing on other platforms.
|
|
35
|
-
* @category Screenshare
|
|
36
|
-
*/
|
|
37
|
-
export const stopForegroundService = () => {
|
|
38
|
-
if (Platform.OS !== 'android') {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
RNFishjamClientModule.stopForegroundService();
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=foregroundService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"foregroundService.js","sourceRoot":"","sources":["../../src/utils/foregroundService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;MAoBM;AACN,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAiC,EAAE,EAAE;IAC1E,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO;IACT,CAAC;IACD,qBAAqB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO;IACT,CAAC;IACD,qBAAqB,CAAC,qBAAqB,EAAE,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { Platform } from 'react-native';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ForegroundServiceOptions } from '../types';\n\n/**\n * Launches a foreground service on Android.\n * Does nothing on other platforms.\n * \n * @remarks\n * You must have have the following permissions enabled before calling this function:\n * @example\n ```\n \"android.permission.FOREGROUND_SERVICE\"\n \"android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION\"\n \"android.permission.FOREGROUND_SERVICE_CAMERA\"\n \"android.permission.FOREGROUND_SERVICE_MICROPHONE\"\n \"android.permission.POST_NOTIFICATIONS\"\n *```\n * as well as FishjamForegroundService in your AndroidManifest:\n * @example\n ```\n <service android:name=\"io.fishjam.reactnative.FishjamForegroundService\" android:foregroundServiceType=\"camera|microphone|mediaProjection\"/>\n ```\n * @category Screenshare\n */\nexport const startForegroundService = (options: ForegroundServiceOptions) => {\n if (Platform.OS !== 'android') {\n return;\n }\n RNFishjamClientModule.startForegroundService(options);\n};\n\n/**\n * Stops previously launched Android foreground service.\n * @see {@link startForegroundService} for further information.\n *\n * Does nothing on other platforms.\n * @category Screenshare\n */\nexport const stopForegroundService = () => {\n if (Platform.OS !== 'android') {\n return;\n }\n RNFishjamClientModule.stopForegroundService();\n};\n"]}
|