react-native-in-app-debugger 1.0.44 → 1.0.46

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 CHANGED
@@ -3,6 +3,7 @@ import { SectionList, TextInput, View, Alert, StyleSheet, TouchableOpacity } fro
3
3
  import Text from '../Text';
4
4
  import Highlight from '../Highlight';
5
5
  import Bookmark from '../Bookmark';
6
+ import X from '../X';
6
7
  import getRandomBrightColor from '../utils/getRandomBrightColor';
7
8
  import { MAX_URL_LENGTH } from './Row';
8
9
  let Clipboard;
@@ -14,10 +15,17 @@ try {
14
15
 
15
16
  import Row from './Row';
16
17
 
18
+ const BlacklistIcon = () => (
19
+ <View style={{ borderRadius: 100, backgroundColor: 'black' }}>
20
+ <X size={12} />
21
+ </View>
22
+ );
23
+
17
24
  const isError = (a) => a.response?.status < 200 || a.response?.status >= 400;
18
25
  export default (props) => {
19
26
  const [filter, setFilter] = useState('');
20
27
  const [errorOnly, setErrorOnly] = useState(false);
28
+ const [showBookmarkOnly, setShowBookmarkOnly] = useState(false);
21
29
  const [expands, setExpands] = useState({});
22
30
  const apis = props.apis.filter((a) => !errorOnly || isError(a));
23
31
 
@@ -28,7 +36,7 @@ export default (props) => {
28
36
  <View style={styles.container}>
29
37
  {!!apis.length && !filter && (
30
38
  <TouchableOpacity
31
- style={{ padding: 5, backgroundColor: 'white', borderRadius: 5 }}
39
+ style={styles.actionButton}
32
40
  onPress={() =>
33
41
  Alert.alert('Are you sure', 'You want to clear all logs', [
34
42
  { text: 'Delete', onPress: props.clear, style: 'cancel' },
@@ -55,7 +63,7 @@ export default (props) => {
55
63
  )}
56
64
  {!!props.blacklists.length && !filter && (
57
65
  <TouchableOpacity
58
- style={{ padding: 5, backgroundColor: 'white', borderRadius: 5 }}
66
+ style={styles.actionButton}
59
67
  onPress={() =>
60
68
  Alert.alert('Are you sure', 'You want to clear all blacklists', [
61
69
  { text: 'Clear', onPress: () => props.setBlacklists(), style: 'cancel' },
@@ -63,16 +71,28 @@ export default (props) => {
63
71
  ])
64
72
  }
65
73
  >
66
- <Text style={{ color: 'black', fontSize: 10 }}>Clear {props.blacklists.length} Blacklists</Text>
74
+ <Text style={{ color: 'black', fontSize: 10 }}>Clear {props.blacklists.length}</Text>
75
+ <BlacklistIcon />
67
76
  </TouchableOpacity>
68
77
  )}
69
-
78
+ {!!Object.keys(props.bookmarks).length && (
79
+ <>
80
+ <TouchableOpacity style={styles.actionButton} onPress={() => setShowBookmarkOnly((v) => !v)}>
81
+ <Bookmark size={7} />
82
+ <Text style={{ color: 'black', fontSize: 10 }}>{showBookmarkOnly ? '& others' : 'Only'}</Text>
83
+ </TouchableOpacity>
84
+ <TouchableOpacity style={styles.actionButton} onPress={() => props.setBookmarks({})}>
85
+ <Text style={{ color: 'black', fontSize: 10 }}>Clear {Object.keys(props.bookmarks).length}</Text>
86
+ <Bookmark size={7} />
87
+ </TouchableOpacity>
88
+ </>
89
+ )}
70
90
  <TextInput
71
91
  value={filter}
72
92
  placeholder='Filter...'
73
93
  clearButtonMode='always'
74
94
  placeholderTextColor='grey'
75
- style={{ paddingHorizontal: 5, color: 'white', flex: 1 }}
95
+ style={styles.textInput}
76
96
  onChangeText={(t) => setFilter(t.toLowerCase())}
77
97
  />
78
98
  </View>
@@ -85,6 +105,7 @@ export default (props) => {
85
105
  showsVerticalScrollIndicator
86
106
  sections={apis
87
107
  .filter((a) => !filter || JSON.stringify(a).toLowerCase().includes(filter))
108
+ .filter((a) => !showBookmarkOnly || props.bookmarks[a.id])
88
109
  .map((data) => ({ data: [data], id: data.id }))}
89
110
  renderItem={(i) => (expands[i.item.id] ? <Row {...i} filter={filter} /> : <View style={{ height: 20 }} />)}
90
111
  renderSectionHeader={({ section: { data } }) => {
@@ -164,7 +185,7 @@ export default (props) => {
164
185
  }}
165
186
  style={styles.actionButton}
166
187
  >
167
- <Text style={{ color: 'black', fontSize: 10 }}>Blacklist</Text>
188
+ <BlacklistIcon />
168
189
  </TouchableOpacity>
169
190
  </View>
170
191
  </View>
@@ -178,11 +199,20 @@ export default (props) => {
178
199
  const styles = StyleSheet.create({
179
200
  container: {
180
201
  flexDirection: 'row',
202
+ flexWrap: 'wrap',
181
203
  paddingLeft: 5,
182
204
  alignItems: 'center',
183
205
  gap: 5,
184
206
  },
185
- actionButton: { backgroundColor: 'white', borderRadius: 5, padding: 4 },
207
+ actionButton: {
208
+ backgroundColor: 'white',
209
+ borderRadius: 5,
210
+ padding: 4,
211
+ flexDirection: 'row',
212
+ alignItems: 'center',
213
+ justifyContent: 'center',
214
+ gap: 3,
215
+ },
186
216
  rowHeader: {
187
217
  flexDirection: 'row',
188
218
  gap: 5,
@@ -200,4 +230,5 @@ const styles = StyleSheet.create({
200
230
  elevation: 10,
201
231
  zIndex: 99,
202
232
  },
233
+ textInput: { paddingHorizontal: 5, color: 'white', flex: 1, minWidth: 100 },
203
234
  });
package/Bookmark.jsx CHANGED
@@ -1,26 +1,19 @@
1
1
  import React from 'react';
2
- import { Pressable, StyleSheet, View } from 'react-native';
2
+ import { TouchableOpacity, StyleSheet, View } from 'react-native';
3
3
 
4
- export default ({ size = 10, color = '#222', onPress }) => {
4
+ export default ({ size = 10, color = '#222', ...rest }) => {
5
5
  const tristyle = { borderRightWidth: size / 2, borderTopWidth: size / 2, borderTopColor: color };
6
+ const Component = rest.onPress ? TouchableOpacity : View;
6
7
  return (
7
- <View>
8
- <View style={{ width: size, height: size, backgroundColor: color }} />
9
- <View style={{ flexDirection: 'row' }}>
10
- <View style={[styles.triangleCorner, tristyle]} />
11
- <View style={[styles.triangleCorner, tristyle, { transform: [{ rotate: '90deg' }] }]} />
8
+ <Component {...rest} style={[styles.container, { height: size + size / 2 }]}>
9
+ <View style={{ transform: [{ scale: 0.3 }] }}>
10
+ <View style={{ width: size, height: size, backgroundColor: color }} />
11
+ <View style={{ flexDirection: 'row' }}>
12
+ <View style={[styles.triangleCorner, tristyle]} />
13
+ <View style={[styles.triangleCorner, tristyle, { transform: [{ rotate: '90deg' }] }]} />
14
+ </View>
12
15
  </View>
13
- <Pressable
14
- onPress={onPress}
15
- style={[
16
- {
17
- width: size,
18
- height: size + size / 2,
19
- },
20
- styles.pressable,
21
- ]}
22
- />
23
- </View>
16
+ </Component>
24
17
  );
25
18
  };
26
19
 
@@ -32,8 +25,7 @@ const styles = StyleSheet.create({
32
25
  borderStyle: 'solid',
33
26
  borderRightColor: 'transparent',
34
27
  },
35
- pressable: {
36
- position: 'absolute',
37
- transform: [{ scale: 1.7 }],
28
+ container: {
29
+ transform: [{ scale: 3 }],
38
30
  },
39
31
  });
package/X.jsx CHANGED
@@ -1,11 +1,13 @@
1
1
  import React from 'react';
2
2
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
3
3
 
4
- export default ({ size = 20, color = 'white', onPress }) => {
4
+ const height = 3;
5
+ export default ({ size = 20, color = 'white', ...rest }) => {
5
6
  const panelStyle = { top: size / 2, width: size, backgroundColor: color };
7
+ const Component = rest.onPress ? TouchableOpacity : View;
6
8
  return (
7
- <TouchableOpacity
8
- onPress={onPress}
9
+ <Component
10
+ {...rest}
9
11
  style={{
10
12
  width: size,
11
13
  height: size,
@@ -13,16 +15,17 @@ export default ({ size = 20, color = 'white', onPress }) => {
13
15
  }}
14
16
  >
15
17
  <View style={{ width: size, height: size, transform: [{ scale: 0.5 }] }}>
16
- <View style={[styles.panel, panelStyle, { transform: [{ rotate: '45deg' }] }]} />
17
- <View style={[styles.panel, panelStyle, { transform: [{ rotate: '-45deg' }] }]} />
18
+ <View style={[styles.panel, panelStyle, { transform: [...styles.panel.transform, { rotate: '45deg' }] }]} />
19
+ <View style={[styles.panel, panelStyle, { transform: [...styles.panel.transform, { rotate: '-45deg' }] }]} />
18
20
  </View>
19
- </TouchableOpacity>
21
+ </Component>
20
22
  );
21
23
  };
22
24
 
23
25
  const styles = StyleSheet.create({
24
26
  panel: {
25
- height: 3,
27
+ height,
28
+ transform: [{ translateY: -height / 2 }],
26
29
  position: 'absolute',
27
30
  },
28
31
  });
package/index.jsx CHANGED
@@ -57,7 +57,8 @@ export default ({
57
57
  version = v,
58
58
  maxNumOfApiToStore = 0,
59
59
  labels = [],
60
- interceptResponse
60
+ interceptResponse,
61
+ tabs = [],
61
62
  }) => {
62
63
  const [blacklists, setB] = useState([]);
63
64
 
@@ -116,6 +117,8 @@ export default ({
116
117
  setIsOpen,
117
118
  shouldShowDetails,
118
119
  } = useAnimation(badgeHeight);
120
+
121
+ const CustomTabComponent = tabs.find(t => tab === t.title)?.component;
119
122
  return (
120
123
  <Animated.View
121
124
  style={{
@@ -163,7 +166,7 @@ export default ({
163
166
  <View style={{ flexDirection: "row", padding: 5 }}>
164
167
  <View style={{ flex: 1, flexDirection: "row" }}>
165
168
  {!!variables &&
166
- ["api", "variables"].map((t) => {
169
+ ["api", "variables", ...tabs.map(t => t.title)].map((t) => {
167
170
  const isSelected = t === tab;
168
171
  return (
169
172
  <TouchableOpacity
@@ -200,6 +203,7 @@ export default ({
200
203
  {...restApiInterceptor}
201
204
  />
202
205
  )}
206
+ {!!CustomTabComponent && <CustomTabComponent />}
203
207
  </SafeAreaView>
204
208
  )}
205
209
  </Animated.View>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-in-app-debugger",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
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": {
@@ -21,6 +21,19 @@ export default (maxNumOfApiToStore, blacklists, interceptResponse) => {
21
21
  const [apis, setApis] = useState([]);
22
22
  const [bookmarks, setBookmarks] = useState({});
23
23
 
24
+ useEffect(() => {
25
+ setBookmarks((v) => {
26
+ const oldV = { ...v };
27
+ const bookmarkkeys = Object.keys(oldV);
28
+ for (let i = 0; i < bookmarkkeys.length; i++) {
29
+ if (!apis.some(({ id }) => id === bookmarkkeys[i])) {
30
+ delete oldV[bookmarkkeys[i]];
31
+ }
32
+ }
33
+ return oldV;
34
+ });
35
+ }, [apis]);
36
+
24
37
  const makeRequest = (data) => {
25
38
  if (blacklists.some((b) => b.url === data.url && b.method === data.method)) return;
26
39
  const date = new Date();