react-native-xenon 2.0.0 → 2.2.0
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/README.md +13 -24
- package/lib/module/assets/icons/arrow-left.png +0 -0
- package/lib/module/assets/icons/beautify.png +0 -0
- package/lib/module/assets/icons/bug.png +0 -0
- package/lib/module/assets/icons/close.png +0 -0
- package/lib/module/assets/icons/delete.png +0 -0
- package/lib/module/assets/icons/hide.png +0 -0
- package/lib/module/assets/icons/move.png +0 -0
- package/lib/module/assets/icons/record.png +0 -0
- package/lib/module/assets/icons/search.png +0 -0
- package/lib/module/assets/icons/share.png +0 -0
- package/lib/module/contexts/MainContext.js.map +1 -1
- package/lib/module/hooks/useNetworkInterceptor.js +8 -3
- package/lib/module/hooks/useNetworkInterceptor.js.map +1 -1
- package/lib/module/interceptors/WebSocketInterceptor.js +2 -2
- package/lib/module/interceptors/WebSocketInterceptor.js.map +1 -1
- package/lib/module/ui/Xenon.js +7 -45
- package/lib/module/ui/Xenon.js.map +1 -1
- package/lib/module/ui/components/bubble/Bubble.js +11 -4
- package/lib/module/ui/components/bubble/Bubble.js.map +1 -1
- package/lib/module/ui/components/common/Empty.js +26 -0
- package/lib/module/ui/components/common/Empty.js.map +1 -0
- package/lib/module/ui/components/index.js +0 -1
- package/lib/module/ui/components/index.js.map +1 -1
- package/lib/module/ui/components/panels/ConsolePanel.js +10 -6
- package/lib/module/ui/components/panels/ConsolePanel.js.map +1 -1
- package/lib/module/ui/components/panels/NetworkPanel.js +6 -2
- package/lib/module/ui/components/panels/NetworkPanel.js.map +1 -1
- package/lib/module/ui/components/panels/Panel.js +57 -7
- package/lib/module/ui/components/panels/Panel.js.map +1 -1
- package/lib/module/ui/components/search-bar/SearchBar.js +5 -13
- package/lib/module/ui/components/search-bar/SearchBar.js.map +1 -1
- package/lib/typescript/src/contexts/MainContext.d.ts +2 -0
- package/lib/typescript/src/contexts/MainContext.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useNetworkInterceptor.d.ts.map +1 -1
- package/lib/typescript/src/interceptors/WebSocketInterceptor.d.ts.map +1 -1
- package/lib/typescript/src/types/websocket.d.ts +10 -0
- package/lib/typescript/src/types/websocket.d.ts.map +1 -1
- package/lib/typescript/src/ui/Xenon.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/bubble/Bubble.d.ts +2 -5
- package/lib/typescript/src/ui/components/bubble/Bubble.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/common/Empty.d.ts +3 -0
- package/lib/typescript/src/ui/components/common/Empty.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/index.d.ts +0 -1
- package/lib/typescript/src/ui/components/index.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/panels/ConsolePanel.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/panels/NetworkPanel.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/panels/Panel.d.ts +5 -1
- package/lib/typescript/src/ui/components/panels/Panel.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/search-bar/SearchBar.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/assets/icons/arrow-left.png +0 -0
- package/src/assets/icons/beautify.png +0 -0
- package/src/assets/icons/bug.png +0 -0
- package/src/assets/icons/close.png +0 -0
- package/src/assets/icons/delete.png +0 -0
- package/src/assets/icons/hide.png +0 -0
- package/src/assets/icons/move.png +0 -0
- package/src/assets/icons/record.png +0 -0
- package/src/assets/icons/search.png +0 -0
- package/src/assets/icons/share.png +0 -0
- package/src/contexts/MainContext.ts +2 -0
- package/src/core/global.d.ts +0 -26
- package/src/hooks/useNetworkInterceptor.ts +11 -5
- package/src/interceptors/WebSocketInterceptor.ts +4 -3
- package/src/types/websocket.ts +16 -0
- package/src/ui/Xenon.tsx +14 -48
- package/src/ui/components/bubble/Bubble.tsx +9 -9
- package/src/ui/components/common/Empty.tsx +15 -0
- package/src/ui/components/index.ts +0 -1
- package/src/ui/components/panels/ConsolePanel.tsx +8 -6
- package/src/ui/components/panels/NetworkPanel.tsx +3 -1
- package/src/ui/components/panels/Panel.tsx +53 -8
- package/src/ui/components/search-bar/SearchBar.tsx +9 -13
@@ -1,29 +1,29 @@
|
|
1
|
-
import { forwardRef, useMemo, useRef, useState } from 'react';
|
1
|
+
import { forwardRef, useContext, useMemo, useRef, useState } from 'react';
|
2
2
|
import {
|
3
3
|
Animated,
|
4
4
|
PanResponder,
|
5
5
|
StyleSheet,
|
6
6
|
View,
|
7
7
|
type PanResponderGestureState,
|
8
|
-
type
|
9
|
-
type ViewStyle,
|
8
|
+
type ViewProps,
|
10
9
|
} from 'react-native';
|
10
|
+
import { MainContext } from '../../../contexts';
|
11
11
|
import refs, { DebuggerVisibility } from '../../../core/refs';
|
12
12
|
import { clamp, getVerticalSafeMargin } from '../../../core/utils';
|
13
13
|
import colors from '../../../theme/colors';
|
14
14
|
import icons from '../../../theme/icons';
|
15
15
|
import Icon from '../common/Icon';
|
16
16
|
|
17
|
-
interface BubbleProps {
|
17
|
+
interface BubbleProps extends ViewProps {
|
18
18
|
bubbleSize: number;
|
19
19
|
idleBubbleOpacity: number;
|
20
|
-
screenWidth: number;
|
21
|
-
screenHeight: number;
|
22
|
-
style?: StyleProp<ViewStyle>;
|
23
20
|
}
|
24
21
|
|
25
22
|
const Bubble = forwardRef<View, BubbleProps>(
|
26
|
-
({ bubbleSize, idleBubbleOpacity,
|
23
|
+
({ bubbleSize, idleBubbleOpacity, style, ...props }, ref) => {
|
24
|
+
const {
|
25
|
+
dimensions: { width: screenWidth, height: screenHeight },
|
26
|
+
} = useContext(MainContext)!;
|
27
27
|
const [idleOpacity, setIdleOpacity] = useState(idleBubbleOpacity);
|
28
28
|
const pan = useRef(new Animated.ValueXY({ x: 0, y: getVerticalSafeMargin(screenHeight) }));
|
29
29
|
const opacityTimer = useRef<NodeJS.Timeout | null>(null);
|
@@ -97,7 +97,7 @@ const Bubble = forwardRef<View, BubbleProps>(
|
|
97
97
|
}, [bubbleSize, idleBubbleOpacity, screenHeight, screenWidth]);
|
98
98
|
|
99
99
|
return (
|
100
|
-
<View ref={ref} style={[styles.bubbleBackdrop, style]}>
|
100
|
+
<View ref={ref} style={[styles.bubbleBackdrop, style]} {...props}>
|
101
101
|
<Animated.View
|
102
102
|
{...panResponder.panHandlers}
|
103
103
|
style={[
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
3
|
+
|
4
|
+
export default function Empty({ children }: PropsWithChildren) {
|
5
|
+
return (
|
6
|
+
<View style={styles.container}>
|
7
|
+
<Text style={styles.text}>{children}</Text>
|
8
|
+
</View>
|
9
|
+
);
|
10
|
+
}
|
11
|
+
|
12
|
+
const styles = StyleSheet.create({
|
13
|
+
container: { padding: 16, alignItems: 'center', justifyContent: 'center' },
|
14
|
+
text: { textAlign: 'center' },
|
15
|
+
});
|
@@ -1,5 +1,4 @@
|
|
1
1
|
export { default as Bubble } from './bubble/Bubble';
|
2
2
|
export { default as IndexedStack } from './common/IndexedStack';
|
3
|
-
export { default as Header } from './headers/Header';
|
4
3
|
export { default as Panel } from './panels/Panel';
|
5
4
|
export { default as SearchBar } from './search-bar/SearchBar';
|
@@ -8,12 +8,13 @@ import {
|
|
8
8
|
type ViewStyle,
|
9
9
|
} from 'react-native';
|
10
10
|
import { MainContext } from '../../../contexts';
|
11
|
-
import { DebuggerPanel, type LogMessage } from '../../../types';
|
12
|
-
import ConsolePanelItem from '../items/ConsolePanelItem';
|
13
11
|
import refs, { HeaderState, PanelState } from '../../../core/refs';
|
14
12
|
import { formatLogMessage } from '../../../core/utils';
|
13
|
+
import { DebuggerPanel, type LogMessage } from '../../../types';
|
14
|
+
import Empty from '../common/Empty';
|
15
|
+
import ConsolePanelItem from '../items/ConsolePanelItem';
|
15
16
|
|
16
|
-
const Separator = () => <View style={styles.
|
17
|
+
const Separator = () => <View style={styles.spacing} />;
|
17
18
|
|
18
19
|
const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ style }, ref) => {
|
19
20
|
const {
|
@@ -60,13 +61,14 @@ const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
60
61
|
return (
|
61
62
|
<FlatList
|
62
63
|
ref={ref}
|
63
|
-
inverted
|
64
|
+
inverted={!!data.length}
|
64
65
|
data={data}
|
65
66
|
renderItem={renderItem}
|
66
67
|
keyExtractor={(_, index) => index.toString()}
|
67
68
|
ItemSeparatorComponent={Separator}
|
68
69
|
style={[styles.container, style]}
|
69
|
-
contentContainerStyle={styles.contentContainer}
|
70
|
+
contentContainerStyle={data.length ? styles.contentContainer : undefined}
|
71
|
+
ListEmptyComponent={<Empty>No logs yet</Empty>}
|
70
72
|
/>
|
71
73
|
);
|
72
74
|
});
|
@@ -78,7 +80,7 @@ const styles = StyleSheet.create({
|
|
78
80
|
contentContainer: {
|
79
81
|
padding: 8,
|
80
82
|
},
|
81
|
-
|
83
|
+
spacing: {
|
82
84
|
height: 4,
|
83
85
|
},
|
84
86
|
});
|
@@ -16,6 +16,7 @@ import {
|
|
16
16
|
type WebSocketRequest,
|
17
17
|
} from '../../../types';
|
18
18
|
import Divider from '../common/Divider';
|
19
|
+
import Empty from '../common/Empty';
|
19
20
|
import NetworkPanelItem from '../items/NetworkPanelItem';
|
20
21
|
|
21
22
|
const Separator = () => <Divider type="horizontal" />;
|
@@ -68,13 +69,14 @@ const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
68
69
|
|
69
70
|
return (
|
70
71
|
<FlatList
|
71
|
-
inverted
|
72
|
+
inverted={!!data.length}
|
72
73
|
data={data}
|
73
74
|
ref={ref}
|
74
75
|
renderItem={renderItem}
|
75
76
|
keyExtractor={([key]) => key}
|
76
77
|
ItemSeparatorComponent={Separator}
|
77
78
|
style={[styles.container, style]}
|
79
|
+
ListEmptyComponent={<Empty>No records yet</Empty>}
|
78
80
|
/>
|
79
81
|
);
|
80
82
|
});
|
@@ -1,17 +1,62 @@
|
|
1
|
+
import { Platform, StyleSheet, View, type ViewProps } from 'react-native';
|
1
2
|
import refs, { PanelState } from '../../../core/refs';
|
2
3
|
import IndexedStack from '../common/IndexedStack';
|
3
4
|
import LogMessageDetails from '../details/LogMessageDetails';
|
4
5
|
import NetworkRequestDetails from '../details/NetworkRequestDetails';
|
5
6
|
import ConsolePanel from './ConsolePanel';
|
6
7
|
import NetworkPanel from './NetworkPanel';
|
8
|
+
import colors from '../../../theme/colors';
|
9
|
+
import { forwardRef, useContext, useMemo } from 'react';
|
10
|
+
import Header from '../headers/Header';
|
11
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
12
|
+
import SafeArea from '../common/SafeArea';
|
13
|
+
import { MainContext } from '../../../contexts';
|
14
|
+
|
15
|
+
interface PanelProps extends ViewProps {}
|
16
|
+
|
17
|
+
const Panel = forwardRef<View, PanelProps>(({ style, ...props }, ref) => {
|
18
|
+
const {
|
19
|
+
debuggerState: { position },
|
20
|
+
dimensions: { width: screenWidth, height: screenHeight },
|
21
|
+
} = useContext(MainContext)!;
|
22
|
+
|
23
|
+
const containerStyle = useMemo(
|
24
|
+
() => [styles.container, { [position]: 0, height: Math.min(screenWidth, screenHeight) * 0.75 }],
|
25
|
+
[position, screenWidth, screenHeight],
|
26
|
+
);
|
7
27
|
|
8
|
-
export default function Panel() {
|
9
28
|
return (
|
10
|
-
<
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
29
|
+
<View style={[containerStyle, style]} ref={ref} {...props}>
|
30
|
+
<SafeAreaProvider>
|
31
|
+
{position === 'top' && <SafeArea inset="top" />}
|
32
|
+
|
33
|
+
<Header />
|
34
|
+
|
35
|
+
<IndexedStack defaultIndex={PanelState.Network} id="debugger-panel" ref={refs.panel}>
|
36
|
+
<NetworkPanel />
|
37
|
+
<ConsolePanel />
|
38
|
+
<NetworkRequestDetails />
|
39
|
+
<LogMessageDetails />
|
40
|
+
</IndexedStack>
|
41
|
+
|
42
|
+
{position === 'bottom' && <SafeArea inset="bottom" />}
|
43
|
+
</SafeAreaProvider>
|
44
|
+
</View>
|
16
45
|
);
|
17
|
-
}
|
46
|
+
});
|
47
|
+
|
48
|
+
const styles = StyleSheet.create({
|
49
|
+
container: {
|
50
|
+
flex: 1,
|
51
|
+
...StyleSheet.absoluteFillObject,
|
52
|
+
pointerEvents: 'box-none',
|
53
|
+
...(Platform.OS === 'android' ? { zIndex: 9999 } : {}),
|
54
|
+
top: undefined,
|
55
|
+
bottom: undefined,
|
56
|
+
backgroundColor: colors.lightGray,
|
57
|
+
borderBottomColor: colors.gray,
|
58
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
59
|
+
},
|
60
|
+
});
|
61
|
+
|
62
|
+
export default Panel;
|
@@ -20,6 +20,8 @@ import SafeArea from '../common/SafeArea';
|
|
20
20
|
|
21
21
|
interface SearchBarProps extends ViewProps {}
|
22
22
|
|
23
|
+
const ICON_SIZE = 20;
|
24
|
+
|
23
25
|
const SearchBar = forwardRef<View, SearchBarProps>(({ style, ...props }, ref) => {
|
24
26
|
const {
|
25
27
|
debuggerState: { searchQuery },
|
@@ -34,7 +36,7 @@ const SearchBar = forwardRef<View, SearchBarProps>(({ style, ...props }, ref) =>
|
|
34
36
|
};
|
35
37
|
|
36
38
|
const onClear = () => {
|
37
|
-
|
39
|
+
setValue('');
|
38
40
|
};
|
39
41
|
|
40
42
|
const onSubmitEditing = ({
|
@@ -53,7 +55,7 @@ const SearchBar = forwardRef<View, SearchBarProps>(({ style, ...props }, ref) =>
|
|
53
55
|
<SafeArea inset="top" />
|
54
56
|
|
55
57
|
<View style={styles.inputWrapper}>
|
56
|
-
<Icon source={icons.search} size={
|
58
|
+
<Icon source={icons.search} size={ICON_SIZE} />
|
57
59
|
|
58
60
|
<TextInput
|
59
61
|
autoCapitalize="none"
|
@@ -71,9 +73,11 @@ const SearchBar = forwardRef<View, SearchBarProps>(({ style, ...props }, ref) =>
|
|
71
73
|
onSubmitEditing={onSubmitEditing}
|
72
74
|
/>
|
73
75
|
|
74
|
-
|
75
|
-
<
|
76
|
-
|
76
|
+
{!!value.length && (
|
77
|
+
<Touchable hitSlop={8} onPress={onClear}>
|
78
|
+
<Icon source={icons.close} size={ICON_SIZE} color={colors.black} />
|
79
|
+
</Touchable>
|
80
|
+
)}
|
77
81
|
</View>
|
78
82
|
</View>
|
79
83
|
|
@@ -116,14 +120,6 @@ const styles = StyleSheet.create({
|
|
116
120
|
color: colors.black,
|
117
121
|
flex: 1,
|
118
122
|
},
|
119
|
-
closeButton: {
|
120
|
-
justifyContent: 'center',
|
121
|
-
alignItems: 'center',
|
122
|
-
width: 18,
|
123
|
-
height: 18,
|
124
|
-
borderRadius: 9,
|
125
|
-
backgroundColor: colors.gray,
|
126
|
-
},
|
127
123
|
});
|
128
124
|
|
129
125
|
export default SearchBar;
|