react-native-xenon 2.2.0 → 2.3.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/lib/module/core/constants.js +2 -0
- package/lib/module/core/constants.js.map +1 -1
- package/lib/module/core/refs.js +11 -1
- package/lib/module/core/refs.js.map +1 -1
- package/lib/module/core/utils.js +6 -1
- package/lib/module/core/utils.js.map +1 -1
- package/lib/module/ui/components/bubble/Bubble.js +1 -1
- package/lib/module/ui/components/bubble/Bubble.js.map +1 -1
- package/lib/module/ui/components/handle/Handle.js +63 -0
- package/lib/module/ui/components/handle/Handle.js.map +1 -0
- package/lib/module/ui/components/headers/DebuggerHeader.js +3 -2
- package/lib/module/ui/components/headers/DebuggerHeader.js.map +1 -1
- package/lib/module/ui/components/items/ConsolePanelItem.js +26 -12
- package/lib/module/ui/components/items/ConsolePanelItem.js.map +1 -1
- package/lib/module/ui/components/items/NetworkPanelItem.js +50 -38
- package/lib/module/ui/components/items/NetworkPanelItem.js.map +1 -1
- package/lib/module/ui/components/panels/ConsolePanel.js +9 -12
- package/lib/module/ui/components/panels/ConsolePanel.js.map +1 -1
- package/lib/module/ui/components/panels/NetworkPanel.js +8 -9
- package/lib/module/ui/components/panels/NetworkPanel.js.map +1 -1
- package/lib/module/ui/components/panels/Panel.js +25 -13
- package/lib/module/ui/components/panels/Panel.js.map +1 -1
- package/lib/typescript/src/core/constants.d.ts +2 -0
- package/lib/typescript/src/core/constants.d.ts.map +1 -1
- package/lib/typescript/src/core/refs.d.ts +2 -1
- package/lib/typescript/src/core/refs.d.ts.map +1 -1
- package/lib/typescript/src/core/utils.d.ts +2 -1
- package/lib/typescript/src/core/utils.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/handle/Handle.d.ts +2 -0
- package/lib/typescript/src/ui/components/handle/Handle.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/headers/DebuggerHeader.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/items/ConsolePanelItem.d.ts +2 -2
- package/lib/typescript/src/ui/components/items/ConsolePanelItem.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/items/NetworkPanelItem.d.ts +2 -2
- package/lib/typescript/src/ui/components/items/NetworkPanelItem.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.map +1 -1
- package/package.json +1 -1
- package/src/core/constants.ts +2 -0
- package/src/core/refs.ts +10 -1
- package/src/core/utils.ts +7 -1
- package/src/ui/components/bubble/Bubble.tsx +1 -1
- package/src/ui/components/handle/Handle.tsx +60 -0
- package/src/ui/components/headers/DebuggerHeader.tsx +3 -2
- package/src/ui/components/items/ConsolePanelItem.tsx +28 -14
- package/src/ui/components/items/NetworkPanelItem.tsx +70 -57
- package/src/ui/components/panels/ConsolePanel.tsx +11 -10
- package/src/ui/components/panels/NetworkPanel.tsx +14 -7
- package/src/ui/components/panels/Panel.tsx +28 -9
@@ -1,6 +1,7 @@
|
|
1
|
-
import { useMemo } from 'react';
|
1
|
+
import { memo, useMemo } from 'react';
|
2
2
|
import { StyleSheet, Text, View } from 'react-native';
|
3
3
|
import { URL } from 'react-native-url-polyfill';
|
4
|
+
import { NETWORK_ITEM_HEIGHT } from '../../../core/constants';
|
4
5
|
import {
|
5
6
|
formatRequestDuration,
|
6
7
|
formatRequestMethod,
|
@@ -8,6 +9,7 @@ import {
|
|
8
9
|
} from '../../../core/utils';
|
9
10
|
import colors from '../../../theme/colors';
|
10
11
|
import type { HttpRequest, NetworkRequest } from '../../../types';
|
12
|
+
import Divider from '../common/Divider';
|
11
13
|
import Touchable from '../common/Touchable';
|
12
14
|
|
13
15
|
interface NetworkPanelItemProps {
|
@@ -39,76 +41,85 @@ const getMethodColor = (method: string) => {
|
|
39
41
|
}
|
40
42
|
};
|
41
43
|
|
42
|
-
|
43
|
-
method,
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}: NetworkPanelItemProps) {
|
50
|
-
const duration = formatRequestDuration(startTime, endTime);
|
51
|
-
const requestMethod = formatRequestMethod(method);
|
52
|
-
const requestStatusCode = formatRequestStatusCode(status);
|
53
|
-
const isRequestFailed = Number.isInteger(status) && status! >= 400 && status! < 600;
|
54
|
-
const textStyle = [styles.text, isRequestFailed && styles.failedText];
|
44
|
+
const NetworkPanelItem = memo<NetworkPanelItemProps>(
|
45
|
+
({ method, name, startTime, endTime, status, onPress }) => {
|
46
|
+
const duration = formatRequestDuration(startTime, endTime);
|
47
|
+
const requestMethod = formatRequestMethod(method);
|
48
|
+
const requestStatusCode = formatRequestStatusCode(status);
|
49
|
+
const isRequestFailed = Number.isInteger(status) && status! >= 400 && status! < 600;
|
50
|
+
const textStyle = [styles.text, isRequestFailed && styles.failedText];
|
55
51
|
|
56
|
-
|
57
|
-
|
52
|
+
const requestPath = useMemo(() => {
|
53
|
+
if (!name) return '[failed]';
|
58
54
|
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
try {
|
56
|
+
const url = new URL(name);
|
57
|
+
const suffixUrl = url.pathname + url.search;
|
62
58
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
if (suffixUrl === '/') return url.host;
|
60
|
+
return suffixUrl;
|
61
|
+
} catch (error) {
|
62
|
+
return name;
|
63
|
+
}
|
64
|
+
}, [name]);
|
69
65
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
66
|
+
return (
|
67
|
+
<View style={styles.container}>
|
68
|
+
<Touchable onPress={onPress} style={styles.wrapper}>
|
69
|
+
<View style={styles.column}>
|
70
|
+
<Text
|
71
|
+
numberOfLines={1}
|
72
|
+
style={[
|
73
|
+
styles.text,
|
74
|
+
styles.methodText,
|
75
|
+
{ backgroundColor: getMethodColor(requestMethod) },
|
76
|
+
]}
|
77
|
+
>
|
78
|
+
{requestMethod}
|
79
|
+
</Text>
|
80
|
+
</View>
|
84
81
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
<View style={[styles.column, styles.pathColumn]}>
|
83
|
+
<Text numberOfLines={1} style={textStyle}>
|
84
|
+
{requestPath}
|
85
|
+
</Text>
|
86
|
+
</View>
|
90
87
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
<View style={[styles.column, styles.durationColumn]}>
|
89
|
+
<Text numberOfLines={1} style={textStyle}>
|
90
|
+
{duration}
|
91
|
+
</Text>
|
92
|
+
</View>
|
96
93
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
94
|
+
<View style={styles.column}>
|
95
|
+
<Text numberOfLines={1} style={textStyle}>
|
96
|
+
{requestStatusCode}
|
97
|
+
</Text>
|
98
|
+
</View>
|
99
|
+
</Touchable>
|
100
|
+
<Divider type="horizontal" />
|
101
101
|
</View>
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
);
|
103
|
+
},
|
104
|
+
(prevProps, nextProps) => {
|
105
|
+
return (
|
106
|
+
prevProps.method === nextProps.method &&
|
107
|
+
prevProps.name === nextProps.name &&
|
108
|
+
prevProps.startTime === nextProps.startTime &&
|
109
|
+
prevProps.endTime === nextProps.endTime &&
|
110
|
+
prevProps.status === nextProps.status
|
111
|
+
);
|
112
|
+
},
|
113
|
+
);
|
105
114
|
|
106
115
|
const styles = StyleSheet.create({
|
107
116
|
container: {
|
108
117
|
flex: 1,
|
118
|
+
},
|
119
|
+
wrapper: {
|
109
120
|
flexDirection: 'row',
|
110
121
|
alignItems: 'center',
|
111
|
-
|
122
|
+
height: NETWORK_ITEM_HEIGHT,
|
112
123
|
columnGap: 8,
|
113
124
|
},
|
114
125
|
pathColumn: {
|
@@ -138,3 +149,5 @@ const styles = StyleSheet.create({
|
|
138
149
|
fontWeight: '600',
|
139
150
|
},
|
140
151
|
});
|
152
|
+
|
153
|
+
export default NetworkPanelItem;
|
@@ -2,20 +2,17 @@ import { forwardRef, useCallback, useContext, useMemo } from 'react';
|
|
2
2
|
import {
|
3
3
|
FlatList,
|
4
4
|
StyleSheet,
|
5
|
-
View,
|
6
5
|
type ListRenderItem,
|
7
6
|
type StyleProp,
|
8
7
|
type ViewStyle,
|
9
8
|
} from 'react-native';
|
10
9
|
import { MainContext } from '../../../contexts';
|
11
|
-
import
|
10
|
+
import { CONSOLE_ITEM_HEIGHT } from '../../../core/constants';
|
12
11
|
import { formatLogMessage } from '../../../core/utils';
|
13
12
|
import { DebuggerPanel, type LogMessage } from '../../../types';
|
14
13
|
import Empty from '../common/Empty';
|
15
14
|
import ConsolePanelItem from '../items/ConsolePanelItem';
|
16
15
|
|
17
|
-
const Separator = () => <View style={styles.spacing} />;
|
18
|
-
|
19
16
|
const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ style }, ref) => {
|
20
17
|
const {
|
21
18
|
debuggerState: { searchQuery },
|
@@ -42,8 +39,6 @@ const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
42
39
|
<ConsolePanelItem
|
43
40
|
{...item}
|
44
41
|
onPress={() => {
|
45
|
-
refs.header.current?.setCurrentIndex(HeaderState.Console);
|
46
|
-
refs.panel.current?.setCurrentIndex(PanelState.ConsoleDetail);
|
47
42
|
setDebuggerState(draft => {
|
48
43
|
draft.detailsData = {
|
49
44
|
type: DebuggerPanel.Console,
|
@@ -58,6 +53,15 @@ const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
58
53
|
[setDebuggerState],
|
59
54
|
);
|
60
55
|
|
56
|
+
const getItemLayout = useCallback(
|
57
|
+
(_: ArrayLike<LogMessage> | null | undefined, index: number) => ({
|
58
|
+
length: CONSOLE_ITEM_HEIGHT,
|
59
|
+
offset: CONSOLE_ITEM_HEIGHT * index,
|
60
|
+
index,
|
61
|
+
}),
|
62
|
+
[],
|
63
|
+
);
|
64
|
+
|
61
65
|
return (
|
62
66
|
<FlatList
|
63
67
|
ref={ref}
|
@@ -65,10 +69,10 @@ const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
65
69
|
data={data}
|
66
70
|
renderItem={renderItem}
|
67
71
|
keyExtractor={(_, index) => index.toString()}
|
68
|
-
ItemSeparatorComponent={Separator}
|
69
72
|
style={[styles.container, style]}
|
70
73
|
contentContainerStyle={data.length ? styles.contentContainer : undefined}
|
71
74
|
ListEmptyComponent={<Empty>No logs yet</Empty>}
|
75
|
+
getItemLayout={getItemLayout}
|
72
76
|
/>
|
73
77
|
);
|
74
78
|
});
|
@@ -80,9 +84,6 @@ const styles = StyleSheet.create({
|
|
80
84
|
contentContainer: {
|
81
85
|
padding: 8,
|
82
86
|
},
|
83
|
-
spacing: {
|
84
|
-
height: 4,
|
85
|
-
},
|
86
87
|
});
|
87
88
|
|
88
89
|
export default ConsolePanel;
|
@@ -7,7 +7,7 @@ import {
|
|
7
7
|
type ViewStyle,
|
8
8
|
} from 'react-native';
|
9
9
|
import { MainContext } from '../../../contexts';
|
10
|
-
import
|
10
|
+
import { NETWORK_ITEM_HEIGHT } from '../../../core/constants';
|
11
11
|
import {
|
12
12
|
DebuggerPanel,
|
13
13
|
NetworkType,
|
@@ -15,12 +15,9 @@ import {
|
|
15
15
|
type ID,
|
16
16
|
type WebSocketRequest,
|
17
17
|
} from '../../../types';
|
18
|
-
import Divider from '../common/Divider';
|
19
18
|
import Empty from '../common/Empty';
|
20
19
|
import NetworkPanelItem from '../items/NetworkPanelItem';
|
21
20
|
|
22
|
-
const Separator = () => <Divider type="horizontal" />;
|
23
|
-
|
24
21
|
const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ style }, ref) => {
|
25
22
|
const {
|
26
23
|
debuggerState: { searchQuery },
|
@@ -51,8 +48,6 @@ const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
51
48
|
endTime={item.endTime}
|
52
49
|
status={item.status}
|
53
50
|
onPress={() => {
|
54
|
-
refs.header.current?.setCurrentIndex(HeaderState.Network);
|
55
|
-
refs.panel.current?.setCurrentIndex(PanelState.NetworkDetail);
|
56
51
|
setDebuggerState(draft => {
|
57
52
|
draft.detailsData = {
|
58
53
|
type: DebuggerPanel.Network,
|
@@ -67,6 +62,18 @@ const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
67
62
|
[setDebuggerState],
|
68
63
|
);
|
69
64
|
|
65
|
+
const getItemLayout = useCallback(
|
66
|
+
(
|
67
|
+
_: ArrayLike<[NonNullable<ID>, HttpRequest | WebSocketRequest]> | null | undefined,
|
68
|
+
index: number,
|
69
|
+
) => ({
|
70
|
+
length: NETWORK_ITEM_HEIGHT,
|
71
|
+
offset: NETWORK_ITEM_HEIGHT * index,
|
72
|
+
index,
|
73
|
+
}),
|
74
|
+
[],
|
75
|
+
);
|
76
|
+
|
70
77
|
return (
|
71
78
|
<FlatList
|
72
79
|
inverted={!!data.length}
|
@@ -74,9 +81,9 @@ const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
|
|
74
81
|
ref={ref}
|
75
82
|
renderItem={renderItem}
|
76
83
|
keyExtractor={([key]) => key}
|
77
|
-
ItemSeparatorComponent={Separator}
|
78
84
|
style={[styles.container, style]}
|
79
85
|
ListEmptyComponent={<Empty>No records yet</Empty>}
|
86
|
+
getItemLayout={getItemLayout}
|
80
87
|
/>
|
81
88
|
);
|
82
89
|
});
|
@@ -1,33 +1,51 @@
|
|
1
|
-
import { Platform, StyleSheet, View, type ViewProps } from 'react-native';
|
2
|
-
import refs, { PanelState } from '../../../core/refs';
|
1
|
+
import { Animated, Platform, StyleSheet, View, type ViewProps } from 'react-native';
|
2
|
+
import refs, { HeaderState, PanelState } from '../../../core/refs';
|
3
3
|
import IndexedStack from '../common/IndexedStack';
|
4
4
|
import LogMessageDetails from '../details/LogMessageDetails';
|
5
5
|
import NetworkRequestDetails from '../details/NetworkRequestDetails';
|
6
6
|
import ConsolePanel from './ConsolePanel';
|
7
7
|
import NetworkPanel from './NetworkPanel';
|
8
8
|
import colors from '../../../theme/colors';
|
9
|
-
import { forwardRef, useContext, useMemo } from 'react';
|
9
|
+
import { forwardRef, useContext, useEffect, useMemo } from 'react';
|
10
10
|
import Header from '../headers/Header';
|
11
11
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
12
12
|
import SafeArea from '../common/SafeArea';
|
13
13
|
import { MainContext } from '../../../contexts';
|
14
|
+
import Handle from '../handle/Handle';
|
15
|
+
import { DebuggerPanel } from '../../../types';
|
14
16
|
|
15
17
|
interface PanelProps extends ViewProps {}
|
16
18
|
|
17
19
|
const Panel = forwardRef<View, PanelProps>(({ style, ...props }, ref) => {
|
18
20
|
const {
|
19
|
-
debuggerState: { position },
|
20
|
-
dimensions: { width: screenWidth, height: screenHeight },
|
21
|
+
debuggerState: { position, detailsData },
|
21
22
|
} = useContext(MainContext)!;
|
22
23
|
|
23
24
|
const containerStyle = useMemo(
|
24
|
-
() => [
|
25
|
-
|
25
|
+
() => [
|
26
|
+
styles.container,
|
27
|
+
{ [position]: 0, width: refs.panelSize.current?.x, height: refs.panelSize.current?.y },
|
28
|
+
],
|
29
|
+
[position],
|
26
30
|
);
|
27
31
|
|
32
|
+
useEffect(() => {
|
33
|
+
switch (detailsData?.type) {
|
34
|
+
case DebuggerPanel.Network:
|
35
|
+
refs.header.current?.setCurrentIndex(HeaderState.Network);
|
36
|
+
refs.panel.current?.setCurrentIndex(PanelState.NetworkDetail);
|
37
|
+
break;
|
38
|
+
case DebuggerPanel.Console:
|
39
|
+
refs.header.current?.setCurrentIndex(HeaderState.Console);
|
40
|
+
refs.panel.current?.setCurrentIndex(PanelState.ConsoleDetail);
|
41
|
+
break;
|
42
|
+
}
|
43
|
+
}, [detailsData?.type]);
|
44
|
+
|
28
45
|
return (
|
29
|
-
<View style={[containerStyle, style]} ref={ref} {...props}>
|
46
|
+
<Animated.View style={[containerStyle, style]} ref={ref} {...props}>
|
30
47
|
<SafeAreaProvider>
|
48
|
+
{position === 'bottom' && <Handle />}
|
31
49
|
{position === 'top' && <SafeArea inset="top" />}
|
32
50
|
|
33
51
|
<Header />
|
@@ -39,9 +57,10 @@ const Panel = forwardRef<View, PanelProps>(({ style, ...props }, ref) => {
|
|
39
57
|
<LogMessageDetails />
|
40
58
|
</IndexedStack>
|
41
59
|
|
60
|
+
{position === 'top' && <Handle />}
|
42
61
|
{position === 'bottom' && <SafeArea inset="bottom" />}
|
43
62
|
</SafeAreaProvider>
|
44
|
-
</View>
|
63
|
+
</Animated.View>
|
45
64
|
);
|
46
65
|
});
|
47
66
|
|