react-native-in-app-debugger 2.0.3 → 2.0.5
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 +6 -2
- package/Api/useApiInterceptor.js +3 -3
- package/Mock/MockDetails.jsx +29 -12
- package/index.jsx +1 -1
- package/package.json +1 -1
- package/parentDependencies.js +1 -0
package/Api/index.jsx
CHANGED
|
@@ -182,7 +182,7 @@ export default (props) => {
|
|
|
182
182
|
: 0;
|
|
183
183
|
const isExpand = expands[item.id];
|
|
184
184
|
const bookmarkColor = props.bookmarks[item.id];
|
|
185
|
-
const color = item.
|
|
185
|
+
const color = !!item.mockid
|
|
186
186
|
? "blue"
|
|
187
187
|
: hasResponse
|
|
188
188
|
? item.response.error
|
|
@@ -279,7 +279,11 @@ export default (props) => {
|
|
|
279
279
|
</TouchableOpacity>
|
|
280
280
|
{item.interface === "axios" && (
|
|
281
281
|
<TouchableOpacity
|
|
282
|
-
onPress={() =>
|
|
282
|
+
onPress={() => {
|
|
283
|
+
props.goToMock(
|
|
284
|
+
item.mockid ? { ...item, id: item.mockid } : item
|
|
285
|
+
);
|
|
286
|
+
}}
|
|
283
287
|
style={styles.actionButton}
|
|
284
288
|
>
|
|
285
289
|
<Text style={{ color: "black", fontSize: 10 }}>Mock</Text>
|
package/Api/useApiInterceptor.js
CHANGED
|
@@ -49,12 +49,12 @@ export default ({ maxNumOfApiToStore, blacklists, blacklistRef, mocks }) => {
|
|
|
49
49
|
timestamp: performance.now(),
|
|
50
50
|
datetime: new Date().toLocaleString(),
|
|
51
51
|
time: `${hour}:${minute}:${second}`,
|
|
52
|
-
|
|
52
|
+
mockid: undefined,
|
|
53
53
|
interface: undefined
|
|
54
54
|
};
|
|
55
55
|
setApis((v) => {
|
|
56
56
|
const newData = [
|
|
57
|
-
{ request, id: Date.now().toString(36) + Math.random().toString(36),
|
|
57
|
+
{ request, id: Date.now().toString(36) + Math.random().toString(36), mockid: data.mockid, interface: data.interface },
|
|
58
58
|
...(maxNumOfApiToStore ? v.slice(0, maxNumOfApiToStore - 1) : v),
|
|
59
59
|
];
|
|
60
60
|
return newData;
|
|
@@ -201,7 +201,7 @@ export default ({ maxNumOfApiToStore, blacklists, blacklistRef, mocks }) => {
|
|
|
201
201
|
headers,
|
|
202
202
|
method,
|
|
203
203
|
data,
|
|
204
|
-
|
|
204
|
+
mockid: mock?.id,
|
|
205
205
|
interface: 'axios',
|
|
206
206
|
});
|
|
207
207
|
}
|
package/Mock/MockDetails.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Alert, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import Text from '../Text';
|
|
4
4
|
import X from '../X';
|
|
5
5
|
|
|
@@ -54,14 +54,21 @@ export default (p) => {
|
|
|
54
54
|
cb?.();
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
+
const hasResponse = !!p.mockDetails.response
|
|
58
|
+
|
|
57
59
|
const reset = () => {
|
|
58
60
|
if (!p.mockDetails) return;
|
|
59
61
|
setTmpMockDetails(JSON.stringify(p.mockDetails, removeId, 4));
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
if (hasResponse) {
|
|
63
|
+
setTmpResBody(JSON.stringify(p.mockDetails.response.data, removeId, 4));
|
|
64
|
+
setTmpResStatus(p.mockDetails.response.status + '' || '');
|
|
65
|
+
} else {
|
|
66
|
+
setTmpResBody('');
|
|
67
|
+
setTmpResStatus('');
|
|
68
|
+
}
|
|
62
69
|
};
|
|
63
70
|
useEffect(reset, [p.mockDetails]);
|
|
64
|
-
const [canReset, setCanReset] = useState(false);
|
|
71
|
+
// const [canReset, setCanReset] = useState(false);
|
|
65
72
|
|
|
66
73
|
const parse = (data) => {
|
|
67
74
|
try {
|
|
@@ -72,16 +79,26 @@ export default (p) => {
|
|
|
72
79
|
}
|
|
73
80
|
};
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
+
// console.log('xxxxx mock details', JSON.stringify(p.mockDetails, removeId)?.replace(/\s+/g, ""))
|
|
83
|
+
// console.log('xxxxx tmpMockDetails', tmpMockDetails?.replace?.(/\s+/g, ""))
|
|
84
|
+
|
|
85
|
+
// useEffect(() => {
|
|
86
|
+
// try {
|
|
87
|
+
// setCanReset(JSON.stringify(p.mockDetails, removeId)?.replace(/\s+/g, "") != tmpMockDetails?.replace?.(/\s+/g, ""));
|
|
88
|
+
// } catch (e) {
|
|
89
|
+
// setCanReset(true);
|
|
90
|
+
// }
|
|
91
|
+
// }, [p.mockDetails, tmpMockDetails]);
|
|
82
92
|
if (!p.mockDetails) return null;
|
|
93
|
+
// const canReset = JSON.stringify(p.mockDetails, removeId)?.replace(/\s+/g, '') !== tmpMockDetails?.replace?.(/\s+/g, '');
|
|
94
|
+
const canReset = !hasResponse ||
|
|
95
|
+
tmpResStatus != p.mockDetails.response.status ||
|
|
96
|
+
JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, '') !== tmpResBody?.replace?.(/\s+/g, '');
|
|
83
97
|
const isnew = !p.mocks.some((m) => m.id === p.mockDetails.id);
|
|
84
98
|
|
|
99
|
+
// console.log('xxxxx response', JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, ''));
|
|
100
|
+
// console.log('xxxxx tmpResBody', tmpResBody?.replace?.(/\s+/g, ''));
|
|
101
|
+
|
|
85
102
|
return (
|
|
86
103
|
<View
|
|
87
104
|
style={{
|
package/index.jsx
CHANGED
|
@@ -126,7 +126,7 @@ export default ({
|
|
|
126
126
|
|
|
127
127
|
const numErrorApiCalls = apis.filter((a) => a.response?.error).length;
|
|
128
128
|
const numPendingApiCalls = apis.filter((a) => !a.response).length;
|
|
129
|
-
const numMockedApiCalls = apis.filter((a) => a.
|
|
129
|
+
const numMockedApiCalls = apis.filter((a) => !!a.mockid).length;
|
|
130
130
|
let badgeHeight = fontSize * 3;
|
|
131
131
|
|
|
132
132
|
const displayLabels = [
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {}
|