react-native-in-app-debugger 1.0.40 → 1.0.42

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.jsx CHANGED
@@ -59,9 +59,7 @@ const Row = ({ item, filter }) => {
59
59
  )}
60
60
  <View>
61
61
  <View style={{ flexDirection: "row" }}>
62
- {tabs.map((t) => (
63
- <Tab key={t.value} {...t} />
64
- ))}
62
+ {tabs.map((t) => <Tab key={t.value} {...t} />)}
65
63
  </View>
66
64
 
67
65
  {tab === tabs[0].value && hasResponse && (
@@ -104,14 +102,7 @@ export default (props) => {
104
102
 
105
103
  return (
106
104
  <>
107
- <View
108
- style={{
109
- flexDirection: "row",
110
- paddingLeft: 5,
111
- alignItems: "center",
112
- gap: 5,
113
- }}
114
- >
105
+ <View style={styles.container}>
115
106
  {!!apis.length && !filter && (
116
107
  <TouchableOpacity
117
108
  style={{ padding: 5, backgroundColor: "white", borderRadius: 5 }}
@@ -122,7 +113,7 @@ export default (props) => {
122
113
  ])
123
114
  }
124
115
  >
125
- <Text style={{ color: "black" }}>
116
+ <Text style={{ color: "black", fontSize: 10 }}>
126
117
  Clear {props.apis.length} APIs
127
118
  </Text>
128
119
  </TouchableOpacity>
@@ -136,6 +127,7 @@ export default (props) => {
136
127
  style={{
137
128
  color: "red",
138
129
  textDecorationLine: errorOnly ? "line-through" : undefined,
130
+ fontSize: 10,
139
131
  }}
140
132
  >
141
133
  {apis.filter(isError).length} error
@@ -143,16 +135,30 @@ export default (props) => {
143
135
  </Text>
144
136
  </TouchableOpacity>
145
137
  )}
146
- <View style={{ flexDirection: "row", flex: 1 }}>
147
- <TextInput
148
- value={filter}
149
- placeholder="Filter..."
150
- clearButtonMode="always"
151
- placeholderTextColor="grey"
152
- style={{ paddingHorizontal: 5, color: "white", flex: 1 }}
153
- onChangeText={(t) => setFilter(t.toLowerCase())}
154
- />
155
- </View>
138
+ {!!props.blacklists.length && !filter && (
139
+ <TouchableOpacity
140
+ style={{ padding: 5, backgroundColor: "white", borderRadius: 5 }}
141
+ onPress={() =>
142
+ Alert.alert("Are you sure", "You want to clear all blacklists", [
143
+ { text: "Clear", onPress: () => props.setBlacklists([]), style: "cancel" },
144
+ { text: "Cancel" },
145
+ ])
146
+ }
147
+ >
148
+ <Text style={{ color: "black", fontSize: 10 }}>
149
+ Clear {props.blacklists.length} Blacklists
150
+ </Text>
151
+ </TouchableOpacity>
152
+ )}
153
+
154
+ <TextInput
155
+ value={filter}
156
+ placeholder="Filter..."
157
+ clearButtonMode="always"
158
+ placeholderTextColor="grey"
159
+ style={{ paddingHorizontal: 5, color: "white", flex: 1 }}
160
+ onChangeText={(t) => setFilter(t.toLowerCase())}
161
+ />
156
162
  </View>
157
163
  {!filter &&
158
164
  !!props.maxNumOfApiToStore &&
@@ -162,7 +168,6 @@ export default (props) => {
162
168
  </Text>
163
169
  )}
164
170
  <SectionList
165
- contentContainerStyle={{ padding: 5 }}
166
171
  keyExtractor={(i) => i.id}
167
172
  stickySectionHeadersEnabled
168
173
  showsVerticalScrollIndicator
@@ -182,23 +187,15 @@ export default (props) => {
182
187
  const item = data[0];
183
188
  const hasResponse = !!item.response;
184
189
 
185
- const duration = item.response?.timestamp
186
- ? ~~(item.response?.timestamp - item.request.timestamp) / 1000
187
- : 0;
190
+ const duration = item.response?.timestamp ? ~~(item.response?.timestamp - item.request.timestamp) / 1000 : 0;
188
191
  const isExpand = expands[item.id];
192
+ const color = hasResponse ? item.response.error ? "red" : "white" : "yellow";
193
+
189
194
  return (
190
195
  <View style={styles.rowHeader}>
191
196
  <Text
192
197
  selectable
193
- style={{
194
- flex: 1,
195
- color: hasResponse
196
- ? item.response.error
197
- ? "red"
198
- : "white"
199
- : "yellow",
200
- marginVertical: 10,
201
- }}
198
+ style={{flex: 1, color, marginVertical: 10}}
202
199
  >
203
200
  <Text style={{ opacity: 0.7 }}>
204
201
  {item.request.method +
@@ -226,7 +223,7 @@ export default (props) => {
226
223
  }
227
224
  style={styles.actionButton}
228
225
  >
229
- <Text style={{ color: "black" }}>
226
+ <Text style={{ color: "black", fontSize: 10 }}>
230
227
  {isExpand ? "Hide" : "Show"}
231
228
  </Text>
232
229
  </TouchableOpacity>
@@ -235,15 +232,24 @@ export default (props) => {
235
232
  onPress={() => {
236
233
  const content = { ...item };
237
234
  delete content.id;
238
- Clipboard.setString(
239
- JSON.stringify(content, undefined, 4)
240
- );
235
+ Clipboard.setString(JSON.stringify(content, undefined, 4));
241
236
  }}
242
237
  style={styles.actionButton}
243
238
  >
244
- <Text style={{ color: "black" }}>Copy</Text>
239
+ <Text style={{ color: "black", fontSize: 10 }}>Copy</Text>
245
240
  </TouchableOpacity>
246
241
  )}
242
+ <TouchableOpacity
243
+ onPress={() => {
244
+ Alert.alert("Are you sure", `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?`, [
245
+ { text: "Blacklist", onPress: () => props.setBlacklists(v => [...v, item.request]), style: "cancel" },
246
+ { text: "Cancel" },
247
+ ])
248
+ }}
249
+ style={styles.actionButton}
250
+ >
251
+ <Text style={{ color: "black", fontSize: 10 }}>Blacklist</Text>
252
+ </TouchableOpacity>
247
253
  </View>
248
254
  </View>
249
255
  );
@@ -254,6 +260,12 @@ export default (props) => {
254
260
  };
255
261
 
256
262
  const styles = StyleSheet.create({
263
+ container: {
264
+ flexDirection: "row",
265
+ paddingLeft: 5,
266
+ alignItems: "center",
267
+ gap: 5,
268
+ },
257
269
  details: {
258
270
  padding: 5,
259
271
  backgroundColor: "#171717",
package/index.jsx CHANGED
@@ -50,7 +50,8 @@ export default ({
50
50
  labels = [],
51
51
  interceptResponse
52
52
  }) => {
53
- const { apis, clear } = useApiInterceptor(maxNumOfApiToStore, interceptResponse);
53
+ const [blacklists, setBlacklists] = useState([]);
54
+ const { apis, clear } = useApiInterceptor(maxNumOfApiToStore, blacklists, interceptResponse);
54
55
 
55
56
  const [tab, setTab] = useState("api");
56
57
 
@@ -162,9 +163,7 @@ export default ({
162
163
  )}
163
164
  {tab === "api" && (
164
165
  <Api
165
- apis={apis}
166
- clear={clear}
167
- maxNumOfApiToStore={maxNumOfApiToStore}
166
+ {...{apis, clear, setBlacklists, blacklists, maxNumOfApiToStore}}
168
167
  />
169
168
  )}
170
169
  </SafeAreaView>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-in-app-debugger",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "This library's main usage is to be used by Non-Technical testers during UAT, SIT or any testing phase.",
5
5
  "main": "index.jsx",
6
6
  "scripts": {
@@ -17,10 +17,11 @@ const parse = (data) => {
17
17
  }
18
18
  };
19
19
 
20
- export default (maxNumOfApiToStore, interceptResponse) => {
20
+ export default (maxNumOfApiToStore, blacklists, interceptResponse) => {
21
21
  const [apis, setApis] = useState([]);
22
22
 
23
23
  const makeRequest = (data) => {
24
+ if (blacklists.some(b => b.url === data.url && b.method === data.method)) return;
24
25
  const date = new Date();
25
26
  let hour = date.getHours();
26
27
  const minute = (date.getMinutes() + "").padStart(2, "0");
@@ -40,6 +41,12 @@ export default (maxNumOfApiToStore, interceptResponse) => {
40
41
  });
41
42
  };
42
43
 
44
+ useEffect(() => {
45
+ setApis((v) => (
46
+ v.filter(v => !blacklists.some(b => b.url === v.request.url && b.method === v.request.method))
47
+ ))
48
+ }, [blacklists])
49
+
43
50
  const receiveResponse = (data) => {
44
51
  const error = data.status < 200 || data.status >= 400;
45
52