react-native-inapp-inspector 2.2.4 → 2.2.5

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.
@@ -8,78 +8,19 @@ import {
8
8
  Animated,
9
9
  Platform,
10
10
  } from 'react-native';
11
- import Svg, {Path} from 'react-native-svg';
12
11
  import {BrandSquareIcon} from '../BrandSquareIcon';
12
+ import {
13
+ SettingsIcon,
14
+ ShieldCheckIcon,
15
+ CheckIcon,
16
+ ClearIcon,
17
+ } from '../NetworkIcons';
13
18
  import {
14
19
  getTelemetryConsentStatus,
15
20
  setTelemetryConsent,
16
21
  sendSessionTelemetryPing,
17
22
  } from '../../helpers/telemetry';
18
23
 
19
- // ─── Inline Crisp SVG Icons ───────────────────────────────────────────────────
20
-
21
- const ShieldCheckSvg = ({size = 15, color = '#7C3AED'}: {size?: number; color?: string}) => (
22
- <Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
23
- <Path
24
- d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"
25
- stroke={color}
26
- strokeWidth="2"
27
- strokeLinecap="round"
28
- strokeLinejoin="round"
29
- />
30
- <Path
31
- d="M9 12l2 2 4-4"
32
- stroke={color}
33
- strokeWidth="2"
34
- strokeLinecap="round"
35
- strokeLinejoin="round"
36
- />
37
- </Svg>
38
- );
39
-
40
- const CheckSvg = ({size = 14, color = '#FFFFFF'}: {size?: number; color?: string}) => (
41
- <Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
42
- <Path
43
- d="M20 6L9 17l-5-5"
44
- stroke={color}
45
- strokeWidth="2.4"
46
- strokeLinecap="round"
47
- strokeLinejoin="round"
48
- />
49
- </Svg>
50
- );
51
-
52
- const CloseSvg = ({size = 13, color = '#64748B'}: {size?: number; color?: string}) => (
53
- <Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
54
- <Path
55
- d="M18 6L6 18M6 6l12 12"
56
- stroke={color}
57
- strokeWidth="2.2"
58
- strokeLinecap="round"
59
- strokeLinejoin="round"
60
- />
61
- </Svg>
62
- );
63
-
64
- const GearSvg = ({size = 13, color = '#6366F1'}: {size?: number; color?: string}) => (
65
- <Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
66
- <Path
67
- d="M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"
68
- stroke={color}
69
- strokeWidth="2"
70
- strokeLinecap="round"
71
- strokeLinejoin="round"
72
- />
73
- <Path
74
- d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1Z"
75
- stroke={color}
76
- strokeWidth="2"
77
- strokeLinecap="round"
78
- strokeLinejoin="round"
79
- />
80
- </Svg>
81
- );
82
-
83
24
  export const TelemetryConsentModal = () => {
84
25
  const [visible, setVisible] = useState(false);
85
26
  const fadeAnim = useState(new Animated.Value(0))[0];
@@ -155,7 +96,7 @@ export const TelemetryConsentModal = () => {
155
96
  onPress={() => handleDecision(false)}
156
97
  hitSlop={10}
157
98
  activeOpacity={0.7}>
158
- <CloseSvg size={13} color="#64748B" />
99
+ <ClearIcon size={12} color="#64748B" />
159
100
  </TouchableOpacity>
160
101
 
161
102
  {/* Centered Enlarged Square Brand Icon Header */}
@@ -169,7 +110,7 @@ export const TelemetryConsentModal = () => {
169
110
 
170
111
  {/* Subheading instruction hint badge */}
171
112
  <View style={styles.hintBadge}>
172
- <GearSvg size={12} color="#6366F1" />
113
+ <SettingsIcon size={12} color="#6366F1" />
173
114
  <Text style={styles.hintBadgeText}>
174
115
  You can enable or disable this anytime in Settings
175
116
  </Text>
@@ -186,7 +127,7 @@ export const TelemetryConsentModal = () => {
186
127
  {/* Privacy Callout Box */}
187
128
  <View style={styles.privacyBadge}>
188
129
  <View style={styles.privacyShieldWrapper}>
189
- <ShieldCheckSvg size={15} color="#7C3AED" />
130
+ <ShieldCheckIcon size={15} color="#7C3AED" />
190
131
  </View>
191
132
  <Text style={styles.privacyText}>
192
133
  <Text style={styles.privacyHighlight}>Privacy Guaranteed:</Text> We
@@ -201,7 +142,7 @@ export const TelemetryConsentModal = () => {
201
142
  style={styles.declineButton}
202
143
  onPress={() => handleDecision(false)}
203
144
  activeOpacity={0.7}>
204
- <CloseSvg size={12} color="#64748B" />
145
+ <ClearIcon size={12} color="#64748B" />
205
146
  <Text style={styles.declineText}>Not Now</Text>
206
147
  </TouchableOpacity>
207
148
 
@@ -209,7 +150,7 @@ export const TelemetryConsentModal = () => {
209
150
  style={styles.allowButton}
210
151
  onPress={() => handleDecision(true)}
211
152
  activeOpacity={0.85}>
212
- <CheckSvg size={13} color="#FFFFFF" />
153
+ <CheckIcon size={13} color="#FFFFFF" />
213
154
  <Text style={styles.allowText}>Allow & Share</Text>
214
155
  </TouchableOpacity>
215
156
  </View>
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED FILE — do not edit by hand.
2
2
  // Regenerated from package.json on every build by scripts/gen-version.js.
3
- export const LIB_VERSION = '2.2.4';
3
+ export const LIB_VERSION = '2.2.5';
@@ -1,4 +1,9 @@
1
- import {NativeModules, NativeEventEmitter, Platform} from 'react-native';
1
+ import {
2
+ NativeModules,
3
+ NativeEventEmitter,
4
+ DeviceEventEmitter,
5
+ Platform,
6
+ } from 'react-native';
2
7
  import NativeNetworkInspector from './NativeNetworkInspector';
3
8
 
4
9
  export interface NativeDeviceMetrics {
@@ -44,12 +49,16 @@ export const isNativeModuleAvailable = (): boolean => {
44
49
  return !!NativeModule;
45
50
  };
46
51
 
47
- const eventTarget: any =
48
- NativeModules.NetworkInspectorModule || NativeNetworkInspector;
52
+ const getNativeEmitter = () => {
53
+ try {
54
+ if (NativeModules && NativeModules.NetworkInspectorModule) {
55
+ return new NativeEventEmitter(NativeModules.NetworkInspectorModule);
56
+ }
57
+ } catch (e) {}
58
+ return null;
59
+ };
49
60
 
50
- const nativeEmitter = eventTarget
51
- ? new NativeEventEmitter(eventTarget)
52
- : null;
61
+ const nativeEmitter = getNativeEmitter();
53
62
 
54
63
  /**
55
64
  * Retrieves low-level native hardware and system metrics (RAM, Heap, Disk, Battery, CPU).
@@ -93,17 +102,27 @@ export const enableNativeCrashProtection = async (options?: {
93
102
  export const subscribeNativeCrashes = (
94
103
  callback: (event: NativeCrashEvent) => void,
95
104
  ): (() => void) => {
96
- if (!nativeEmitter) {
97
- return () => {};
98
- }
105
+ const cleanups: Array<() => void> = [];
106
+
99
107
  try {
100
- const subscription = nativeEmitter.addListener('onNativeCrash', callback);
101
- return () => {
102
- subscription.remove();
103
- };
104
- } catch (e) {
105
- return () => {};
108
+ const sub1 = DeviceEventEmitter.addListener('onNativeCrash', callback);
109
+ cleanups.push(() => sub1.remove());
110
+ } catch (e) {}
111
+
112
+ if (nativeEmitter) {
113
+ try {
114
+ const sub2 = nativeEmitter.addListener('onNativeCrash', callback);
115
+ cleanups.push(() => sub2.remove());
116
+ } catch (e) {}
106
117
  }
118
+
119
+ return () => {
120
+ cleanups.forEach(fn => {
121
+ try {
122
+ fn();
123
+ } catch (e) {}
124
+ });
125
+ };
107
126
  };
108
127
 
109
128
  export interface FloatingButtonOptions {
@@ -168,20 +187,33 @@ export const setNativeFloatingButtonBadge = async (
168
187
  export const subscribeNativeFloatingButtonPress = (
169
188
  callback: () => void,
170
189
  ): (() => void) => {
171
- if (!nativeEmitter) {
172
- return () => {};
173
- }
190
+ const cleanups: Array<() => void> = [];
191
+
174
192
  try {
175
- const subscription = nativeEmitter.addListener(
193
+ const sub1 = DeviceEventEmitter.addListener(
176
194
  'onFloatingButtonPress',
177
195
  callback,
178
196
  );
179
- return () => {
180
- subscription.remove();
181
- };
182
- } catch (e) {
183
- return () => {};
197
+ cleanups.push(() => sub1.remove());
198
+ } catch (e) {}
199
+
200
+ if (nativeEmitter) {
201
+ try {
202
+ const sub2 = nativeEmitter.addListener(
203
+ 'onFloatingButtonPress',
204
+ callback,
205
+ );
206
+ cleanups.push(() => sub2.remove());
207
+ } catch (e) {}
184
208
  }
209
+
210
+ return () => {
211
+ cleanups.forEach(fn => {
212
+ try {
213
+ fn();
214
+ } catch (e) {}
215
+ });
216
+ };
185
217
  };
186
218
 
187
219
  /**