@limrun/ui 0.4.0-rc.7 → 0.4.0-rc.9
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 +317 -311
- package/index.html +4 -2
- package/package.json +1 -1
- package/src/assets/CHf0W2V8oUYM0sz1zN3AItWTl78EDajyAcUfQPYA5LRzxR69YBM334mnZAMo2PCKcIo=w480-h960-rw +0 -0
- package/src/assets/android_boot.gif +0 -0
- package/src/assets/android_boot.webp +0 -0
- 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 +19 -7
- 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
package/src/assets/CHf0W2V8oUYM0sz1zN3AItWTl78EDajyAcUfQPYA5LRzxR69YBM334mnZAMo2PCKcIo=w480-h960-rw
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
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,7 +6,10 @@ 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';
|
|
12
|
+
import androidBootImage from '../assets/android_boot.webp';
|
|
10
13
|
import {
|
|
11
14
|
createTouchControlMessage,
|
|
12
15
|
createInjectKeycodeMessage,
|
|
@@ -92,15 +95,19 @@ const detectPlatform = (url: string): DevicePlatform => {
|
|
|
92
95
|
const deviceConfig = {
|
|
93
96
|
ios: {
|
|
94
97
|
frameImage: iphoneFrameImage,
|
|
98
|
+
frameImageLandscape: iphoneFrameImageLandscape,
|
|
95
99
|
frameWidthMultiplier: 1.0841,
|
|
96
100
|
videoBorderRadiusMultiplier: 0.15,
|
|
97
101
|
loadingLogo: appleLogoSvg,
|
|
102
|
+
loadingLogoSize: '20%',
|
|
98
103
|
},
|
|
99
104
|
android: {
|
|
100
105
|
frameImage: pixelFrameImage,
|
|
106
|
+
frameImageLandscape: pixelFrameImageLandscape,
|
|
101
107
|
frameWidthMultiplier: 1.107,
|
|
102
108
|
videoBorderRadiusMultiplier: 0.13,
|
|
103
|
-
loadingLogo:
|
|
109
|
+
loadingLogo: androidBootImage,
|
|
110
|
+
loadingLogoSize: '40%',
|
|
104
111
|
},
|
|
105
112
|
};
|
|
106
113
|
|
|
@@ -139,6 +146,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
139
146
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
140
147
|
const frameRef = useRef<HTMLImageElement>(null);
|
|
141
148
|
const [videoLoaded, setVideoLoaded] = useState(false);
|
|
149
|
+
const [isLandscape, setIsLandscape] = useState(false);
|
|
142
150
|
const wsRef = useRef<WebSocket | null>(null);
|
|
143
151
|
const peerConnectionRef = useRef<RTCPeerConnection | null>(null);
|
|
144
152
|
const dataChannelRef = useRef<RTCDataChannel | null>(null);
|
|
@@ -787,14 +795,18 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
787
795
|
|
|
788
796
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
789
797
|
for (const entry of entries) {
|
|
798
|
+
const landscape = entry.contentRect.width > entry.contentRect.height;
|
|
799
|
+
setIsLandscape(landscape);
|
|
790
800
|
const videoWidth = entry.contentRect.width;
|
|
801
|
+
const videoHeight = entry.contentRect.height;
|
|
791
802
|
const originalFrameWidth = frame.clientWidth;
|
|
792
803
|
const newFrameWidth = videoWidth * config.frameWidthMultiplier;
|
|
793
804
|
// 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) {
|
|
805
|
+
if (!landscape && newFrameWidth > 0.9*originalFrameWidth) {
|
|
806
|
+
// This is mostly for iOS where the video size is slightly inconsistent.
|
|
795
807
|
frame.style.width = `${videoWidth * config.frameWidthMultiplier}px`;
|
|
796
808
|
}
|
|
797
|
-
video.style.borderRadius = `${videoWidth * config.videoBorderRadiusMultiplier}px`;
|
|
809
|
+
video.style.borderRadius = `${(entry.contentRect.width > entry.contentRect.height ? videoHeight : videoWidth) * config.videoBorderRadiusMultiplier}px`;
|
|
798
810
|
}
|
|
799
811
|
});
|
|
800
812
|
|
|
@@ -934,9 +946,9 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
934
946
|
{showFrame && (
|
|
935
947
|
<img
|
|
936
948
|
ref={frameRef}
|
|
937
|
-
src={config.frameImage}
|
|
949
|
+
src={isLandscape ? config.frameImageLandscape : config.frameImage}
|
|
938
950
|
alt=""
|
|
939
|
-
className=
|
|
951
|
+
className={clsx('rc-phone-frame', isLandscape ? 'rc-phone-frame-landscape' : 'rc-phone-frame-portrait')}
|
|
940
952
|
draggable={false}
|
|
941
953
|
/>
|
|
942
954
|
)}
|
|
@@ -944,7 +956,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
944
956
|
ref={videoRef}
|
|
945
957
|
className={clsx(
|
|
946
958
|
'rc-video',
|
|
947
|
-
showFrame ? (platform === 'ios' ? 'rc-video-ios' : 'rc-video-android') : 'rc-video-frameless',
|
|
959
|
+
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
960
|
!videoLoaded && 'rc-video-loading',
|
|
949
961
|
)}
|
|
950
962
|
style={
|
|
@@ -953,7 +965,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
|
|
|
953
965
|
backgroundImage: `url("${config.loadingLogo}")`,
|
|
954
966
|
backgroundRepeat: 'no-repeat',
|
|
955
967
|
backgroundPosition: 'center',
|
|
956
|
-
backgroundSize:
|
|
968
|
+
backgroundSize: config.loadingLogoSize,
|
|
957
969
|
}
|
|
958
970
|
: {}
|
|
959
971
|
}
|
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/android_eustg_01kd887q1vedb9nt1xkp0s1nan/endpointWebSocket');
|
|
7
|
+
const [token, setToken] = useState('lim_6ffd2b5de18c6dcc59e047b7b8d923024fb45d59c802ca5d');
|
|
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
|