@limrun/ui 0.4.0-rc.5 → 0.4.0-rc.7
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/components/remote-control.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +282 -282
- package/package.json +1 -1
- package/src/components/remote-control.css +9 -2
- package/src/components/remote-control.tsx +19 -13
- package/src/demo.tsx +3 -2
package/package.json
CHANGED
|
@@ -27,18 +27,25 @@
|
|
|
27
27
|
background-color: black;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
.rc-video-frameless {
|
|
31
|
+
position: relative;
|
|
32
|
+
height: 100%;
|
|
33
|
+
top: auto;
|
|
34
|
+
left: auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
.rc-video-loading {
|
|
31
38
|
aspect-ratio: 9 / 19.5;
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
.rc-video-ios {
|
|
35
|
-
top: 1.
|
|
42
|
+
top: 1.61%;
|
|
36
43
|
left: 3.9%;
|
|
37
44
|
height: 96.76%;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
.rc-video-android {
|
|
41
|
-
top: 2.
|
|
48
|
+
top: 2.25%;
|
|
42
49
|
left: 4.5%;
|
|
43
50
|
height: 95.9%;
|
|
44
51
|
}
|
|
@@ -41,6 +41,10 @@ interface RemoteControlProps {
|
|
|
41
41
|
//
|
|
42
42
|
// If not provided, the component will not open any URL.
|
|
43
43
|
openUrl?: string;
|
|
44
|
+
|
|
45
|
+
// showFrame controls whether to display the device frame
|
|
46
|
+
// around the video. Defaults to true.
|
|
47
|
+
showFrame?: boolean;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
interface ScreenshotData {
|
|
@@ -89,13 +93,13 @@ const deviceConfig = {
|
|
|
89
93
|
ios: {
|
|
90
94
|
frameImage: iphoneFrameImage,
|
|
91
95
|
frameWidthMultiplier: 1.0841,
|
|
92
|
-
videoBorderRadiusMultiplier: 0.
|
|
96
|
+
videoBorderRadiusMultiplier: 0.15,
|
|
93
97
|
loadingLogo: appleLogoSvg,
|
|
94
98
|
},
|
|
95
99
|
android: {
|
|
96
100
|
frameImage: pixelFrameImage,
|
|
97
101
|
frameWidthMultiplier: 1.107,
|
|
98
|
-
videoBorderRadiusMultiplier: 0.
|
|
102
|
+
videoBorderRadiusMultiplier: 0.13,
|
|
99
103
|
loadingLogo: undefined,
|
|
100
104
|
},
|
|
101
105
|
};
|
|
@@ -131,7 +135,7 @@ function getAndroidKeycodeAndMeta(event: React.KeyboardEvent): { keycode: number
|
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>(
|
|
134
|
-
({ className, url, token, sessionId: propSessionId, openUrl }: RemoteControlProps, ref) => {
|
|
138
|
+
({ className, url, token, sessionId: propSessionId, openUrl, showFrame = true }: RemoteControlProps, ref) => {
|
|
135
139
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
136
140
|
const frameRef = useRef<HTMLImageElement>(null);
|
|
137
141
|
const [videoLoaded, setVideoLoaded] = useState(false);
|
|
@@ -779,7 +783,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
779
783
|
useEffect(() => {
|
|
780
784
|
const video = videoRef.current;
|
|
781
785
|
const frame = frameRef.current;
|
|
782
|
-
if (!video || !frame) return;
|
|
786
|
+
if (!video || !frame || !showFrame) return;
|
|
783
787
|
|
|
784
788
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
785
789
|
for (const entry of entries) {
|
|
@@ -799,7 +803,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
799
803
|
return () => {
|
|
800
804
|
resizeObserver.disconnect();
|
|
801
805
|
};
|
|
802
|
-
}, [config]);
|
|
806
|
+
}, [config, showFrame]);
|
|
803
807
|
|
|
804
808
|
const handleVideoClick = () => {
|
|
805
809
|
if (videoRef.current) {
|
|
@@ -927,18 +931,20 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
927
931
|
onTouchEnd={handleInteraction}
|
|
928
932
|
onTouchCancel={handleInteraction}
|
|
929
933
|
>
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
934
|
+
{showFrame && (
|
|
935
|
+
<img
|
|
936
|
+
ref={frameRef}
|
|
937
|
+
src={config.frameImage}
|
|
938
|
+
alt=""
|
|
939
|
+
className="rc-phone-frame"
|
|
940
|
+
draggable={false}
|
|
941
|
+
/>
|
|
942
|
+
)}
|
|
937
943
|
<video
|
|
938
944
|
ref={videoRef}
|
|
939
945
|
className={clsx(
|
|
940
946
|
'rc-video',
|
|
941
|
-
platform === 'ios' ? 'rc-video-ios' : 'rc-video-android',
|
|
947
|
+
showFrame ? (platform === 'ios' ? 'rc-video-ios' : 'rc-video-android') : 'rc-video-frameless',
|
|
942
948
|
!videoLoaded && 'rc-video-loading',
|
|
943
949
|
)}
|
|
944
950
|
style={
|
package/src/demo.tsx
CHANGED
|
@@ -3,8 +3,8 @@ import { createRoot } from 'react-dom/client';
|
|
|
3
3
|
import { RemoteControl, RemoteControlHandle } from './components/remote-control';
|
|
4
4
|
|
|
5
5
|
function Demo() {
|
|
6
|
-
const [url, setUrl] = useState('wss://eu-hel1-5-staging.limrun.dev/v1/organizations/org_01k3v8bvxvecfvscdhvcp3rga1/
|
|
7
|
-
const [token, setToken] = useState('
|
|
6
|
+
const [url, setUrl] = useState('wss://eu-hel1-5-staging.limrun.dev/v1/organizations/org_01k3v8bvxvecfvscdhvcp3rga1/android.limrun.com/v1/instances/android_eustg_01kd60xh0yfxzv6ccr0jz5dwf9/endpointWebSocket');
|
|
7
|
+
const [token, setToken] = useState('lim_0961f306d81a78c743aca5826d4d122c18ed5e55b813e181');
|
|
8
8
|
const [platform, setPlatform] = useState<'ios' | 'android'>('ios');
|
|
9
9
|
const [isConnected, setIsConnected] = useState(false);
|
|
10
10
|
const [key, setKey] = useState(0);
|
|
@@ -165,6 +165,7 @@ function Demo() {
|
|
|
165
165
|
ref={remoteControlRef}
|
|
166
166
|
url={url}
|
|
167
167
|
token={token}
|
|
168
|
+
showFrame={false}
|
|
168
169
|
/>
|
|
169
170
|
</div>
|
|
170
171
|
</div>
|