kasunk99-livestream-core 0.3.29 → 0.3.31
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStreamViewerItem.d.ts","sourceRoot":"","sources":["../../src/components/LiveStreamViewerItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LiveStreamViewerItem.d.ts","sourceRoot":"","sources":["../../src/components/LiveStreamViewerItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAiB1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAmEF,eAAO,MAAM,oBAAoB,uDAuY/B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { ActivityIndicator, Keyboard, NativeModules, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View, } from 'react-native';
|
|
3
|
+
import { ActivityIndicator, Keyboard, KeyboardAvoidingView as RNKeyboardAvoidingView, NativeModules, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View, } from 'react-native';
|
|
4
4
|
import { useViewerSocket } from '../hooks/useViewerSocket';
|
|
5
5
|
const CHAT_NAME_COLORS = ['#f97316', '#22c55e', '#3b82f6', '#eab308', '#ec4899', '#a855f7'];
|
|
6
6
|
const BOTTOM_SAFE = Platform.OS === 'ios' ? 28 : 10;
|
|
@@ -23,11 +23,22 @@ try {
|
|
|
23
23
|
IoniconsComponent = vi.Ionicons;
|
|
24
24
|
}
|
|
25
25
|
catch { }
|
|
26
|
-
|
|
26
|
+
// RNGH TouchableOpacity — fires at the native gesture layer (GestureHandlerRootView is
|
|
27
|
+
// outermost in _layout.tsx, above KeyboardProvider), so it claims the touch before
|
|
28
|
+
// RNKC's InputMethodManager intercept drops it. This is why onPressIn/Pressable fail
|
|
29
|
+
// but this component works for the send button when the keyboard is open.
|
|
30
|
+
let RNGHTouchable = null;
|
|
31
|
+
try {
|
|
32
|
+
const rgh = require('react-native-gesture-handler');
|
|
33
|
+
if (rgh.TouchableOpacity)
|
|
34
|
+
RNGHTouchable = rgh.TouchableOpacity;
|
|
35
|
+
}
|
|
36
|
+
catch { }
|
|
37
|
+
let KeyboardAvoidingView = RNKeyboardAvoidingView;
|
|
27
38
|
try {
|
|
28
39
|
const rnkc = require('react-native-keyboard-controller');
|
|
29
|
-
if (rnkc.
|
|
30
|
-
|
|
40
|
+
if (rnkc.KeyboardAvoidingView)
|
|
41
|
+
KeyboardAvoidingView = rnkc.KeyboardAvoidingView;
|
|
31
42
|
}
|
|
32
43
|
catch { }
|
|
33
44
|
export const LiveStreamViewerItem = memo(function LiveStreamViewerItem({ stream, isActive, index: _index, }) {
|
|
@@ -56,29 +67,9 @@ export const LiveStreamViewerItem = memo(function LiveStreamViewerItem({ stream,
|
|
|
56
67
|
const textInputRef = useRef(null);
|
|
57
68
|
// Ref so sendChat always reads the latest typed text regardless of React's render cycle.
|
|
58
69
|
const chatInputRef = useRef('');
|
|
59
|
-
// Keyboard height used to pad the container above the keyboard.
|
|
60
|
-
// We track it manually instead of using KeyboardAvoidingView because
|
|
61
|
-
// KAV's internal measure() returns wrong coordinates inside a FlatList on Android.
|
|
62
|
-
const [kbPadding, setKbPadding] = useState(0);
|
|
63
70
|
useEffect(() => {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
// RNKC's KeyboardEvents fire with the accurate WindowInsetsCompat height.
|
|
67
|
-
// keyboardWillShow fires at the START of the animation so the bar is
|
|
68
|
-
// already above the keyboard before it finishes rising.
|
|
69
|
-
const show = RNKCKeyboardEvents.addListener('keyboardWillShow', (e) => {
|
|
70
|
-
if (e.height > 0)
|
|
71
|
-
setKbPadding(e.height);
|
|
72
|
-
});
|
|
73
|
-
const hide = RNKCKeyboardEvents.addListener('keyboardDidHide', onHide);
|
|
74
|
-
return () => { show.remove(); hide.remove(); };
|
|
75
|
-
}
|
|
76
|
-
// Fallback: standard RN events (fires after animation completes).
|
|
77
|
-
const show = Keyboard.addListener('keyboardDidShow', (e) => {
|
|
78
|
-
setKbPadding(e.endCoordinates.height);
|
|
79
|
-
});
|
|
80
|
-
const hide = Keyboard.addListener('keyboardDidHide', onHide);
|
|
81
|
-
return () => { show.remove(); hide.remove(); };
|
|
71
|
+
const sub = Keyboard.addListener('keyboardDidHide', () => setIsTyping(false));
|
|
72
|
+
return () => sub.remove();
|
|
82
73
|
}, []);
|
|
83
74
|
// Dismiss input when stream becomes inactive (e.g. user swipes to next stream)
|
|
84
75
|
useEffect(() => {
|
|
@@ -231,9 +222,11 @@ export const LiveStreamViewerItem = memo(function LiveStreamViewerItem({ stream,
|
|
|
231
222
|
const avatarLetter = hostLabel[0]?.toUpperCase() ?? 'L';
|
|
232
223
|
const hasUnsent = chatInput.trim().length > 0;
|
|
233
224
|
const canType = joined && !joining && !error;
|
|
234
|
-
return (_jsxs(
|
|
225
|
+
return (_jsxs(KeyboardAvoidingView, { style: styles.container, behavior: "padding", automaticOffset: true, children: [showVideo && RTCViewComponent && streamURL ? (_jsx(RTCViewComponent, { streamURL: streamURL, stream: displayStream, style: StyleSheet.absoluteFillObject, objectFit: "cover", mirror: false, pointerEvents: "none" }, `rtc-${trackCount}-${streamURL}`)) : (_jsxs(View, { style: [StyleSheet.absoluteFillObject, styles.videoPlaceholder], children: [joining && _jsx(ActivityIndicator, { size: "large", color: "rgba(255,255,255,0.6)" }), !joining && error && _jsx(Text, { style: styles.placeholderError, children: error }), joined && !joining && !error && hasVideo && !remoteStream && (_jsx(ActivityIndicator, { size: "large", color: "rgba(255,255,255,0.45)" })), joined && !joining && !error && hasVideo && webrtcUnavailable && (_jsx(Text, { style: styles.placeholderHint, children: "Video needs a development build" })), joined && !joining && !error && hasVideo && consumeError && (_jsx(Text, { style: styles.placeholderError, children: consumeError }))] })), LinearGradient ? (_jsx(LinearGradient, { colors: ['rgba(0,0,0,0.70)', 'rgba(0,0,0,0.0)', 'rgba(0,0,0,0.0)', 'rgba(0,0,0,0.78)'], locations: [0, 0.28, 0.48, 1], style: StyleSheet.absoluteFillObject, pointerEvents: "none" })) : null, _jsxs(View, { style: styles.topBar, pointerEvents: "box-none", children: [_jsxs(View, { style: styles.hostRow, pointerEvents: "none", children: [_jsx(View, { style: styles.avatar, children: _jsx(Text, { style: styles.avatarLetter, children: avatarLetter }) }), _jsx(Text, { style: styles.hostName, numberOfLines: 1, children: hostLabel }), _jsx(View, { style: styles.livePill, children: _jsx(Text, { style: styles.livePillText, children: "LIVE" }) })] }), _jsxs(View, { style: styles.viewerChip, pointerEvents: "none", children: [_jsx(Text, { style: styles.viewerEye, children: "\uD83D\uDC41" }), _jsx(Text, { style: styles.viewerCount, children: viewerCount > 0 ? viewerCount.toLocaleString() : '—' })] })] }), _jsx(View, { style: styles.spacer, pointerEvents: "none" }), _jsx(ScrollView, { ref: chatListRef, style: styles.chatList, contentContainerStyle: styles.chatContent, showsVerticalScrollIndicator: false, keyboardShouldPersistTaps: "always", children: chatData.map((item) => item.displayName ? (_jsx(View, { style: styles.chatBubble, children: _jsxs(Text, { style: styles.chatLine, numberOfLines: 3, children: [_jsxs(Text, { style: [styles.chatUsername, { color: getNameColor(item.displayName) }], children: [item.displayName, ' '] }), _jsx(Text, { style: styles.chatMsg, children: item.text })] }) }, item.id)) : (_jsx(View, { style: styles.joinBubble, children: _jsx(Text, { style: styles.joinText, children: item.text }) }, item.id))) }), isTyping ? (_jsxs(View, { style: styles.inputBar, children: [_jsx(TextInput, { ref: textInputRef, style: styles.textInput, value: chatInput, onChangeText: (text) => { chatInputRef.current = text; setChatInput(text); }, placeholder: "Say something...", placeholderTextColor: "rgba(255,255,255,0.40)", editable: canType, onSubmitEditing: sendChat, returnKeyType: "send", submitBehavior: "submit", autoFocus: true }), RNGHTouchable ? (_jsx(RNGHTouchable, { onPress: sendChat, activeOpacity: 0.75, style: [styles.sendBtn, (!hasUnsent || !joined) && styles.sendBtnOff], hitSlop: { top: 8, right: 8, bottom: 8, left: 8 }, children: IoniconsComponent
|
|
226
|
+
? _jsx(IoniconsComponent, { name: "send", size: 18, color: "#fff" })
|
|
227
|
+
: _jsx(Text, { style: styles.sendIcon, children: "\u27A4" }) })) : (_jsx(Pressable, { style: [styles.sendBtn, (!hasUnsent || !joined) && styles.sendBtnOff], onPressIn: sendChat, hitSlop: { top: 8, right: 8, bottom: 8, left: 8 }, children: IoniconsComponent
|
|
235
228
|
? _jsx(IoniconsComponent, { name: "send", size: 18, color: "#fff" })
|
|
236
|
-
: _jsx(Text, { style: styles.sendIcon, children: "\u27A4" }) })] })) : (
|
|
229
|
+
: _jsx(Text, { style: styles.sendIcon, children: "\u27A4" }) }))] })) : (
|
|
237
230
|
// Pill bar — tapping opens the input bar.
|
|
238
231
|
_jsxs(View, { style: styles.bottomBar, children: [_jsx(TouchableOpacity, { style: [styles.typeTouchable, hasUnsent && styles.typeTouchableFilled], onPress: () => { if (canType)
|
|
239
232
|
setIsTyping(true); }, activeOpacity: 0.7, children: _jsx(Text, { style: [styles.typePlaceholder, hasUnsent && styles.typePlaceholderFilled], numberOfLines: 1, children: hasUnsent ? chatInput : (joined && !joining ? 'Say something...' : 'Connecting...') }) }), _jsx(TouchableOpacity, { style: styles.bottomIconBtn, activeOpacity: 0.7, children: _jsx(Text, { style: styles.bottomIconGlyph, children: "\u263A" }) }), _jsx(TouchableOpacity, { style: styles.bottomIconBtn, activeOpacity: 0.7, children: _jsx(Text, { style: [styles.bottomIconGlyph, styles.heartIcon], children: "\u2665" }) })] })), streamEnded && (_jsx(View, { style: styles.endedOverlay, children: _jsxs(View, { style: styles.endedCard, children: [_jsx(Text, { style: styles.endedTitle, children: "Stream ended" }), _jsx(Text, { style: styles.endedSub, children: "The host has ended this live stream" })] }) }))] }));
|
package/package.json
CHANGED