react-native-inapp-inspector 1.1.35 → 2.0.0

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.
Files changed (82) hide show
  1. package/README.md +123 -101
  2. package/android/build.gradle +13 -1
  3. package/android/src/main/java/com/inappinspector/NetworkInspectorModule.kt +904 -0
  4. package/android/src/main/java/com/inappinspector/NetworkInspectorPackage.kt +17 -0
  5. package/dist/commonjs/components/CopyButton.js +3 -0
  6. package/dist/commonjs/components/ErrorBoundary.js +3 -0
  7. package/dist/commonjs/components/Inspector/AnalyticsTab.js +7 -3
  8. package/dist/commonjs/components/Inspector/BundleTab.js +1 -1
  9. package/dist/commonjs/components/Inspector/ConsoleTab.js +1 -1
  10. package/dist/commonjs/components/Inspector/CrashTab.js +97 -90
  11. package/dist/commonjs/components/Inspector/InspectorHeader.js +12 -8
  12. package/dist/commonjs/components/Inspector/MainScreen.js +14 -101
  13. package/dist/commonjs/components/Inspector/NetworkTab.js +47 -10
  14. package/dist/commonjs/components/Inspector/PerformanceTab.js +96 -3
  15. package/dist/commonjs/components/Inspector/ReduxTab.js +18 -10
  16. package/dist/commonjs/components/Inspector/SettingsPanel.js +342 -88
  17. package/dist/commonjs/components/Inspector/TabBar.js +6 -3
  18. package/dist/commonjs/components/NetworkIcons.d.ts +1 -0
  19. package/dist/commonjs/components/NetworkIcons.js +6 -1
  20. package/dist/commonjs/components/TouchableScale.d.ts +1 -0
  21. package/dist/commonjs/components/TouchableScale.js +30 -32
  22. package/dist/commonjs/constants/index.d.ts +1 -2
  23. package/dist/commonjs/constants/index.js +4 -0
  24. package/dist/commonjs/constants/version.d.ts +1 -1
  25. package/dist/commonjs/constants/version.js +1 -1
  26. package/dist/commonjs/customHooks/analyticsLogger.d.ts +4 -0
  27. package/dist/commonjs/customHooks/analyticsLogger.js +7 -5
  28. package/dist/commonjs/customHooks/crashHandler.js +7 -0
  29. package/dist/commonjs/helpers/index.js +10 -1
  30. package/dist/commonjs/helpers/settingsStore.d.ts +9 -0
  31. package/dist/commonjs/helpers/settingsStore.js +59 -3
  32. package/dist/commonjs/index.d.ts +1 -0
  33. package/dist/commonjs/index.js +229 -39
  34. package/dist/commonjs/native/NativeInspector.d.ts +125 -0
  35. package/dist/commonjs/native/NativeInspector.js +313 -0
  36. package/dist/commonjs/native/NativeNetworkInspector.d.ts +22 -0
  37. package/dist/commonjs/native/NativeNetworkInspector.js +4 -0
  38. package/dist/commonjs/styles/index.js +6 -6
  39. package/dist/commonjs/types/enums.d.ts +1 -1
  40. package/dist/commonjs/types/interfaces.d.ts +9 -0
  41. package/dist/esm/components/CopyButton.js +3 -0
  42. package/dist/esm/components/ErrorBoundary.js +3 -0
  43. package/dist/esm/components/Inspector/AnalyticsTab.js +7 -3
  44. package/dist/esm/components/Inspector/BundleTab.js +1 -1
  45. package/dist/esm/components/Inspector/ConsoleTab.js +1 -1
  46. package/dist/esm/components/Inspector/CrashTab.js +97 -90
  47. package/dist/esm/components/Inspector/InspectorHeader.js +13 -9
  48. package/dist/esm/components/Inspector/MainScreen.js +15 -69
  49. package/dist/esm/components/Inspector/NetworkTab.js +47 -10
  50. package/dist/esm/components/Inspector/PerformanceTab.js +96 -3
  51. package/dist/esm/components/Inspector/ReduxTab.js +18 -10
  52. package/dist/esm/components/Inspector/SettingsPanel.js +344 -90
  53. package/dist/esm/components/Inspector/TabBar.js +7 -4
  54. package/dist/esm/components/NetworkIcons.d.ts +1 -0
  55. package/dist/esm/components/NetworkIcons.js +4 -0
  56. package/dist/esm/components/TouchableScale.d.ts +1 -0
  57. package/dist/esm/components/TouchableScale.js +31 -33
  58. package/dist/esm/constants/index.d.ts +1 -2
  59. package/dist/esm/constants/index.js +4 -0
  60. package/dist/esm/constants/version.d.ts +1 -1
  61. package/dist/esm/constants/version.js +1 -1
  62. package/dist/esm/customHooks/analyticsLogger.d.ts +4 -0
  63. package/dist/esm/customHooks/analyticsLogger.js +5 -4
  64. package/dist/esm/customHooks/crashHandler.js +7 -0
  65. package/dist/esm/helpers/index.js +10 -1
  66. package/dist/esm/helpers/settingsStore.d.ts +9 -0
  67. package/dist/esm/helpers/settingsStore.js +58 -3
  68. package/dist/esm/index.d.ts +1 -0
  69. package/dist/esm/index.js +215 -39
  70. package/dist/esm/native/NativeInspector.d.ts +125 -0
  71. package/dist/esm/native/NativeInspector.js +289 -0
  72. package/dist/esm/native/NativeNetworkInspector.d.ts +22 -0
  73. package/dist/esm/native/NativeNetworkInspector.js +2 -0
  74. package/dist/esm/styles/index.js +6 -6
  75. package/dist/esm/types/enums.d.ts +1 -1
  76. package/dist/esm/types/interfaces.d.ts +9 -0
  77. package/ios/NetworkInspectorModule.h +6 -0
  78. package/ios/NetworkInspectorModule.m +720 -5
  79. package/package.json +13 -2
  80. package/react-native-inapp-inspector.podspec +7 -2
  81. package/android/src/main/java/com/inappinspector/NetworkInspectorModule.java +0 -97
  82. package/android/src/main/java/com/inappinspector/NetworkInspectorPackage.java +0 -28
@@ -0,0 +1,289 @@
1
+ import { NativeModules, NativeEventEmitter } from 'react-native';
2
+ import NativeNetworkInspector from './NativeNetworkInspector';
3
+ // Seamless TurboModule (New Architecture / JSI) & Legacy NativeModules Bridge resolution
4
+ const NativeModule = NativeNetworkInspector || NativeModules.NetworkInspectorModule;
5
+ export const isNativeModuleAvailable = () => {
6
+ return !!NativeModule;
7
+ };
8
+ const nativeEmitter = isNativeModuleAvailable()
9
+ ? new NativeEventEmitter(NativeModule)
10
+ : null;
11
+ /**
12
+ * Retrieves low-level native hardware and system metrics (RAM, Heap, Disk, Battery, CPU).
13
+ */
14
+ export const getNativeDeviceMetrics = async () => {
15
+ if (!NativeModule || !NativeModule.getDeviceMetrics) {
16
+ return null;
17
+ }
18
+ try {
19
+ const metrics = await NativeModule.getDeviceMetrics();
20
+ return metrics;
21
+ }
22
+ catch (error) {
23
+ return null;
24
+ }
25
+ };
26
+ /**
27
+ * Enables native signal and uncaught exception protection in the iOS / Android runtime.
28
+ * Automatically ensures the native floating icon is shown and available before UI renders.
29
+ */
30
+ export const enableNativeCrashProtection = async (options) => {
31
+ if (!NativeModule || !NativeModule.enableNativeCrashProtection) {
32
+ return false;
33
+ }
34
+ try {
35
+ const result = await NativeModule.enableNativeCrashProtection();
36
+ if (options?.showFloatingButton !== false) {
37
+ await showNativeFloatingButton();
38
+ }
39
+ return !!result;
40
+ }
41
+ catch (error) {
42
+ return false;
43
+ }
44
+ };
45
+ /**
46
+ * Subscribes to fatal native crash events caught by the iOS / Kotlin exception handlers.
47
+ */
48
+ export const subscribeNativeCrashes = (callback) => {
49
+ if (!nativeEmitter) {
50
+ return () => { };
51
+ }
52
+ try {
53
+ const subscription = nativeEmitter.addListener('onNativeCrash', callback);
54
+ return () => {
55
+ subscription.remove();
56
+ };
57
+ }
58
+ catch (e) {
59
+ return () => { };
60
+ }
61
+ };
62
+ /**
63
+ * Displays the 100% native main-thread floating overlay button.
64
+ * Dragging & touches run on the native UI thread, completely isolated from JS thread stalls.
65
+ */
66
+ export const showNativeFloatingButton = async (options) => {
67
+ if (!NativeModule || !NativeModule.showFloatingButton) {
68
+ return false;
69
+ }
70
+ try {
71
+ const result = await NativeModule.showFloatingButton(options || {});
72
+ return !!result;
73
+ }
74
+ catch (error) {
75
+ return false;
76
+ }
77
+ };
78
+ /**
79
+ * Hides the native floating overlay button.
80
+ */
81
+ export const hideNativeFloatingButton = async () => {
82
+ if (!NativeModule || !NativeModule.hideFloatingButton) {
83
+ return false;
84
+ }
85
+ try {
86
+ const result = await NativeModule.hideFloatingButton();
87
+ return !!result;
88
+ }
89
+ catch (error) {
90
+ return false;
91
+ }
92
+ };
93
+ /**
94
+ * Updates the badge/status dot on the native floating overlay button.
95
+ */
96
+ export const setNativeFloatingButtonBadge = async (hasBadge) => {
97
+ if (!NativeModule || !NativeModule.setFloatingButtonBadge) {
98
+ return false;
99
+ }
100
+ try {
101
+ const result = await NativeModule.setFloatingButtonBadge(hasBadge);
102
+ return !!result;
103
+ }
104
+ catch (error) {
105
+ return false;
106
+ }
107
+ };
108
+ /**
109
+ * Subscribes to tap events on the native floating button.
110
+ */
111
+ export const subscribeNativeFloatingButtonPress = (callback) => {
112
+ if (!nativeEmitter) {
113
+ return () => { };
114
+ }
115
+ try {
116
+ const subscription = nativeEmitter.addListener('onFloatingButtonPress', callback);
117
+ return () => {
118
+ subscription.remove();
119
+ };
120
+ }
121
+ catch (e) {
122
+ return () => { };
123
+ }
124
+ };
125
+ /**
126
+ * Starts hardware-accurate native UI thread FPS tracking (CADisplayLink / Choreographer).
127
+ */
128
+ export const startNativeFpsMonitoring = async () => {
129
+ if (!NativeModule || !NativeModule.startFpsMonitoring) {
130
+ return false;
131
+ }
132
+ try {
133
+ const result = await NativeModule.startFpsMonitoring();
134
+ return !!result;
135
+ }
136
+ catch {
137
+ return false;
138
+ }
139
+ };
140
+ /**
141
+ * Stops native FPS tracking.
142
+ */
143
+ export const stopNativeFpsMonitoring = async () => {
144
+ if (!NativeModule || !NativeModule.stopFpsMonitoring) {
145
+ return false;
146
+ }
147
+ try {
148
+ const result = await NativeModule.stopFpsMonitoring();
149
+ return !!result;
150
+ }
151
+ catch {
152
+ return false;
153
+ }
154
+ };
155
+ /**
156
+ * Reads the latest live hardware FPS from CADisplayLink (iOS) or Choreographer (Android).
157
+ */
158
+ export const getNativeFpsMetrics = async () => {
159
+ if (!NativeModule || !NativeModule.getFpsMetrics) {
160
+ return { fps: 60, targetFps: 60 };
161
+ }
162
+ try {
163
+ const metrics = await NativeModule.getFpsMetrics();
164
+ return {
165
+ fps: typeof metrics?.fps === 'number' ? metrics.fps : 60,
166
+ targetFps: typeof metrics?.targetFps === 'number' ? metrics.targetFps : 60,
167
+ };
168
+ }
169
+ catch {
170
+ return { fps: 60, targetFps: 60 };
171
+ }
172
+ };
173
+ /**
174
+ * Subscribes to physical hardware shake events (or Cmd+Ctrl+Z on iOS simulator).
175
+ */
176
+ export const subscribeNativeDeviceShake = (callback) => {
177
+ if (!nativeEmitter) {
178
+ return () => { };
179
+ }
180
+ try {
181
+ const subscription = nativeEmitter.addListener('onDeviceShake', callback);
182
+ return () => {
183
+ subscription.remove();
184
+ };
185
+ }
186
+ catch {
187
+ return () => { };
188
+ }
189
+ };
190
+ /**
191
+ * Reads a persisted value synchronously from native NSUserDefaults / SharedPreferences.
192
+ */
193
+ export const getNativeStorageItem = async (key) => {
194
+ if (!NativeModule || !NativeModule.getNativeStorageItem) {
195
+ return null;
196
+ }
197
+ try {
198
+ const val = await NativeModule.getNativeStorageItem(key);
199
+ return typeof val === 'string' ? val : null;
200
+ }
201
+ catch {
202
+ return null;
203
+ }
204
+ };
205
+ /**
206
+ * Persists a key-value pair to native NSUserDefaults / SharedPreferences with 0ms latency.
207
+ */
208
+ export const setNativeStorageItem = async (key, value) => {
209
+ if (!NativeModule || !NativeModule.setNativeStorageItem) {
210
+ return false;
211
+ }
212
+ try {
213
+ const result = await NativeModule.setNativeStorageItem(key, value);
214
+ return !!result;
215
+ }
216
+ catch {
217
+ return false;
218
+ }
219
+ };
220
+ /**
221
+ * Triggers hardware native haptic feedback (iOS UIFeedbackGenerator / Android VibrationEffect).
222
+ */
223
+ export const triggerNativeHaptic = async (style = 'light') => {
224
+ if (!NativeModule || !NativeModule.triggerHaptic) {
225
+ return false;
226
+ }
227
+ try {
228
+ const result = await NativeModule.triggerHaptic(style);
229
+ return !!result;
230
+ }
231
+ catch {
232
+ return false;
233
+ }
234
+ };
235
+ /**
236
+ * Retrieves live system thermal state and RAM telemetry directly from native layer.
237
+ */
238
+ export const getNativeSystemMetrics = async () => {
239
+ if (!NativeModule || !NativeModule.getNativeSystemMetrics) {
240
+ return null;
241
+ }
242
+ try {
243
+ const metrics = await NativeModule.getNativeSystemMetrics();
244
+ return metrics;
245
+ }
246
+ catch {
247
+ return null;
248
+ }
249
+ };
250
+ /**
251
+ * Pushes a log payload to native background worker queues for instant native page caching.
252
+ */
253
+ export const pushNativeLogRecord = async (pageKey, jsonPayload) => {
254
+ if (!NativeModule || !NativeModule.pushNativeLogRecord) {
255
+ return false;
256
+ }
257
+ try {
258
+ const result = await NativeModule.pushNativeLogRecord(pageKey, jsonPayload);
259
+ return !!result;
260
+ }
261
+ catch {
262
+ return false;
263
+ }
264
+ };
265
+ /**
266
+ * Fetches pre-indexed, pre-sliced page data directly from native background memory queues.
267
+ * Delivers instantaneous 0ms page loading without blocking JS render thread.
268
+ */
269
+ export const fetchNativeCachedPage = async (pageKey, offset = 0, limit = 50, query = '') => {
270
+ if (!NativeModule || !NativeModule.getNativeCachedPage) {
271
+ return null;
272
+ }
273
+ try {
274
+ const rawJson = await NativeModule.getNativeCachedPage(pageKey, offset, limit, query);
275
+ if (!rawJson)
276
+ return null;
277
+ const parsed = JSON.parse(rawJson);
278
+ const parsedItems = (parsed.items || []).map((item) => typeof item === 'string' ? JSON.parse(item) : item);
279
+ return {
280
+ pageKey: parsed.pageKey || pageKey,
281
+ total: parsed.total || 0,
282
+ offset: parsed.offset || offset,
283
+ items: parsedItems,
284
+ };
285
+ }
286
+ catch {
287
+ return null;
288
+ }
289
+ };
@@ -0,0 +1,22 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ enableNativeCrashProtection(): Promise<boolean>;
4
+ getDeviceMetrics(): Promise<Object>;
5
+ showFloatingButton(options: Object): Promise<boolean>;
6
+ hideFloatingButton(): Promise<boolean>;
7
+ setFloatingButtonBadge(hasBadge: boolean): Promise<boolean>;
8
+ setFloatingButtonPosition(x: number, y: number): Promise<boolean>;
9
+ startFpsMonitoring(): Promise<boolean>;
10
+ stopFpsMonitoring(): Promise<boolean>;
11
+ getFpsMetrics(): Promise<Object>;
12
+ getNativeStorageItem(key: string): Promise<string | null>;
13
+ setNativeStorageItem(key: string, value: string | null): Promise<boolean>;
14
+ triggerHaptic(style: string): Promise<boolean>;
15
+ getNativeSystemMetrics(): Promise<Object>;
16
+ pushNativeLogRecord(pageKey: string, jsonPayload: string): Promise<boolean>;
17
+ getNativeCachedPage(pageKey: string, offset: number, limit: number, query: string): Promise<string>;
18
+ addListener(eventName: string): void;
19
+ removeListeners(count: number): void;
20
+ }
21
+ declare const _default: Spec;
22
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+ export default TurboModuleRegistry.get('NetworkInspectorModule');
@@ -140,8 +140,8 @@ export const getRawStyles = (colors) => ({
140
140
  // #2 — scroll-to-top button, always shown at the bottom right.
141
141
  scrollTopBtn: {
142
142
  position: 'absolute',
143
- bottom: 25,
144
- right: 15,
143
+ bottom: 22,
144
+ right: 16,
145
145
  width: 38,
146
146
  height: 38,
147
147
  borderRadius: 19,
@@ -150,10 +150,10 @@ export const getRawStyles = (colors) => ({
150
150
  justifyContent: 'center',
151
151
  shadowColor: colors.black,
152
152
  shadowOffset: { width: 0, height: 3 },
153
- shadowOpacity: 0.25,
154
- shadowRadius: 5,
155
- elevation: 6,
156
- zIndex: 50,
153
+ shadowOpacity: 0.3,
154
+ shadowRadius: 6,
155
+ elevation: 12,
156
+ zIndex: 999,
157
157
  },
158
158
  detailScroll: { flex: 1 },
159
159
  closeButtonSquare: {
@@ -25,7 +25,7 @@ export declare const StatusFilter: {
25
25
  readonly FiveXx: "5xx";
26
26
  readonly Failed: "Failed";
27
27
  };
28
- export type StatusFilter = (typeof StatusFilter)[keyof typeof StatusFilter];
28
+ export type StatusFilter = (typeof StatusFilter)[keyof typeof StatusFilter] | string;
29
29
  export declare const SortOrder: {
30
30
  readonly Newest: "newest";
31
31
  readonly Oldest: "oldest";
@@ -140,6 +140,9 @@ export interface PersistedSettings {
140
140
  defaultTab?: string;
141
141
  maxNetworkLogs?: number;
142
142
  maxConsoleLogs?: number;
143
+ maxAnalyticsEventsLimit?: number;
144
+ maxCrashLogs?: number;
145
+ isAutoRamLimitEnabled?: boolean;
143
146
  showConsoleLevels?: {
144
147
  info: boolean;
145
148
  warn: boolean;
@@ -197,6 +200,7 @@ export interface InspectorContextValue {
197
200
  activePulseAnim: Animated.Value;
198
201
  unreadPulseAnim: Animated.Value;
199
202
  runClearAllWithAnimation: () => void;
203
+ useNativeFab: boolean;
200
204
  fabPan: Animated.ValueXY;
201
205
  fabPanResponder: PanResponderInstance;
202
206
  fabDraggedRef: React.MutableRefObject<boolean>;
@@ -313,6 +317,11 @@ export interface InspectorContextValue {
313
317
  setMaxNetworkLogs: React.Dispatch<React.SetStateAction<number>>;
314
318
  maxConsoleLogs: number;
315
319
  setMaxConsoleLogs: React.Dispatch<React.SetStateAction<number>>;
320
+ maxAnalyticsEventsLimit: number;
321
+ setMaxAnalyticsEventsLimit: React.Dispatch<React.SetStateAction<number>>;
322
+ isAutoRamLimitEnabled: boolean;
323
+ setIsAutoRamLimitEnabled: React.Dispatch<React.SetStateAction<boolean>>;
324
+ deviceFreeRamMb: number;
316
325
  reduxAutoRefresh: boolean;
317
326
  setReduxAutoRefreshState: React.Dispatch<React.SetStateAction<boolean>>;
318
327
  reduxExpandDepth: number;
@@ -1,8 +1,14 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import <React/RCTEventEmitter.h>
3
3
 
4
+ #ifdef RCT_NEW_ARCH_ENABLED
5
+ #import <RNInAppInspectorSpec/RNInAppInspectorSpec.h>
6
+ @interface NetworkInspectorModule : RCTEventEmitter <NativeNetworkInspectorSpec, RCTBridgeModule>
7
+ #else
4
8
  @interface NetworkInspectorModule : RCTEventEmitter <RCTBridgeModule>
9
+ #endif
5
10
 
6
11
  - (void)emitCrashEventWithMessage:(NSString *)message stackTrace:(NSString *)stackTrace;
7
12
 
8
13
  @end
14
+