react-native-in-app-debugger 2.0.6 → 2.0.8
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/Api/index.jsx +62 -54
- package/Mock/MockDetails.jsx +81 -44
- package/package.json +1 -1
package/Api/index.jsx
CHANGED
|
@@ -192,37 +192,40 @@ export default (props) => {
|
|
|
192
192
|
|
|
193
193
|
return (
|
|
194
194
|
<View style={styles.rowHeader}>
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
195
|
+
<View style={{ flex: 1 }}>
|
|
196
|
+
<View style={{ flexDirection: "row", gap: 5 }}>
|
|
197
|
+
<Bookmark
|
|
198
|
+
color={bookmarkColor}
|
|
199
|
+
onPress={() => {
|
|
200
|
+
props.setBookmarks((v) => {
|
|
201
|
+
if (!bookmarkColor)
|
|
202
|
+
return { ...v, [item.id]: getRandomBrightColor() };
|
|
203
|
+
const newV = { ...v };
|
|
204
|
+
delete newV[item.id];
|
|
205
|
+
return newV;
|
|
206
|
+
});
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
<Text style={{ color: "#555", fontSize: 8 }}>
|
|
210
|
+
{item.id + "\n"}
|
|
211
|
+
</Text>
|
|
212
|
+
</View>
|
|
213
|
+
<Text selectable style={{ flex: 1, color }}>
|
|
214
|
+
<Text style={{ opacity: 0.7 }}>
|
|
215
|
+
{item.request.method +
|
|
216
|
+
` (${item.response?.status ?? "no response"})` +
|
|
217
|
+
" - " +
|
|
218
|
+
item.request.time +
|
|
219
|
+
(hasResponse ? " - " + duration + " second(s)" : "") +
|
|
220
|
+
"\n"}
|
|
221
|
+
</Text>
|
|
222
|
+
<Highlight
|
|
223
|
+
text={item.request.url.slice(0, MAX_URL_LENGTH)}
|
|
224
|
+
filter={filter}
|
|
225
|
+
/>
|
|
226
|
+
{item.request.url.length > MAX_URL_LENGTH && "......."}
|
|
219
227
|
</Text>
|
|
220
|
-
|
|
221
|
-
text={item.request.url.slice(0, MAX_URL_LENGTH)}
|
|
222
|
-
filter={filter}
|
|
223
|
-
/>
|
|
224
|
-
{item.request.url.length > MAX_URL_LENGTH && "......."}
|
|
225
|
-
</Text>
|
|
228
|
+
</View>
|
|
226
229
|
<View style={{ gap: 4 }}>
|
|
227
230
|
<TouchableOpacity
|
|
228
231
|
onPress={() =>
|
|
@@ -254,30 +257,35 @@ export default (props) => {
|
|
|
254
257
|
<Text style={{ color: "black", fontSize: 10 }}>Copy</Text>
|
|
255
258
|
</TouchableOpacity>
|
|
256
259
|
)}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
260
|
+
{isExpand && (
|
|
261
|
+
<TouchableOpacity
|
|
262
|
+
onPress={() => {
|
|
263
|
+
Alert.alert(
|
|
264
|
+
"Are you sure",
|
|
265
|
+
`You want to blacklist: \n\n(${item.request.method}) ${item.request.url} \n\nwhere all history logs for this API will be removed and all future request for this API will not be recorded?`,
|
|
266
|
+
[
|
|
267
|
+
{
|
|
268
|
+
text: "Blacklist",
|
|
269
|
+
onPress: () =>
|
|
270
|
+
props.setBlacklists({
|
|
271
|
+
method: item.request.method,
|
|
272
|
+
url: item.request.url,
|
|
273
|
+
}),
|
|
274
|
+
style: "cancel",
|
|
275
|
+
},
|
|
276
|
+
{ text: "Cancel" },
|
|
277
|
+
]
|
|
278
|
+
);
|
|
279
|
+
}}
|
|
280
|
+
style={styles.actionButton}
|
|
281
|
+
>
|
|
282
|
+
<Text style={{ color: "black", fontSize: 10 }}>
|
|
283
|
+
Blacklist{" "}
|
|
284
|
+
</Text>
|
|
285
|
+
<BlacklistIcon />
|
|
286
|
+
</TouchableOpacity>
|
|
287
|
+
)}
|
|
288
|
+
{isExpand && item.interface === "axios" && (
|
|
281
289
|
<TouchableOpacity
|
|
282
290
|
onPress={() => {
|
|
283
291
|
props.goToMock(
|
package/Mock/MockDetails.jsx
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { useEffect, useState } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Alert,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
TextInput,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import Text from "../Text";
|
|
10
|
+
import X from "../X";
|
|
5
11
|
|
|
6
|
-
const removeId = (key, value) => (key ===
|
|
12
|
+
const removeId = (key, value) => (key === "id" ? undefined : value);
|
|
7
13
|
export default (p) => {
|
|
8
|
-
const [tab, setTab] = useState(
|
|
9
|
-
const [tmpResBody, setTmpResBody] = useState(
|
|
10
|
-
const [tmpResStatus, setTmpResStatus] = useState(
|
|
14
|
+
const [tab, setTab] = useState("response");
|
|
15
|
+
const [tmpResBody, setTmpResBody] = useState("");
|
|
16
|
+
const [tmpResStatus, setTmpResStatus] = useState("");
|
|
11
17
|
const [tmpMockDetails, setTmpMockDetails] = useState({});
|
|
12
18
|
|
|
13
19
|
const save = (cb) => {
|
|
14
|
-
if (tab ===
|
|
20
|
+
if (tab === "response") {
|
|
15
21
|
try {
|
|
16
22
|
if (!tmpResStatus) {
|
|
17
|
-
return Alert.alert(
|
|
23
|
+
return Alert.alert("Sorry", "Status code is required");
|
|
18
24
|
}
|
|
19
25
|
const tmp = JSON.parse(tmpMockDetails);
|
|
20
26
|
tmp.response.data = JSON.parse(tmpResBody);
|
|
@@ -46,25 +52,25 @@ export default (p) => {
|
|
|
46
52
|
// })
|
|
47
53
|
cb?.();
|
|
48
54
|
} catch (e) {
|
|
49
|
-
return Alert.alert(
|
|
55
|
+
return Alert.alert("Sorry", "Please fix the response body JSON");
|
|
50
56
|
}
|
|
51
|
-
} else if (tab ===
|
|
57
|
+
} else if (tab === "json") {
|
|
52
58
|
cb?.();
|
|
53
|
-
} else if (tab ===
|
|
59
|
+
} else if (tab === "request") {
|
|
54
60
|
cb?.();
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
|
-
const hasResponse = !!p.mockDetails?.response
|
|
63
|
+
const hasResponse = !!p.mockDetails?.response;
|
|
58
64
|
|
|
59
65
|
const reset = () => {
|
|
60
66
|
if (!p.mockDetails) return;
|
|
61
67
|
setTmpMockDetails(JSON.stringify(p.mockDetails, removeId, 4));
|
|
62
68
|
if (hasResponse) {
|
|
63
69
|
setTmpResBody(JSON.stringify(p.mockDetails.response.data, removeId, 4));
|
|
64
|
-
setTmpResStatus(p.mockDetails.response.status +
|
|
70
|
+
setTmpResStatus(p.mockDetails.response.status + "" || "");
|
|
65
71
|
} else {
|
|
66
|
-
setTmpResBody(
|
|
67
|
-
setTmpResStatus(
|
|
72
|
+
setTmpResBody("");
|
|
73
|
+
setTmpResStatus("");
|
|
68
74
|
}
|
|
69
75
|
};
|
|
70
76
|
useEffect(reset, [p.mockDetails]);
|
|
@@ -91,9 +97,11 @@ export default (p) => {
|
|
|
91
97
|
// }, [p.mockDetails, tmpMockDetails]);
|
|
92
98
|
if (!p.mockDetails) return null;
|
|
93
99
|
// const canReset = JSON.stringify(p.mockDetails, removeId)?.replace(/\s+/g, '') !== tmpMockDetails?.replace?.(/\s+/g, '');
|
|
94
|
-
const canReset =
|
|
100
|
+
const canReset =
|
|
101
|
+
!hasResponse ||
|
|
95
102
|
tmpResStatus != p.mockDetails.response.status ||
|
|
96
|
-
JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g,
|
|
103
|
+
JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, "") !==
|
|
104
|
+
tmpResBody?.replace?.(/\s+/g, "");
|
|
97
105
|
const isnew = !p.mocks.some((m) => m.id === p.mockDetails.id);
|
|
98
106
|
|
|
99
107
|
// console.log('xxxxx response', JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, ''));
|
|
@@ -106,17 +114,19 @@ export default (p) => {
|
|
|
106
114
|
bottom: 0,
|
|
107
115
|
left: 0,
|
|
108
116
|
right: 0,
|
|
109
|
-
position:
|
|
117
|
+
position: "absolute",
|
|
110
118
|
zIndex: 1000,
|
|
111
|
-
backgroundColor:
|
|
112
|
-
width:
|
|
113
|
-
height:
|
|
119
|
+
backgroundColor: "grey",
|
|
120
|
+
width: "100%",
|
|
121
|
+
height: "100%",
|
|
114
122
|
paddingTop: 50,
|
|
115
123
|
}}
|
|
116
124
|
>
|
|
117
125
|
{!isnew && <Text style={{ opacity: 0.3 }}>{p.mockDetails.id}</Text>}
|
|
118
|
-
<View style={{ flexDirection:
|
|
119
|
-
<Text
|
|
126
|
+
<View style={{ flexDirection: "row" }}>
|
|
127
|
+
<Text
|
|
128
|
+
style={{ flex: 1 }}
|
|
129
|
+
>{`(${p.mockDetails.request.method}) ${p.mockDetails.request.url}`}</Text>
|
|
120
130
|
<TouchableOpacity onPress={() => p.setMockDetails(null)}>
|
|
121
131
|
<X size={25} />
|
|
122
132
|
</TouchableOpacity>
|
|
@@ -124,34 +134,46 @@ export default (p) => {
|
|
|
124
134
|
<View
|
|
125
135
|
style={{
|
|
126
136
|
marginVertical: 10,
|
|
127
|
-
flexDirection:
|
|
128
|
-
justifyContent:
|
|
129
|
-
backgroundColor:
|
|
137
|
+
flexDirection: "row",
|
|
138
|
+
justifyContent: "space-around",
|
|
139
|
+
backgroundColor: "black",
|
|
130
140
|
borderRadius: 5,
|
|
131
141
|
padding: 5,
|
|
132
142
|
}}
|
|
133
143
|
>
|
|
134
|
-
{[
|
|
144
|
+
{["request", "response", "json"].map((item) => {
|
|
135
145
|
const isSelected = item === tab;
|
|
136
146
|
return (
|
|
137
147
|
<TouchableOpacity
|
|
138
|
-
style={{
|
|
148
|
+
style={{
|
|
149
|
+
backgroundColor: isSelected ? "white" : "black",
|
|
150
|
+
padding: 3,
|
|
151
|
+
borderRadius: 5,
|
|
152
|
+
}}
|
|
139
153
|
onPress={() => {
|
|
140
|
-
save(() => setTab(item));
|
|
154
|
+
// save(() => setTab(item));
|
|
155
|
+
setTab(item);
|
|
141
156
|
}}
|
|
142
157
|
>
|
|
143
|
-
<Text
|
|
158
|
+
<Text
|
|
159
|
+
style={{
|
|
160
|
+
textTransform: "uppercase",
|
|
161
|
+
color: isSelected ? "black" : "white",
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
{item}
|
|
165
|
+
</Text>
|
|
144
166
|
</TouchableOpacity>
|
|
145
167
|
);
|
|
146
168
|
})}
|
|
147
169
|
</View>
|
|
148
|
-
{tab ===
|
|
170
|
+
{tab === "response" && (
|
|
149
171
|
<View style={{ gap: 3 }}>
|
|
150
|
-
<View style={{ flexDirection:
|
|
172
|
+
<View style={{ flexDirection: "row", gap: 5 }}>
|
|
151
173
|
<Text>Status</Text>
|
|
152
174
|
<TextInput
|
|
153
|
-
style={{ backgroundColor:
|
|
154
|
-
inputMode=
|
|
175
|
+
style={{ backgroundColor: "#ccc", width: 50, padding: 2 }}
|
|
176
|
+
inputMode="numeric"
|
|
155
177
|
onChangeText={(t) => {
|
|
156
178
|
setTmpResStatus(t);
|
|
157
179
|
// try {
|
|
@@ -166,10 +188,15 @@ export default (p) => {
|
|
|
166
188
|
/>
|
|
167
189
|
</View>
|
|
168
190
|
|
|
169
|
-
<View style={{ flexDirection:
|
|
191
|
+
<View style={{ flexDirection: "row", gap: 5 }}>
|
|
170
192
|
<Text>Body</Text>
|
|
171
193
|
<TextInput
|
|
172
|
-
style={{
|
|
194
|
+
style={{
|
|
195
|
+
backgroundColor: "#ccc",
|
|
196
|
+
height: 250,
|
|
197
|
+
flex: 1,
|
|
198
|
+
padding: 2,
|
|
199
|
+
}}
|
|
173
200
|
multiline
|
|
174
201
|
onChangeText={setTmpResBody}
|
|
175
202
|
value={tmpResBody}
|
|
@@ -177,12 +204,22 @@ export default (p) => {
|
|
|
177
204
|
</View>
|
|
178
205
|
</View>
|
|
179
206
|
)}
|
|
180
|
-
{tab !==
|
|
207
|
+
{tab !== "response" && (
|
|
208
|
+
<Text style={{ marginTop: 30, textAlign: "center" }}>
|
|
209
|
+
To be developed later
|
|
210
|
+
</Text>
|
|
211
|
+
)}
|
|
181
212
|
{/* {tab === 'json' && (
|
|
182
213
|
<TextInput onChangeText={setTmpMockDetails} value={tmpMockDetails} style={{ height: '40%' }} multiline />
|
|
183
214
|
)} */}
|
|
184
|
-
{tab ===
|
|
185
|
-
<View
|
|
215
|
+
{tab === "response" && (
|
|
216
|
+
<View
|
|
217
|
+
style={{
|
|
218
|
+
flexDirection: "row",
|
|
219
|
+
justifyContent: "space-between",
|
|
220
|
+
padding: 10,
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
186
223
|
{!isnew && (
|
|
187
224
|
<TouchableOpacity
|
|
188
225
|
style={styles.actionButton}
|
|
@@ -233,10 +270,10 @@ export default (p) => {
|
|
|
233
270
|
|
|
234
271
|
const styles = StyleSheet.create({
|
|
235
272
|
actionButton: {
|
|
236
|
-
backgroundColor:
|
|
273
|
+
backgroundColor: "white",
|
|
237
274
|
borderRadius: 5,
|
|
238
275
|
padding: 4,
|
|
239
|
-
alignItems:
|
|
240
|
-
justifyContent:
|
|
276
|
+
alignItems: "center",
|
|
277
|
+
justifyContent: "center",
|
|
241
278
|
},
|
|
242
279
|
});
|
package/package.json
CHANGED