@limrun/ui 0.4.0-rc.7 → 0.4.0-rc.8
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 +306 -302
- package/index.html +4 -2
- package/package.json +1 -1
- package/src/assets/iphone16pro_black_landscape.webp +0 -0
- package/src/assets/pixel9_black_landscape.webp +0 -0
- package/src/components/remote-control.css +23 -5
- package/src/components/remote-control.tsx +14 -5
- package/src/demo.tsx +2 -3
- package/src/image.png +0 -0
- package/src/landscape.png +0 -0
- package/src/portrait.png +0 -0
package/index.html
CHANGED
|
@@ -134,7 +134,8 @@
|
|
|
134
134
|
.preview-item {
|
|
135
135
|
flex: 1;
|
|
136
136
|
min-width: 300px;
|
|
137
|
-
max-width:
|
|
137
|
+
max-width: 800px;
|
|
138
|
+
max-height: 800px;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
.preview-item h3 {
|
|
@@ -145,7 +146,8 @@
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
.device-wrapper {
|
|
148
|
-
height:
|
|
149
|
+
height: 100%;
|
|
150
|
+
width: 100%;
|
|
149
151
|
background: #f9fafb;
|
|
150
152
|
border-radius: 12px;
|
|
151
153
|
overflow: hidden;
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -12,10 +12,16 @@
|
|
|
12
12
|
position: relative;
|
|
13
13
|
z-index: 20;
|
|
14
14
|
display: block;
|
|
15
|
-
height: 100%;
|
|
16
15
|
pointer-events: none;
|
|
17
16
|
user-select: none;
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.rc-phone-frame-portrait {
|
|
20
|
+
height: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.rc-phone-frame-landscape {
|
|
24
|
+
width: 100%;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
.rc-video {
|
|
@@ -38,14 +44,26 @@
|
|
|
38
44
|
aspect-ratio: 9 / 19.5;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
.rc-video-ios {
|
|
47
|
+
.rc-video-ios-portrait {
|
|
42
48
|
top: 1.61%;
|
|
43
49
|
left: 3.9%;
|
|
44
|
-
height: 96.
|
|
50
|
+
height: 96.78%;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.rc-video-ios-landscape {
|
|
54
|
+
top: 3.9%;
|
|
55
|
+
left: 1.61%;
|
|
56
|
+
width: 96.78%;
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
.rc-video-android {
|
|
59
|
+
.rc-video-android-portrait {
|
|
48
60
|
top: 2.25%;
|
|
49
61
|
left: 4.5%;
|
|
50
62
|
height: 95.9%;
|
|
51
63
|
}
|
|
64
|
+
|
|
65
|
+
.rc-video-android-landscape {
|
|
66
|
+
left: 2.25%;
|
|
67
|
+
top: 4.5%;
|
|
68
|
+
width: 95.9%;
|
|
69
|
+
}
|
|
@@ -6,6 +6,8 @@ import { ANDROID_KEYS, AMOTION_EVENT, codeMap } from '../core/constants';
|
|
|
6
6
|
|
|
7
7
|
import iphoneFrameImage from '../assets/iphone16pro_black.webp';
|
|
8
8
|
import pixelFrameImage from '../assets/pixel9_black.webp';
|
|
9
|
+
import pixelFrameImageLandscape from '../assets/pixel9_black_landscape.webp';
|
|
10
|
+
import iphoneFrameImageLandscape from '../assets/iphone16pro_black_landscape.webp';
|
|
9
11
|
import appleLogoSvg from '../assets/Apple_logo_white.svg';
|
|
10
12
|
import {
|
|
11
13
|
createTouchControlMessage,
|
|
@@ -92,12 +94,14 @@ const detectPlatform = (url: string): DevicePlatform => {
|
|
|
92
94
|
const deviceConfig = {
|
|
93
95
|
ios: {
|
|
94
96
|
frameImage: iphoneFrameImage,
|
|
97
|
+
frameImageLandscape: iphoneFrameImageLandscape,
|
|
95
98
|
frameWidthMultiplier: 1.0841,
|
|
96
99
|
videoBorderRadiusMultiplier: 0.15,
|
|
97
100
|
loadingLogo: appleLogoSvg,
|
|
98
101
|
},
|
|
99
102
|
android: {
|
|
100
103
|
frameImage: pixelFrameImage,
|
|
104
|
+
frameImageLandscape: pixelFrameImageLandscape,
|
|
101
105
|
frameWidthMultiplier: 1.107,
|
|
102
106
|
videoBorderRadiusMultiplier: 0.13,
|
|
103
107
|
loadingLogo: undefined,
|
|
@@ -139,6 +143,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
139
143
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
140
144
|
const frameRef = useRef<HTMLImageElement>(null);
|
|
141
145
|
const [videoLoaded, setVideoLoaded] = useState(false);
|
|
146
|
+
const [isLandscape, setIsLandscape] = useState(false);
|
|
142
147
|
const wsRef = useRef<WebSocket | null>(null);
|
|
143
148
|
const peerConnectionRef = useRef<RTCPeerConnection | null>(null);
|
|
144
149
|
const dataChannelRef = useRef<RTCDataChannel | null>(null);
|
|
@@ -787,14 +792,18 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
787
792
|
|
|
788
793
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
789
794
|
for (const entry of entries) {
|
|
795
|
+
const landscape = entry.contentRect.width > entry.contentRect.height;
|
|
796
|
+
setIsLandscape(landscape);
|
|
790
797
|
const videoWidth = entry.contentRect.width;
|
|
798
|
+
const videoHeight = entry.contentRect.height;
|
|
791
799
|
const originalFrameWidth = frame.clientWidth;
|
|
792
800
|
const newFrameWidth = videoWidth * config.frameWidthMultiplier;
|
|
793
801
|
// 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.
|
|
794
|
-
if (newFrameWidth > 0.9*originalFrameWidth) {
|
|
802
|
+
if (!landscape && newFrameWidth > 0.9*originalFrameWidth) {
|
|
803
|
+
// This is mostly for iOS where the video size is slightly inconsistent.
|
|
795
804
|
frame.style.width = `${videoWidth * config.frameWidthMultiplier}px`;
|
|
796
805
|
}
|
|
797
|
-
video.style.borderRadius = `${videoWidth * config.videoBorderRadiusMultiplier}px`;
|
|
806
|
+
video.style.borderRadius = `${(entry.contentRect.width > entry.contentRect.height ? videoHeight : videoWidth) * config.videoBorderRadiusMultiplier}px`;
|
|
798
807
|
}
|
|
799
808
|
});
|
|
800
809
|
|
|
@@ -934,9 +943,9 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
934
943
|
{showFrame && (
|
|
935
944
|
<img
|
|
936
945
|
ref={frameRef}
|
|
937
|
-
src={config.frameImage}
|
|
946
|
+
src={isLandscape ? config.frameImageLandscape : config.frameImage}
|
|
938
947
|
alt=""
|
|
939
|
-
className=
|
|
948
|
+
className={clsx('rc-phone-frame', isLandscape ? 'rc-phone-frame-landscape' : 'rc-phone-frame-portrait')}
|
|
940
949
|
draggable={false}
|
|
941
950
|
/>
|
|
942
951
|
)}
|
|
@@ -944,7 +953,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
944
953
|
ref={videoRef}
|
|
945
954
|
className={clsx(
|
|
946
955
|
'rc-video',
|
|
947
|
-
showFrame ? (platform === 'ios' ? 'rc-video-ios' : 'rc-video-android') : 'rc-video-frameless',
|
|
956
|
+
showFrame ? (platform === 'ios' ? (isLandscape ? 'rc-video-ios-landscape' : 'rc-video-ios-portrait') : isLandscape ? 'rc-video-android-landscape' : 'rc-video-android-portrait') : 'rc-video-frameless',
|
|
948
957
|
!videoLoaded && 'rc-video-loading',
|
|
949
958
|
)}
|
|
950
959
|
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/
|
|
7
|
-
const [token, setToken] = useState('
|
|
6
|
+
const [url, setUrl] = useState('wss://eu-hel1-5-staging.limrun.dev/v1/ios_eustg_01kd7xz7wnecrr3qtc0mp9pyb4/endpointWebSocket');
|
|
7
|
+
const [token, setToken] = useState('lim_e38efd8b6b38733e268514a866e7b568d1bdc106632bfc9f');
|
|
8
8
|
const [platform, setPlatform] = useState<'ios' | 'android'>('ios');
|
|
9
9
|
const [isConnected, setIsConnected] = useState(false);
|
|
10
10
|
const [key, setKey] = useState(0);
|
|
@@ -165,7 +165,6 @@ function Demo() {
|
|
|
165
165
|
ref={remoteControlRef}
|
|
166
166
|
url={url}
|
|
167
167
|
token={token}
|
|
168
|
-
showFrame={false}
|
|
169
168
|
/>
|
|
170
169
|
</div>
|
|
171
170
|
</div>
|
package/src/image.png
ADDED
|
Binary file
|
|
Binary file
|
package/src/portrait.png
ADDED
|
Binary file
|