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

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
@@ -8,6 +8,7 @@ import {
8
8
  TouchableOpacity,
9
9
  } from "react-native";
10
10
  import Text from "./Text";
11
+ import Highlight from "./Highlight";
11
12
  let Clipboard;
12
13
  try {
13
14
  Clipboard = require("@react-native-clipboard/clipboard")?.default;
@@ -17,7 +18,7 @@ try {
17
18
 
18
19
  const MAX_URL_LENGTH = 100;
19
20
 
20
- const Row = ({ item }) => {
21
+ const Row = ({ item, filter }) => {
21
22
  const tabs = [
22
23
  { value: "Response Body" },
23
24
  { value: "Request Body", hide: !item.request.data },
@@ -53,7 +54,7 @@ const Row = ({ item }) => {
53
54
  <View style={styles.details}>
54
55
  {item.request.url.length > MAX_URL_LENGTH && (
55
56
  <Text style={{ color: "#ffffff99", paddingVertical: 20 }}>
56
- {item.request.url}
57
+ <Highlight text={item.request.url} filter={filter} />
57
58
  </Text>
58
59
  )}
59
60
  <View>
@@ -65,17 +66,26 @@ const Row = ({ item }) => {
65
66
 
66
67
  {tab === tabs[0].value && hasResponse && (
67
68
  <Text style={{ color: "white" }}>
68
- {JSON.stringify(item.response.data, undefined, 4)}
69
+ <Highlight
70
+ text={JSON.stringify(item.response.data, undefined, 4)}
71
+ filter={filter}
72
+ />
69
73
  </Text>
70
74
  )}
71
75
  {tab === tabs[1].value && (
72
76
  <Text style={{ color: "white" }}>
73
- {JSON.stringify(item.request.data, undefined, 4)}
77
+ <Highlight
78
+ text={JSON.stringify(item.request.data, undefined, 4)}
79
+ filter={filter}
80
+ />
74
81
  </Text>
75
82
  )}
76
83
  {tab === tabs[2].value && (
77
84
  <Text style={{ color: "white" }}>
78
- {JSON.stringify(item.request.headers, undefined, 4)}
85
+ <Highlight
86
+ text={JSON.stringify(item.request.headers, undefined, 4)}
87
+ filter={filter}
88
+ />
79
89
  </Text>
80
90
  )}
81
91
  </View>
@@ -175,7 +185,11 @@ export default (props) => {
175
185
  )
176
186
  .map((data) => ({ data: [data], id: data.id }))}
177
187
  renderItem={(i) =>
178
- expands[i.item.id] ? <Row {...i} /> : <View style={{ height: 20 }} />
188
+ expands[i.item.id] ? (
189
+ <Row {...i} filter={filter} />
190
+ ) : (
191
+ <View style={{ height: 20 }} />
192
+ )
179
193
  }
180
194
  renderSectionHeader={({ section: { data } }) => {
181
195
  const item = data[0];
@@ -207,7 +221,10 @@ export default (props) => {
207
221
  (hasResponse ? " - " + duration + " second(s)" : "") +
208
222
  "\n"}
209
223
  </Text>
210
- {item.request.url.slice(0, MAX_URL_LENGTH)}
224
+ <Highlight
225
+ text={item.request.url.slice(0, MAX_URL_LENGTH)}
226
+ filter={filter}
227
+ />
211
228
  {item.request.url.length > MAX_URL_LENGTH && "......."}
212
229
  </Text>
213
230
  <View style={{ gap: 4 }}>
package/Highlight.jsx ADDED
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import Text from './Text';
3
+
4
+ export default ({ text, filter }) => {
5
+ if (!filter || !/^[a-zA-Z0-9./]+$/.test(filter)) return text;
6
+ const indices = [...text.matchAll(new RegExp(filter, 'gi'))].map((a) => a.index);
7
+ if (!indices.length) return text;
8
+ return (
9
+ <>
10
+ {indices.map((i, ii) => {
11
+ const preText = !ii ? text.slice(0, i) : text.slice(indices[ii - 1] + filter.length, i);
12
+ const searchText = text.slice(i, i + filter.length);
13
+ const seqText = !indices[ii + 1] ? text.slice(i + filter.length) : '';
14
+ return (
15
+ <>
16
+ {preText}
17
+ <Text style={{ backgroundColor: 'yellow', color: 'black' }}>{searchText}</Text>
18
+ {seqText}
19
+ </>
20
+ );
21
+ })}
22
+ </>
23
+ );
24
+ };
package/Variables.jsx CHANGED
@@ -1,30 +1,36 @@
1
- import React, { useState } from 'react';
2
- import { FlatList, TextInput } from 'react-native';
1
+ import React, { useState } from "react";
2
+ import { FlatList, TextInput } from "react-native";
3
3
  import Text from "./Text";
4
+ import Highlight from "./Highlight";
4
5
 
5
6
  export default ({ variables }) => {
6
- const [filter, setFilter] = useState('');
7
+ const [filter, setFilter] = useState("");
7
8
 
8
9
  return (
9
10
  <>
10
11
  <TextInput
11
12
  value={filter}
12
- placeholder='Filter...'
13
- placeholderTextColor='grey'
14
- style={{ paddingHorizontal: 5, color: 'white' }}
13
+ placeholder="Filter..."
14
+ placeholderTextColor="grey"
15
+ style={{ paddingHorizontal: 5, color: "white" }}
15
16
  onChangeText={(t) => setFilter(t.toLowerCase())}
16
17
  clearButtonMode="always"
17
18
  />
18
19
  <FlatList
19
20
  contentContainerStyle={{ padding: 5, paddingBottom: 20 }}
20
21
  data={Object.keys(variables).filter(
21
- (k) => !filter || variables[k].toLowerCase().includes(filter) || k.toLowerCase().includes(filter),
22
+ (k) =>
23
+ !filter ||
24
+ variables[k].toLowerCase().includes(filter) ||
25
+ k.toLowerCase().includes(filter)
22
26
  )}
23
27
  showsVerticalScrollIndicator
24
28
  keyExtractor={(i) => i}
25
29
  renderItem={({ item }) => (
26
- <Text selectable style={{ color: 'white', marginVertical: 10 }}>
27
- {item + ' : ' + variables[item]}
30
+ <Text selectable style={{ color: "white", marginVertical: 10 }}>
31
+ <Highlight text={item} filter={filter} />
32
+ {" : "}
33
+ <Highlight text={variables[item]} filter={filter} />
28
34
  </Text>
29
35
  )}
30
36
  />
package/index.jsx CHANGED
@@ -78,6 +78,7 @@ export default ({
78
78
  isOpen,
79
79
  panResponder,
80
80
  setIsOpen,
81
+ shouldShowDetails,
81
82
  } = useAnimation(badgeHeight);
82
83
  return (
83
84
  <Animated.View
@@ -92,7 +93,7 @@ export default ({
92
93
  }}
93
94
  {...(isOpen ? {} : panResponder.panHandlers)}
94
95
  >
95
- {!isOpen ? (
96
+ {!shouldShowDetails ? (
96
97
  <TouchableOpacity
97
98
  onPress={() => setIsOpen(true)}
98
99
  style={styles.box}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-in-app-debugger",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
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": {
package/useAnimation.ts CHANGED
@@ -14,6 +14,7 @@ export default (defaultBadgeHeight) => {
14
14
  const badgeWidth = useRef(new Animated.Value(defaultBadgeWidth)).current;
15
15
  const { width, height } = useWindowDimensions();
16
16
  const [isOpen, setIsOpen] = useState(false);
17
+ const [shouldShowDetails, setShouldShowDetails] = useState(false);
17
18
 
18
19
  useEffect(() => {
19
20
  const showSubscription = Keyboard.addListener('keyboardDidShow', () => {
@@ -29,7 +30,6 @@ export default (defaultBadgeHeight) => {
29
30
  };
30
31
  }, [isOpen]);
31
32
 
32
-
33
33
  const panResponder = useRef(
34
34
  PanResponder.create({
35
35
  onStartShouldSetPanResponder: () => false,
@@ -57,6 +57,7 @@ export default (defaultBadgeHeight) => {
57
57
  }, [defaultBadgeHeight]);
58
58
 
59
59
  useEffect(() => {
60
+ setTimeout(() => setShouldShowDetails(isOpen), isOpen ? 200 : 0);
60
61
  Animated.spring(position, { toValue: isOpen ? { x: 0, y: 0 } : cachePosition.current, ...und }).start();
61
62
  Animated.spring(borderRadius, { toValue: isOpen ? 0 : defaultBorderRadius, ...und }).start();
62
63
  Animated.spring(badgeHeight, { toValue: isOpen ? height : defaultBadgeHeight, ...und }).start();
@@ -72,5 +73,6 @@ export default (defaultBadgeHeight) => {
72
73
  isOpen,
73
74
  setIsOpen,
74
75
  borderRadius,
76
+ shouldShowDetails,
75
77
  };
76
78
  };