@fishjam-cloud/react-native-client 0.25.0 → 0.25.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.
- package/dist/hooks/usePermissions.d.ts +49 -0
- package/dist/hooks/usePermissions.d.ts.map +1 -0
- package/dist/hooks/usePermissions.js +56 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/overrides/getUserMedia.d.ts +2 -0
- package/dist/overrides/getUserMedia.d.ts.map +1 -0
- package/dist/overrides/getUserMedia.js +25 -0
- package/dist/webrtc-polyfill.d.ts +2 -0
- package/dist/webrtc-polyfill.d.ts.map +1 -1
- package/dist/webrtc-polyfill.js +4 -0
- package/package.json +11 -17
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The current status of a device permission.
|
|
3
|
+
*
|
|
4
|
+
* - `'granted'` – the user has granted the permission.
|
|
5
|
+
* - `'denied'` – the user has denied the permission.
|
|
6
|
+
* - `'prompt'` – the user has not yet been asked (or the permission can be requested again).
|
|
7
|
+
*/
|
|
8
|
+
export type PermissionStatus = 'granted' | 'denied' | 'prompt';
|
|
9
|
+
/**
|
|
10
|
+
* Hook for querying and requesting camera permission on the device.
|
|
11
|
+
*
|
|
12
|
+
* @returns A tuple of `[query, request]`:
|
|
13
|
+
* - `query` – checks the current camera permission status without prompting the user.
|
|
14
|
+
* - `request` – triggers the native permission dialog and returns the resulting status.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useCameraPermissions } from "@fishjam-cloud/react-native-client";
|
|
19
|
+
* // ---cut---
|
|
20
|
+
* const [queryCameraPermission, requestCameraPermission] = useCameraPermissions();
|
|
21
|
+
*
|
|
22
|
+
* const status = await queryCameraPermission();
|
|
23
|
+
* if (status !== 'granted') {
|
|
24
|
+
* await requestCameraPermission();
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useCameraPermissions(): [query: () => Promise<PermissionStatus>, request: () => Promise<PermissionStatus>];
|
|
29
|
+
/**
|
|
30
|
+
* Hook for querying and requesting microphone permission on the device.
|
|
31
|
+
*
|
|
32
|
+
* @returns A tuple of `[query, request]`:
|
|
33
|
+
* - `query` – checks the current microphone permission status without prompting the user.
|
|
34
|
+
* - `request` – triggers the native permission dialog and returns the resulting status.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* import { useMicrophonePermissions } from "@fishjam-cloud/react-native-client";
|
|
39
|
+
* // ---cut---
|
|
40
|
+
* const [queryMicPermission, requestMicPermission] = useMicrophonePermissions();
|
|
41
|
+
*
|
|
42
|
+
* const status = await queryMicPermission();
|
|
43
|
+
* if (status !== 'granted') {
|
|
44
|
+
* await requestMicPermission();
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function useMicrophonePermissions(): [query: () => Promise<PermissionStatus>, request: () => Promise<PermissionStatus>];
|
|
49
|
+
//# sourceMappingURL=usePermissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePermissions.d.ts","sourceRoot":"","sources":["../../src/hooks/usePermissions.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAiB/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,kBAhCnB,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,OAAO,CAAC,gBAAgB,CAAC,EAkCnF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,kBAvDvB,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,OAAO,CAAC,gBAAgB,CAAC,EAyDnF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { permissions } from '@fishjam-cloud/react-native-webrtc';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
function usePermission(name) {
|
|
4
|
+
const query = useCallback(async () => {
|
|
5
|
+
return (await permissions.query({ name }));
|
|
6
|
+
}, [name]);
|
|
7
|
+
const request = useCallback(async () => {
|
|
8
|
+
await permissions.request({ name });
|
|
9
|
+
return (await permissions.query({ name }));
|
|
10
|
+
}, [name]);
|
|
11
|
+
return [query, request];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hook for querying and requesting camera permission on the device.
|
|
15
|
+
*
|
|
16
|
+
* @returns A tuple of `[query, request]`:
|
|
17
|
+
* - `query` – checks the current camera permission status without prompting the user.
|
|
18
|
+
* - `request` – triggers the native permission dialog and returns the resulting status.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { useCameraPermissions } from "@fishjam-cloud/react-native-client";
|
|
23
|
+
* // ---cut---
|
|
24
|
+
* const [queryCameraPermission, requestCameraPermission] = useCameraPermissions();
|
|
25
|
+
*
|
|
26
|
+
* const status = await queryCameraPermission();
|
|
27
|
+
* if (status !== 'granted') {
|
|
28
|
+
* await requestCameraPermission();
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function useCameraPermissions() {
|
|
33
|
+
return usePermission('camera');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hook for querying and requesting microphone permission on the device.
|
|
37
|
+
*
|
|
38
|
+
* @returns A tuple of `[query, request]`:
|
|
39
|
+
* - `query` – checks the current microphone permission status without prompting the user.
|
|
40
|
+
* - `request` – triggers the native permission dialog and returns the resulting status.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* import { useMicrophonePermissions } from "@fishjam-cloud/react-native-client";
|
|
45
|
+
* // ---cut---
|
|
46
|
+
* const [queryMicPermission, requestMicPermission] = useMicrophonePermissions();
|
|
47
|
+
*
|
|
48
|
+
* const status = await queryMicPermission();
|
|
49
|
+
* if (status !== 'granted') {
|
|
50
|
+
* await requestMicPermission();
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function useMicrophonePermissions() {
|
|
55
|
+
return usePermission('microphone');
|
|
56
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ export { RTCView, RTCPIPView, type RTCVideoViewProps, type RTCPIPViewProps } fro
|
|
|
5
5
|
export { ScreenCapturePickerView, startPIP, stopPIP, useCallKit, useCallKitEvent, useCallKitService, } from '@fishjam-cloud/react-native-webrtc';
|
|
6
6
|
export type { CallKitAction, CallKitConfig, MediaStream } from '@fishjam-cloud/react-native-webrtc';
|
|
7
7
|
export { useForegroundService, type ForegroundServiceConfig } from './useForegroundService';
|
|
8
|
-
export {
|
|
8
|
+
export { useCameraPermissions, useMicrophonePermissions, type PermissionStatus, } from './hooks/usePermissions';
|
|
9
|
+
export { useCamera, useInitializeDevices, InitializeDevicesSettings, useConnection, useCustomSource, useDataChannel, useLivestreamStreamer, useLivestreamViewer, usePeers, useSandbox, useScreenShare, useUpdatePeerMetadata, useVAD, Variant, } from '@fishjam-cloud/react-client';
|
|
9
10
|
export declare const useMicrophone: () => Omit<ReturnType<typeof useMicrophoneReactClient>, "toggleMicrophoneMute">;
|
|
10
|
-
export type { UseInitializeDevicesParams, JoinRoomConfig, ConnectStreamerConfig, StreamerInputs, UseLivestreamStreamerResult, ConnectViewerConfig, UseLivestreamViewerResult, PeerWithTracks, RoomType, UseSandboxProps, BandwidthLimits, Brand, CustomSource, DeviceError, DeviceItem, InitializeDevicesResult, InitializeDevicesStatus, MiddlewareResult, PeerId, PeerStatus, PersistLastDeviceHandlers, SimulcastBandwidthLimits, StreamConfig, Track, TrackId, TrackMiddleware, TracksMiddleware, TracksMiddlewareResult, AuthErrorReason, JoinErrorReason, Metadata, ReconnectConfig, ReconnectionStatus, SimulcastBandwidthLimit, SimulcastConfig, TrackBandwidthLimit, } from '@fishjam-cloud/react-client';
|
|
11
|
+
export type { UseInitializeDevicesParams, JoinRoomConfig, ConnectStreamerConfig, StreamerInputs, UseLivestreamStreamerResult, ConnectViewerConfig, UseLivestreamViewerResult, PeerWithTracks, RoomType, UseSandboxProps, BandwidthLimits, Brand, CustomSource, DeviceError, DeviceItem, InitializeDevicesResult, InitializeDevicesStatus, MiddlewareResult, PeerId, PeerStatus, PersistLastDeviceHandlers, SimulcastBandwidthLimits, StreamConfig, Track, TrackId, TrackMiddleware, TracksMiddleware, TracksMiddlewareResult, AuthErrorReason, JoinErrorReason, UseDataChannelResult, DataCallback, DataChannelOptions, Metadata, ReconnectConfig, ReconnectionStatus, SimulcastBandwidthLimit, SimulcastConfig, TrackBandwidthLimit, } from '@fishjam-cloud/react-client';
|
|
11
12
|
export type FishjamProviderProps = Omit<ReactClientFishjamProviderProps, 'persistLastDevice' | 'fishjamClient'>;
|
|
12
13
|
export declare function FishjamProvider(props: FishjamProviderProps): React.FunctionComponentElement<ReactClientFishjamProviderProps>;
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,mBAAmB,CAAC;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,KAAK,oBAAoB,IAAI,+BAA+B,EAC5D,aAAa,IAAI,wBAAwB,EAC1C,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EACL,uBAAuB,EACvB,QAAQ,EACR,OAAO,EACP,UAAU,EACV,eAAe,EACf,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAE5C,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW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EACd,QAAQ,EACR,eAAe,EACf,eAAe,EACf,KAAK,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,yBAAyB,EACzB,wBAAwB,EACxB,YAAY,EACZ,KAAK,EACL,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,+BAA+B,EAAE,mBAAmB,GAAG,eAAe,CAAC,CAAC;AAChH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,mEAO1D"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,8 @@ import { FishjamClient } from '@fishjam-cloud/ts-client';
|
|
|
10
10
|
export { RTCView, RTCPIPView } from './overrides/RTCView';
|
|
11
11
|
export { ScreenCapturePickerView, startPIP, stopPIP, useCallKit, useCallKitEvent, useCallKitService, } from '@fishjam-cloud/react-native-webrtc';
|
|
12
12
|
export { useForegroundService } from './useForegroundService';
|
|
13
|
-
export {
|
|
13
|
+
export { useCameraPermissions, useMicrophonePermissions, } from './hooks/usePermissions';
|
|
14
|
+
export { useCamera, useInitializeDevices, useConnection, useCustomSource, useDataChannel, useLivestreamStreamer, useLivestreamViewer, usePeers, useSandbox, useScreenShare, useUpdatePeerMetadata, useVAD, Variant, } from '@fishjam-cloud/react-client';
|
|
14
15
|
export const useMicrophone = useMicrophoneReactClient;
|
|
15
16
|
export function FishjamProvider(props) {
|
|
16
17
|
const fishjamClient = new FishjamClient({ reconnect: props.reconnect, debug: props.debug, clientType: 'mobile' });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserMedia.d.ts","sourceRoot":"","sources":["../../src/overrides/getUserMedia.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uCAAuC,YAyBnD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { permissions } from '@fishjam-cloud/react-native-webrtc';
|
|
2
|
+
export const patchGetUserMediaWithPermissionWarnings = () => {
|
|
3
|
+
const original = globalThis.navigator?.mediaDevices?.getUserMedia;
|
|
4
|
+
if (!original)
|
|
5
|
+
return;
|
|
6
|
+
const boundOriginal = original.bind(globalThis.navigator.mediaDevices);
|
|
7
|
+
globalThis.navigator.mediaDevices.getUserMedia = async (constraints) => {
|
|
8
|
+
try {
|
|
9
|
+
const [cameraStatus, micStatus] = await Promise.all([
|
|
10
|
+
constraints?.video ? permissions.query({ name: 'camera' }) : null,
|
|
11
|
+
constraints?.audio ? permissions.query({ name: 'microphone' }) : null,
|
|
12
|
+
]);
|
|
13
|
+
if (cameraStatus && cameraStatus !== 'granted') {
|
|
14
|
+
console.warn(`Attempting to access camera with permission status: "${cameraStatus}".`);
|
|
15
|
+
}
|
|
16
|
+
if (micStatus && micStatus !== 'granted') {
|
|
17
|
+
console.warn(`Attempting to access microphone with permission status: "${micStatus}".`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.warn('Failed to check permissions before getUserMedia', error);
|
|
22
|
+
}
|
|
23
|
+
return boundOriginal(constraints);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webrtc-polyfill.d.ts","sourceRoot":"","sources":["../src/webrtc-polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"webrtc-polyfill.d.ts","sourceRoot":"","sources":["../src/webrtc-polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,gCAAgC,CAAC;AACxC,OAAO,gCAAgC,CAAC"}
|
package/dist/webrtc-polyfill.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import 'fast-text-encoding';
|
|
1
2
|
import 'react-native-get-random-values';
|
|
3
|
+
import 'react-native-url-polyfill/auto';
|
|
2
4
|
import { registerGlobals } from '@fishjam-cloud/react-native-webrtc';
|
|
3
5
|
// @ts-ignore - event-target-shim types not properly exported via package.json exports
|
|
4
6
|
import { EventTarget } from 'event-target-shim';
|
|
7
|
+
import { patchGetUserMediaWithPermissionWarnings } from './overrides/getUserMedia';
|
|
5
8
|
import { RTCPeerConnection } from './overrides/RTCPeerConnection';
|
|
6
9
|
import { LocalStoragePolyfill } from './polyfills/local-storage';
|
|
7
10
|
const registerGlobalsPolyfill = () => {
|
|
@@ -10,5 +13,6 @@ const registerGlobalsPolyfill = () => {
|
|
|
10
13
|
registerGlobals();
|
|
11
14
|
// Custom overrides
|
|
12
15
|
globalThis.RTCPeerConnection = RTCPeerConnection;
|
|
16
|
+
patchGetUserMediaWithPermissionWarnings();
|
|
13
17
|
};
|
|
14
18
|
registerGlobalsPolyfill();
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/react-native-client",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.2",
|
|
4
4
|
"description": "React Native client library for Fishjam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Fishjam Team",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
|
-
"module": "./dist/index.js",
|
|
9
8
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"react-native": "
|
|
9
|
+
"react-native": "dist/index.js",
|
|
11
10
|
"files": [
|
|
12
11
|
"dist/**",
|
|
13
12
|
"plugin/build/**",
|
|
@@ -25,29 +24,24 @@
|
|
|
25
24
|
"webrtc",
|
|
26
25
|
"fishjam"
|
|
27
26
|
],
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"import": "./dist/index.js",
|
|
31
|
-
"types": "./dist/index.d.ts"
|
|
32
|
-
},
|
|
33
|
-
"./app.plugin": "./app.plugin.js",
|
|
34
|
-
"./app.plugin.js": "./app.plugin.js",
|
|
35
|
-
"./package.json": "./package.json"
|
|
36
|
-
},
|
|
37
27
|
"scripts": {
|
|
38
28
|
"build": "tsc && EXPO_NONINTERACTIVE=1 expo-module build plugin",
|
|
39
29
|
"lint": "eslint . --ext .ts,.tsx --fix",
|
|
40
30
|
"prepare": "tsc && EXPO_NONINTERACTIVE=1 expo-module build plugin"
|
|
41
31
|
},
|
|
42
32
|
"peerDependencies": {
|
|
33
|
+
"@fishjam-cloud/react-native-webrtc": "0.25.4",
|
|
43
34
|
"expo": "*",
|
|
44
35
|
"react": "*",
|
|
45
|
-
"react-native": "*"
|
|
36
|
+
"react-native": "*",
|
|
37
|
+
"react-native-get-random-values": "1.11.0"
|
|
46
38
|
},
|
|
47
39
|
"dependencies": {
|
|
48
|
-
"@fishjam-cloud/react-client": "
|
|
49
|
-
"@fishjam-cloud/react-native-webrtc": "0.25.
|
|
50
|
-
"
|
|
40
|
+
"@fishjam-cloud/react-client": "workspace:*",
|
|
41
|
+
"@fishjam-cloud/react-native-webrtc": "0.25.4",
|
|
42
|
+
"fast-text-encoding": "1.0.6",
|
|
43
|
+
"react-native-get-random-values": "1.11.0",
|
|
44
|
+
"react-native-url-polyfill": "3.0.0"
|
|
51
45
|
},
|
|
52
46
|
"devDependencies": {
|
|
53
47
|
"eslint-config-expo": "~9.2.0",
|
|
@@ -55,4 +49,4 @@
|
|
|
55
49
|
"expo-module-scripts": "^5.0.7"
|
|
56
50
|
},
|
|
57
51
|
"packageManager": "yarn@4.12.0"
|
|
58
|
-
}
|
|
52
|
+
}
|