react-native-xenon 2.3.0 → 2.4.1

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 (84) hide show
  1. package/lib/module/core/utils.js +1 -1
  2. package/lib/module/core/utils.js.map +1 -1
  3. package/lib/module/interceptors/ConsoleInterceptor.js +27 -11
  4. package/lib/module/interceptors/ConsoleInterceptor.js.map +1 -1
  5. package/lib/module/ui/Xenon.js +1 -1
  6. package/lib/module/ui/Xenon.js.map +1 -1
  7. package/lib/module/ui/components/bubble/Bubble.js +4 -6
  8. package/lib/module/ui/components/bubble/Bubble.js.map +1 -1
  9. package/lib/module/ui/components/common/IndexedStack.js +5 -6
  10. package/lib/module/ui/components/common/IndexedStack.js.map +1 -1
  11. package/lib/module/ui/components/details/LogMessageDetails.js +10 -9
  12. package/lib/module/ui/components/details/LogMessageDetails.js.map +1 -1
  13. package/lib/module/ui/components/details/NetworkRequestDetails.js +6 -6
  14. package/lib/module/ui/components/details/NetworkRequestDetails.js.map +1 -1
  15. package/lib/module/ui/components/headers/ConsoleHeader.js +5 -6
  16. package/lib/module/ui/components/headers/ConsoleHeader.js.map +1 -1
  17. package/lib/module/ui/components/headers/DebuggerHeader.js +7 -7
  18. package/lib/module/ui/components/headers/DebuggerHeader.js.map +1 -1
  19. package/lib/module/ui/components/headers/HeaderComponents.js +6 -5
  20. package/lib/module/ui/components/headers/HeaderComponents.js.map +1 -1
  21. package/lib/module/ui/components/headers/NetworkHeader.js +6 -6
  22. package/lib/module/ui/components/headers/NetworkHeader.js.map +1 -1
  23. package/lib/module/ui/components/items/ConsolePanelItem.js +1 -3
  24. package/lib/module/ui/components/items/ConsolePanelItem.js.map +1 -1
  25. package/lib/module/ui/components/items/DebuggerHeaderItem.js +2 -1
  26. package/lib/module/ui/components/items/DebuggerHeaderItem.js.map +1 -1
  27. package/lib/module/ui/components/items/NetworkPanelItem.js +1 -3
  28. package/lib/module/ui/components/items/NetworkPanelItem.js.map +1 -1
  29. package/lib/module/ui/components/panels/ConsolePanel.js +6 -6
  30. package/lib/module/ui/components/panels/ConsolePanel.js.map +1 -1
  31. package/lib/module/ui/components/panels/NetworkPanel.js +7 -7
  32. package/lib/module/ui/components/panels/NetworkPanel.js.map +1 -1
  33. package/lib/module/ui/components/panels/Panel.js +4 -6
  34. package/lib/module/ui/components/panels/Panel.js.map +1 -1
  35. package/lib/module/ui/components/search-bar/SearchBar.js +4 -6
  36. package/lib/module/ui/components/search-bar/SearchBar.js.map +1 -1
  37. package/lib/typescript/src/interceptors/ConsoleInterceptor.d.ts +3 -0
  38. package/lib/typescript/src/interceptors/ConsoleInterceptor.d.ts.map +1 -1
  39. package/lib/typescript/src/ui/Xenon.d.ts +16 -14
  40. package/lib/typescript/src/ui/Xenon.d.ts.map +1 -1
  41. package/lib/typescript/src/ui/components/bubble/Bubble.d.ts +4 -2
  42. package/lib/typescript/src/ui/components/bubble/Bubble.d.ts.map +1 -1
  43. package/lib/typescript/src/ui/components/common/IndexedStack.d.ts +4 -3
  44. package/lib/typescript/src/ui/components/common/IndexedStack.d.ts.map +1 -1
  45. package/lib/typescript/src/ui/components/details/LogMessageDetails.d.ts +6 -3
  46. package/lib/typescript/src/ui/components/details/LogMessageDetails.d.ts.map +1 -1
  47. package/lib/typescript/src/ui/components/details/NetworkRequestDetails.d.ts +6 -3
  48. package/lib/typescript/src/ui/components/details/NetworkRequestDetails.d.ts.map +1 -1
  49. package/lib/typescript/src/ui/components/headers/ConsoleHeader.d.ts +5 -3
  50. package/lib/typescript/src/ui/components/headers/ConsoleHeader.d.ts.map +1 -1
  51. package/lib/typescript/src/ui/components/headers/DebuggerHeader.d.ts +4 -2
  52. package/lib/typescript/src/ui/components/headers/DebuggerHeader.d.ts.map +1 -1
  53. package/lib/typescript/src/ui/components/headers/HeaderComponents.d.ts +6 -5
  54. package/lib/typescript/src/ui/components/headers/HeaderComponents.d.ts.map +1 -1
  55. package/lib/typescript/src/ui/components/headers/NetworkHeader.d.ts +4 -2
  56. package/lib/typescript/src/ui/components/headers/NetworkHeader.d.ts.map +1 -1
  57. package/lib/typescript/src/ui/components/items/NetworkPanelItem.d.ts.map +1 -1
  58. package/lib/typescript/src/ui/components/panels/ConsolePanel.d.ts +6 -3
  59. package/lib/typescript/src/ui/components/panels/ConsolePanel.d.ts.map +1 -1
  60. package/lib/typescript/src/ui/components/panels/NetworkPanel.d.ts +7 -5
  61. package/lib/typescript/src/ui/components/panels/NetworkPanel.d.ts.map +1 -1
  62. package/lib/typescript/src/ui/components/panels/Panel.d.ts +5 -3
  63. package/lib/typescript/src/ui/components/panels/Panel.d.ts.map +1 -1
  64. package/lib/typescript/src/ui/components/search-bar/SearchBar.d.ts +4 -2
  65. package/lib/typescript/src/ui/components/search-bar/SearchBar.d.ts.map +1 -1
  66. package/package.json +2 -1
  67. package/src/core/utils.ts +1 -1
  68. package/src/interceptors/ConsoleInterceptor.ts +40 -21
  69. package/src/ui/Xenon.tsx +18 -15
  70. package/src/ui/components/bubble/Bubble.tsx +97 -100
  71. package/src/ui/components/common/IndexedStack.tsx +8 -20
  72. package/src/ui/components/details/LogMessageDetails.tsx +25 -27
  73. package/src/ui/components/details/NetworkRequestDetails.tsx +152 -151
  74. package/src/ui/components/headers/ConsoleHeader.tsx +13 -16
  75. package/src/ui/components/headers/DebuggerHeader.tsx +82 -83
  76. package/src/ui/components/headers/HeaderComponents.tsx +18 -16
  77. package/src/ui/components/headers/NetworkHeader.tsx +47 -50
  78. package/src/ui/components/items/ConsolePanelItem.tsx +3 -3
  79. package/src/ui/components/items/DebuggerHeaderItem.tsx +1 -0
  80. package/src/ui/components/items/NetworkPanelItem.tsx +6 -9
  81. package/src/ui/components/panels/ConsolePanel.tsx +8 -5
  82. package/src/ui/components/panels/NetworkPanel.tsx +9 -13
  83. package/src/ui/components/panels/Panel.tsx +7 -7
  84. package/src/ui/components/search-bar/SearchBar.tsx +7 -7
@@ -1,33 +1,33 @@
1
- import { ScrollView, StyleSheet, Text, type StyleProp, type ViewStyle } from 'react-native';
1
+ import { useContext, type Ref } from 'react';
2
+ import { ScrollView, StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { MainContext } from '../../../contexts';
2
4
  import { formatLogMessage, getConsoleTypeColor } from '../../../core/utils';
3
- import type { LogMessage } from '../../../types';
4
5
  import colors from '../../../theme/colors';
5
- import { forwardRef, useContext } from 'react';
6
- import { MainContext } from '../../../contexts';
6
+ import type { LogMessage } from '../../../types';
7
+ import ShareableText from '../common/ShareableText';
7
8
 
8
- const LogMessageDetails = forwardRef<ScrollView, { style?: StyleProp<ViewStyle> }>(
9
- ({ style }, ref) => {
10
- const {
11
- debuggerState: { detailsData },
12
- } = useContext(MainContext)!;
9
+ interface LogMessageDetailsProps {
10
+ style?: StyleProp<ViewStyle>;
11
+ ref?: Ref<ScrollView>;
12
+ }
13
13
 
14
- const item = detailsData?.data as LogMessage | undefined;
14
+ export default function LogMessageDetails({ style, ref }: LogMessageDetailsProps) {
15
+ const {
16
+ debuggerState: { detailsData },
17
+ } = useContext(MainContext)!;
15
18
 
16
- return (
17
- <ScrollView
18
- ref={ref}
19
- style={[
20
- styles.container,
21
- { backgroundColor: getConsoleTypeColor(item?.type ?? '') },
22
- style,
23
- ]}
24
- contentContainerStyle={styles.contentContainer}
25
- >
26
- <Text style={styles.text}>{formatLogMessage(item?.values ?? [])}</Text>
27
- </ScrollView>
28
- );
29
- },
30
- );
19
+ const item = detailsData?.data as LogMessage | undefined;
20
+
21
+ return (
22
+ <ScrollView
23
+ ref={ref}
24
+ style={[styles.container, { backgroundColor: getConsoleTypeColor(item?.type ?? '') }, style]}
25
+ contentContainerStyle={styles.contentContainer}
26
+ >
27
+ <ShareableText style={styles.text}>{formatLogMessage(item?.values ?? [])}</ShareableText>
28
+ </ScrollView>
29
+ );
30
+ }
31
31
 
32
32
  const styles = StyleSheet.create({
33
33
  container: {
@@ -41,5 +41,3 @@ const styles = StyleSheet.create({
41
41
  fontSize: 14,
42
42
  },
43
43
  });
44
-
45
- export default LogMessageDetails;
@@ -1,5 +1,11 @@
1
- import { forwardRef, useContext, useRef, type JSX, type ReactNode } from 'react';
1
+ import { useContext, useRef, type JSX, type ReactNode, type Ref } from 'react';
2
2
  import { ScrollView, StyleSheet, View, type StyleProp, type ViewStyle } from 'react-native';
3
+
4
+ interface NetworkRequestDetailsProps {
5
+ style?: StyleProp<ViewStyle>;
6
+ ref?: Ref<View>;
7
+ }
8
+
3
9
  import { MainContext } from '../../../contexts';
4
10
  import {
5
11
  beautify,
@@ -18,165 +24,162 @@ const TabScrollView = ({ id, children }: { id: string; children: ReactNode }) =>
18
24
  </ScrollView>
19
25
  );
20
26
 
21
- const NetworkRequestDetails = forwardRef<View, { style?: StyleProp<ViewStyle> }>(
22
- ({ style }, ref) => {
23
- const {
24
- debuggerState: { detailsData },
25
- } = useContext(MainContext)!;
26
-
27
- const item = detailsData?.data as HttpRequest | WebSocketRequest | undefined;
28
-
29
- const beautified = useRef<boolean | null>(null);
30
- const shouldBeautifiedRefUpdate =
31
- beautified.current !== detailsData?.beautified &&
32
- typeof detailsData?.beautified === 'boolean';
33
-
34
- const {
35
- isWS,
36
- requestUrl,
37
- overviewShown,
38
- headersShown,
39
- requestShown,
40
- responseShown,
41
- messagesShown,
42
- } = getNetworkUtils(item);
43
-
44
- const content = useRef<Record<Exclude<DetailTab, 'logMessage'>, JSX.Element | null>>({
45
- overview: null,
46
- headers: null,
47
- request: null,
48
- response: null,
49
- messages: null,
50
- });
51
-
52
- if (!item) {
53
- content.current.overview = null;
54
- content.current.headers = null;
55
- content.current.request = null;
56
- content.current.response = null;
57
- content.current.messages = null;
58
- beautified.current = null;
59
- }
60
-
61
- if (overviewShown && !content.current.overview && item) {
62
- content.current.overview = (
63
- <TabScrollView id="overview">
64
- <NetworkRequestDetailsItem label="Request Type" content={item.type} />
65
-
66
- <NetworkRequestDetailsItem label="Request URL" content={item.url} />
67
-
68
- <NetworkRequestDetailsItem
69
- label="Request Method"
70
- content={formatRequestMethod(isWS ? undefined : (item as HttpRequest).method)}
71
- />
72
-
73
- <NetworkRequestDetailsItem
74
- label="Status Code"
75
- content={formatRequestStatusCode(item.status)}
76
- />
77
-
78
- <NetworkRequestDetailsItem
79
- label="Start Time"
80
- content={new Date(item.startTime ?? 0).toISOString()}
81
- />
82
-
83
- <NetworkRequestDetailsItem
84
- label="End Time"
85
- content={new Date(item.endTime ?? 0).toISOString()}
86
- />
87
-
88
- <NetworkRequestDetailsItem
89
- label="Duration"
90
- content={formatRequestDuration(item.startTime, item.endTime)}
91
- />
92
- </TabScrollView>
93
- );
94
- }
95
-
96
- if (headersShown && !content.current.headers && item) {
97
- let headers: [string, string][] = [];
98
- const requestHeaders: [string, string][] = [];
99
- const responseHeaders: [string, string][] = [];
100
-
101
- if (isWS) {
102
- headers = Object.entries((item as WebSocketRequest).options?.headers ?? {});
103
- } else {
104
- for (const [key, value] of ((item as HttpRequest).requestHeaders ?? new Map()).entries()) {
105
- requestHeaders.push([key, value]);
106
- }
107
- for (const [key, value] of ((item as HttpRequest).responseHeaders ?? new Map()).entries()) {
108
- responseHeaders.push([key, value]);
109
- }
27
+ export default function NetworkRequestDetails({ style, ref }: NetworkRequestDetailsProps) {
28
+ const {
29
+ debuggerState: { detailsData },
30
+ } = useContext(MainContext)!;
31
+
32
+ const item = detailsData?.data as HttpRequest | WebSocketRequest | undefined;
33
+
34
+ const beautified = useRef<boolean | null>(null);
35
+ const shouldBeautifiedRefUpdate =
36
+ beautified.current !== detailsData?.beautified && typeof detailsData?.beautified === 'boolean';
37
+
38
+ const {
39
+ isWS,
40
+ requestUrl,
41
+ overviewShown,
42
+ headersShown,
43
+ requestShown,
44
+ responseShown,
45
+ messagesShown,
46
+ } = getNetworkUtils(item);
47
+
48
+ const content = useRef<Record<Exclude<DetailTab, 'logMessage'>, JSX.Element | null>>({
49
+ overview: null,
50
+ headers: null,
51
+ request: null,
52
+ response: null,
53
+ messages: null,
54
+ });
55
+
56
+ if (!item) {
57
+ content.current.overview = null;
58
+ content.current.headers = null;
59
+ content.current.request = null;
60
+ content.current.response = null;
61
+ content.current.messages = null;
62
+ beautified.current = null;
63
+ }
64
+
65
+ if (overviewShown && !content.current.overview && item) {
66
+ content.current.overview = (
67
+ <TabScrollView id="overview">
68
+ <NetworkRequestDetailsItem label="Request Type" content={item.type} />
69
+
70
+ <NetworkRequestDetailsItem label="Request URL" content={item.url} />
71
+
72
+ <NetworkRequestDetailsItem
73
+ label="Request Method"
74
+ content={formatRequestMethod(isWS ? undefined : (item as HttpRequest).method)}
75
+ />
76
+
77
+ <NetworkRequestDetailsItem
78
+ label="Status Code"
79
+ content={formatRequestStatusCode(item.status)}
80
+ />
81
+
82
+ <NetworkRequestDetailsItem
83
+ label="Start Time"
84
+ content={new Date(item.startTime ?? 0).toISOString()}
85
+ />
86
+
87
+ <NetworkRequestDetailsItem
88
+ label="End Time"
89
+ content={new Date(item.endTime ?? 0).toISOString()}
90
+ />
91
+
92
+ <NetworkRequestDetailsItem
93
+ label="Duration"
94
+ content={formatRequestDuration(item.startTime, item.endTime)}
95
+ />
96
+ </TabScrollView>
97
+ );
98
+ }
99
+
100
+ if (headersShown && !content.current.headers && item) {
101
+ let headers: [string, string][] = [];
102
+ const requestHeaders: [string, string][] = [];
103
+ const responseHeaders: [string, string][] = [];
104
+
105
+ if (isWS) {
106
+ headers = Object.entries((item as WebSocketRequest).options?.headers ?? {});
107
+ } else {
108
+ for (const [key, value] of ((item as HttpRequest).requestHeaders ?? new Map()).entries()) {
109
+ requestHeaders.push([key, value]);
110
+ }
111
+ for (const [key, value] of ((item as HttpRequest).responseHeaders ?? new Map()).entries()) {
112
+ responseHeaders.push([key, value]);
110
113
  }
111
-
112
- content.current.headers = (
113
- <TabScrollView id="headers">
114
- {isWS && !!headers.length && (
115
- <NetworkRequestDetailsItem label="Headers" content={headers} />
116
- )}
117
-
118
- {!isWS && !!requestHeaders.length && (
119
- <NetworkRequestDetailsItem label="Request Headers" content={requestHeaders} />
120
- )}
121
-
122
- {!isWS && !!responseHeaders.length && (
123
- <NetworkRequestDetailsItem label="Response Headers" content={responseHeaders} />
124
- )}
125
- </TabScrollView>
126
- );
127
114
  }
128
115
 
129
- if (requestShown && shouldBeautifiedRefUpdate && item) {
130
- const queryStringParameters: [string, string][] = [];
116
+ content.current.headers = (
117
+ <TabScrollView id="headers">
118
+ {isWS && !!headers.length && (
119
+ <NetworkRequestDetailsItem label="Headers" content={headers} />
120
+ )}
131
121
 
132
- requestUrl.searchParams.forEach((value, name) => {
133
- queryStringParameters.push([name, value]);
134
- });
122
+ {!isWS && !!requestHeaders.length && (
123
+ <NetworkRequestDetailsItem label="Request Headers" content={requestHeaders} />
124
+ )}
135
125
 
136
- const body = beautify((item as HttpRequest).body, detailsData?.beautified ?? false);
126
+ {!isWS && !!responseHeaders.length && (
127
+ <NetworkRequestDetailsItem label="Response Headers" content={responseHeaders} />
128
+ )}
129
+ </TabScrollView>
130
+ );
131
+ }
137
132
 
138
- content.current.request = (
139
- <TabScrollView id="request">
140
- {!!queryStringParameters.length && (
141
- <NetworkRequestDetailsItem label="Query String" content={queryStringParameters} />
142
- )}
133
+ if (requestShown && shouldBeautifiedRefUpdate && item) {
134
+ const queryStringParameters: [string, string][] = [];
143
135
 
144
- {!!body && <NetworkRequestDetailsItem label="Body" content={body} />}
145
- </TabScrollView>
146
- );
147
- }
148
-
149
- if (responseShown && shouldBeautifiedRefUpdate && item) {
150
- const response = beautify((item as HttpRequest).response, detailsData?.beautified ?? false);
151
- content.current.response = (
152
- <TabScrollView id="response">
153
- <NetworkRequestDetailsItem label="Response" content={response} />
154
- </TabScrollView>
155
- );
156
- }
136
+ requestUrl.searchParams.forEach((value, name) => {
137
+ queryStringParameters.push([name, value]);
138
+ });
157
139
 
158
- if (messagesShown && !content.current.messages && item) {
159
- content.current.messages = (
160
- <TabScrollView id="messages">
161
- <NetworkRequestDetailsItem
162
- label="Messages"
163
- content={(item as WebSocketRequest).messages!}
164
- />
165
- </TabScrollView>
166
- );
167
- }
140
+ const body = beautify((item as HttpRequest).body, detailsData?.beautified ?? false);
168
141
 
169
- if (shouldBeautifiedRefUpdate) {
170
- beautified.current = detailsData?.beautified ?? false;
171
- }
142
+ content.current.request = (
143
+ <TabScrollView id="request">
144
+ {!!queryStringParameters.length && (
145
+ <NetworkRequestDetailsItem label="Query String" content={queryStringParameters} />
146
+ )}
172
147
 
173
- return (
174
- <View ref={ref} style={[styles.container, style]}>
175
- {content.current[detailsData?.selectedTab as keyof typeof content.current]}
176
- </View>
148
+ {!!body && <NetworkRequestDetailsItem label="Body" content={body} />}
149
+ </TabScrollView>
177
150
  );
178
- },
179
- );
151
+ }
152
+
153
+ if (responseShown && shouldBeautifiedRefUpdate && item) {
154
+ const response = beautify((item as HttpRequest).response, detailsData?.beautified ?? false);
155
+ content.current.response = (
156
+ <TabScrollView id="response">
157
+ <NetworkRequestDetailsItem label="Response" content={response} />
158
+ </TabScrollView>
159
+ );
160
+ }
161
+
162
+ if (messagesShown && !content.current.messages && item) {
163
+ content.current.messages = (
164
+ <TabScrollView id="messages">
165
+ <NetworkRequestDetailsItem
166
+ label="Messages"
167
+ content={(item as WebSocketRequest).messages!}
168
+ />
169
+ </TabScrollView>
170
+ );
171
+ }
172
+
173
+ if (shouldBeautifiedRefUpdate) {
174
+ beautified.current = detailsData?.beautified ?? false;
175
+ }
176
+
177
+ return (
178
+ <View ref={ref} style={[styles.container, style]}>
179
+ {content.current[detailsData?.selectedTab as keyof typeof content.current]}
180
+ </View>
181
+ );
182
+ }
180
183
 
181
184
  const styles = StyleSheet.create({
182
185
  container: {
@@ -201,5 +204,3 @@ const styles = StyleSheet.create({
201
204
  alignItems: 'center',
202
205
  },
203
206
  });
204
-
205
- export default NetworkRequestDetails;
@@ -1,25 +1,22 @@
1
- import { forwardRef } from 'react';
1
+ import type { Ref } from 'react';
2
+ import type { ScrollView, StyleProp, ViewStyle } from 'react-native';
2
3
  import type { PanelState } from '../../../core/refs';
3
4
  import Divider from '../common/Divider';
4
5
  import HeaderComponents from './HeaderComponents';
5
- import type { ScrollView, StyleProp, ViewStyle } from 'react-native';
6
6
 
7
7
  interface ConsoleHeaderProps {
8
8
  selectedPanel: PanelState;
9
9
  style?: StyleProp<ViewStyle>;
10
+ ref?: Ref<ScrollView>;
10
11
  }
11
12
 
12
- const ConsoleHeader = forwardRef<ScrollView, ConsoleHeaderProps>(
13
- ({ selectedPanel, style }, ref) => {
14
- return (
15
- <HeaderComponents.Wrapper ref={ref} style={style}>
16
- <HeaderComponents.Back selectedPanel={selectedPanel} />
17
- <HeaderComponents.MainButtons />
18
- <Divider type="vertical" />
19
- <HeaderComponents.DetailTabItem tab="logMessage" label="Console" />
20
- </HeaderComponents.Wrapper>
21
- );
22
- },
23
- );
24
-
25
- export default ConsoleHeader;
13
+ export default function ConsoleHeader({ selectedPanel, style, ref }: ConsoleHeaderProps) {
14
+ return (
15
+ <HeaderComponents.Wrapper ref={ref} style={style}>
16
+ <HeaderComponents.Back selectedPanel={selectedPanel} />
17
+ <HeaderComponents.MainButtons />
18
+ <Divider type="vertical" />
19
+ <HeaderComponents.DetailTabItem tab="logMessage" label="Console" />
20
+ </HeaderComponents.Wrapper>
21
+ );
22
+ }
@@ -1,97 +1,96 @@
1
- import { forwardRef, useContext } from 'react';
1
+ import { useContext, type Ref } from 'react';
2
2
  import type { ScrollView, StyleProp, ViewStyle } from 'react-native';
3
3
  import { MainContext } from '../../../contexts';
4
4
  import refs, { DebuggerVisibility, PanelState } from '../../../core/refs';
5
+ import { formatCount } from '../../../core/utils';
5
6
  import icons from '../../../theme/icons';
6
7
  import Divider from '../common/Divider';
7
8
  import DebuggerHeaderItem from '../items/DebuggerHeaderItem';
8
9
  import HeaderComponents from './HeaderComponents';
9
- import { formatCount } from '../../../core/utils';
10
10
 
11
11
  interface DebuggerHeaderProps {
12
12
  selectedPanel: PanelState;
13
13
  setSelectedPanel: React.Dispatch<React.SetStateAction<PanelState>>;
14
14
  style?: StyleProp<ViewStyle>;
15
+ ref?: Ref<ScrollView>;
15
16
  }
16
17
 
17
- const DebuggerHeader = forwardRef<ScrollView, DebuggerHeaderProps>(
18
- ({ selectedPanel, setSelectedPanel, style }, ref) => {
19
- const { setDebuggerState, networkInterceptor, consoleInterceptor } = useContext(MainContext)!;
20
-
21
- const switchTo = (panelState: PanelState) => {
22
- refs.panel.current?.setCurrentIndex(panelState);
23
- setSelectedPanel(panelState);
24
-
25
- setDebuggerState(draft => {
26
- draft.detailsData = null;
27
- });
28
- };
29
-
30
- const toggleNetworkInterception = () => {
31
- networkInterceptor.isInterceptorEnabled
32
- ? networkInterceptor.disableInterception()
33
- : networkInterceptor.enableInterception();
34
- };
35
-
36
- const toggleConsoleInterception = () => {
37
- consoleInterceptor.isInterceptorEnabled
38
- ? consoleInterceptor.disableInterception()
39
- : consoleInterceptor.enableInterception();
40
- };
41
-
42
- const onShowSearchInput = () => {
43
- refs.debugger.current?.setCurrentIndex(DebuggerVisibility.Search);
44
- refs.searchInput.current?.focus();
45
- };
46
-
47
- return (
48
- <HeaderComponents.Wrapper ref={ref} style={style}>
49
- <DebuggerHeaderItem onPress={onShowSearchInput} content={icons.search} />
50
-
51
- <HeaderComponents.MainButtons />
52
-
53
- <Divider type="vertical" />
54
-
55
- <DebuggerHeaderItem
56
- isLabel
57
- isActive={selectedPanel === PanelState.Network}
58
- content={`Network (${formatCount(networkInterceptor.networkRequests.size)})`}
59
- onPress={() => switchTo(PanelState.Network)}
60
- />
61
-
62
- <DebuggerHeaderItem
63
- onPress={toggleNetworkInterception}
64
- isActive={networkInterceptor.isInterceptorEnabled}
65
- content={icons.record}
66
- />
67
-
68
- <DebuggerHeaderItem
69
- onPress={networkInterceptor.clearAllNetworkRequests}
70
- content={icons.delete}
71
- />
72
-
73
- <Divider type="vertical" />
74
-
75
- <DebuggerHeaderItem
76
- isLabel
77
- isActive={selectedPanel === PanelState.Console}
78
- content={`Console (${formatCount(consoleInterceptor.logMessages.length)})`}
79
- onPress={() => switchTo(PanelState.Console)}
80
- />
81
-
82
- <DebuggerHeaderItem
83
- onPress={toggleConsoleInterception}
84
- isActive={consoleInterceptor.isInterceptorEnabled}
85
- content={icons.record}
86
- />
87
-
88
- <DebuggerHeaderItem
89
- onPress={consoleInterceptor.clearAllLogMessages}
90
- content={icons.delete}
91
- />
92
- </HeaderComponents.Wrapper>
93
- );
94
- },
95
- );
96
-
97
- export default DebuggerHeader;
18
+ export default function DebuggerHeader({
19
+ selectedPanel,
20
+ setSelectedPanel,
21
+ style,
22
+ ref,
23
+ }: DebuggerHeaderProps) {
24
+ const { setDebuggerState, networkInterceptor, consoleInterceptor } = useContext(MainContext)!;
25
+
26
+ const switchTo = (panelState: PanelState) => {
27
+ refs.panel.current?.setCurrentIndex(panelState);
28
+ setSelectedPanel(panelState);
29
+
30
+ setDebuggerState(draft => {
31
+ draft.detailsData = null;
32
+ });
33
+ };
34
+
35
+ const toggleNetworkInterception = () => {
36
+ networkInterceptor.isInterceptorEnabled
37
+ ? networkInterceptor.disableInterception()
38
+ : networkInterceptor.enableInterception();
39
+ };
40
+
41
+ const toggleConsoleInterception = () => {
42
+ consoleInterceptor.isInterceptorEnabled
43
+ ? consoleInterceptor.disableInterception()
44
+ : consoleInterceptor.enableInterception();
45
+ };
46
+
47
+ const onShowSearchInput = () => {
48
+ refs.debugger.current?.setCurrentIndex(DebuggerVisibility.Search);
49
+ refs.searchInput.current?.focus();
50
+ };
51
+
52
+ return (
53
+ <HeaderComponents.Wrapper ref={ref} style={style}>
54
+ <DebuggerHeaderItem onPress={onShowSearchInput} content={icons.search} />
55
+
56
+ <HeaderComponents.MainButtons />
57
+
58
+ <Divider type="vertical" />
59
+
60
+ <DebuggerHeaderItem
61
+ isLabel
62
+ isActive={selectedPanel === PanelState.Network}
63
+ content={`Network (${formatCount(networkInterceptor.networkRequests.size)})`}
64
+ onPress={() => switchTo(PanelState.Network)}
65
+ />
66
+
67
+ <DebuggerHeaderItem
68
+ onPress={toggleNetworkInterception}
69
+ isActive={networkInterceptor.isInterceptorEnabled}
70
+ content={icons.record}
71
+ />
72
+
73
+ <DebuggerHeaderItem
74
+ onPress={networkInterceptor.clearAllNetworkRequests}
75
+ content={icons.delete}
76
+ />
77
+
78
+ <Divider type="vertical" />
79
+
80
+ <DebuggerHeaderItem
81
+ isLabel
82
+ isActive={selectedPanel === PanelState.Console}
83
+ content={`Console (${formatCount(consoleInterceptor.logMessages.length)})`}
84
+ onPress={() => switchTo(PanelState.Console)}
85
+ />
86
+
87
+ <DebuggerHeaderItem
88
+ onPress={toggleConsoleInterception}
89
+ isActive={consoleInterceptor.isInterceptorEnabled}
90
+ content={icons.record}
91
+ />
92
+
93
+ <DebuggerHeaderItem onPress={consoleInterceptor.clearAllLogMessages} content={icons.delete} />
94
+ </HeaderComponents.Wrapper>
95
+ );
96
+ }
@@ -1,4 +1,4 @@
1
- import { forwardRef, useContext, type PropsWithChildren } from 'react';
1
+ import { useContext, type PropsWithChildren, type Ref } from 'react';
2
2
  import { ScrollView, StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
3
3
  import { MainContext } from '../../../contexts';
4
4
  import refs, { DebuggerVisibility, HeaderState, PanelState } from '../../../core/refs';
@@ -65,21 +65,23 @@ const MainButtons = () => {
65
65
  );
66
66
  };
67
67
 
68
- const Wrapper = forwardRef<ScrollView, PropsWithChildren<{ style?: StyleProp<ViewStyle> }>>(
69
- ({ children, style }, ref) => {
70
- return (
71
- <ScrollView
72
- ref={ref}
73
- horizontal
74
- style={[styles.container, style]}
75
- contentContainerStyle={styles.contentContainer}
76
- showsHorizontalScrollIndicator={false}
77
- >
78
- {children}
79
- </ScrollView>
80
- );
81
- },
82
- );
68
+ function Wrapper({
69
+ children,
70
+ style,
71
+ ref,
72
+ }: PropsWithChildren<{ style?: StyleProp<ViewStyle>; ref?: Ref<ScrollView> }>) {
73
+ return (
74
+ <ScrollView
75
+ ref={ref}
76
+ horizontal
77
+ style={[styles.container, style]}
78
+ contentContainerStyle={styles.contentContainer}
79
+ showsHorizontalScrollIndicator={false}
80
+ >
81
+ {children}
82
+ </ScrollView>
83
+ );
84
+ }
83
85
 
84
86
  const styles = StyleSheet.create({
85
87
  container: {