react-native-in-app-debugger 1.0.39 → 1.0.41

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 && (
@@ -97,7 +95,6 @@ const isError = (a) => a.response?.status < 200 || a.response?.status >= 400;
97
95
  export default (props) => {
98
96
  const [filter, setFilter] = useState("");
99
97
  const [errorOnly, setErrorOnly] = useState(false);
100
- const [filterUrlOnly, setFilterUrlOnly] = useState(true);
101
98
  const [expands, setExpands] = useState({});
102
99
  const apis = props.apis.filter((a) => !errorOnly || isError(a));
103
100
 
@@ -105,14 +102,7 @@ export default (props) => {
105
102
 
106
103
  return (
107
104
  <>
108
- <View
109
- style={{
110
- flexDirection: "row",
111
- paddingLeft: 5,
112
- alignItems: "center",
113
- gap: 5,
114
- }}
115
- >
105
+ <View style={styles.container}>
116
106
  {!!apis.length && !filter && (
117
107
  <TouchableOpacity
118
108
  style={{ padding: 5, backgroundColor: "white", borderRadius: 5 }}
@@ -123,7 +113,7 @@ export default (props) => {
123
113
  ])
124
114
  }
125
115
  >
126
- <Text style={{ color: "black" }}>
116
+ <Text style={{ color: "black", fontSize: 10 }}>
127
117
  Clear {props.apis.length} APIs
128
118
  </Text>
129
119
  </TouchableOpacity>
@@ -137,6 +127,7 @@ export default (props) => {
137
127
  style={{
138
128
  color: "red",
139
129
  textDecorationLine: errorOnly ? "line-through" : undefined,
130
+ fontSize: 10,
140
131
  }}
141
132
  >
142
133
  {apis.filter(isError).length} error
@@ -144,26 +135,30 @@ export default (props) => {
144
135
  </Text>
145
136
  </TouchableOpacity>
146
137
  )}
147
- <View style={{ flexDirection: "row", flex: 1 }}>
148
- <TextInput
149
- value={filter}
150
- placeholder="Filter..."
151
- clearButtonMode="always"
152
- placeholderTextColor="grey"
153
- style={{ paddingHorizontal: 5, color: "white", flex: 1 }}
154
- onChangeText={(t) => setFilter(t.toLowerCase())}
155
- />
156
- </View>
157
- {!!filter && (
138
+ {!!props.blacklists.length && !filter && (
158
139
  <TouchableOpacity
159
- style={{ padding: 5 }}
160
- onPress={() => setFilterUrlOnly((v) => !v)}
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
+ }
161
147
  >
162
- <Text style={{ color: "#ffffff88" }}>
163
- {filterUrlOnly ? "by URL" : "by URL & body"}
148
+ <Text style={{ color: "black", fontSize: 10 }}>
149
+ Clear {props.blacklists.length} Blacklists
164
150
  </Text>
165
151
  </TouchableOpacity>
166
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
+ />
167
162
  </View>
168
163
  {!filter &&
169
164
  !!props.maxNumOfApiToStore &&
@@ -173,15 +168,12 @@ export default (props) => {
173
168
  </Text>
174
169
  )}
175
170
  <SectionList
176
- contentContainerStyle={{ padding: 5 }}
177
171
  keyExtractor={(i) => i.id}
178
172
  stickySectionHeadersEnabled
179
173
  showsVerticalScrollIndicator
180
174
  sections={apis
181
175
  .filter((a) =>
182
- !filter || filterUrlOnly
183
- ? a.request.url.includes(filter)
184
- : JSON.stringify(a).toLowerCase().includes(filter)
176
+ !filter || JSON.stringify(a).toLowerCase().includes(filter)
185
177
  )
186
178
  .map((data) => ({ data: [data], id: data.id }))}
187
179
  renderItem={(i) =>
@@ -195,23 +187,15 @@ export default (props) => {
195
187
  const item = data[0];
196
188
  const hasResponse = !!item.response;
197
189
 
198
- const duration = item.response?.timestamp
199
- ? ~~(item.response?.timestamp - item.request.timestamp) / 1000
200
- : 0;
190
+ const duration = item.response?.timestamp ? ~~(item.response?.timestamp - item.request.timestamp) / 1000 : 0;
201
191
  const isExpand = expands[item.id];
192
+ const color = hasResponse ? item.response.error ? "red" : "white" : "yellow";
193
+
202
194
  return (
203
195
  <View style={styles.rowHeader}>
204
196
  <Text
205
197
  selectable
206
- style={{
207
- flex: 1,
208
- color: hasResponse
209
- ? item.response.error
210
- ? "red"
211
- : "white"
212
- : "yellow",
213
- marginVertical: 10,
214
- }}
198
+ style={{flex: 1, color, marginVertical: 10}}
215
199
  >
216
200
  <Text style={{ opacity: 0.7 }}>
217
201
  {item.request.method +
@@ -239,7 +223,7 @@ export default (props) => {
239
223
  }
240
224
  style={styles.actionButton}
241
225
  >
242
- <Text style={{ color: "black" }}>
226
+ <Text style={{ color: "black", fontSize: 10 }}>
243
227
  {isExpand ? "Hide" : "Show"}
244
228
  </Text>
245
229
  </TouchableOpacity>
@@ -248,15 +232,19 @@ export default (props) => {
248
232
  onPress={() => {
249
233
  const content = { ...item };
250
234
  delete content.id;
251
- Clipboard.setString(
252
- JSON.stringify(content, undefined, 4)
253
- );
235
+ Clipboard.setString(JSON.stringify(content, undefined, 4));
254
236
  }}
255
237
  style={styles.actionButton}
256
238
  >
257
- <Text style={{ color: "black" }}>Copy</Text>
239
+ <Text style={{ color: "black", fontSize: 10 }}>Copy</Text>
258
240
  </TouchableOpacity>
259
241
  )}
242
+ <TouchableOpacity
243
+ onPress={() => props.setBlacklists(v => [...v, item.request])}
244
+ style={styles.actionButton}
245
+ >
246
+ <Text style={{ color: "black", fontSize: 10 }}>Blacklist</Text>
247
+ </TouchableOpacity>
260
248
  </View>
261
249
  </View>
262
250
  );
@@ -267,6 +255,12 @@ export default (props) => {
267
255
  };
268
256
 
269
257
  const styles = StyleSheet.create({
258
+ container: {
259
+ flexDirection: "row",
260
+ paddingLeft: 5,
261
+ alignItems: "center",
262
+ gap: 5,
263
+ },
270
264
  details: {
271
265
  padding: 5,
272
266
  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
 
@@ -86,7 +87,7 @@ export default ({
86
87
  transform: [{ translateX }, { translateY }],
87
88
  position: "absolute",
88
89
  borderRadius,
89
- backgroundColor: "#000000" + (isOpen ? "dd" : "bb"),
90
+ backgroundColor: "#000000" + (isOpen ? "ee" : "bb"),
90
91
  height,
91
92
  width,
92
93
  borderTopRightRadius: numPendingApiCalls || errors ? 0 : undefined,
@@ -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.39",
3
+ "version": "1.0.41",
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