react-native-debug-toolkit 0.1.6 → 0.1.7
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/views/HttpLogDetails.js +10 -86
- package/package.json +1 -1
|
@@ -74,8 +74,6 @@ const LongTextContent = ({ text }) => {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const JSONValue = ({ value, path = '', level = 0, maxExpandLevel = 2 }) => {
|
|
77
|
-
const [expanded, setExpanded] = useState(level < maxExpandLevel)
|
|
78
|
-
|
|
79
77
|
if (value === null) {
|
|
80
78
|
return <Text style={styles.jsonNull}>null</Text>
|
|
81
79
|
}
|
|
@@ -95,9 +93,7 @@ const JSONValue = ({ value, path = '', level = 0, maxExpandLevel = 2 }) => {
|
|
|
95
93
|
if (typeof value === 'string') {
|
|
96
94
|
if (value.length > 150) {
|
|
97
95
|
return (
|
|
98
|
-
<CollapsibleSection
|
|
99
|
-
title={`String (${value.length} chars)`}
|
|
100
|
-
initiallyExpanded={false}>
|
|
96
|
+
<CollapsibleSection title={`String (${value.length} chars)`} initiallyExpanded={false}>
|
|
101
97
|
<LongTextContent text={value} />
|
|
102
98
|
</CollapsibleSection>
|
|
103
99
|
)
|
|
@@ -110,88 +106,16 @@ const JSONValue = ({ value, path = '', level = 0, maxExpandLevel = 2 }) => {
|
|
|
110
106
|
)
|
|
111
107
|
}
|
|
112
108
|
|
|
113
|
-
|
|
114
|
-
if (value.length === 0) {
|
|
115
|
-
return <Text style={styles.jsonArray}>[]</Text>
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<View style={styles.jsonContainer}>
|
|
120
|
-
<Pressable
|
|
121
|
-
onPress={() => setExpanded(!expanded)}
|
|
122
|
-
style={styles.jsonToggle}>
|
|
123
|
-
<Text style={styles.jsonBrackets}>
|
|
124
|
-
[{!expanded && '...'}
|
|
125
|
-
{expanded && value.length > 0 && ''}
|
|
126
|
-
</Text>
|
|
127
|
-
{!expanded && (
|
|
128
|
-
<Text style={styles.jsonCollapsed}> Array({value.length}) </Text>
|
|
129
|
-
)}
|
|
130
|
-
</Pressable>
|
|
131
|
-
|
|
132
|
-
{expanded && (
|
|
133
|
-
<View style={styles.jsonChildren}>
|
|
134
|
-
{value.map((item, index) => (
|
|
135
|
-
<View key={`${path}-${index}`} style={styles.jsonArrayItem}>
|
|
136
|
-
<Text style={styles.jsonKey}>{index}: </Text>
|
|
137
|
-
<View style={styles.jsonValue}>
|
|
138
|
-
<JSONValue
|
|
139
|
-
value={item}
|
|
140
|
-
path={`${path}[${index}]`}
|
|
141
|
-
level={level + 1}
|
|
142
|
-
/>
|
|
143
|
-
</View>
|
|
144
|
-
</View>
|
|
145
|
-
))}
|
|
146
|
-
</View>
|
|
147
|
-
)}
|
|
148
|
-
|
|
149
|
-
{expanded && <Text style={styles.jsonBrackets}>]</Text>}
|
|
150
|
-
</View>
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
|
|
109
|
+
// For objects and arrays, use JSONTree for improved large data handling
|
|
154
110
|
if (typeof value === 'object') {
|
|
155
|
-
const keys = Object.keys(value)
|
|
156
|
-
|
|
157
|
-
if (keys.length === 0) {
|
|
158
|
-
return <Text style={styles.jsonObject}>{'{}'}</Text>
|
|
159
|
-
}
|
|
160
|
-
|
|
161
111
|
return (
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
{expanded && keys.length > 0 && ''}
|
|
170
|
-
</Text>
|
|
171
|
-
{!expanded && (
|
|
172
|
-
<Text style={styles.jsonCollapsed}> Object({keys.length}) </Text>
|
|
173
|
-
)}
|
|
174
|
-
</Pressable>
|
|
175
|
-
|
|
176
|
-
{expanded && (
|
|
177
|
-
<View style={styles.jsonChildren}>
|
|
178
|
-
{keys.map((key) => (
|
|
179
|
-
<View key={`${path}-${key}`} style={styles.jsonProperty}>
|
|
180
|
-
<Text style={styles.jsonKey}>{key}: </Text>
|
|
181
|
-
<View style={styles.jsonValue}>
|
|
182
|
-
<JSONValue
|
|
183
|
-
value={value[key]}
|
|
184
|
-
path={`${path}.${key}`}
|
|
185
|
-
level={level + 1}
|
|
186
|
-
/>
|
|
187
|
-
</View>
|
|
188
|
-
</View>
|
|
189
|
-
))}
|
|
190
|
-
</View>
|
|
191
|
-
)}
|
|
192
|
-
|
|
193
|
-
{expanded && <Text style={styles.jsonBrackets}>{'}'}</Text>}
|
|
194
|
-
</View>
|
|
112
|
+
<JSONTree
|
|
113
|
+
data={value}
|
|
114
|
+
theme={theme}
|
|
115
|
+
invertTheme={true}
|
|
116
|
+
hideRoot={true}
|
|
117
|
+
shouldExpandNode={(keyPath, nodeData, currentLevel) => currentLevel < maxExpandLevel}
|
|
118
|
+
/>
|
|
195
119
|
)
|
|
196
120
|
}
|
|
197
121
|
|
|
@@ -407,7 +331,7 @@ const HttpLogDetails = ({ log }) => {
|
|
|
407
331
|
nestedScrollEnabled={true}
|
|
408
332
|
bounces={false}
|
|
409
333
|
showsVerticalScrollIndicator={true}>
|
|
410
|
-
<
|
|
334
|
+
<JSONValue value={responseData} maxExpandLevel={2} />
|
|
411
335
|
</ScrollView>
|
|
412
336
|
</View>
|
|
413
337
|
</View>
|
package/package.json
CHANGED