react-native-in-app-debugger 2.0.7 → 2.0.8

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.
@@ -1,20 +1,26 @@
1
- import { useEffect, useState } from 'react';
2
- import { Alert, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
3
- import Text from '../Text';
4
- import X from '../X';
1
+ import { useEffect, useState } from "react";
2
+ import {
3
+ Alert,
4
+ StyleSheet,
5
+ TextInput,
6
+ TouchableOpacity,
7
+ View,
8
+ } from "react-native";
9
+ import Text from "../Text";
10
+ import X from "../X";
5
11
 
6
- const removeId = (key, value) => (key === 'id' ? undefined : value);
12
+ const removeId = (key, value) => (key === "id" ? undefined : value);
7
13
  export default (p) => {
8
- const [tab, setTab] = useState('response');
9
- const [tmpResBody, setTmpResBody] = useState('');
10
- const [tmpResStatus, setTmpResStatus] = useState('');
14
+ const [tab, setTab] = useState("response");
15
+ const [tmpResBody, setTmpResBody] = useState("");
16
+ const [tmpResStatus, setTmpResStatus] = useState("");
11
17
  const [tmpMockDetails, setTmpMockDetails] = useState({});
12
18
 
13
19
  const save = (cb) => {
14
- if (tab === 'response') {
20
+ if (tab === "response") {
15
21
  try {
16
22
  if (!tmpResStatus) {
17
- return Alert.alert('Sorry', 'Status code is required');
23
+ return Alert.alert("Sorry", "Status code is required");
18
24
  }
19
25
  const tmp = JSON.parse(tmpMockDetails);
20
26
  tmp.response.data = JSON.parse(tmpResBody);
@@ -46,25 +52,25 @@ export default (p) => {
46
52
  // })
47
53
  cb?.();
48
54
  } catch (e) {
49
- return Alert.alert('Sorry', 'Please fix the response body JSON');
55
+ return Alert.alert("Sorry", "Please fix the response body JSON");
50
56
  }
51
- } else if (tab === 'json') {
57
+ } else if (tab === "json") {
52
58
  cb?.();
53
- } else if (tab === 'request') {
59
+ } else if (tab === "request") {
54
60
  cb?.();
55
61
  }
56
62
  };
57
- const hasResponse = !!p.mockDetails?.response
63
+ const hasResponse = !!p.mockDetails?.response;
58
64
 
59
65
  const reset = () => {
60
66
  if (!p.mockDetails) return;
61
67
  setTmpMockDetails(JSON.stringify(p.mockDetails, removeId, 4));
62
68
  if (hasResponse) {
63
69
  setTmpResBody(JSON.stringify(p.mockDetails.response.data, removeId, 4));
64
- setTmpResStatus(p.mockDetails.response.status + '' || '');
70
+ setTmpResStatus(p.mockDetails.response.status + "" || "");
65
71
  } else {
66
- setTmpResBody('');
67
- setTmpResStatus('');
72
+ setTmpResBody("");
73
+ setTmpResStatus("");
68
74
  }
69
75
  };
70
76
  useEffect(reset, [p.mockDetails]);
@@ -91,9 +97,11 @@ export default (p) => {
91
97
  // }, [p.mockDetails, tmpMockDetails]);
92
98
  if (!p.mockDetails) return null;
93
99
  // const canReset = JSON.stringify(p.mockDetails, removeId)?.replace(/\s+/g, '') !== tmpMockDetails?.replace?.(/\s+/g, '');
94
- const canReset = !hasResponse ||
100
+ const canReset =
101
+ !hasResponse ||
95
102
  tmpResStatus != p.mockDetails.response.status ||
96
- JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, '') !== tmpResBody?.replace?.(/\s+/g, '');
103
+ JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, "") !==
104
+ tmpResBody?.replace?.(/\s+/g, "");
97
105
  const isnew = !p.mocks.some((m) => m.id === p.mockDetails.id);
98
106
 
99
107
  // console.log('xxxxx response', JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, ''));
@@ -106,17 +114,19 @@ export default (p) => {
106
114
  bottom: 0,
107
115
  left: 0,
108
116
  right: 0,
109
- position: 'absolute',
117
+ position: "absolute",
110
118
  zIndex: 1000,
111
- backgroundColor: 'grey',
112
- width: '100%',
113
- height: '100%',
119
+ backgroundColor: "grey",
120
+ width: "100%",
121
+ height: "100%",
114
122
  paddingTop: 50,
115
123
  }}
116
124
  >
117
125
  {!isnew && <Text style={{ opacity: 0.3 }}>{p.mockDetails.id}</Text>}
118
- <View style={{ flexDirection: 'row' }}>
119
- <Text style={{ flex: 1 }}>{`(${p.mockDetails.request.method}) ${p.mockDetails.request.url}`}</Text>
126
+ <View style={{ flexDirection: "row" }}>
127
+ <Text
128
+ style={{ flex: 1 }}
129
+ >{`(${p.mockDetails.request.method}) ${p.mockDetails.request.url}`}</Text>
120
130
  <TouchableOpacity onPress={() => p.setMockDetails(null)}>
121
131
  <X size={25} />
122
132
  </TouchableOpacity>
@@ -124,34 +134,46 @@ export default (p) => {
124
134
  <View
125
135
  style={{
126
136
  marginVertical: 10,
127
- flexDirection: 'row',
128
- justifyContent: 'space-around',
129
- backgroundColor: 'black',
137
+ flexDirection: "row",
138
+ justifyContent: "space-around",
139
+ backgroundColor: "black",
130
140
  borderRadius: 5,
131
141
  padding: 5,
132
142
  }}
133
143
  >
134
- {['request', 'response', 'json'].map((item) => {
144
+ {["request", "response", "json"].map((item) => {
135
145
  const isSelected = item === tab;
136
146
  return (
137
147
  <TouchableOpacity
138
- style={{ backgroundColor: isSelected ? 'white' : 'black', padding: 3, borderRadius: 5 }}
148
+ style={{
149
+ backgroundColor: isSelected ? "white" : "black",
150
+ padding: 3,
151
+ borderRadius: 5,
152
+ }}
139
153
  onPress={() => {
140
- save(() => setTab(item));
154
+ // save(() => setTab(item));
155
+ setTab(item);
141
156
  }}
142
157
  >
143
- <Text style={{ textTransform: 'uppercase', color: isSelected ? 'black' : 'white' }}>{item}</Text>
158
+ <Text
159
+ style={{
160
+ textTransform: "uppercase",
161
+ color: isSelected ? "black" : "white",
162
+ }}
163
+ >
164
+ {item}
165
+ </Text>
144
166
  </TouchableOpacity>
145
167
  );
146
168
  })}
147
169
  </View>
148
- {tab === 'response' && (
170
+ {tab === "response" && (
149
171
  <View style={{ gap: 3 }}>
150
- <View style={{ flexDirection: 'row', gap: 5 }}>
172
+ <View style={{ flexDirection: "row", gap: 5 }}>
151
173
  <Text>Status</Text>
152
174
  <TextInput
153
- style={{ backgroundColor: '#ccc', width: 50, padding: 2 }}
154
- inputMode='numeric'
175
+ style={{ backgroundColor: "#ccc", width: 50, padding: 2 }}
176
+ inputMode="numeric"
155
177
  onChangeText={(t) => {
156
178
  setTmpResStatus(t);
157
179
  // try {
@@ -166,10 +188,15 @@ export default (p) => {
166
188
  />
167
189
  </View>
168
190
 
169
- <View style={{ flexDirection: 'row', gap: 5 }}>
191
+ <View style={{ flexDirection: "row", gap: 5 }}>
170
192
  <Text>Body</Text>
171
193
  <TextInput
172
- style={{ backgroundColor: '#ccc', height: 250, flex: 1, padding: 2 }}
194
+ style={{
195
+ backgroundColor: "#ccc",
196
+ height: 250,
197
+ flex: 1,
198
+ padding: 2,
199
+ }}
173
200
  multiline
174
201
  onChangeText={setTmpResBody}
175
202
  value={tmpResBody}
@@ -177,12 +204,22 @@ export default (p) => {
177
204
  </View>
178
205
  </View>
179
206
  )}
180
- {tab !== 'response' && <Text style={{ marginTop: 30, textAlign: 'center' }}>To be developed later</Text>}
207
+ {tab !== "response" && (
208
+ <Text style={{ marginTop: 30, textAlign: "center" }}>
209
+ To be developed later
210
+ </Text>
211
+ )}
181
212
  {/* {tab === 'json' && (
182
213
  <TextInput onChangeText={setTmpMockDetails} value={tmpMockDetails} style={{ height: '40%' }} multiline />
183
214
  )} */}
184
- {tab === 'response' && (
185
- <View style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 10 }}>
215
+ {tab === "response" && (
216
+ <View
217
+ style={{
218
+ flexDirection: "row",
219
+ justifyContent: "space-between",
220
+ padding: 10,
221
+ }}
222
+ >
186
223
  {!isnew && (
187
224
  <TouchableOpacity
188
225
  style={styles.actionButton}
@@ -233,10 +270,10 @@ export default (p) => {
233
270
 
234
271
  const styles = StyleSheet.create({
235
272
  actionButton: {
236
- backgroundColor: 'white',
273
+ backgroundColor: "white",
237
274
  borderRadius: 5,
238
275
  padding: 4,
239
- alignItems: 'center',
240
- justifyContent: 'center',
276
+ alignItems: "center",
277
+ justifyContent: "center",
241
278
  },
242
279
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-in-app-debugger",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
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": {