react-native-xenon 2.2.0 → 2.4.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.
Files changed (99) hide show
  1. package/lib/module/core/constants.js +2 -0
  2. package/lib/module/core/constants.js.map +1 -1
  3. package/lib/module/core/refs.js +11 -1
  4. package/lib/module/core/refs.js.map +1 -1
  5. package/lib/module/core/utils.js +7 -2
  6. package/lib/module/core/utils.js.map +1 -1
  7. package/lib/module/ui/Xenon.js +1 -1
  8. package/lib/module/ui/Xenon.js.map +1 -1
  9. package/lib/module/ui/components/bubble/Bubble.js +5 -7
  10. package/lib/module/ui/components/bubble/Bubble.js.map +1 -1
  11. package/lib/module/ui/components/common/IndexedStack.js +5 -6
  12. package/lib/module/ui/components/common/IndexedStack.js.map +1 -1
  13. package/lib/module/ui/components/details/LogMessageDetails.js +10 -9
  14. package/lib/module/ui/components/details/LogMessageDetails.js.map +1 -1
  15. package/lib/module/ui/components/details/NetworkRequestDetails.js +6 -6
  16. package/lib/module/ui/components/details/NetworkRequestDetails.js.map +1 -1
  17. package/lib/module/ui/components/handle/Handle.js +63 -0
  18. package/lib/module/ui/components/handle/Handle.js.map +1 -0
  19. package/lib/module/ui/components/headers/ConsoleHeader.js +5 -6
  20. package/lib/module/ui/components/headers/ConsoleHeader.js.map +1 -1
  21. package/lib/module/ui/components/headers/DebuggerHeader.js +9 -8
  22. package/lib/module/ui/components/headers/DebuggerHeader.js.map +1 -1
  23. package/lib/module/ui/components/headers/HeaderComponents.js +6 -5
  24. package/lib/module/ui/components/headers/HeaderComponents.js.map +1 -1
  25. package/lib/module/ui/components/headers/NetworkHeader.js +6 -6
  26. package/lib/module/ui/components/headers/NetworkHeader.js.map +1 -1
  27. package/lib/module/ui/components/items/ConsolePanelItem.js +24 -12
  28. package/lib/module/ui/components/items/ConsolePanelItem.js.map +1 -1
  29. package/lib/module/ui/components/items/DebuggerHeaderItem.js +2 -1
  30. package/lib/module/ui/components/items/DebuggerHeaderItem.js.map +1 -1
  31. package/lib/module/ui/components/items/NetworkPanelItem.js +48 -38
  32. package/lib/module/ui/components/items/NetworkPanelItem.js.map +1 -1
  33. package/lib/module/ui/components/panels/ConsolePanel.js +15 -18
  34. package/lib/module/ui/components/panels/ConsolePanel.js.map +1 -1
  35. package/lib/module/ui/components/panels/NetworkPanel.js +15 -16
  36. package/lib/module/ui/components/panels/NetworkPanel.js.map +1 -1
  37. package/lib/module/ui/components/panels/Panel.js +28 -18
  38. package/lib/module/ui/components/panels/Panel.js.map +1 -1
  39. package/lib/module/ui/components/search-bar/SearchBar.js +4 -6
  40. package/lib/module/ui/components/search-bar/SearchBar.js.map +1 -1
  41. package/lib/typescript/src/core/constants.d.ts +2 -0
  42. package/lib/typescript/src/core/constants.d.ts.map +1 -1
  43. package/lib/typescript/src/core/refs.d.ts +2 -1
  44. package/lib/typescript/src/core/refs.d.ts.map +1 -1
  45. package/lib/typescript/src/core/utils.d.ts +2 -1
  46. package/lib/typescript/src/core/utils.d.ts.map +1 -1
  47. package/lib/typescript/src/ui/Xenon.d.ts +16 -14
  48. package/lib/typescript/src/ui/Xenon.d.ts.map +1 -1
  49. package/lib/typescript/src/ui/components/bubble/Bubble.d.ts +4 -2
  50. package/lib/typescript/src/ui/components/bubble/Bubble.d.ts.map +1 -1
  51. package/lib/typescript/src/ui/components/common/IndexedStack.d.ts +4 -3
  52. package/lib/typescript/src/ui/components/common/IndexedStack.d.ts.map +1 -1
  53. package/lib/typescript/src/ui/components/details/LogMessageDetails.d.ts +6 -3
  54. package/lib/typescript/src/ui/components/details/LogMessageDetails.d.ts.map +1 -1
  55. package/lib/typescript/src/ui/components/details/NetworkRequestDetails.d.ts +6 -3
  56. package/lib/typescript/src/ui/components/details/NetworkRequestDetails.d.ts.map +1 -1
  57. package/lib/typescript/src/ui/components/handle/Handle.d.ts +2 -0
  58. package/lib/typescript/src/ui/components/handle/Handle.d.ts.map +1 -0
  59. package/lib/typescript/src/ui/components/headers/ConsoleHeader.d.ts +5 -3
  60. package/lib/typescript/src/ui/components/headers/ConsoleHeader.d.ts.map +1 -1
  61. package/lib/typescript/src/ui/components/headers/DebuggerHeader.d.ts +4 -2
  62. package/lib/typescript/src/ui/components/headers/DebuggerHeader.d.ts.map +1 -1
  63. package/lib/typescript/src/ui/components/headers/HeaderComponents.d.ts +6 -5
  64. package/lib/typescript/src/ui/components/headers/HeaderComponents.d.ts.map +1 -1
  65. package/lib/typescript/src/ui/components/headers/NetworkHeader.d.ts +4 -2
  66. package/lib/typescript/src/ui/components/headers/NetworkHeader.d.ts.map +1 -1
  67. package/lib/typescript/src/ui/components/items/ConsolePanelItem.d.ts +2 -2
  68. package/lib/typescript/src/ui/components/items/ConsolePanelItem.d.ts.map +1 -1
  69. package/lib/typescript/src/ui/components/items/NetworkPanelItem.d.ts +2 -2
  70. package/lib/typescript/src/ui/components/items/NetworkPanelItem.d.ts.map +1 -1
  71. package/lib/typescript/src/ui/components/panels/ConsolePanel.d.ts +6 -3
  72. package/lib/typescript/src/ui/components/panels/ConsolePanel.d.ts.map +1 -1
  73. package/lib/typescript/src/ui/components/panels/NetworkPanel.d.ts +7 -5
  74. package/lib/typescript/src/ui/components/panels/NetworkPanel.d.ts.map +1 -1
  75. package/lib/typescript/src/ui/components/panels/Panel.d.ts +5 -3
  76. package/lib/typescript/src/ui/components/panels/Panel.d.ts.map +1 -1
  77. package/lib/typescript/src/ui/components/search-bar/SearchBar.d.ts +4 -2
  78. package/lib/typescript/src/ui/components/search-bar/SearchBar.d.ts.map +1 -1
  79. package/package.json +2 -1
  80. package/src/core/constants.ts +2 -0
  81. package/src/core/refs.ts +10 -1
  82. package/src/core/utils.ts +8 -2
  83. package/src/ui/Xenon.tsx +18 -15
  84. package/src/ui/components/bubble/Bubble.tsx +97 -100
  85. package/src/ui/components/common/IndexedStack.tsx +8 -20
  86. package/src/ui/components/details/LogMessageDetails.tsx +25 -27
  87. package/src/ui/components/details/NetworkRequestDetails.tsx +152 -151
  88. package/src/ui/components/handle/Handle.tsx +60 -0
  89. package/src/ui/components/headers/ConsoleHeader.tsx +13 -16
  90. package/src/ui/components/headers/DebuggerHeader.tsx +82 -82
  91. package/src/ui/components/headers/HeaderComponents.tsx +18 -16
  92. package/src/ui/components/headers/NetworkHeader.tsx +47 -50
  93. package/src/ui/components/items/ConsolePanelItem.tsx +28 -14
  94. package/src/ui/components/items/DebuggerHeaderItem.tsx +1 -0
  95. package/src/ui/components/items/NetworkPanelItem.tsx +67 -57
  96. package/src/ui/components/panels/ConsolePanel.tsx +18 -14
  97. package/src/ui/components/panels/NetworkPanel.tsx +22 -19
  98. package/src/ui/components/panels/Panel.tsx +33 -14
  99. package/src/ui/components/search-bar/SearchBar.tsx +7 -7
@@ -1,4 +1,4 @@
1
- import { forwardRef, useContext } from 'react';
1
+ import { useContext, type Ref } from 'react';
2
2
  import { type ScrollView, type StyleProp, type ViewStyle } from 'react-native';
3
3
  import { MainContext } from '../../../contexts';
4
4
  import { type PanelState } from '../../../core/refs';
@@ -13,61 +13,58 @@ import HeaderComponents from './HeaderComponents';
13
13
  interface NetworkHeaderProps {
14
14
  selectedPanel: PanelState;
15
15
  style?: StyleProp<ViewStyle>;
16
+ ref?: Ref<ScrollView>;
16
17
  }
17
18
 
18
- const NetworkHeader = forwardRef<ScrollView, NetworkHeaderProps>(
19
- ({ selectedPanel, style }, ref) => {
20
- const {
21
- debuggerState: { detailsData },
22
- setDebuggerState,
23
- } = useContext(MainContext)!;
19
+ export default function NetworkHeader({ selectedPanel, style, ref }: NetworkHeaderProps) {
20
+ const {
21
+ debuggerState: { detailsData },
22
+ setDebuggerState,
23
+ } = useContext(MainContext)!;
24
24
 
25
- const data = detailsData?.data as HttpRequest | WebSocketRequest | undefined;
25
+ const data = detailsData?.data as HttpRequest | WebSocketRequest | undefined;
26
26
 
27
- const { isWS, overviewShown, headersShown, requestShown, responseShown, messagesShown } =
28
- getNetworkUtils(data);
27
+ const { isWS, overviewShown, headersShown, requestShown, responseShown, messagesShown } =
28
+ getNetworkUtils(data);
29
29
 
30
- return (
31
- <HeaderComponents.Wrapper ref={ref} style={style}>
32
- <HeaderComponents.Back selectedPanel={selectedPanel} />
33
- <HeaderComponents.MainButtons />
30
+ return (
31
+ <HeaderComponents.Wrapper ref={ref} style={style}>
32
+ <HeaderComponents.Back selectedPanel={selectedPanel} />
33
+ <HeaderComponents.MainButtons />
34
34
 
35
- <Divider type="vertical" />
35
+ <Divider type="vertical" />
36
36
 
37
- {!!overviewShown && <HeaderComponents.DetailTabItem tab="overview" label="Overview" />}
38
- {!!headersShown && <HeaderComponents.DetailTabItem tab="headers" label="Headers" />}
39
- {!!requestShown && <HeaderComponents.DetailTabItem tab="request" label="Request" />}
40
- {!!responseShown && <HeaderComponents.DetailTabItem tab="response" label="Response" />}
41
- {!!messagesShown && <HeaderComponents.DetailTabItem tab="messages" label="Messages" />}
37
+ {!!overviewShown && <HeaderComponents.DetailTabItem tab="overview" label="Overview" />}
38
+ {!!headersShown && <HeaderComponents.DetailTabItem tab="headers" label="Headers" />}
39
+ {!!requestShown && <HeaderComponents.DetailTabItem tab="request" label="Request" />}
40
+ {!!responseShown && <HeaderComponents.DetailTabItem tab="response" label="Response" />}
41
+ {!!messagesShown && <HeaderComponents.DetailTabItem tab="messages" label="Messages" />}
42
42
 
43
- {!isWS && (
44
- <>
45
- <Divider type="vertical" />
43
+ {!isWS && (
44
+ <>
45
+ <Divider type="vertical" />
46
46
 
47
- <DebuggerHeaderItem
48
- content={icons.beautify}
49
- isActive={detailsData?.beautified}
50
- activeColor={colors.green}
51
- onPress={() => {
52
- setDebuggerState(draft => {
53
- draft.detailsData!.beautified = !draft.detailsData?.beautified;
54
- });
55
- }}
56
- />
57
- <DebuggerHeaderItem
58
- content={icons.share}
59
- onPress={async () => {
60
- if (data?.type === NetworkType.WS) return;
61
- await shareText(
62
- convertToCurl(data!.method, data!.url, data!.requestHeaders, data!.body),
63
- );
64
- }}
65
- />
66
- </>
67
- )}
68
- </HeaderComponents.Wrapper>
69
- );
70
- },
71
- );
72
-
73
- export default NetworkHeader;
47
+ <DebuggerHeaderItem
48
+ content={icons.beautify}
49
+ isActive={detailsData?.beautified}
50
+ activeColor={colors.green}
51
+ onPress={() => {
52
+ setDebuggerState(draft => {
53
+ draft.detailsData!.beautified = !draft.detailsData?.beautified;
54
+ });
55
+ }}
56
+ />
57
+ <DebuggerHeaderItem
58
+ content={icons.share}
59
+ onPress={async () => {
60
+ if (data?.type === NetworkType.WS) return;
61
+ await shareText(
62
+ convertToCurl(data!.method, data!.url, data!.requestHeaders, data!.body),
63
+ );
64
+ }}
65
+ />
66
+ </>
67
+ )}
68
+ </HeaderComponents.Wrapper>
69
+ );
70
+ }
@@ -1,4 +1,6 @@
1
- import { StyleSheet, Text } from 'react-native';
1
+ import { memo } from 'react';
2
+ import { StyleSheet, Text, View } from 'react-native';
3
+ import { CONSOLE_ITEM_HEIGHT } from '../../../core/constants';
2
4
  import { formatLogMessage, getConsoleTypeColor } from '../../../core/utils';
3
5
  import colors from '../../../theme/colors';
4
6
  import type { LogMessage } from '../../../types';
@@ -8,23 +10,33 @@ interface ConsolePanelItemProps extends LogMessage {
8
10
  onPress: () => void;
9
11
  }
10
12
 
11
- export default function ConsolePanelItem({ type, values, onPress }: ConsolePanelItemProps) {
12
- return (
13
- <Touchable
14
- onPress={onPress}
15
- style={[styles.container, { backgroundColor: getConsoleTypeColor(type) }]}
16
- >
17
- <Text numberOfLines={1} style={styles.text}>
18
- {formatLogMessage(values)}
19
- </Text>
20
- </Touchable>
21
- );
22
- }
13
+ const ConsolePanelItem = memo<ConsolePanelItemProps>(
14
+ ({ type, values, onPress }) => {
15
+ return (
16
+ <Touchable onPress={onPress} style={styles.container}>
17
+ <View style={[styles.wrapper, { backgroundColor: getConsoleTypeColor(type) }]}>
18
+ <Text numberOfLines={1} style={styles.text}>
19
+ {formatLogMessage(values)}
20
+ </Text>
21
+ </View>
22
+ </Touchable>
23
+ );
24
+ },
25
+ (prevProps, nextProps) =>
26
+ prevProps.type === nextProps.type &&
27
+ JSON.stringify(prevProps.values) === JSON.stringify(nextProps.values),
28
+ );
23
29
 
24
30
  const styles = StyleSheet.create({
25
31
  container: {
26
32
  flex: 1,
27
- padding: 8,
33
+ paddingBottom: 4,
34
+ height: CONSOLE_ITEM_HEIGHT,
35
+ },
36
+ wrapper: {
37
+ flex: 1,
38
+ paddingHorizontal: 8,
39
+ justifyContent: 'center',
28
40
  borderRadius: 8,
29
41
  },
30
42
  text: {
@@ -32,3 +44,5 @@ const styles = StyleSheet.create({
32
44
  fontSize: 14,
33
45
  },
34
46
  });
47
+
48
+ export default ConsolePanelItem;
@@ -65,5 +65,6 @@ const styles = StyleSheet.create({
65
65
  lineHeight: 18,
66
66
  fontWeight: '600',
67
67
  color: colors.black,
68
+ fontVariant: ['tabular-nums'],
68
69
  },
69
70
  });
@@ -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,82 @@ const getMethodColor = (method: string) => {
39
41
  }
40
42
  };
41
43
 
42
- export default function NetworkPanelItem({
43
- method,
44
- name,
45
- startTime,
46
- endTime,
47
- status,
48
- onPress,
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
- const requestPath = useMemo(() => {
57
- if (!name) return '[failed]';
52
+ const requestPath = useMemo(() => {
53
+ if (!name) return '[failed]';
58
54
 
59
- try {
60
- const url = new URL(name);
61
- const suffixUrl = url.pathname + url.search;
55
+ try {
56
+ const url = new URL(name);
57
+ const suffixUrl = url.pathname + url.search;
62
58
 
63
- if (suffixUrl === '/') return url.host;
64
- return suffixUrl;
65
- } catch (error) {
66
- return name;
67
- }
68
- }, [name]);
59
+ if (suffixUrl === '/') return url.host;
60
+ return suffixUrl;
61
+ } catch (error) {
62
+ return name;
63
+ }
64
+ }, [name]);
69
65
 
70
- return (
71
- <Touchable onPress={onPress} style={styles.container}>
72
- <View style={styles.column}>
73
- <Text
74
- numberOfLines={1}
75
- style={[
76
- styles.text,
77
- styles.methodText,
78
- { backgroundColor: getMethodColor(requestMethod) },
79
- ]}
80
- >
81
- {requestMethod}
82
- </Text>
83
- </View>
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
- <View style={[styles.column, styles.pathColumn]}>
86
- <Text numberOfLines={1} style={textStyle}>
87
- {requestPath}
88
- </Text>
89
- </View>
82
+ <View style={[styles.column, styles.pathColumn]}>
83
+ <Text numberOfLines={1} style={textStyle}>
84
+ {requestPath}
85
+ </Text>
86
+ </View>
90
87
 
91
- <View style={[styles.column, styles.durationColumn]}>
92
- <Text numberOfLines={1} style={textStyle}>
93
- {duration}
94
- </Text>
95
- </View>
88
+ <View style={[styles.column, styles.durationColumn]}>
89
+ <Text numberOfLines={1} style={textStyle}>
90
+ {duration}
91
+ </Text>
92
+ </View>
96
93
 
97
- <View style={styles.column}>
98
- <Text numberOfLines={1} style={textStyle}>
99
- {requestStatusCode}
100
- </Text>
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
- </Touchable>
103
- );
104
- }
102
+ );
103
+ },
104
+ (prevProps, nextProps) =>
105
+ prevProps.method === nextProps.method &&
106
+ prevProps.name === nextProps.name &&
107
+ prevProps.startTime === nextProps.startTime &&
108
+ prevProps.endTime === nextProps.endTime &&
109
+ prevProps.status === nextProps.status,
110
+ );
105
111
 
106
112
  const styles = StyleSheet.create({
107
113
  container: {
108
114
  flex: 1,
115
+ },
116
+ wrapper: {
109
117
  flexDirection: 'row',
110
118
  alignItems: 'center',
111
- paddingVertical: 8,
119
+ height: NETWORK_ITEM_HEIGHT,
112
120
  columnGap: 8,
113
121
  },
114
122
  pathColumn: {
@@ -138,3 +146,5 @@ const styles = StyleSheet.create({
138
146
  fontWeight: '600',
139
147
  },
140
148
  });
149
+
150
+ export default NetworkPanelItem;
@@ -1,22 +1,24 @@
1
- import { forwardRef, useCallback, useContext, useMemo } from 'react';
1
+ import { useCallback, useContext, useMemo, type Ref } 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 refs, { HeaderState, PanelState } from '../../../core/refs';
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} />;
16
+ interface ConsolePanelProps {
17
+ style?: StyleProp<ViewStyle>;
18
+ ref?: Ref<FlatList<any>>;
19
+ }
18
20
 
19
- const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ style }, ref) => {
21
+ export default function ConsolePanel({ style, ref }: ConsolePanelProps) {
20
22
  const {
21
23
  debuggerState: { searchQuery },
22
24
  consoleInterceptor: { logMessages },
@@ -42,8 +44,6 @@ const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
42
44
  <ConsolePanelItem
43
45
  {...item}
44
46
  onPress={() => {
45
- refs.header.current?.setCurrentIndex(HeaderState.Console);
46
- refs.panel.current?.setCurrentIndex(PanelState.ConsoleDetail);
47
47
  setDebuggerState(draft => {
48
48
  draft.detailsData = {
49
49
  type: DebuggerPanel.Console,
@@ -58,6 +58,15 @@ const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
58
58
  [setDebuggerState],
59
59
  );
60
60
 
61
+ const getItemLayout = useCallback(
62
+ (_: ArrayLike<LogMessage> | null | undefined, index: number) => ({
63
+ length: CONSOLE_ITEM_HEIGHT,
64
+ offset: CONSOLE_ITEM_HEIGHT * index,
65
+ index,
66
+ }),
67
+ [],
68
+ );
69
+
61
70
  return (
62
71
  <FlatList
63
72
  ref={ref}
@@ -65,13 +74,13 @@ const ConsolePanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
65
74
  data={data}
66
75
  renderItem={renderItem}
67
76
  keyExtractor={(_, index) => index.toString()}
68
- ItemSeparatorComponent={Separator}
69
77
  style={[styles.container, style]}
70
78
  contentContainerStyle={data.length ? styles.contentContainer : undefined}
71
79
  ListEmptyComponent={<Empty>No logs yet</Empty>}
80
+ getItemLayout={getItemLayout}
72
81
  />
73
82
  );
74
- });
83
+ }
75
84
 
76
85
  const styles = StyleSheet.create({
77
86
  container: {
@@ -80,9 +89,4 @@ const styles = StyleSheet.create({
80
89
  contentContainer: {
81
90
  padding: 8,
82
91
  },
83
- spacing: {
84
- height: 4,
85
- },
86
92
  });
87
-
88
- export default ConsolePanel;
@@ -1,13 +1,7 @@
1
- import { forwardRef, useCallback, useContext, useMemo } from 'react';
2
- import {
3
- FlatList,
4
- StyleSheet,
5
- type ListRenderItem,
6
- type StyleProp,
7
- type ViewStyle,
8
- } from 'react-native';
1
+ import { useCallback, useContext, useMemo, type Ref } from 'react';
2
+ import { FlatList, StyleSheet, type ListRenderItem, type ViewProps } from 'react-native';
9
3
  import { MainContext } from '../../../contexts';
10
- import refs, { HeaderState, PanelState } from '../../../core/refs';
4
+ import { NETWORK_ITEM_HEIGHT } from '../../../core/constants';
11
5
  import {
12
6
  DebuggerPanel,
13
7
  NetworkType,
@@ -15,13 +9,14 @@ import {
15
9
  type ID,
16
10
  type WebSocketRequest,
17
11
  } from '../../../types';
18
- import Divider from '../common/Divider';
19
12
  import Empty from '../common/Empty';
20
13
  import NetworkPanelItem from '../items/NetworkPanelItem';
21
14
 
22
- const Separator = () => <Divider type="horizontal" />;
15
+ interface NetworkPanelProps extends ViewProps {
16
+ ref?: Ref<FlatList<any>>;
17
+ }
23
18
 
24
- const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ style }, ref) => {
19
+ export default function NetworkPanel({ style, ref }: NetworkPanelProps) {
25
20
  const {
26
21
  debuggerState: { searchQuery },
27
22
  networkInterceptor: { networkRequests },
@@ -51,8 +46,6 @@ const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
51
46
  endTime={item.endTime}
52
47
  status={item.status}
53
48
  onPress={() => {
54
- refs.header.current?.setCurrentIndex(HeaderState.Network);
55
- refs.panel.current?.setCurrentIndex(PanelState.NetworkDetail);
56
49
  setDebuggerState(draft => {
57
50
  draft.detailsData = {
58
51
  type: DebuggerPanel.Network,
@@ -67,19 +60,31 @@ const NetworkPanel = forwardRef<FlatList, { style?: StyleProp<ViewStyle> }>(({ s
67
60
  [setDebuggerState],
68
61
  );
69
62
 
63
+ const getItemLayout = useCallback(
64
+ (
65
+ _: ArrayLike<[NonNullable<ID>, HttpRequest | WebSocketRequest]> | null | undefined,
66
+ index: number,
67
+ ) => ({
68
+ length: NETWORK_ITEM_HEIGHT,
69
+ offset: NETWORK_ITEM_HEIGHT * index,
70
+ index,
71
+ }),
72
+ [],
73
+ );
74
+
70
75
  return (
71
76
  <FlatList
77
+ ref={ref}
72
78
  inverted={!!data.length}
73
79
  data={data}
74
- ref={ref}
75
80
  renderItem={renderItem}
76
81
  keyExtractor={([key]) => key}
77
- ItemSeparatorComponent={Separator}
78
82
  style={[styles.container, style]}
79
83
  ListEmptyComponent={<Empty>No records yet</Empty>}
84
+ getItemLayout={getItemLayout}
80
85
  />
81
86
  );
82
- });
87
+ }
83
88
 
84
89
  const styles = StyleSheet.create({
85
90
  container: {
@@ -87,5 +92,3 @@ const styles = StyleSheet.create({
87
92
  paddingHorizontal: 8,
88
93
  },
89
94
  });
90
-
91
- export default NetworkPanel;
@@ -1,33 +1,53 @@
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 { useContext, useEffect, useMemo, type Ref } 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
- interface PanelProps extends ViewProps {}
17
+ interface PanelComponentProps extends ViewProps {
18
+ ref?: Ref<View>;
19
+ }
16
20
 
17
- const Panel = forwardRef<View, PanelProps>(({ style, ...props }, ref) => {
21
+ export default function Panel({ style, ...props }: PanelComponentProps) {
18
22
  const {
19
- debuggerState: { position },
20
- dimensions: { width: screenWidth, height: screenHeight },
23
+ debuggerState: { position, detailsData },
21
24
  } = useContext(MainContext)!;
22
25
 
23
26
  const containerStyle = useMemo(
24
- () => [styles.container, { [position]: 0, height: Math.min(screenWidth, screenHeight) * 0.75 }],
25
- [position, screenWidth, screenHeight],
27
+ () => [
28
+ styles.container,
29
+ { [position]: 0, width: refs.panelSize.current?.x, height: refs.panelSize.current?.y },
30
+ ],
31
+ [position],
26
32
  );
27
33
 
34
+ useEffect(() => {
35
+ switch (detailsData?.type) {
36
+ case DebuggerPanel.Network:
37
+ refs.header.current?.setCurrentIndex(HeaderState.Network);
38
+ refs.panel.current?.setCurrentIndex(PanelState.NetworkDetail);
39
+ break;
40
+ case DebuggerPanel.Console:
41
+ refs.header.current?.setCurrentIndex(HeaderState.Console);
42
+ refs.panel.current?.setCurrentIndex(PanelState.ConsoleDetail);
43
+ break;
44
+ }
45
+ }, [detailsData?.type]);
46
+
28
47
  return (
29
- <View style={[containerStyle, style]} ref={ref} {...props}>
48
+ <Animated.View style={[containerStyle, style]} {...props}>
30
49
  <SafeAreaProvider>
50
+ {position === 'bottom' && <Handle />}
31
51
  {position === 'top' && <SafeArea inset="top" />}
32
52
 
33
53
  <Header />
@@ -39,11 +59,12 @@ const Panel = forwardRef<View, PanelProps>(({ style, ...props }, ref) => {
39
59
  <LogMessageDetails />
40
60
  </IndexedStack>
41
61
 
62
+ {position === 'top' && <Handle />}
42
63
  {position === 'bottom' && <SafeArea inset="bottom" />}
43
64
  </SafeAreaProvider>
44
- </View>
65
+ </Animated.View>
45
66
  );
46
- });
67
+ }
47
68
 
48
69
  const styles = StyleSheet.create({
49
70
  container: {
@@ -58,5 +79,3 @@ const styles = StyleSheet.create({
58
79
  borderBottomWidth: StyleSheet.hairlineWidth,
59
80
  },
60
81
  });
61
-
62
- export default Panel;
@@ -1,4 +1,4 @@
1
- import { forwardRef, useContext, useState } from 'react';
1
+ import { useContext, useState, type Ref } from 'react';
2
2
  import {
3
3
  Keyboard,
4
4
  Platform,
@@ -18,11 +18,13 @@ import Icon from '../common/Icon';
18
18
  import Touchable from '../common/Touchable';
19
19
  import SafeArea from '../common/SafeArea';
20
20
 
21
- interface SearchBarProps extends ViewProps {}
21
+ interface SearchBarProps extends ViewProps {
22
+ ref?: Ref<View>;
23
+ }
22
24
 
23
25
  const ICON_SIZE = 20;
24
26
 
25
- const SearchBar = forwardRef<View, SearchBarProps>(({ style, ...props }, ref) => {
27
+ export default function SearchBar({ style, ...props }: SearchBarProps) {
26
28
  const {
27
29
  debuggerState: { searchQuery },
28
30
  setDebuggerState,
@@ -49,7 +51,7 @@ const SearchBar = forwardRef<View, SearchBarProps>(({ style, ...props }, ref) =>
49
51
  };
50
52
 
51
53
  return (
52
- <View ref={ref} style={[styles.container, style]} {...props}>
54
+ <View style={[styles.container, style]} {...props}>
53
55
  <SafeAreaProvider>
54
56
  <View style={styles.barView}>
55
57
  <SafeArea inset="top" />
@@ -87,7 +89,7 @@ const SearchBar = forwardRef<View, SearchBarProps>(({ style, ...props }, ref) =>
87
89
  </SafeAreaProvider>
88
90
  </View>
89
91
  );
90
- });
92
+ }
91
93
 
92
94
  const styles = StyleSheet.create({
93
95
  container: {
@@ -121,5 +123,3 @@ const styles = StyleSheet.create({
121
123
  flex: 1,
122
124
  },
123
125
  });
124
-
125
- export default SearchBar;