@limrun/ui 0.4.0-rc.2 → 0.4.0-rc.4
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/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +273 -268
- package/package.json +1 -1
- package/src/components/remote-control.css +4 -0
- package/src/components/remote-control.tsx +17 -3
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useMemo, useState, forwardRef, useImperativeHandle } from 'react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import './remote-control.css';
|
|
4
4
|
|
|
@@ -134,6 +134,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
134
134
|
({ className, url, token, sessionId: propSessionId, openUrl }: RemoteControlProps, ref) => {
|
|
135
135
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
136
136
|
const frameRef = useRef<HTMLImageElement>(null);
|
|
137
|
+
const [videoLoaded, setVideoLoaded] = useState(false);
|
|
137
138
|
const wsRef = useRef<WebSocket | null>(null);
|
|
138
139
|
const peerConnectionRef = useRef<RTCPeerConnection | null>(null);
|
|
139
140
|
const dataChannelRef = useRef<RTCDataChannel | null>(null);
|
|
@@ -752,6 +753,9 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
752
753
|
};
|
|
753
754
|
|
|
754
755
|
useEffect(() => {
|
|
756
|
+
// Reset video loaded state when connection params change
|
|
757
|
+
setVideoLoaded(false);
|
|
758
|
+
|
|
755
759
|
// Start connection when component mounts
|
|
756
760
|
start();
|
|
757
761
|
|
|
@@ -780,7 +784,12 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
780
784
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
781
785
|
for (const entry of entries) {
|
|
782
786
|
const videoWidth = entry.contentRect.width;
|
|
783
|
-
|
|
787
|
+
const originalFrameWidth = frame.clientWidth;
|
|
788
|
+
const newFrameWidth = videoWidth * config.frameWidthMultiplier;
|
|
789
|
+
// The video is too small up until the first frame is visible, so we need to make sure we don't scale the frame down too much.
|
|
790
|
+
if (newFrameWidth > 0.9*originalFrameWidth) {
|
|
791
|
+
frame.style.width = `${videoWidth * config.frameWidthMultiplier}px`;
|
|
792
|
+
}
|
|
784
793
|
video.style.borderRadius = `${videoWidth * config.videoBorderRadiusMultiplier}px`;
|
|
785
794
|
}
|
|
786
795
|
});
|
|
@@ -927,7 +936,11 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
927
936
|
/>
|
|
928
937
|
<video
|
|
929
938
|
ref={videoRef}
|
|
930
|
-
className={clsx(
|
|
939
|
+
className={clsx(
|
|
940
|
+
'rc-video',
|
|
941
|
+
platform === 'ios' ? 'rc-video-ios' : 'rc-video-android',
|
|
942
|
+
!videoLoaded && 'rc-video-loading',
|
|
943
|
+
)}
|
|
931
944
|
style={
|
|
932
945
|
config.loadingLogo
|
|
933
946
|
? {
|
|
@@ -945,6 +958,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
945
958
|
onKeyDown={handleKeyboard}
|
|
946
959
|
onKeyUp={handleKeyboard}
|
|
947
960
|
onClick={handleVideoClick}
|
|
961
|
+
onPlaying={() => setVideoLoaded(true)}
|
|
948
962
|
onFocus={() => {
|
|
949
963
|
if (videoRef.current) {
|
|
950
964
|
videoRef.current.style.outline = 'none';
|