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.
- package/lib/module/core/utils.js +1 -1
- package/lib/module/core/utils.js.map +1 -1
- package/lib/module/interceptors/ConsoleInterceptor.js +27 -11
- package/lib/module/interceptors/ConsoleInterceptor.js.map +1 -1
- package/lib/module/ui/Xenon.js +1 -1
- package/lib/module/ui/Xenon.js.map +1 -1
- package/lib/module/ui/components/bubble/Bubble.js +4 -6
- package/lib/module/ui/components/bubble/Bubble.js.map +1 -1
- package/lib/module/ui/components/common/IndexedStack.js +5 -6
- package/lib/module/ui/components/common/IndexedStack.js.map +1 -1
- package/lib/module/ui/components/details/LogMessageDetails.js +10 -9
- package/lib/module/ui/components/details/LogMessageDetails.js.map +1 -1
- package/lib/module/ui/components/details/NetworkRequestDetails.js +6 -6
- package/lib/module/ui/components/details/NetworkRequestDetails.js.map +1 -1
- package/lib/module/ui/components/headers/ConsoleHeader.js +5 -6
- package/lib/module/ui/components/headers/ConsoleHeader.js.map +1 -1
- package/lib/module/ui/components/headers/DebuggerHeader.js +7 -7
- package/lib/module/ui/components/headers/DebuggerHeader.js.map +1 -1
- package/lib/module/ui/components/headers/HeaderComponents.js +6 -5
- package/lib/module/ui/components/headers/HeaderComponents.js.map +1 -1
- package/lib/module/ui/components/headers/NetworkHeader.js +6 -6
- package/lib/module/ui/components/headers/NetworkHeader.js.map +1 -1
- package/lib/module/ui/components/items/ConsolePanelItem.js +1 -3
- package/lib/module/ui/components/items/ConsolePanelItem.js.map +1 -1
- package/lib/module/ui/components/items/DebuggerHeaderItem.js +2 -1
- package/lib/module/ui/components/items/DebuggerHeaderItem.js.map +1 -1
- package/lib/module/ui/components/items/NetworkPanelItem.js +1 -3
- package/lib/module/ui/components/items/NetworkPanelItem.js.map +1 -1
- package/lib/module/ui/components/panels/ConsolePanel.js +6 -6
- package/lib/module/ui/components/panels/ConsolePanel.js.map +1 -1
- package/lib/module/ui/components/panels/NetworkPanel.js +7 -7
- package/lib/module/ui/components/panels/NetworkPanel.js.map +1 -1
- package/lib/module/ui/components/panels/Panel.js +4 -6
- package/lib/module/ui/components/panels/Panel.js.map +1 -1
- package/lib/module/ui/components/search-bar/SearchBar.js +4 -6
- package/lib/module/ui/components/search-bar/SearchBar.js.map +1 -1
- package/lib/typescript/src/interceptors/ConsoleInterceptor.d.ts +3 -0
- package/lib/typescript/src/interceptors/ConsoleInterceptor.d.ts.map +1 -1
- package/lib/typescript/src/ui/Xenon.d.ts +16 -14
- package/lib/typescript/src/ui/Xenon.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/bubble/Bubble.d.ts +4 -2
- package/lib/typescript/src/ui/components/bubble/Bubble.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/common/IndexedStack.d.ts +4 -3
- package/lib/typescript/src/ui/components/common/IndexedStack.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/details/LogMessageDetails.d.ts +6 -3
- package/lib/typescript/src/ui/components/details/LogMessageDetails.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/details/NetworkRequestDetails.d.ts +6 -3
- package/lib/typescript/src/ui/components/details/NetworkRequestDetails.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/headers/ConsoleHeader.d.ts +5 -3
- package/lib/typescript/src/ui/components/headers/ConsoleHeader.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/headers/DebuggerHeader.d.ts +4 -2
- package/lib/typescript/src/ui/components/headers/DebuggerHeader.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/headers/HeaderComponents.d.ts +6 -5
- package/lib/typescript/src/ui/components/headers/HeaderComponents.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/headers/NetworkHeader.d.ts +4 -2
- package/lib/typescript/src/ui/components/headers/NetworkHeader.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/items/NetworkPanelItem.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/panels/ConsolePanel.d.ts +6 -3
- package/lib/typescript/src/ui/components/panels/ConsolePanel.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/panels/NetworkPanel.d.ts +7 -5
- package/lib/typescript/src/ui/components/panels/NetworkPanel.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/panels/Panel.d.ts +5 -3
- package/lib/typescript/src/ui/components/panels/Panel.d.ts.map +1 -1
- package/lib/typescript/src/ui/components/search-bar/SearchBar.d.ts +4 -2
- package/lib/typescript/src/ui/components/search-bar/SearchBar.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/core/utils.ts +1 -1
- package/src/interceptors/ConsoleInterceptor.ts +40 -21
- package/src/ui/Xenon.tsx +18 -15
- package/src/ui/components/bubble/Bubble.tsx +97 -100
- package/src/ui/components/common/IndexedStack.tsx +8 -20
- package/src/ui/components/details/LogMessageDetails.tsx +25 -27
- package/src/ui/components/details/NetworkRequestDetails.tsx +152 -151
- package/src/ui/components/headers/ConsoleHeader.tsx +13 -16
- package/src/ui/components/headers/DebuggerHeader.tsx +82 -83
- package/src/ui/components/headers/HeaderComponents.tsx +18 -16
- package/src/ui/components/headers/NetworkHeader.tsx +47 -50
- package/src/ui/components/items/ConsolePanelItem.tsx +3 -3
- package/src/ui/components/items/DebuggerHeaderItem.tsx +1 -0
- package/src/ui/components/items/NetworkPanelItem.tsx +6 -9
- package/src/ui/components/panels/ConsolePanel.tsx +8 -5
- package/src/ui/components/panels/NetworkPanel.tsx +9 -13
- package/src/ui/components/panels/Panel.tsx +7 -7
- package/src/ui/components/search-bar/SearchBar.tsx +7 -7
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
6
|
-
import
|
|
6
|
+
import type { LogMessage } from '../../../types';
|
|
7
|
+
import ShareableText from '../common/ShareableText';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = useContext(MainContext)!;
|
|
9
|
+
interface LogMessageDetailsProps {
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
ref?: Ref<ScrollView>;
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
export default function LogMessageDetails({ style, ref }: LogMessageDetailsProps) {
|
|
15
|
+
const {
|
|
16
|
+
debuggerState: { detailsData },
|
|
17
|
+
} = useContext(MainContext)!;
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 {
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
130
|
-
|
|
116
|
+
content.current.headers = (
|
|
117
|
+
<TabScrollView id="headers">
|
|
118
|
+
{isWS && !!headers.length && (
|
|
119
|
+
<NetworkRequestDetailsItem label="Headers" content={headers} />
|
|
120
|
+
)}
|
|
131
121
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
{!isWS && !!requestHeaders.length && (
|
|
123
|
+
<NetworkRequestDetailsItem label="Request Headers" content={requestHeaders} />
|
|
124
|
+
)}
|
|
135
125
|
|
|
136
|
-
|
|
126
|
+
{!isWS && !!responseHeaders.length && (
|
|
127
|
+
<NetworkRequestDetailsItem label="Response Headers" content={responseHeaders} />
|
|
128
|
+
)}
|
|
129
|
+
</TabScrollView>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
137
132
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
{!!queryStringParameters.length && (
|
|
141
|
-
<NetworkRequestDetailsItem label="Query String" content={queryStringParameters} />
|
|
142
|
-
)}
|
|
133
|
+
if (requestShown && shouldBeautifiedRefUpdate && item) {
|
|
134
|
+
const queryStringParameters: [string, string][] = [];
|
|
143
135
|
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
142
|
+
content.current.request = (
|
|
143
|
+
<TabScrollView id="request">
|
|
144
|
+
{!!queryStringParameters.length && (
|
|
145
|
+
<NetworkRequestDetailsItem label="Query String" content={queryStringParameters} />
|
|
146
|
+
)}
|
|
172
147
|
|
|
173
|
-
|
|
174
|
-
|
|
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 {
|
|
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
|
-
|
|
13
|
-
(
|
|
14
|
-
|
|
15
|
-
<HeaderComponents.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 {
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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 {
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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: {
|