react-native-prod-debugger 1.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 (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +350 -0
  3. package/lib/commonjs/core/DebugBubble.js +139 -0
  4. package/lib/commonjs/core/DebugBubble.js.map +1 -0
  5. package/lib/commonjs/core/DebugOverlay.js +184 -0
  6. package/lib/commonjs/core/DebugOverlay.js.map +1 -0
  7. package/lib/commonjs/core/DebuggerProvider.js +174 -0
  8. package/lib/commonjs/core/DebuggerProvider.js.map +1 -0
  9. package/lib/commonjs/core/GestureDetector.js +83 -0
  10. package/lib/commonjs/core/GestureDetector.js.map +1 -0
  11. package/lib/commonjs/core/PluginRegistry.js +124 -0
  12. package/lib/commonjs/core/PluginRegistry.js.map +1 -0
  13. package/lib/commonjs/core/theme.js +50 -0
  14. package/lib/commonjs/core/theme.js.map +1 -0
  15. package/lib/commonjs/core/types.js +6 -0
  16. package/lib/commonjs/core/types.js.map +1 -0
  17. package/lib/commonjs/core/useDebugger.js +27 -0
  18. package/lib/commonjs/core/useDebugger.js.map +1 -0
  19. package/lib/commonjs/core/utils.js +239 -0
  20. package/lib/commonjs/core/utils.js.map +1 -0
  21. package/lib/commonjs/index.js +132 -0
  22. package/lib/commonjs/index.js.map +1 -0
  23. package/lib/commonjs/plugins/console/ConsoleInterceptor.js +103 -0
  24. package/lib/commonjs/plugins/console/ConsoleInterceptor.js.map +1 -0
  25. package/lib/commonjs/plugins/console/ConsoleViewerPlugin.js +269 -0
  26. package/lib/commonjs/plugins/console/ConsoleViewerPlugin.js.map +1 -0
  27. package/lib/commonjs/plugins/crashReporter/CrashReporterPlugin.js +363 -0
  28. package/lib/commonjs/plugins/crashReporter/CrashReporterPlugin.js.map +1 -0
  29. package/lib/commonjs/plugins/customActions/CustomActionsPlugin.js +218 -0
  30. package/lib/commonjs/plugins/customActions/CustomActionsPlugin.js.map +1 -0
  31. package/lib/commonjs/plugins/customActions/actionStore.js +46 -0
  32. package/lib/commonjs/plugins/customActions/actionStore.js.map +1 -0
  33. package/lib/commonjs/plugins/deepLinkTester/DeepLinkTesterPlugin.js +268 -0
  34. package/lib/commonjs/plugins/deepLinkTester/DeepLinkTesterPlugin.js.map +1 -0
  35. package/lib/commonjs/plugins/deviceInfo/DeviceInfoPlugin.js +184 -0
  36. package/lib/commonjs/plugins/deviceInfo/DeviceInfoPlugin.js.map +1 -0
  37. package/lib/commonjs/plugins/featureFlags/FeatureFlagsPlugin.js +381 -0
  38. package/lib/commonjs/plugins/featureFlags/FeatureFlagsPlugin.js.map +1 -0
  39. package/lib/commonjs/plugins/featureFlags/flagStore.js +125 -0
  40. package/lib/commonjs/plugins/featureFlags/flagStore.js.map +1 -0
  41. package/lib/commonjs/plugins/navigationInspector/NavigationInspectorPlugin.js +250 -0
  42. package/lib/commonjs/plugins/navigationInspector/NavigationInspectorPlugin.js.map +1 -0
  43. package/lib/commonjs/plugins/navigationInspector/navigationStore.js +65 -0
  44. package/lib/commonjs/plugins/navigationInspector/navigationStore.js.map +1 -0
  45. package/lib/commonjs/plugins/network/NetworkInspectorPlugin.js +709 -0
  46. package/lib/commonjs/plugins/network/NetworkInspectorPlugin.js.map +1 -0
  47. package/lib/commonjs/plugins/network/NetworkInterceptor.js +305 -0
  48. package/lib/commonjs/plugins/network/NetworkInterceptor.js.map +1 -0
  49. package/lib/commonjs/plugins/performance/PerformanceMonitorPlugin.js +261 -0
  50. package/lib/commonjs/plugins/performance/PerformanceMonitorPlugin.js.map +1 -0
  51. package/lib/commonjs/plugins/remoteConfig/RemoteConfigPlugin.js +265 -0
  52. package/lib/commonjs/plugins/remoteConfig/RemoteConfigPlugin.js.map +1 -0
  53. package/lib/commonjs/plugins/remoteConfig/remoteConfigStore.js +50 -0
  54. package/lib/commonjs/plugins/remoteConfig/remoteConfigStore.js.map +1 -0
  55. package/lib/commonjs/plugins/stateInspector/StateInspectorPlugin.js +378 -0
  56. package/lib/commonjs/plugins/stateInspector/StateInspectorPlugin.js.map +1 -0
  57. package/lib/commonjs/plugins/stateInspector/stateAdapterRegistry.js +62 -0
  58. package/lib/commonjs/plugins/stateInspector/stateAdapterRegistry.js.map +1 -0
  59. package/lib/commonjs/plugins/storageBrowser/StorageBrowserPlugin.js +496 -0
  60. package/lib/commonjs/plugins/storageBrowser/StorageBrowserPlugin.js.map +1 -0
  61. package/lib/commonjs/plugins/storageBrowser/storageAdapterRegistry.js +44 -0
  62. package/lib/commonjs/plugins/storageBrowser/storageAdapterRegistry.js.map +1 -0
  63. package/lib/commonjs/plugins/timeline/TimelinePlugin.js +294 -0
  64. package/lib/commonjs/plugins/timeline/TimelinePlugin.js.map +1 -0
  65. package/lib/commonjs/plugins/timeline/timelineStore.js +61 -0
  66. package/lib/commonjs/plugins/timeline/timelineStore.js.map +1 -0
  67. package/lib/module/core/DebugBubble.js +131 -0
  68. package/lib/module/core/DebugBubble.js.map +1 -0
  69. package/lib/module/core/DebugOverlay.js +176 -0
  70. package/lib/module/core/DebugOverlay.js.map +1 -0
  71. package/lib/module/core/DebuggerProvider.js +167 -0
  72. package/lib/module/core/DebuggerProvider.js.map +1 -0
  73. package/lib/module/core/GestureDetector.js +75 -0
  74. package/lib/module/core/GestureDetector.js.map +1 -0
  75. package/lib/module/core/PluginRegistry.js +116 -0
  76. package/lib/module/core/PluginRegistry.js.map +1 -0
  77. package/lib/module/core/theme.js +43 -0
  78. package/lib/module/core/theme.js.map +1 -0
  79. package/lib/module/core/types.js +2 -0
  80. package/lib/module/core/types.js.map +1 -0
  81. package/lib/module/core/useDebugger.js +21 -0
  82. package/lib/module/core/useDebugger.js.map +1 -0
  83. package/lib/module/core/utils.js +219 -0
  84. package/lib/module/core/utils.js.map +1 -0
  85. package/lib/module/index.js +44 -0
  86. package/lib/module/index.js.map +1 -0
  87. package/lib/module/plugins/console/ConsoleInterceptor.js +97 -0
  88. package/lib/module/plugins/console/ConsoleInterceptor.js.map +1 -0
  89. package/lib/module/plugins/console/ConsoleViewerPlugin.js +262 -0
  90. package/lib/module/plugins/console/ConsoleViewerPlugin.js.map +1 -0
  91. package/lib/module/plugins/crashReporter/CrashReporterPlugin.js +357 -0
  92. package/lib/module/plugins/crashReporter/CrashReporterPlugin.js.map +1 -0
  93. package/lib/module/plugins/customActions/CustomActionsPlugin.js +211 -0
  94. package/lib/module/plugins/customActions/CustomActionsPlugin.js.map +1 -0
  95. package/lib/module/plugins/customActions/actionStore.js +38 -0
  96. package/lib/module/plugins/customActions/actionStore.js.map +1 -0
  97. package/lib/module/plugins/deepLinkTester/DeepLinkTesterPlugin.js +261 -0
  98. package/lib/module/plugins/deepLinkTester/DeepLinkTesterPlugin.js.map +1 -0
  99. package/lib/module/plugins/deviceInfo/DeviceInfoPlugin.js +177 -0
  100. package/lib/module/plugins/deviceInfo/DeviceInfoPlugin.js.map +1 -0
  101. package/lib/module/plugins/featureFlags/FeatureFlagsPlugin.js +374 -0
  102. package/lib/module/plugins/featureFlags/FeatureFlagsPlugin.js.map +1 -0
  103. package/lib/module/plugins/featureFlags/flagStore.js +117 -0
  104. package/lib/module/plugins/featureFlags/flagStore.js.map +1 -0
  105. package/lib/module/plugins/navigationInspector/NavigationInspectorPlugin.js +243 -0
  106. package/lib/module/plugins/navigationInspector/NavigationInspectorPlugin.js.map +1 -0
  107. package/lib/module/plugins/navigationInspector/navigationStore.js +58 -0
  108. package/lib/module/plugins/navigationInspector/navigationStore.js.map +1 -0
  109. package/lib/module/plugins/network/NetworkInspectorPlugin.js +703 -0
  110. package/lib/module/plugins/network/NetworkInspectorPlugin.js.map +1 -0
  111. package/lib/module/plugins/network/NetworkInterceptor.js +299 -0
  112. package/lib/module/plugins/network/NetworkInterceptor.js.map +1 -0
  113. package/lib/module/plugins/performance/PerformanceMonitorPlugin.js +254 -0
  114. package/lib/module/plugins/performance/PerformanceMonitorPlugin.js.map +1 -0
  115. package/lib/module/plugins/remoteConfig/RemoteConfigPlugin.js +258 -0
  116. package/lib/module/plugins/remoteConfig/RemoteConfigPlugin.js.map +1 -0
  117. package/lib/module/plugins/remoteConfig/remoteConfigStore.js +43 -0
  118. package/lib/module/plugins/remoteConfig/remoteConfigStore.js.map +1 -0
  119. package/lib/module/plugins/stateInspector/StateInspectorPlugin.js +372 -0
  120. package/lib/module/plugins/stateInspector/StateInspectorPlugin.js.map +1 -0
  121. package/lib/module/plugins/stateInspector/stateAdapterRegistry.js +54 -0
  122. package/lib/module/plugins/stateInspector/stateAdapterRegistry.js.map +1 -0
  123. package/lib/module/plugins/storageBrowser/StorageBrowserPlugin.js +489 -0
  124. package/lib/module/plugins/storageBrowser/StorageBrowserPlugin.js.map +1 -0
  125. package/lib/module/plugins/storageBrowser/storageAdapterRegistry.js +36 -0
  126. package/lib/module/plugins/storageBrowser/storageAdapterRegistry.js.map +1 -0
  127. package/lib/module/plugins/timeline/TimelinePlugin.js +287 -0
  128. package/lib/module/plugins/timeline/TimelinePlugin.js.map +1 -0
  129. package/lib/module/plugins/timeline/timelineStore.js +54 -0
  130. package/lib/module/plugins/timeline/timelineStore.js.map +1 -0
  131. package/lib/typescript/core/DebugBubble.d.ts +22 -0
  132. package/lib/typescript/core/DebugBubble.d.ts.map +1 -0
  133. package/lib/typescript/core/DebugOverlay.d.ts +18 -0
  134. package/lib/typescript/core/DebugOverlay.d.ts.map +1 -0
  135. package/lib/typescript/core/DebuggerProvider.d.ts +25 -0
  136. package/lib/typescript/core/DebuggerProvider.d.ts.map +1 -0
  137. package/lib/typescript/core/GestureDetector.d.ts +20 -0
  138. package/lib/typescript/core/GestureDetector.d.ts.map +1 -0
  139. package/lib/typescript/core/PluginRegistry.d.ts +41 -0
  140. package/lib/typescript/core/PluginRegistry.d.ts.map +1 -0
  141. package/lib/typescript/core/theme.d.ts +11 -0
  142. package/lib/typescript/core/theme.d.ts.map +1 -0
  143. package/lib/typescript/core/types.d.ts +269 -0
  144. package/lib/typescript/core/types.d.ts.map +1 -0
  145. package/lib/typescript/core/useDebugger.d.ts +14 -0
  146. package/lib/typescript/core/useDebugger.d.ts.map +1 -0
  147. package/lib/typescript/core/utils.d.ts +46 -0
  148. package/lib/typescript/core/utils.d.ts.map +1 -0
  149. package/lib/typescript/index.d.ts +23 -0
  150. package/lib/typescript/index.d.ts.map +1 -0
  151. package/lib/typescript/plugins/console/ConsoleInterceptor.d.ts +32 -0
  152. package/lib/typescript/plugins/console/ConsoleInterceptor.d.ts.map +1 -0
  153. package/lib/typescript/plugins/console/ConsoleViewerPlugin.d.ts +3 -0
  154. package/lib/typescript/plugins/console/ConsoleViewerPlugin.d.ts.map +1 -0
  155. package/lib/typescript/plugins/crashReporter/CrashReporterPlugin.d.ts +3 -0
  156. package/lib/typescript/plugins/crashReporter/CrashReporterPlugin.d.ts.map +1 -0
  157. package/lib/typescript/plugins/customActions/CustomActionsPlugin.d.ts +3 -0
  158. package/lib/typescript/plugins/customActions/CustomActionsPlugin.d.ts.map +1 -0
  159. package/lib/typescript/plugins/customActions/actionStore.d.ts +16 -0
  160. package/lib/typescript/plugins/customActions/actionStore.d.ts.map +1 -0
  161. package/lib/typescript/plugins/deepLinkTester/DeepLinkTesterPlugin.d.ts +3 -0
  162. package/lib/typescript/plugins/deepLinkTester/DeepLinkTesterPlugin.d.ts.map +1 -0
  163. package/lib/typescript/plugins/deviceInfo/DeviceInfoPlugin.d.ts +3 -0
  164. package/lib/typescript/plugins/deviceInfo/DeviceInfoPlugin.d.ts.map +1 -0
  165. package/lib/typescript/plugins/featureFlags/FeatureFlagsPlugin.d.ts +3 -0
  166. package/lib/typescript/plugins/featureFlags/FeatureFlagsPlugin.d.ts.map +1 -0
  167. package/lib/typescript/plugins/featureFlags/flagStore.d.ts +45 -0
  168. package/lib/typescript/plugins/featureFlags/flagStore.d.ts.map +1 -0
  169. package/lib/typescript/plugins/navigationInspector/NavigationInspectorPlugin.d.ts +3 -0
  170. package/lib/typescript/plugins/navigationInspector/NavigationInspectorPlugin.d.ts.map +1 -0
  171. package/lib/typescript/plugins/navigationInspector/navigationStore.d.ts +30 -0
  172. package/lib/typescript/plugins/navigationInspector/navigationStore.d.ts.map +1 -0
  173. package/lib/typescript/plugins/network/NetworkInspectorPlugin.d.ts +3 -0
  174. package/lib/typescript/plugins/network/NetworkInspectorPlugin.d.ts.map +1 -0
  175. package/lib/typescript/plugins/network/NetworkInterceptor.d.ts +42 -0
  176. package/lib/typescript/plugins/network/NetworkInterceptor.d.ts.map +1 -0
  177. package/lib/typescript/plugins/performance/PerformanceMonitorPlugin.d.ts +3 -0
  178. package/lib/typescript/plugins/performance/PerformanceMonitorPlugin.d.ts.map +1 -0
  179. package/lib/typescript/plugins/remoteConfig/RemoteConfigPlugin.d.ts +3 -0
  180. package/lib/typescript/plugins/remoteConfig/RemoteConfigPlugin.d.ts.map +1 -0
  181. package/lib/typescript/plugins/remoteConfig/remoteConfigStore.d.ts +20 -0
  182. package/lib/typescript/plugins/remoteConfig/remoteConfigStore.d.ts.map +1 -0
  183. package/lib/typescript/plugins/stateInspector/StateInspectorPlugin.d.ts +3 -0
  184. package/lib/typescript/plugins/stateInspector/StateInspectorPlugin.d.ts.map +1 -0
  185. package/lib/typescript/plugins/stateInspector/stateAdapterRegistry.d.ts +34 -0
  186. package/lib/typescript/plugins/stateInspector/stateAdapterRegistry.d.ts.map +1 -0
  187. package/lib/typescript/plugins/storageBrowser/StorageBrowserPlugin.d.ts +3 -0
  188. package/lib/typescript/plugins/storageBrowser/StorageBrowserPlugin.d.ts.map +1 -0
  189. package/lib/typescript/plugins/storageBrowser/storageAdapterRegistry.d.ts +16 -0
  190. package/lib/typescript/plugins/storageBrowser/storageAdapterRegistry.d.ts.map +1 -0
  191. package/lib/typescript/plugins/timeline/TimelinePlugin.d.ts +3 -0
  192. package/lib/typescript/plugins/timeline/TimelinePlugin.d.ts.map +1 -0
  193. package/lib/typescript/plugins/timeline/timelineStore.d.ts +24 -0
  194. package/lib/typescript/plugins/timeline/timelineStore.d.ts.map +1 -0
  195. package/package.json +131 -0
  196. package/src/core/DebugBubble.tsx +149 -0
  197. package/src/core/DebugOverlay.tsx +211 -0
  198. package/src/core/DebuggerProvider.tsx +211 -0
  199. package/src/core/GestureDetector.tsx +95 -0
  200. package/src/core/PluginRegistry.ts +118 -0
  201. package/src/core/theme.ts +41 -0
  202. package/src/core/types.ts +339 -0
  203. package/src/core/useDebugger.ts +24 -0
  204. package/src/core/utils.ts +221 -0
  205. package/src/index.ts +67 -0
  206. package/src/plugins/console/ConsoleInterceptor.ts +110 -0
  207. package/src/plugins/console/ConsoleViewerPlugin.tsx +241 -0
  208. package/src/plugins/crashReporter/CrashReporterPlugin.tsx +316 -0
  209. package/src/plugins/customActions/CustomActionsPlugin.tsx +199 -0
  210. package/src/plugins/customActions/actionStore.ts +49 -0
  211. package/src/plugins/deepLinkTester/DeepLinkTesterPlugin.tsx +213 -0
  212. package/src/plugins/deviceInfo/DeviceInfoPlugin.tsx +153 -0
  213. package/src/plugins/featureFlags/FeatureFlagsPlugin.tsx +338 -0
  214. package/src/plugins/featureFlags/flagStore.ts +118 -0
  215. package/src/plugins/navigationInspector/NavigationInspectorPlugin.tsx +170 -0
  216. package/src/plugins/navigationInspector/navigationStore.ts +70 -0
  217. package/src/plugins/network/NetworkInspectorPlugin.tsx +598 -0
  218. package/src/plugins/network/NetworkInterceptor.ts +344 -0
  219. package/src/plugins/performance/PerformanceMonitorPlugin.tsx +194 -0
  220. package/src/plugins/remoteConfig/RemoteConfigPlugin.tsx +205 -0
  221. package/src/plugins/remoteConfig/remoteConfigStore.ts +48 -0
  222. package/src/plugins/stateInspector/StateInspectorPlugin.tsx +342 -0
  223. package/src/plugins/stateInspector/stateAdapterRegistry.ts +66 -0
  224. package/src/plugins/storageBrowser/StorageBrowserPlugin.tsx +410 -0
  225. package/src/plugins/storageBrowser/storageAdapterRegistry.ts +47 -0
  226. package/src/plugins/timeline/TimelinePlugin.tsx +242 -0
  227. package/src/plugins/timeline/timelineStore.ts +65 -0
@@ -0,0 +1,598 @@
1
+ import React, { useState, useEffect, useCallback, useMemo } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ FlatList,
6
+ TouchableOpacity,
7
+ TextInput,
8
+ StyleSheet,
9
+ ScrollView,
10
+ } from 'react-native';
11
+ import type { PluginComponentProps, NetworkRequest } from '../../core/types';
12
+ import type { DebuggerPlugin } from '../../core/types';
13
+ import { NetworkInterceptor } from './NetworkInterceptor';
14
+ import {
15
+ formatDuration,
16
+ formatBytes,
17
+ formatTimestamp,
18
+ getStatusColor,
19
+ getMethodColor,
20
+ truncate,
21
+ toCurl,
22
+ copyToClipboard,
23
+ safeStringify,
24
+ shareText,
25
+ } from '../../core/utils';
26
+
27
+ // ─── Network Inspector Plugin Component ─────────────────────────────────────
28
+
29
+ const NetworkInspectorPanel: React.FC<PluginComponentProps> = ({ theme }) => {
30
+ const [requests, setRequests] = useState<NetworkRequest[]>([]);
31
+ const [searchQuery, setSearchQuery] = useState('');
32
+ const [selectedRequest, setSelectedRequest] = useState<NetworkRequest | null>(null);
33
+ const [activeDetailTab, setActiveDetailTab] = useState<
34
+ 'headers' | 'request' | 'response' | 'timing'
35
+ >('headers');
36
+ const [methodFilter, setMethodFilter] = useState<string | null>(null);
37
+
38
+ useEffect(() => {
39
+ const unsubscribe = NetworkInterceptor.subscribe(setRequests);
40
+ return unsubscribe;
41
+ }, []);
42
+
43
+ const filteredRequests = useMemo(() => {
44
+ let filtered = requests;
45
+ if (searchQuery) {
46
+ const q = searchQuery.toLowerCase();
47
+ filtered = filtered.filter(
48
+ (r) =>
49
+ r.url.toLowerCase().includes(q) ||
50
+ r.method.toLowerCase().includes(q) ||
51
+ r.gqlOperation?.toLowerCase().includes(q) ||
52
+ String(r.status).includes(q),
53
+ );
54
+ }
55
+ if (methodFilter) {
56
+ filtered = filtered.filter((r) => r.method === methodFilter);
57
+ }
58
+ return filtered;
59
+ }, [requests, searchQuery, methodFilter]);
60
+
61
+ const stats = useMemo(() => {
62
+ const total = requests.length;
63
+ const errors = requests.filter((r) => r.isError).length;
64
+ const pending = requests.filter((r) => !r.endTime).length;
65
+ return { total, errors, pending };
66
+ }, [requests]);
67
+
68
+ const handleClear = useCallback(() => {
69
+ NetworkInterceptor.clear();
70
+ setSelectedRequest(null);
71
+ }, []);
72
+
73
+ const handleCopyCurl = useCallback((req: NetworkRequest) => {
74
+ copyToClipboard(toCurl(req));
75
+ }, []);
76
+
77
+ const handleShareRequest = useCallback((req: NetworkRequest) => {
78
+ const data = safeStringify({
79
+ url: req.url,
80
+ method: req.method,
81
+ status: req.status,
82
+ duration: req.duration,
83
+ requestHeaders: req.requestHeaders,
84
+ responseHeaders: req.responseHeaders,
85
+ requestBody: req.requestBody,
86
+ responseBody: req.responseBody,
87
+ });
88
+ shareText(data, `${req.method} ${req.url}`);
89
+ }, []);
90
+
91
+ if (selectedRequest) {
92
+ return (
93
+ <RequestDetail
94
+ request={selectedRequest}
95
+ theme={theme}
96
+ activeTab={activeDetailTab}
97
+ onTabChange={setActiveDetailTab}
98
+ onBack={() => setSelectedRequest(null)}
99
+ onCopyCurl={handleCopyCurl}
100
+ onShare={handleShareRequest}
101
+ />
102
+ );
103
+ }
104
+
105
+ return (
106
+ <View style={styles.container}>
107
+ {/* Stats Bar */}
108
+ <View style={[styles.statsBar, { backgroundColor: theme.surface }]}>
109
+ <View style={styles.statsRow}>
110
+ <Text style={[styles.statText, { color: theme.text }]}>{stats.total} requests</Text>
111
+ {stats.errors > 0 && (
112
+ <Text style={[styles.statText, { color: theme.error }]}>{stats.errors} errors</Text>
113
+ )}
114
+ {stats.pending > 0 && (
115
+ <Text style={[styles.statText, { color: theme.warning }]}>{stats.pending} pending</Text>
116
+ )}
117
+ </View>
118
+ <TouchableOpacity onPress={handleClear} activeOpacity={0.7}>
119
+ <Text style={[styles.clearButton, { color: theme.error }]}>Clear</Text>
120
+ </TouchableOpacity>
121
+ </View>
122
+
123
+ {/* Search */}
124
+ <View style={[styles.searchContainer, { backgroundColor: theme.surface }]}>
125
+ <TextInput
126
+ style={[
127
+ styles.searchInput,
128
+ { color: theme.text, backgroundColor: theme.surfaceAlt, borderColor: theme.border },
129
+ ]}
130
+ placeholder="Search URL, method, status..."
131
+ placeholderTextColor={theme.textMuted}
132
+ value={searchQuery}
133
+ onChangeText={setSearchQuery}
134
+ autoCapitalize="none"
135
+ autoCorrect={false}
136
+ />
137
+ </View>
138
+
139
+ {/* Method Filters */}
140
+ <ScrollView
141
+ horizontal
142
+ showsHorizontalScrollIndicator={false}
143
+ style={[styles.filterContainer, { backgroundColor: theme.surface }]}
144
+ contentContainerStyle={styles.filterContent}
145
+ >
146
+ {['ALL', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'].map((method) => (
147
+ <TouchableOpacity
148
+ key={method}
149
+ style={[
150
+ styles.filterChip,
151
+ {
152
+ backgroundColor:
153
+ (method === 'ALL' && !methodFilter) || methodFilter === method
154
+ ? theme.accent
155
+ : theme.surfaceAlt,
156
+ borderColor: theme.border,
157
+ },
158
+ ]}
159
+ onPress={() => setMethodFilter(method === 'ALL' ? null : method)}
160
+ activeOpacity={0.7}
161
+ >
162
+ <Text
163
+ style={[
164
+ styles.filterChipText,
165
+ {
166
+ color:
167
+ (method === 'ALL' && !methodFilter) || methodFilter === method
168
+ ? '#FFFFFF'
169
+ : theme.textSecondary,
170
+ },
171
+ ]}
172
+ >
173
+ {method}
174
+ </Text>
175
+ </TouchableOpacity>
176
+ ))}
177
+ </ScrollView>
178
+
179
+ {/* Request List */}
180
+ <FlatList
181
+ data={filteredRequests}
182
+ keyExtractor={(item) => item.id}
183
+ renderItem={({ item }) => (
184
+ <RequestRow request={item} theme={theme} onPress={() => setSelectedRequest(item)} />
185
+ )}
186
+ ListEmptyComponent={
187
+ <View style={styles.emptyContainer}>
188
+ <Text style={[styles.emptyText, { color: theme.textMuted }]}>
189
+ {searchQuery ? 'No matching requests' : 'No network requests captured yet'}
190
+ </Text>
191
+ </View>
192
+ }
193
+ initialNumToRender={20}
194
+ maxToRenderPerBatch={10}
195
+ windowSize={10}
196
+ />
197
+ </View>
198
+ );
199
+ };
200
+
201
+ // ─── Request Row ────────────────────────────────────────────────────────────
202
+
203
+ interface RequestRowProps {
204
+ request: NetworkRequest;
205
+ theme: PluginComponentProps['theme'];
206
+ onPress: () => void;
207
+ }
208
+
209
+ const RequestRow: React.FC<RequestRowProps> = React.memo(({ request, theme, onPress }) => {
210
+ const urlPath = useMemo(() => {
211
+ try {
212
+ const parsed = new URL(request.url);
213
+ return parsed.pathname + parsed.search;
214
+ } catch {
215
+ return request.url;
216
+ }
217
+ }, [request.url]);
218
+
219
+ return (
220
+ <TouchableOpacity
221
+ style={[
222
+ styles.requestRow,
223
+ {
224
+ backgroundColor: request.isError ? `${theme.error}10` : theme.surface,
225
+ borderBottomColor: theme.border,
226
+ },
227
+ ]}
228
+ onPress={onPress}
229
+ activeOpacity={0.7}
230
+ >
231
+ <View style={styles.requestRowLeft}>
232
+ <View style={styles.requestMethodContainer}>
233
+ <Text style={[styles.requestMethod, { color: getMethodColor(request.method) }]}>
234
+ {request.method}
235
+ </Text>
236
+ <Text style={[styles.requestStatus, { color: getStatusColor(request.status) }]}>
237
+ {request.status ?? '...'}
238
+ </Text>
239
+ </View>
240
+ <Text style={[styles.requestUrl, { color: theme.text }]} numberOfLines={1}>
241
+ {request.gqlOperation
242
+ ? `[${request.gqlType}] ${request.gqlOperation}`
243
+ : truncate(urlPath, 60)}
244
+ </Text>
245
+ </View>
246
+ <View style={styles.requestRowRight}>
247
+ <Text style={[styles.requestDuration, { color: theme.textSecondary }]}>
248
+ {formatDuration(request.duration)}
249
+ </Text>
250
+ <Text style={[styles.requestSize, { color: theme.textMuted }]}>
251
+ {formatBytes(request.responseSize)}
252
+ </Text>
253
+ <Text style={[styles.requestTime, { color: theme.textMuted }]}>
254
+ {formatTimestamp(request.startTime)}
255
+ </Text>
256
+ </View>
257
+ </TouchableOpacity>
258
+ );
259
+ });
260
+
261
+ // ─── Request Detail ─────────────────────────────────────────────────────────
262
+
263
+ interface RequestDetailProps {
264
+ request: NetworkRequest;
265
+ theme: PluginComponentProps['theme'];
266
+ activeTab: 'headers' | 'request' | 'response' | 'timing';
267
+ onTabChange: (tab: 'headers' | 'request' | 'response' | 'timing') => void;
268
+ onBack: () => void;
269
+ onCopyCurl: (req: NetworkRequest) => void;
270
+ onShare: (req: NetworkRequest) => void;
271
+ }
272
+
273
+ const RequestDetail: React.FC<RequestDetailProps> = ({
274
+ request,
275
+ theme,
276
+ activeTab,
277
+ onTabChange,
278
+ onBack,
279
+ onCopyCurl,
280
+ onShare,
281
+ }) => {
282
+ const tabs = ['headers', 'request', 'response', 'timing'] as const;
283
+
284
+ return (
285
+ <View style={styles.container}>
286
+ {/* Detail Header */}
287
+ <View
288
+ style={[
289
+ styles.detailHeader,
290
+ { backgroundColor: theme.surface, borderBottomColor: theme.border },
291
+ ]}
292
+ >
293
+ <TouchableOpacity onPress={onBack} activeOpacity={0.7}>
294
+ <Text style={[styles.backButton, { color: theme.accent }]}>← Back</Text>
295
+ </TouchableOpacity>
296
+ <View style={styles.detailActions}>
297
+ <TouchableOpacity
298
+ onPress={() => onCopyCurl(request)}
299
+ style={[styles.actionButton, { backgroundColor: theme.surfaceAlt }]}
300
+ activeOpacity={0.7}
301
+ >
302
+ <Text style={[styles.actionButtonText, { color: theme.textSecondary }]}>cURL</Text>
303
+ </TouchableOpacity>
304
+ <TouchableOpacity
305
+ onPress={() => onShare(request)}
306
+ style={[styles.actionButton, { backgroundColor: theme.surfaceAlt }]}
307
+ activeOpacity={0.7}
308
+ >
309
+ <Text style={[styles.actionButtonText, { color: theme.textSecondary }]}>Share</Text>
310
+ </TouchableOpacity>
311
+ </View>
312
+ </View>
313
+
314
+ {/* URL Display */}
315
+ <View style={[styles.urlDisplay, { backgroundColor: theme.codeBackground }]}>
316
+ <Text style={[styles.urlMethod, { color: getMethodColor(request.method) }]}>
317
+ {request.method}
318
+ </Text>
319
+ <Text style={[styles.urlText, { color: theme.codeText }]} selectable>
320
+ {request.url}
321
+ </Text>
322
+ </View>
323
+
324
+ {/* Detail Tabs */}
325
+ <View style={[styles.detailTabBar, { backgroundColor: theme.surface }]}>
326
+ {tabs.map((tab) => (
327
+ <TouchableOpacity
328
+ key={tab}
329
+ style={[
330
+ styles.detailTab,
331
+ {
332
+ borderBottomColor: activeTab === tab ? theme.accent : 'transparent',
333
+ },
334
+ ]}
335
+ onPress={() => onTabChange(tab)}
336
+ activeOpacity={0.7}
337
+ >
338
+ <Text
339
+ style={[
340
+ styles.detailTabText,
341
+ { color: activeTab === tab ? theme.accent : theme.textSecondary },
342
+ ]}
343
+ >
344
+ {tab.charAt(0).toUpperCase() + tab.slice(1)}
345
+ </Text>
346
+ </TouchableOpacity>
347
+ ))}
348
+ </View>
349
+
350
+ {/* Tab Content */}
351
+ <ScrollView style={styles.detailContent}>
352
+ {activeTab === 'headers' && <HeadersView request={request} theme={theme} />}
353
+ {activeTab === 'request' && (
354
+ <BodyView body={request.requestBody} theme={theme} label="Request Body" />
355
+ )}
356
+ {activeTab === 'response' && (
357
+ <BodyView body={request.responseBody} theme={theme} label="Response Body" />
358
+ )}
359
+ {activeTab === 'timing' && <TimingView request={request} theme={theme} />}
360
+ </ScrollView>
361
+ </View>
362
+ );
363
+ };
364
+
365
+ // ─── Sub-views ──────────────────────────────────────────────────────────────
366
+
367
+ const HeadersView: React.FC<{ request: NetworkRequest; theme: PluginComponentProps['theme'] }> = ({
368
+ request,
369
+ theme,
370
+ }) => (
371
+ <View style={styles.sectionContainer}>
372
+ <Text style={[styles.sectionTitle, { color: theme.text }]}>Request Headers</Text>
373
+ {request.requestHeaders && Object.keys(request.requestHeaders).length > 0 ? (
374
+ Object.entries(request.requestHeaders).map(([key, value]) => (
375
+ <View key={key} style={[styles.headerRow, { borderBottomColor: theme.border }]}>
376
+ <Text style={[styles.headerKey, { color: theme.accent }]}>{key}</Text>
377
+ <Text style={[styles.headerValue, { color: theme.text }]} selectable>
378
+ {value}
379
+ </Text>
380
+ </View>
381
+ ))
382
+ ) : (
383
+ <Text style={[styles.emptyText, { color: theme.textMuted }]}>No headers</Text>
384
+ )}
385
+
386
+ <Text style={[styles.sectionTitle, { color: theme.text, marginTop: 16 }]}>
387
+ Response Headers
388
+ </Text>
389
+ {request.responseHeaders && Object.keys(request.responseHeaders).length > 0 ? (
390
+ Object.entries(request.responseHeaders).map(([key, value]) => (
391
+ <View key={key} style={[styles.headerRow, { borderBottomColor: theme.border }]}>
392
+ <Text style={[styles.headerKey, { color: theme.accent }]}>{key}</Text>
393
+ <Text style={[styles.headerValue, { color: theme.text }]} selectable>
394
+ {value}
395
+ </Text>
396
+ </View>
397
+ ))
398
+ ) : (
399
+ <Text style={[styles.emptyText, { color: theme.textMuted }]}>
400
+ {request.endTime ? 'No headers' : 'Pending...'}
401
+ </Text>
402
+ )}
403
+ </View>
404
+ );
405
+
406
+ const BodyView: React.FC<{
407
+ body: string | undefined;
408
+ theme: PluginComponentProps['theme'];
409
+ label: string;
410
+ }> = ({ body, theme, label }) => {
411
+ const formatted = useMemo(() => {
412
+ if (!body) return null;
413
+ try {
414
+ const parsed = JSON.parse(body);
415
+ return JSON.stringify(parsed, null, 2);
416
+ } catch {
417
+ return body;
418
+ }
419
+ }, [body]);
420
+
421
+ return (
422
+ <View style={styles.sectionContainer}>
423
+ <View style={styles.sectionHeaderRow}>
424
+ <Text style={[styles.sectionTitle, { color: theme.text }]}>{label}</Text>
425
+ {formatted && (
426
+ <TouchableOpacity onPress={() => copyToClipboard(formatted)} activeOpacity={0.7}>
427
+ <Text style={[styles.copyButton, { color: theme.accent }]}>Copy</Text>
428
+ </TouchableOpacity>
429
+ )}
430
+ </View>
431
+ {formatted ? (
432
+ <View style={[styles.codeBlock, { backgroundColor: theme.codeBackground }]}>
433
+ <Text style={[styles.codeText, { color: theme.codeText }]} selectable>
434
+ {formatted}
435
+ </Text>
436
+ </View>
437
+ ) : (
438
+ <Text style={[styles.emptyText, { color: theme.textMuted }]}>No body</Text>
439
+ )}
440
+ </View>
441
+ );
442
+ };
443
+
444
+ const TimingView: React.FC<{ request: NetworkRequest; theme: PluginComponentProps['theme'] }> = ({
445
+ request,
446
+ theme,
447
+ }) => (
448
+ <View style={styles.sectionContainer}>
449
+ <View style={[styles.timingRow, { borderBottomColor: theme.border }]}>
450
+ <Text style={[styles.timingLabel, { color: theme.textSecondary }]}>Started</Text>
451
+ <Text style={[styles.timingValue, { color: theme.text }]}>
452
+ {formatTimestamp(request.startTime)}
453
+ </Text>
454
+ </View>
455
+ {request.endTime && (
456
+ <View style={[styles.timingRow, { borderBottomColor: theme.border }]}>
457
+ <Text style={[styles.timingLabel, { color: theme.textSecondary }]}>Completed</Text>
458
+ <Text style={[styles.timingValue, { color: theme.text }]}>
459
+ {formatTimestamp(request.endTime)}
460
+ </Text>
461
+ </View>
462
+ )}
463
+ <View style={[styles.timingRow, { borderBottomColor: theme.border }]}>
464
+ <Text style={[styles.timingLabel, { color: theme.textSecondary }]}>Duration</Text>
465
+ <Text
466
+ style={[
467
+ styles.timingValue,
468
+ { color: request.duration && request.duration > 3000 ? theme.warning : theme.success },
469
+ ]}
470
+ >
471
+ {formatDuration(request.duration)}
472
+ </Text>
473
+ </View>
474
+ <View style={[styles.timingRow, { borderBottomColor: theme.border }]}>
475
+ <Text style={[styles.timingLabel, { color: theme.textSecondary }]}>Request Size</Text>
476
+ <Text style={[styles.timingValue, { color: theme.text }]}>
477
+ {formatBytes(request.requestSize)}
478
+ </Text>
479
+ </View>
480
+ <View style={[styles.timingRow, { borderBottomColor: theme.border }]}>
481
+ <Text style={[styles.timingLabel, { color: theme.textSecondary }]}>Response Size</Text>
482
+ <Text style={[styles.timingValue, { color: theme.text }]}>
483
+ {formatBytes(request.responseSize)}
484
+ </Text>
485
+ </View>
486
+ </View>
487
+ );
488
+
489
+ // ─── Styles ─────────────────────────────────────────────────────────────────
490
+
491
+ const styles = StyleSheet.create({
492
+ container: { flex: 1 },
493
+ statsBar: {
494
+ flexDirection: 'row',
495
+ justifyContent: 'space-between',
496
+ alignItems: 'center',
497
+ paddingHorizontal: 12,
498
+ paddingVertical: 8,
499
+ },
500
+ statsRow: { flexDirection: 'row', gap: 12 },
501
+ statText: { fontSize: 12, fontWeight: '600' },
502
+ clearButton: { fontSize: 13, fontWeight: '700' },
503
+ searchContainer: { paddingHorizontal: 12, paddingBottom: 8 },
504
+ searchInput: {
505
+ height: 36,
506
+ borderRadius: 8,
507
+ paddingHorizontal: 12,
508
+ fontSize: 13,
509
+ borderWidth: 1,
510
+ },
511
+ filterContainer: { maxHeight: 44 },
512
+ filterContent: { paddingHorizontal: 12, paddingBottom: 8, gap: 6 },
513
+ filterChip: {
514
+ paddingHorizontal: 12,
515
+ paddingVertical: 4,
516
+ borderRadius: 12,
517
+ borderWidth: 1,
518
+ },
519
+ filterChipText: { fontSize: 11, fontWeight: '600' },
520
+ requestRow: {
521
+ flexDirection: 'row',
522
+ justifyContent: 'space-between',
523
+ alignItems: 'center',
524
+ paddingHorizontal: 12,
525
+ paddingVertical: 10,
526
+ borderBottomWidth: StyleSheet.hairlineWidth,
527
+ },
528
+ requestRowLeft: { flex: 1, marginRight: 8 },
529
+ requestRowRight: { alignItems: 'flex-end' },
530
+ requestMethodContainer: { flexDirection: 'row', alignItems: 'center', gap: 8, marginBottom: 2 },
531
+ requestMethod: { fontSize: 11, fontWeight: '800', letterSpacing: 0.5 },
532
+ requestStatus: { fontSize: 11, fontWeight: '700' },
533
+ requestUrl: { fontSize: 12 },
534
+ requestDuration: { fontSize: 11, fontWeight: '600' },
535
+ requestSize: { fontSize: 10, marginTop: 1 },
536
+ requestTime: { fontSize: 10, marginTop: 1 },
537
+ emptyContainer: { alignItems: 'center', paddingVertical: 40 },
538
+ emptyText: { fontSize: 13 },
539
+ detailHeader: {
540
+ flexDirection: 'row',
541
+ justifyContent: 'space-between',
542
+ alignItems: 'center',
543
+ paddingHorizontal: 12,
544
+ paddingVertical: 10,
545
+ borderBottomWidth: StyleSheet.hairlineWidth,
546
+ },
547
+ backButton: { fontSize: 14, fontWeight: '600' },
548
+ detailActions: { flexDirection: 'row', gap: 8 },
549
+ actionButton: { paddingHorizontal: 10, paddingVertical: 4, borderRadius: 8 },
550
+ actionButtonText: { fontSize: 11, fontWeight: '600' },
551
+ urlDisplay: { padding: 12, flexDirection: 'row', alignItems: 'flex-start', gap: 8 },
552
+ urlMethod: { fontSize: 12, fontWeight: '800' },
553
+ urlText: { fontSize: 11, flex: 1 },
554
+ detailTabBar: { flexDirection: 'row' },
555
+ detailTab: { flex: 1, alignItems: 'center', paddingVertical: 10, borderBottomWidth: 2 },
556
+ detailTabText: { fontSize: 12, fontWeight: '600' },
557
+ detailContent: { flex: 1 },
558
+ sectionContainer: { padding: 12 },
559
+ sectionTitle: { fontSize: 14, fontWeight: '700', marginBottom: 8 },
560
+ sectionHeaderRow: {
561
+ flexDirection: 'row',
562
+ justifyContent: 'space-between',
563
+ alignItems: 'center',
564
+ marginBottom: 8,
565
+ },
566
+ copyButton: { fontSize: 12, fontWeight: '600' },
567
+ headerRow: {
568
+ flexDirection: 'row',
569
+ paddingVertical: 6,
570
+ borderBottomWidth: StyleSheet.hairlineWidth,
571
+ },
572
+ headerKey: { fontSize: 11, fontWeight: '600', width: 120, marginRight: 8 },
573
+ headerValue: { fontSize: 11, flex: 1 },
574
+ codeBlock: { padding: 12, borderRadius: 8 },
575
+ codeText: { fontSize: 11, fontFamily: 'monospace', lineHeight: 18 },
576
+ timingRow: {
577
+ flexDirection: 'row',
578
+ justifyContent: 'space-between',
579
+ paddingVertical: 10,
580
+ borderBottomWidth: StyleSheet.hairlineWidth,
581
+ },
582
+ timingLabel: { fontSize: 13 },
583
+ timingValue: { fontSize: 13, fontWeight: '600' },
584
+ });
585
+
586
+ // ─── Plugin Factory ─────────────────────────────────────────────────────────
587
+
588
+ export function createNetworkInspectorPlugin(): DebuggerPlugin {
589
+ return {
590
+ id: 'network-inspector',
591
+ name: 'Network',
592
+ icon: '🌐',
593
+ component: NetworkInspectorPanel,
594
+ order: 10,
595
+ onInit: () => NetworkInterceptor.start(),
596
+ onDestroy: () => NetworkInterceptor.stop(),
597
+ };
598
+ }