react-native-inapp-inspector 2.2.2 → 2.2.4
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/dist/commonjs/components/AnalyticsDetail.js +5 -1
- package/dist/commonjs/components/AnalyticsEventCard.js +2 -1
- package/dist/commonjs/components/DiffViewer.js +1 -1
- package/dist/commonjs/components/Inspector/BundleTab.js +22 -0
- package/dist/commonjs/components/Inspector/DeviceInfoTab.d.ts +3 -0
- package/dist/commonjs/components/Inspector/DeviceInfoTab.js +835 -0
- package/dist/commonjs/components/Inspector/InspectorHeader.js +12 -14
- package/dist/commonjs/components/Inspector/LogDetail.js +6 -3
- package/dist/commonjs/components/Inspector/MainScreen.js +7 -3
- package/dist/commonjs/components/Inspector/NetworkTab.js +92 -15
- package/dist/commonjs/components/Inspector/PerformanceTab.js +38 -12
- package/dist/commonjs/components/Inspector/SettingsPanel.js +440 -229
- package/dist/commonjs/components/Inspector/StorageTab.d.ts +3 -0
- package/dist/commonjs/components/Inspector/StorageTab.js +892 -0
- package/dist/commonjs/components/Inspector/TabBar.js +14 -0
- package/dist/commonjs/components/Inspector/TelemetryConsentModal.js +11 -2
- package/dist/commonjs/components/Inspector/UpdateAvailableModal.js +4 -1
- package/dist/commonjs/components/NetworkIcons.d.ts +6 -0
- package/dist/commonjs/components/NetworkIcons.js +30 -1
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -1
- package/dist/commonjs/customHooks/bundleAnalyzer.js +44 -22
- package/dist/commonjs/customHooks/storageInspector.d.ts +67 -0
- package/dist/commonjs/customHooks/storageInspector.js +486 -0
- package/dist/commonjs/i18n/locales/en.json +8 -2
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.js +16 -1
- package/dist/commonjs/storage.d.ts +5 -0
- package/dist/commonjs/storage.js +18 -0
- package/dist/commonjs/types/enums.d.ts +5 -0
- package/dist/commonjs/types/enums.js +5 -0
- package/dist/esm/components/AnalyticsDetail.js +6 -2
- package/dist/esm/components/AnalyticsEventCard.js +2 -1
- package/dist/esm/components/DiffViewer.js +1 -1
- package/dist/esm/components/Inspector/BundleTab.js +22 -0
- package/dist/esm/components/Inspector/DeviceInfoTab.d.ts +3 -0
- package/dist/esm/components/Inspector/DeviceInfoTab.js +796 -0
- package/dist/esm/components/Inspector/InspectorHeader.js +13 -15
- package/dist/esm/components/Inspector/LogDetail.js +7 -4
- package/dist/esm/components/Inspector/MainScreen.js +7 -3
- package/dist/esm/components/Inspector/NetworkTab.js +93 -16
- package/dist/esm/components/Inspector/PerformanceTab.js +39 -13
- package/dist/esm/components/Inspector/SettingsPanel.js +441 -230
- package/dist/esm/components/Inspector/StorageTab.d.ts +3 -0
- package/dist/esm/components/Inspector/StorageTab.js +853 -0
- package/dist/esm/components/Inspector/TabBar.js +15 -1
- package/dist/esm/components/Inspector/TelemetryConsentModal.js +11 -2
- package/dist/esm/components/Inspector/UpdateAvailableModal.js +4 -1
- package/dist/esm/components/NetworkIcons.d.ts +6 -0
- package/dist/esm/components/NetworkIcons.js +23 -0
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/customHooks/bundleAnalyzer.js +44 -22
- package/dist/esm/customHooks/storageInspector.d.ts +67 -0
- package/dist/esm/customHooks/storageInspector.js +469 -0
- package/dist/esm/i18n/locales/en.json +8 -2
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/storage.d.ts +5 -0
- package/dist/esm/storage.js +5 -0
- package/dist/esm/types/enums.d.ts +5 -0
- package/dist/esm/types/enums.js +5 -0
- package/package.json +9 -1
- package/src/analytics.ts +35 -0
- package/src/bundle.ts +25 -0
- package/src/components/AnalyticsDetail.tsx +870 -0
- package/src/components/AnalyticsEventCard.tsx +442 -0
- package/src/components/AnalyticsGraph.tsx +583 -0
- package/src/components/AnimatedEntrance.tsx +64 -0
- package/src/components/AppHeaderLogo.tsx +109 -0
- package/src/components/BrandCircleIcon.tsx +144 -0
- package/src/components/BrandSquareIcon.tsx +144 -0
- package/src/components/CodeSnippet.tsx +725 -0
- package/src/components/ConsoleLogCard.tsx +628 -0
- package/src/components/CopyButton.tsx +87 -0
- package/src/components/DiffViewer.tsx +82 -0
- package/src/components/DomainHeader.tsx +237 -0
- package/src/components/EmptyState.tsx +73 -0
- package/src/components/EndOfListFooter.tsx +100 -0
- package/src/components/ErrorBoundary.tsx +688 -0
- package/src/components/HeadersSection.tsx +192 -0
- package/src/components/HighlightText.tsx +100 -0
- package/src/components/Inspector/AnalyticsFilterModal.tsx +1250 -0
- package/src/components/Inspector/AnalyticsTab.tsx +1336 -0
- package/src/components/Inspector/BundleTab.tsx +4760 -0
- package/src/components/Inspector/ConsoleTab.tsx +702 -0
- package/src/components/Inspector/CrashDetail.tsx +941 -0
- package/src/components/Inspector/CrashFilterModal.tsx +721 -0
- package/src/components/Inspector/CrashTab.tsx +871 -0
- package/src/components/Inspector/DeviceInfoTab.tsx +1204 -0
- package/src/components/Inspector/FabLauncher.tsx +80 -0
- package/src/components/Inspector/InspectorContext.tsx +28 -0
- package/src/components/Inspector/InspectorHeader.tsx +972 -0
- package/src/components/Inspector/LogDetail.tsx +1431 -0
- package/src/components/Inspector/MainScreen.tsx +262 -0
- package/src/components/Inspector/NavigationTracker.tsx +13 -0
- package/src/components/Inspector/NetworkDetail.tsx +794 -0
- package/src/components/Inspector/NetworkTab.tsx +1183 -0
- package/src/components/Inspector/NpmUpdateToast.tsx +392 -0
- package/src/components/Inspector/PerformanceTab.tsx +1928 -0
- package/src/components/Inspector/ReduxDetail.tsx +1651 -0
- package/src/components/Inspector/ReduxTab.tsx +954 -0
- package/src/components/Inspector/SettingsPanel.tsx +3447 -0
- package/src/components/Inspector/StorageTab.tsx +1048 -0
- package/src/components/Inspector/TabBar.tsx +207 -0
- package/src/components/Inspector/TelemetryConsentModal.tsx +416 -0
- package/src/components/Inspector/UpdateAvailableModal.tsx +557 -0
- package/src/components/JsonViewer.tsx +486 -0
- package/src/components/LogCard.tsx +491 -0
- package/src/components/LogSyntaxHighlighter.tsx +178 -0
- package/src/components/MetaAccordion.tsx +340 -0
- package/src/components/MiniBarChart.tsx +42 -0
- package/src/components/MiniLineChart.tsx +33 -0
- package/src/components/NetworkIcons.tsx +2221 -0
- package/src/components/SectionHeader.tsx +113 -0
- package/src/components/SegmentedTabs.tsx +83 -0
- package/src/components/Slider.tsx +300 -0
- package/src/components/SourcePageCard.tsx +148 -0
- package/src/components/Toast.tsx +131 -0
- package/src/components/TouchableScale.tsx +91 -0
- package/src/components/TreeNode.tsx +186 -0
- package/src/console.ts +24 -0
- package/src/constants/index.ts +38 -0
- package/src/constants/version.ts +3 -0
- package/src/crash.ts +32 -0
- package/src/customHooks/analyticsLogger.ts +336 -0
- package/src/customHooks/bundleAnalyzer.ts +1256 -0
- package/src/customHooks/consoleLogger.ts +497 -0
- package/src/customHooks/crashHandler.ts +944 -0
- package/src/customHooks/logFilters.ts +32 -0
- package/src/customHooks/networkLogger.ts +419 -0
- package/src/customHooks/performanceTracker.ts +1014 -0
- package/src/customHooks/reduxLogger.ts +406 -0
- package/src/customHooks/storageInspector.ts +509 -0
- package/src/customHooks/useAccordion.tsx +60 -0
- package/src/decorators/index.ts +184 -0
- package/src/helpers/gaAnalyticsRegistry.ts +204 -0
- package/src/helpers/index.ts +860 -0
- package/src/helpers/memoryManager.ts +138 -0
- package/src/helpers/searchQueryParser.ts +283 -0
- package/src/helpers/settingsStore.ts +171 -0
- package/src/helpers/telemetry.ts +505 -0
- package/src/helpers/toast.ts +17 -0
- package/src/i18n/index.ts +69 -0
- package/src/i18n/locales/en.json +1058 -0
- package/src/index.tsx +2356 -0
- package/src/native/NativeInspector.ts +397 -0
- package/src/native/NativeNetworkInspector.ts +24 -0
- package/src/network.ts +22 -0
- package/src/performance.ts +38 -0
- package/src/redux.ts +23 -0
- package/src/storage.ts +18 -0
- package/src/styles/AppColors.ts +408 -0
- package/src/styles/AppFonts.ts +8 -0
- package/src/styles/common.ts +209 -0
- package/src/styles/index.ts +1570 -0
- package/src/types/enums.ts +199 -0
- package/src/types/index.ts +34 -0
- package/src/types/interfaces.ts +515 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import {NativeModules, NativeEventEmitter, Platform} from 'react-native';
|
|
2
|
+
import NativeNetworkInspector from './NativeNetworkInspector';
|
|
3
|
+
|
|
4
|
+
export interface NativeDeviceMetrics {
|
|
5
|
+
totalRAM?: number;
|
|
6
|
+
freeRAM?: number;
|
|
7
|
+
usedRAM?: number;
|
|
8
|
+
residentMemory?: number;
|
|
9
|
+
virtualMemory?: number;
|
|
10
|
+
isLowMemory?: boolean;
|
|
11
|
+
nativeHeapAllocated?: number;
|
|
12
|
+
nativeHeapSize?: number;
|
|
13
|
+
nativeHeapFree?: number;
|
|
14
|
+
freeStorage?: number;
|
|
15
|
+
totalStorage?: number;
|
|
16
|
+
batteryPercent?: number;
|
|
17
|
+
isCharging?: boolean;
|
|
18
|
+
deviceModel?: string;
|
|
19
|
+
deviceBrand?: string;
|
|
20
|
+
osVersion?: string;
|
|
21
|
+
apiLevel?: number;
|
|
22
|
+
cpuAbi?: string;
|
|
23
|
+
appName?: string;
|
|
24
|
+
appVersion?: string;
|
|
25
|
+
appBuild?: string;
|
|
26
|
+
appBundleId?: string;
|
|
27
|
+
appPackageName?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NativeCrashEvent {
|
|
31
|
+
platform: 'android' | 'ios';
|
|
32
|
+
error: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
stack?: string;
|
|
35
|
+
threadName?: string;
|
|
36
|
+
timestamp: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Seamless TurboModule (New Architecture / JSI) & Legacy NativeModules Bridge resolution
|
|
40
|
+
const NativeModule: any =
|
|
41
|
+
NativeNetworkInspector || NativeModules.NetworkInspectorModule;
|
|
42
|
+
|
|
43
|
+
export const isNativeModuleAvailable = (): boolean => {
|
|
44
|
+
return !!NativeModule;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const eventTarget: any =
|
|
48
|
+
NativeModules.NetworkInspectorModule || NativeNetworkInspector;
|
|
49
|
+
|
|
50
|
+
const nativeEmitter = eventTarget
|
|
51
|
+
? new NativeEventEmitter(eventTarget)
|
|
52
|
+
: null;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves low-level native hardware and system metrics (RAM, Heap, Disk, Battery, CPU).
|
|
56
|
+
*/
|
|
57
|
+
export const getNativeDeviceMetrics = async (): Promise<NativeDeviceMetrics | null> => {
|
|
58
|
+
if (!NativeModule || !NativeModule.getDeviceMetrics) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const metrics: NativeDeviceMetrics = await NativeModule.getDeviceMetrics();
|
|
63
|
+
return metrics;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Enables native signal and uncaught exception protection in the iOS / Android runtime.
|
|
71
|
+
* Automatically ensures the native floating icon is shown and available before UI renders.
|
|
72
|
+
*/
|
|
73
|
+
export const enableNativeCrashProtection = async (options?: {
|
|
74
|
+
showFloatingButton?: boolean;
|
|
75
|
+
}): Promise<boolean> => {
|
|
76
|
+
if (!NativeModule || !NativeModule.enableNativeCrashProtection) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const result = await NativeModule.enableNativeCrashProtection();
|
|
81
|
+
if (options?.showFloatingButton !== false) {
|
|
82
|
+
await showNativeFloatingButton();
|
|
83
|
+
}
|
|
84
|
+
return !!result;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Subscribes to fatal native crash events caught by the iOS / Kotlin exception handlers.
|
|
92
|
+
*/
|
|
93
|
+
export const subscribeNativeCrashes = (
|
|
94
|
+
callback: (event: NativeCrashEvent) => void,
|
|
95
|
+
): (() => void) => {
|
|
96
|
+
if (!nativeEmitter) {
|
|
97
|
+
return () => {};
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const subscription = nativeEmitter.addListener('onNativeCrash', callback);
|
|
101
|
+
return () => {
|
|
102
|
+
subscription.remove();
|
|
103
|
+
};
|
|
104
|
+
} catch (e) {
|
|
105
|
+
return () => {};
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export interface FloatingButtonOptions {
|
|
110
|
+
size?: number;
|
|
111
|
+
x?: number;
|
|
112
|
+
y?: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Displays the 100% native main-thread floating overlay button.
|
|
117
|
+
* Dragging & touches run on the native UI thread, completely isolated from JS thread stalls.
|
|
118
|
+
*/
|
|
119
|
+
export const showNativeFloatingButton = async (
|
|
120
|
+
options?: FloatingButtonOptions,
|
|
121
|
+
): Promise<boolean> => {
|
|
122
|
+
if (!NativeModule || !NativeModule.showFloatingButton) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const result = await NativeModule.showFloatingButton(options || {});
|
|
127
|
+
return !!result;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Hides the native floating overlay button.
|
|
135
|
+
*/
|
|
136
|
+
export const hideNativeFloatingButton = async (): Promise<boolean> => {
|
|
137
|
+
if (!NativeModule || !NativeModule.hideFloatingButton) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
const result = await NativeModule.hideFloatingButton();
|
|
142
|
+
return !!result;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Updates the badge/status dot on the native floating overlay button.
|
|
150
|
+
*/
|
|
151
|
+
export const setNativeFloatingButtonBadge = async (
|
|
152
|
+
hasBadge: boolean,
|
|
153
|
+
): Promise<boolean> => {
|
|
154
|
+
if (!NativeModule || !NativeModule.setFloatingButtonBadge) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const result = await NativeModule.setFloatingButtonBadge(hasBadge);
|
|
159
|
+
return !!result;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Subscribes to tap events on the native floating button.
|
|
167
|
+
*/
|
|
168
|
+
export const subscribeNativeFloatingButtonPress = (
|
|
169
|
+
callback: () => void,
|
|
170
|
+
): (() => void) => {
|
|
171
|
+
if (!nativeEmitter) {
|
|
172
|
+
return () => {};
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const subscription = nativeEmitter.addListener(
|
|
176
|
+
'onFloatingButtonPress',
|
|
177
|
+
callback,
|
|
178
|
+
);
|
|
179
|
+
return () => {
|
|
180
|
+
subscription.remove();
|
|
181
|
+
};
|
|
182
|
+
} catch (e) {
|
|
183
|
+
return () => {};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Starts hardware-accurate native UI thread FPS tracking (CADisplayLink / Choreographer).
|
|
189
|
+
*/
|
|
190
|
+
export const startNativeFpsMonitoring = async (): Promise<boolean> => {
|
|
191
|
+
if (!NativeModule || !NativeModule.startFpsMonitoring) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
const result = await NativeModule.startFpsMonitoring();
|
|
196
|
+
return !!result;
|
|
197
|
+
} catch {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Stops native FPS tracking.
|
|
204
|
+
*/
|
|
205
|
+
export const stopNativeFpsMonitoring = async (): Promise<boolean> => {
|
|
206
|
+
if (!NativeModule || !NativeModule.stopFpsMonitoring) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
const result = await NativeModule.stopFpsMonitoring();
|
|
211
|
+
return !!result;
|
|
212
|
+
} catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export interface NativeFpsMetrics {
|
|
218
|
+
fps: number;
|
|
219
|
+
targetFps: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Reads the latest live hardware FPS from CADisplayLink (iOS) or Choreographer (Android).
|
|
224
|
+
*/
|
|
225
|
+
export const getNativeFpsMetrics = async (): Promise<NativeFpsMetrics> => {
|
|
226
|
+
if (!NativeModule || !NativeModule.getFpsMetrics) {
|
|
227
|
+
return {fps: 60, targetFps: 60};
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const metrics = await NativeModule.getFpsMetrics();
|
|
231
|
+
return {
|
|
232
|
+
fps: typeof metrics?.fps === 'number' ? metrics.fps : 60,
|
|
233
|
+
targetFps: typeof metrics?.targetFps === 'number' ? metrics.targetFps : 60,
|
|
234
|
+
};
|
|
235
|
+
} catch {
|
|
236
|
+
return {fps: 60, targetFps: 60};
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Subscribes to physical hardware shake events (or Cmd+Ctrl+Z on iOS simulator).
|
|
242
|
+
*/
|
|
243
|
+
export const subscribeNativeDeviceShake = (
|
|
244
|
+
callback: () => void,
|
|
245
|
+
): (() => void) => {
|
|
246
|
+
if (!nativeEmitter) {
|
|
247
|
+
return () => {};
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
const subscription = nativeEmitter.addListener('onDeviceShake', callback);
|
|
251
|
+
return () => {
|
|
252
|
+
subscription.remove();
|
|
253
|
+
};
|
|
254
|
+
} catch {
|
|
255
|
+
return () => {};
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Reads a persisted value synchronously from native NSUserDefaults / SharedPreferences.
|
|
261
|
+
*/
|
|
262
|
+
export const getNativeStorageItem = async (
|
|
263
|
+
key: string,
|
|
264
|
+
): Promise<string | null> => {
|
|
265
|
+
if (!NativeModule || !NativeModule.getNativeStorageItem) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
const val = await NativeModule.getNativeStorageItem(key);
|
|
270
|
+
return typeof val === 'string' ? val : null;
|
|
271
|
+
} catch {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Persists a key-value pair to native NSUserDefaults / SharedPreferences with 0ms latency.
|
|
278
|
+
*/
|
|
279
|
+
export const setNativeStorageItem = async (
|
|
280
|
+
key: string,
|
|
281
|
+
value: string | null,
|
|
282
|
+
): Promise<boolean> => {
|
|
283
|
+
if (!NativeModule || !NativeModule.setNativeStorageItem) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
const result = await NativeModule.setNativeStorageItem(key, value);
|
|
288
|
+
return !!result;
|
|
289
|
+
} catch {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export type HapticStyle = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error';
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Triggers hardware native haptic feedback (iOS UIFeedbackGenerator / Android VibrationEffect).
|
|
298
|
+
*/
|
|
299
|
+
export const triggerNativeHaptic = async (
|
|
300
|
+
style: HapticStyle = 'light',
|
|
301
|
+
): Promise<boolean> => {
|
|
302
|
+
if (!NativeModule || !NativeModule.triggerHaptic) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const result = await NativeModule.triggerHaptic(style);
|
|
307
|
+
return !!result;
|
|
308
|
+
} catch {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export interface NativeSystemMetrics {
|
|
314
|
+
thermalState: 'nominal' | 'fair' | 'serious' | 'critical';
|
|
315
|
+
residentRamMb: number;
|
|
316
|
+
totalPhysicalRamMb: number;
|
|
317
|
+
fps: number;
|
|
318
|
+
activeCpuCores: number;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Retrieves live system thermal state and RAM telemetry directly from native layer.
|
|
323
|
+
*/
|
|
324
|
+
export const getNativeSystemMetrics = async (): Promise<NativeSystemMetrics | null> => {
|
|
325
|
+
if (!NativeModule || !NativeModule.getNativeSystemMetrics) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
const metrics = await NativeModule.getNativeSystemMetrics();
|
|
330
|
+
return metrics as NativeSystemMetrics;
|
|
331
|
+
} catch {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Pushes a log payload to native background worker queues for instant native page caching.
|
|
338
|
+
*/
|
|
339
|
+
export const pushNativeLogRecord = async (
|
|
340
|
+
pageKey: 'apis' | 'logs' | 'analytics' | 'crash',
|
|
341
|
+
jsonPayload: string,
|
|
342
|
+
): Promise<boolean> => {
|
|
343
|
+
if (!NativeModule || !NativeModule.pushNativeLogRecord) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
try {
|
|
347
|
+
const result = await NativeModule.pushNativeLogRecord(pageKey, jsonPayload);
|
|
348
|
+
return !!result;
|
|
349
|
+
} catch {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
export interface NativeCachedPageResult<T = any> {
|
|
355
|
+
pageKey: string;
|
|
356
|
+
total: number;
|
|
357
|
+
offset: number;
|
|
358
|
+
items: T[];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Fetches pre-indexed, pre-sliced page data directly from native background memory queues.
|
|
363
|
+
* Delivers instantaneous 0ms page loading without blocking JS render thread.
|
|
364
|
+
*/
|
|
365
|
+
export const fetchNativeCachedPage = async <T = any>(
|
|
366
|
+
pageKey: 'apis' | 'logs' | 'analytics' | 'crash',
|
|
367
|
+
offset: number = 0,
|
|
368
|
+
limit: number = 50,
|
|
369
|
+
query: string = '',
|
|
370
|
+
): Promise<NativeCachedPageResult<T> | null> => {
|
|
371
|
+
if (!NativeModule || !NativeModule.getNativeCachedPage) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
const rawJson: string = await NativeModule.getNativeCachedPage(
|
|
376
|
+
pageKey,
|
|
377
|
+
offset,
|
|
378
|
+
limit,
|
|
379
|
+
query,
|
|
380
|
+
);
|
|
381
|
+
if (!rawJson) return null;
|
|
382
|
+
const parsed = JSON.parse(rawJson);
|
|
383
|
+
const parsedItems = (parsed.items || []).map((item: string | object) =>
|
|
384
|
+
typeof item === 'string' ? JSON.parse(item) : item,
|
|
385
|
+
);
|
|
386
|
+
return {
|
|
387
|
+
pageKey: parsed.pageKey || pageKey,
|
|
388
|
+
total: parsed.total || 0,
|
|
389
|
+
offset: parsed.offset || offset,
|
|
390
|
+
items: parsedItems,
|
|
391
|
+
};
|
|
392
|
+
} catch {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type {TurboModule} from 'react-native';
|
|
2
|
+
import {TurboModuleRegistry} from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
enableNativeCrashProtection(): Promise<boolean>;
|
|
6
|
+
getDeviceMetrics(): Promise<Object>;
|
|
7
|
+
showFloatingButton(options: Object): Promise<boolean>;
|
|
8
|
+
hideFloatingButton(): Promise<boolean>;
|
|
9
|
+
setFloatingButtonBadge(hasBadge: boolean): Promise<boolean>;
|
|
10
|
+
setFloatingButtonPosition(x: number, y: number): Promise<boolean>;
|
|
11
|
+
startFpsMonitoring(): Promise<boolean>;
|
|
12
|
+
stopFpsMonitoring(): Promise<boolean>;
|
|
13
|
+
getFpsMetrics(): Promise<Object>;
|
|
14
|
+
getNativeStorageItem(key: string): Promise<string | null>;
|
|
15
|
+
setNativeStorageItem(key: string, value: string | null): Promise<boolean>;
|
|
16
|
+
triggerHaptic(style: string): Promise<boolean>;
|
|
17
|
+
getNativeSystemMetrics(): Promise<Object>;
|
|
18
|
+
pushNativeLogRecord(pageKey: string, jsonPayload: string): Promise<boolean>;
|
|
19
|
+
getNativeCachedPage(pageKey: string, offset: number, limit: number, query: string): Promise<string>;
|
|
20
|
+
addListener(eventName: string): void;
|
|
21
|
+
removeListeners(count: number): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default TurboModuleRegistry.get<Spec>('NetworkInspectorModule');
|
package/src/network.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sub-module entry point: react-native-inapp-inspector/network
|
|
3
|
+
* Clean tree-shaking & isolated network logger without UI or React Context dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export {
|
|
6
|
+
setupNetworkLogger,
|
|
7
|
+
clearNetworkLogs,
|
|
8
|
+
subscribeNetworkLogs,
|
|
9
|
+
getNetworkLogs,
|
|
10
|
+
setNetworkModuleEnabled,
|
|
11
|
+
getNetworkModuleEnabled,
|
|
12
|
+
setMaxNetworkLogsLimit,
|
|
13
|
+
getMaxNetworkLogsLimit,
|
|
14
|
+
pruneNetworkLogs,
|
|
15
|
+
} from './customHooks/networkLogger';
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
NetworkLog,
|
|
19
|
+
Method,
|
|
20
|
+
StatusFilter,
|
|
21
|
+
SortOrder,
|
|
22
|
+
} from './types';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sub-module entry point: react-native-inapp-inspector/performance
|
|
3
|
+
* Clean tree-shaking & isolated performance tracker and profiler.
|
|
4
|
+
*/
|
|
5
|
+
export {
|
|
6
|
+
usePerformanceTracker,
|
|
7
|
+
useComponentProfiler,
|
|
8
|
+
useNavigationProfiler,
|
|
9
|
+
trackComponentRender,
|
|
10
|
+
trackNavigationTransition,
|
|
11
|
+
trackHeavyTask,
|
|
12
|
+
measureAsync,
|
|
13
|
+
getHermesMemoryStats,
|
|
14
|
+
registerComponentProfile,
|
|
15
|
+
subscribeRenderProfiles,
|
|
16
|
+
getRenderProfiles,
|
|
17
|
+
logPerformanceEvent,
|
|
18
|
+
clearPerformanceEvents,
|
|
19
|
+
subscribePerformanceEvents,
|
|
20
|
+
getPerformanceEvents,
|
|
21
|
+
getInitialRenderProfiles,
|
|
22
|
+
getInitialPerformanceEvents,
|
|
23
|
+
generateFixSnippet,
|
|
24
|
+
setPerformanceModuleEnabled,
|
|
25
|
+
getPerformanceModuleEnabled,
|
|
26
|
+
setMaxPerformanceEventsLimit,
|
|
27
|
+
getMaxPerformanceEventsLimit,
|
|
28
|
+
prunePerformanceEvents,
|
|
29
|
+
type PerformanceEvent,
|
|
30
|
+
type LiveMemoryStats,
|
|
31
|
+
type ComponentRenderProfile,
|
|
32
|
+
type CoreMobileVitals,
|
|
33
|
+
type PerformanceFixKey,
|
|
34
|
+
} from './customHooks/performanceTracker';
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
PerformanceSubTab,
|
|
38
|
+
} from './types';
|
package/src/redux.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sub-module entry point: react-native-inapp-inspector/redux
|
|
3
|
+
* Clean tree-shaking & isolated Redux middleware and state inspector.
|
|
4
|
+
*/
|
|
5
|
+
export {
|
|
6
|
+
connectReduxStore,
|
|
7
|
+
inspectorReduxMiddleware,
|
|
8
|
+
getReduxState,
|
|
9
|
+
subscribeReduxState,
|
|
10
|
+
getActionHistory,
|
|
11
|
+
clearActionHistory,
|
|
12
|
+
getLastActionForReducer,
|
|
13
|
+
clearLastActionForReducer,
|
|
14
|
+
setReduxAutoRefresh,
|
|
15
|
+
getReduxAutoRefresh,
|
|
16
|
+
isReduxConnected,
|
|
17
|
+
setReduxModuleEnabled,
|
|
18
|
+
getReduxModuleEnabled,
|
|
19
|
+
setMaxReduxHistoryLimit,
|
|
20
|
+
getMaxReduxHistoryLimit,
|
|
21
|
+
pruneReduxHistory,
|
|
22
|
+
type ReduxHistoryEntry,
|
|
23
|
+
} from './customHooks/reduxLogger';
|
package/src/storage.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sub-module entry point: react-native-inapp-inspector/storage
|
|
3
|
+
* Universal AsyncStorage and MMKV live inspector with full CRUD operations.
|
|
4
|
+
*/
|
|
5
|
+
export {
|
|
6
|
+
connectAsyncStorage,
|
|
7
|
+
connectMMKV,
|
|
8
|
+
isAsyncStorageConnected,
|
|
9
|
+
isMMKVConnected,
|
|
10
|
+
getRegisteredMMKVInstanceIds,
|
|
11
|
+
fetchStorageEntries,
|
|
12
|
+
setStorageEntry,
|
|
13
|
+
removeStorageEntry,
|
|
14
|
+
clearStorageDriver,
|
|
15
|
+
subscribeToStorageChanges,
|
|
16
|
+
type StorageEntry,
|
|
17
|
+
type StorageDriver,
|
|
18
|
+
} from './customHooks/storageInspector';
|