@livekit/react-native 2.0.2 → 2.1.0-0
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/lib/commonjs/components/LiveKitRoom.js +43 -0
- package/lib/commonjs/components/LiveKitRoom.js.map +1 -0
- package/lib/commonjs/components/VideoTrack.js +171 -0
- package/lib/commonjs/components/VideoTrack.js.map +1 -0
- package/lib/commonjs/components/VideoView.js +3 -0
- package/lib/commonjs/components/VideoView.js.map +1 -1
- package/lib/commonjs/hooks.js +232 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +42 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/useParticipant.js +1 -0
- package/lib/commonjs/useParticipant.js.map +1 -1
- package/lib/commonjs/useRoom.js +1 -0
- package/lib/commonjs/useRoom.js.map +1 -1
- package/lib/module/components/LiveKitRoom.js +32 -0
- package/lib/module/components/LiveKitRoom.js.map +1 -0
- package/lib/module/components/VideoTrack.js +152 -0
- package/lib/module/components/VideoTrack.js.map +1 -0
- package/lib/module/components/VideoView.js +7 -0
- package/lib/module/components/VideoView.js.map +1 -1
- package/lib/module/hooks.js +3 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +9 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/useParticipant.js +3 -0
- package/lib/module/useParticipant.js.map +1 -1
- package/lib/module/useRoom.js +2 -0
- package/lib/module/useRoom.js.map +1 -1
- package/lib/typescript/components/LiveKitRoom.d.ts +90 -0
- package/lib/typescript/components/VideoTrack.d.ts +11 -0
- package/lib/typescript/components/VideoView.d.ts +6 -0
- package/lib/typescript/hooks.d.ts +2 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/useParticipant.d.ts +2 -0
- package/lib/typescript/useRoom.d.ts +1 -0
- package/livekit-react-native.podspec +5 -0
- package/package.json +2 -1
- package/src/components/LiveKitRoom.tsx +118 -0
- package/src/components/VideoTrack.tsx +150 -0
- package/src/components/VideoView.tsx +6 -0
- package/src/hooks.ts +40 -0
- package/src/index.tsx +6 -4
- package/src/useParticipant.ts +2 -1
- package/src/useRoom.ts +1 -0
- package/android/local.properties +0 -8
- package/ios/LivekitReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/LivekitReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/LivekitReactNative.xcodeproj/project.xcworkspace/xcuserdata/davidliu.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/LivekitReactNative.xcodeproj/xcuserdata/davidliu.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { FeatureFlags } from '@livekit/components-react';
|
|
2
|
+
import type { AudioCaptureOptions, RoomConnectOptions, RoomOptions, ScreenShareCaptureOptions, VideoCaptureOptions } from 'livekit-client';
|
|
3
|
+
import type { MediaDeviceFailure, Room } from 'livekit-client';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** @public */
|
|
6
|
+
export interface LiveKitRoomProps {
|
|
7
|
+
/**
|
|
8
|
+
* URL to the LiveKit server.
|
|
9
|
+
* For example: `wss://<domain>.livekit.cloud`
|
|
10
|
+
* To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string url can the connection be established.
|
|
11
|
+
*/
|
|
12
|
+
serverUrl: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* A user specific access token for a client to authenticate to the room.
|
|
15
|
+
* This token is necessary to establish a connection to the room.
|
|
16
|
+
* To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string token can the connection be established.
|
|
17
|
+
*
|
|
18
|
+
* @see https://docs.livekit.io/cloud/project-management/keys-and-tokens/#generating-access-tokens
|
|
19
|
+
*/
|
|
20
|
+
token: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Publish audio immediately after connecting to your LiveKit room.
|
|
23
|
+
* @defaultValue `false`
|
|
24
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/AudioCaptureOptions.html
|
|
25
|
+
*/
|
|
26
|
+
audio?: AudioCaptureOptions | boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Publish video immediately after connecting to your LiveKit room.
|
|
29
|
+
* @defaultValue `false`
|
|
30
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/VideoCaptureOptions.html
|
|
31
|
+
*/
|
|
32
|
+
video?: VideoCaptureOptions | boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Publish screen share immediately after connecting to your LiveKit room.
|
|
35
|
+
* @defaultValue `false`
|
|
36
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/ScreenShareCaptureOptions.html
|
|
37
|
+
*/
|
|
38
|
+
screen?: ScreenShareCaptureOptions | boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If set to true a connection to LiveKit room is initiated.
|
|
41
|
+
* @defaultValue `false`
|
|
42
|
+
*/
|
|
43
|
+
connect?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Options for when creating a new room.
|
|
46
|
+
* When you pass your own room instance to this component, these options have no effect.
|
|
47
|
+
* Instead, set the options directly in the room instance.
|
|
48
|
+
*
|
|
49
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/RoomOptions.html
|
|
50
|
+
*/
|
|
51
|
+
options?: RoomOptions;
|
|
52
|
+
/**
|
|
53
|
+
* Define options how to connect to the LiveKit server.
|
|
54
|
+
*
|
|
55
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/RoomConnectOptions.html
|
|
56
|
+
*/
|
|
57
|
+
connectOptions?: RoomConnectOptions;
|
|
58
|
+
onConnected?: () => void;
|
|
59
|
+
onDisconnected?: () => void;
|
|
60
|
+
onError?: (error: Error) => void;
|
|
61
|
+
onMediaDeviceFailure?: (failure?: MediaDeviceFailure) => void;
|
|
62
|
+
onEncryptionError?: (error: Error) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Optional room instance.
|
|
65
|
+
* By passing your own room instance you overwrite the `options` parameter,
|
|
66
|
+
* make sure to set the options directly on the room instance itself.
|
|
67
|
+
*/
|
|
68
|
+
room?: Room;
|
|
69
|
+
simulateParticipants?: number | undefined;
|
|
70
|
+
/** @experimental */
|
|
71
|
+
featureFlags?: FeatureFlags | undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The `LiveKitRoom` component provides the room context to all its child components.
|
|
75
|
+
* It is generally the starting point of your LiveKit app and the root of the LiveKit component tree.
|
|
76
|
+
* It provides the room state as a React context to all child components, so you don't have to pass it yourself.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <LiveKitRoom
|
|
81
|
+
* token='<livekit-token>'
|
|
82
|
+
* serverUrl='<url-to-livekit-server>'
|
|
83
|
+
* connect={true}
|
|
84
|
+
* >
|
|
85
|
+
* ...
|
|
86
|
+
* </LiveKitRoom>
|
|
87
|
+
* ```
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export declare function LiveKitRoom(props: React.PropsWithChildren<LiveKitRoomProps>): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import type { TrackReference } from '@livekit/components-react';
|
|
4
|
+
export declare type VideoTrackProps = {
|
|
5
|
+
trackRef: TrackReference | undefined;
|
|
6
|
+
style?: ViewStyle;
|
|
7
|
+
objectFit?: 'cover' | 'contain' | undefined;
|
|
8
|
+
mirror?: boolean;
|
|
9
|
+
zOrder?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const VideoTrack: ({ style, trackRef, objectFit, zOrder, mirror, }: VideoTrackProps) => React.JSX.Element;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ViewStyle } from 'react-native';
|
|
3
3
|
import { VideoTrack } from 'livekit-client';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use `VideoTrack` and `VideoTrackProps` instead.
|
|
6
|
+
*/
|
|
4
7
|
export declare type Props = {
|
|
5
8
|
videoTrack?: VideoTrack | undefined;
|
|
6
9
|
style?: ViewStyle;
|
|
@@ -8,4 +11,7 @@ export declare type Props = {
|
|
|
8
11
|
mirror?: boolean;
|
|
9
12
|
zOrder?: number;
|
|
10
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated use `VideoTrack` and `VideoTrackProps` instead.
|
|
16
|
+
*/
|
|
11
17
|
export declare const VideoView: ({ style, videoTrack, objectFit, zOrder, mirror, }: Props) => React.JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { useConnectionState, useDataChannel, useIsSpeaking, useLocalParticipant, UseLocalParticipantOptions, useLocalParticipantPermissions, useParticipantInfo, UseParticipantInfoOptions, useParticipants, UseParticipantsOptions, useRemoteParticipants, UseRemoteParticipantOptions, useRemoteParticipant, UseRemoteParticipantsOptions, useSpeakingParticipants, useSortedParticipants, useChat, useIsEncrypted, useIsMuted, useParticipantTracks, useLiveKitRoom, RoomContext, useRoomContext, ParticipantContext, useParticipantContext, TrackRefContext, useTrackRefContext, useTracks, UseTracksOptions, TrackReference, TrackReferenceOrPlaceholder, isTrackReference, useEnsureTrackRef, useTrackMutedIndicator, useVisualStableUpdate, UseVisualStableUpdateOptions, } from '@livekit/components-react';
|
|
2
|
+
export { ReceivedDataMessage } from '@livekit/components-core';
|
|
@@ -8,6 +8,9 @@ import type { LogLevel, SetLogLevelOptions } from './logger';
|
|
|
8
8
|
* Must be called before using LiveKit.
|
|
9
9
|
*/
|
|
10
10
|
export declare function registerGlobals(): void;
|
|
11
|
+
export * from './hooks';
|
|
12
|
+
export * from './components/LiveKitRoom';
|
|
13
|
+
export * from './components/VideoTrack';
|
|
11
14
|
export * from './components/VideoView';
|
|
12
15
|
export * from './useParticipant';
|
|
13
16
|
export * from './useRoom';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConnectionQuality, Participant, TrackPublication } from 'livekit-client';
|
|
2
|
+
/** @deprecated use `useRemoteParticipant` or `useLocalParticipant` instead */
|
|
2
3
|
export interface ParticipantState {
|
|
3
4
|
isSpeaking: boolean;
|
|
4
5
|
connectionQuality: ConnectionQuality;
|
|
@@ -10,4 +11,5 @@ export interface ParticipantState {
|
|
|
10
11
|
microphonePublication?: TrackPublication;
|
|
11
12
|
screenSharePublication?: TrackPublication;
|
|
12
13
|
}
|
|
14
|
+
/** @deprecated use `useRemoteParticipant` or `useLocalParticipant` instead */
|
|
13
15
|
export declare function useParticipant(participant: Participant): ParticipantState;
|
|
@@ -8,6 +8,7 @@ export interface RoomState {
|
|
|
8
8
|
export interface RoomOptions {
|
|
9
9
|
sortParticipants?: (participants: Participant[]) => void;
|
|
10
10
|
}
|
|
11
|
+
/** @deprecated wrap your components in a <LiveKitRoom> component instead and use more granular hooks to track state you're interested in */
|
|
11
12
|
export declare function useRoom(room: Room, options?: RoomOptions): RoomState;
|
|
12
13
|
/**
|
|
13
14
|
* Default sort for participants, it'll order participants by:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livekit/react-native",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-0",
|
|
4
4
|
"description": "LiveKit for React Native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"android"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@livekit/components-react": "^2.0.6",
|
|
45
46
|
"array.prototype.at": "^1.1.1",
|
|
46
47
|
"fastestsmallesttextencoderdecoder": "^1.0.22",
|
|
47
48
|
"livekit-client": "^2.0.0",
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FeatureFlags,
|
|
3
|
+
LKFeatureContext,
|
|
4
|
+
RoomContext,
|
|
5
|
+
useLiveKitRoom,
|
|
6
|
+
} from '@livekit/components-react';
|
|
7
|
+
import type {
|
|
8
|
+
AudioCaptureOptions,
|
|
9
|
+
RoomConnectOptions,
|
|
10
|
+
RoomOptions,
|
|
11
|
+
ScreenShareCaptureOptions,
|
|
12
|
+
VideoCaptureOptions,
|
|
13
|
+
} from 'livekit-client';
|
|
14
|
+
import type { MediaDeviceFailure, Room } from 'livekit-client';
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
18
|
+
export interface LiveKitRoomProps {
|
|
19
|
+
/**
|
|
20
|
+
* URL to the LiveKit server.
|
|
21
|
+
* For example: `wss://<domain>.livekit.cloud`
|
|
22
|
+
* To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string url can the connection be established.
|
|
23
|
+
*/
|
|
24
|
+
serverUrl: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* A user specific access token for a client to authenticate to the room.
|
|
27
|
+
* This token is necessary to establish a connection to the room.
|
|
28
|
+
* To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string token can the connection be established.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.livekit.io/cloud/project-management/keys-and-tokens/#generating-access-tokens
|
|
31
|
+
*/
|
|
32
|
+
token: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Publish audio immediately after connecting to your LiveKit room.
|
|
35
|
+
* @defaultValue `false`
|
|
36
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/AudioCaptureOptions.html
|
|
37
|
+
*/
|
|
38
|
+
audio?: AudioCaptureOptions | boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Publish video immediately after connecting to your LiveKit room.
|
|
41
|
+
* @defaultValue `false`
|
|
42
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/VideoCaptureOptions.html
|
|
43
|
+
*/
|
|
44
|
+
video?: VideoCaptureOptions | boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Publish screen share immediately after connecting to your LiveKit room.
|
|
47
|
+
* @defaultValue `false`
|
|
48
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/ScreenShareCaptureOptions.html
|
|
49
|
+
*/
|
|
50
|
+
screen?: ScreenShareCaptureOptions | boolean;
|
|
51
|
+
/**
|
|
52
|
+
* If set to true a connection to LiveKit room is initiated.
|
|
53
|
+
* @defaultValue `false`
|
|
54
|
+
*/
|
|
55
|
+
connect?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Options for when creating a new room.
|
|
58
|
+
* When you pass your own room instance to this component, these options have no effect.
|
|
59
|
+
* Instead, set the options directly in the room instance.
|
|
60
|
+
*
|
|
61
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/RoomOptions.html
|
|
62
|
+
*/
|
|
63
|
+
options?: RoomOptions;
|
|
64
|
+
/**
|
|
65
|
+
* Define options how to connect to the LiveKit server.
|
|
66
|
+
*
|
|
67
|
+
* @see https://docs.livekit.io/client-sdk-js/interfaces/RoomConnectOptions.html
|
|
68
|
+
*/
|
|
69
|
+
connectOptions?: RoomConnectOptions;
|
|
70
|
+
onConnected?: () => void;
|
|
71
|
+
onDisconnected?: () => void;
|
|
72
|
+
onError?: (error: Error) => void;
|
|
73
|
+
onMediaDeviceFailure?: (failure?: MediaDeviceFailure) => void;
|
|
74
|
+
onEncryptionError?: (error: Error) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Optional room instance.
|
|
77
|
+
* By passing your own room instance you overwrite the `options` parameter,
|
|
78
|
+
* make sure to set the options directly on the room instance itself.
|
|
79
|
+
*/
|
|
80
|
+
room?: Room;
|
|
81
|
+
|
|
82
|
+
simulateParticipants?: number | undefined;
|
|
83
|
+
|
|
84
|
+
/** @experimental */
|
|
85
|
+
featureFlags?: FeatureFlags | undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The `LiveKitRoom` component provides the room context to all its child components.
|
|
90
|
+
* It is generally the starting point of your LiveKit app and the root of the LiveKit component tree.
|
|
91
|
+
* It provides the room state as a React context to all child components, so you don't have to pass it yourself.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <LiveKitRoom
|
|
96
|
+
* token='<livekit-token>'
|
|
97
|
+
* serverUrl='<url-to-livekit-server>'
|
|
98
|
+
* connect={true}
|
|
99
|
+
* >
|
|
100
|
+
* ...
|
|
101
|
+
* </LiveKitRoom>
|
|
102
|
+
* ```
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export function LiveKitRoom(props: React.PropsWithChildren<LiveKitRoomProps>) {
|
|
106
|
+
const { room } = useLiveKitRoom(props);
|
|
107
|
+
return (
|
|
108
|
+
<>
|
|
109
|
+
{room && (
|
|
110
|
+
<RoomContext.Provider value={room}>
|
|
111
|
+
<LKFeatureContext.Provider value={props.featureFlags}>
|
|
112
|
+
{props.children}
|
|
113
|
+
</LKFeatureContext.Provider>
|
|
114
|
+
</RoomContext.Provider>
|
|
115
|
+
)}
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { LayoutChangeEvent, StyleSheet, View, ViewStyle } from 'react-native';
|
|
4
|
+
import {
|
|
5
|
+
ElementInfo,
|
|
6
|
+
LocalVideoTrack,
|
|
7
|
+
Track,
|
|
8
|
+
TrackEvent,
|
|
9
|
+
} from 'livekit-client';
|
|
10
|
+
import { RTCView } from '@livekit/react-native-webrtc';
|
|
11
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
12
|
+
import { RemoteVideoTrack } from 'livekit-client';
|
|
13
|
+
import ViewPortDetector from './ViewPortDetector';
|
|
14
|
+
import type { TrackReference } from '@livekit/components-react';
|
|
15
|
+
|
|
16
|
+
export type VideoTrackProps = {
|
|
17
|
+
trackRef: TrackReference | undefined;
|
|
18
|
+
style?: ViewStyle;
|
|
19
|
+
objectFit?: 'cover' | 'contain' | undefined;
|
|
20
|
+
mirror?: boolean;
|
|
21
|
+
zOrder?: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const VideoTrack = ({
|
|
25
|
+
style = {},
|
|
26
|
+
trackRef,
|
|
27
|
+
objectFit = 'cover',
|
|
28
|
+
zOrder,
|
|
29
|
+
mirror,
|
|
30
|
+
}: VideoTrackProps) => {
|
|
31
|
+
const [elementInfo] = useState(() => {
|
|
32
|
+
let info = new VideoTrackElementInfo();
|
|
33
|
+
info.id = trackRef?.publication?.trackSid;
|
|
34
|
+
return info;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const layoutOnChange = useCallback(
|
|
38
|
+
(event: LayoutChangeEvent) => elementInfo.onLayout(event),
|
|
39
|
+
[elementInfo]
|
|
40
|
+
);
|
|
41
|
+
const visibilityOnChange = useCallback(
|
|
42
|
+
(isVisible: boolean) => elementInfo.onVisibility(isVisible),
|
|
43
|
+
[elementInfo]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const videoTrack = trackRef?.publication.track;
|
|
47
|
+
|
|
48
|
+
const shouldObserveVisibility = useMemo(() => {
|
|
49
|
+
return (
|
|
50
|
+
videoTrack instanceof RemoteVideoTrack && videoTrack.isAdaptiveStream
|
|
51
|
+
);
|
|
52
|
+
}, [videoTrack]);
|
|
53
|
+
|
|
54
|
+
const [mediaStream, setMediaStream] = useState(videoTrack?.mediaStream);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
setMediaStream(videoTrack?.mediaStream);
|
|
57
|
+
if (videoTrack instanceof LocalVideoTrack) {
|
|
58
|
+
const onRestarted = (track: Track | null) => {
|
|
59
|
+
setMediaStream(track?.mediaStream);
|
|
60
|
+
};
|
|
61
|
+
videoTrack.on(TrackEvent.Restarted, onRestarted);
|
|
62
|
+
|
|
63
|
+
return () => {
|
|
64
|
+
videoTrack.off(TrackEvent.Restarted, onRestarted);
|
|
65
|
+
};
|
|
66
|
+
} else {
|
|
67
|
+
return () => {};
|
|
68
|
+
}
|
|
69
|
+
}, [videoTrack]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (videoTrack instanceof RemoteVideoTrack && videoTrack.isAdaptiveStream) {
|
|
73
|
+
videoTrack?.observeElementInfo(elementInfo);
|
|
74
|
+
return () => {
|
|
75
|
+
videoTrack?.stopObservingElementInfo(elementInfo);
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
return () => {};
|
|
79
|
+
}
|
|
80
|
+
}, [videoTrack, elementInfo]);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<View style={{ ...style, ...styles.container }} onLayout={layoutOnChange}>
|
|
84
|
+
<ViewPortDetector
|
|
85
|
+
onChange={visibilityOnChange}
|
|
86
|
+
style={styles.videoTrack}
|
|
87
|
+
disabled={!shouldObserveVisibility}
|
|
88
|
+
propKey={videoTrack}
|
|
89
|
+
>
|
|
90
|
+
<RTCView
|
|
91
|
+
style={styles.videoTrack}
|
|
92
|
+
streamURL={mediaStream?.toURL() ?? ''}
|
|
93
|
+
objectFit={objectFit}
|
|
94
|
+
zOrder={zOrder}
|
|
95
|
+
mirror={mirror}
|
|
96
|
+
/>
|
|
97
|
+
</ViewPortDetector>
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const styles = StyleSheet.create({
|
|
103
|
+
container: {},
|
|
104
|
+
videoTrack: {
|
|
105
|
+
flex: 1,
|
|
106
|
+
width: '100%',
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
class VideoTrackElementInfo implements ElementInfo {
|
|
111
|
+
element: object = {};
|
|
112
|
+
something?: any;
|
|
113
|
+
id?: string;
|
|
114
|
+
_width = 0;
|
|
115
|
+
_height = 0;
|
|
116
|
+
_observing = false;
|
|
117
|
+
visible: boolean = true;
|
|
118
|
+
visibilityChangedAt: number | undefined;
|
|
119
|
+
pictureInPicture = false;
|
|
120
|
+
handleResize?: (() => void) | undefined;
|
|
121
|
+
handleVisibilityChanged?: (() => void) | undefined;
|
|
122
|
+
width = () => this._width;
|
|
123
|
+
height = () => this._height;
|
|
124
|
+
|
|
125
|
+
observe(): void {
|
|
126
|
+
this._observing = true;
|
|
127
|
+
}
|
|
128
|
+
stopObserving(): void {
|
|
129
|
+
this._observing = false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
onLayout(event: LayoutChangeEvent) {
|
|
133
|
+
let { width, height } = event.nativeEvent.layout;
|
|
134
|
+
this._width = width;
|
|
135
|
+
this._height = height;
|
|
136
|
+
|
|
137
|
+
if (this._observing) {
|
|
138
|
+
this.handleResize?.();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
onVisibility(isVisible: boolean) {
|
|
142
|
+
if (this.visible !== isVisible) {
|
|
143
|
+
this.visible = isVisible;
|
|
144
|
+
this.visibilityChangedAt = Date.now();
|
|
145
|
+
if (this._observing) {
|
|
146
|
+
this.handleVisibilityChanged?.();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -13,6 +13,9 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
13
13
|
import { RemoteVideoTrack } from 'livekit-client';
|
|
14
14
|
import ViewPortDetector from './ViewPortDetector';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use `VideoTrack` and `VideoTrackProps` instead.
|
|
18
|
+
*/
|
|
16
19
|
export type Props = {
|
|
17
20
|
videoTrack?: VideoTrack | undefined;
|
|
18
21
|
style?: ViewStyle;
|
|
@@ -21,6 +24,9 @@ export type Props = {
|
|
|
21
24
|
zOrder?: number;
|
|
22
25
|
};
|
|
23
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated use `VideoTrack` and `VideoTrackProps` instead.
|
|
29
|
+
*/
|
|
24
30
|
export const VideoView = ({
|
|
25
31
|
style = {},
|
|
26
32
|
videoTrack,
|
package/src/hooks.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export {
|
|
2
|
+
useConnectionState,
|
|
3
|
+
useDataChannel,
|
|
4
|
+
useIsSpeaking,
|
|
5
|
+
useLocalParticipant,
|
|
6
|
+
UseLocalParticipantOptions,
|
|
7
|
+
useLocalParticipantPermissions,
|
|
8
|
+
useParticipantInfo,
|
|
9
|
+
UseParticipantInfoOptions,
|
|
10
|
+
useParticipants,
|
|
11
|
+
UseParticipantsOptions,
|
|
12
|
+
useRemoteParticipants,
|
|
13
|
+
UseRemoteParticipantOptions,
|
|
14
|
+
useRemoteParticipant,
|
|
15
|
+
UseRemoteParticipantsOptions,
|
|
16
|
+
useSpeakingParticipants,
|
|
17
|
+
useSortedParticipants,
|
|
18
|
+
useChat,
|
|
19
|
+
useIsEncrypted,
|
|
20
|
+
useIsMuted,
|
|
21
|
+
useParticipantTracks,
|
|
22
|
+
useLiveKitRoom,
|
|
23
|
+
RoomContext,
|
|
24
|
+
useRoomContext,
|
|
25
|
+
ParticipantContext,
|
|
26
|
+
useParticipantContext,
|
|
27
|
+
TrackRefContext,
|
|
28
|
+
useTrackRefContext,
|
|
29
|
+
useTracks,
|
|
30
|
+
UseTracksOptions,
|
|
31
|
+
TrackReference,
|
|
32
|
+
TrackReferenceOrPlaceholder,
|
|
33
|
+
isTrackReference,
|
|
34
|
+
useEnsureTrackRef,
|
|
35
|
+
useTrackMutedIndicator,
|
|
36
|
+
useVisualStableUpdate,
|
|
37
|
+
UseVisualStableUpdateOptions,
|
|
38
|
+
} from '@livekit/components-react';
|
|
39
|
+
|
|
40
|
+
export { ReceivedDataMessage } from '@livekit/components-core';
|
package/src/index.tsx
CHANGED
|
@@ -74,10 +74,12 @@ function shimIterator() {
|
|
|
74
74
|
var shim = require('well-known-symbols/Symbol.iterator/shim');
|
|
75
75
|
shim();
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
export * from './components/
|
|
79
|
-
export * from './
|
|
80
|
-
export * from './
|
|
77
|
+
export * from './hooks';
|
|
78
|
+
export * from './components/LiveKitRoom';
|
|
79
|
+
export * from './components/VideoTrack';
|
|
80
|
+
export * from './components/VideoView'; // deprecated
|
|
81
|
+
export * from './useParticipant'; // deprecated
|
|
82
|
+
export * from './useRoom'; // deprecated
|
|
81
83
|
export * from './logger';
|
|
82
84
|
export * from './audio/AudioManager';
|
|
83
85
|
|
package/src/useParticipant.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from 'livekit-client';
|
|
9
9
|
import { useEffect, useState } from 'react';
|
|
10
10
|
|
|
11
|
+
/** @deprecated use `useRemoteParticipant` or `useLocalParticipant` instead */
|
|
11
12
|
export interface ParticipantState {
|
|
12
13
|
isSpeaking: boolean;
|
|
13
14
|
connectionQuality: ConnectionQuality;
|
|
@@ -19,7 +20,7 @@ export interface ParticipantState {
|
|
|
19
20
|
microphonePublication?: TrackPublication;
|
|
20
21
|
screenSharePublication?: TrackPublication;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
/** @deprecated use `useRemoteParticipant` or `useLocalParticipant` instead */
|
|
23
24
|
export function useParticipant(participant: Participant): ParticipantState {
|
|
24
25
|
const [isAudioMuted, setAudioMuted] = useState(false);
|
|
25
26
|
const [, setVideoMuted] = useState(false);
|
package/src/useRoom.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface RoomOptions {
|
|
|
23
23
|
sortParticipants?: (participants: Participant[]) => void;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** @deprecated wrap your components in a <LiveKitRoom> component instead and use more granular hooks to track state you're interested in */
|
|
26
27
|
export function useRoom(room: Room, options?: RoomOptions): RoomState {
|
|
27
28
|
const [error] = useState<Error>();
|
|
28
29
|
const [participants, setParticipants] = useState<Participant[]>([]);
|
package/android/local.properties
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
-
# as it contains information specific to your local configuration.
|
|
3
|
-
#
|
|
4
|
-
# Location of the SDK. This is only used by Gradle.
|
|
5
|
-
# For customization when using a Version Control System, please read the
|
|
6
|
-
# header note.
|
|
7
|
-
#Mon Jan 23 20:31:14 JST 2023
|
|
8
|
-
sdk.dir=/Users/davidliu/Library/Android/sdk
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>LivekitReactNative.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>0</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
</dict>
|
|
13
|
-
</dict>
|
|
14
|
-
</plist>
|