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,410 @@
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
+ Alert,
11
+ } from 'react-native';
12
+ import type { PluginComponentProps, StorageAdapter, DebuggerPlugin } from '../../core/types';
13
+ import { storageAdapterRegistry } from './storageAdapterRegistry';
14
+ import { copyToClipboard, safeStringify, safeParse } from '../../core/utils';
15
+
16
+ const StorageBrowserPanel: React.FC<PluginComponentProps> = ({ theme }) => {
17
+ const [adapters, setAdapters] = useState<Map<string, StorageAdapter>>(new Map());
18
+ const [activeAdapterId, setActiveAdapterId] = useState<string | null>(null);
19
+ const [keys, setKeys] = useState<string[]>([]);
20
+ const [searchQuery, setSearchQuery] = useState('');
21
+ const [selectedKey, setSelectedKey] = useState<string | null>(null);
22
+ const [selectedValue, setSelectedValue] = useState<string>('');
23
+ const [isEditing, setIsEditing] = useState(false);
24
+ const [editValue, setEditValue] = useState('');
25
+ const [loading, setLoading] = useState(false);
26
+
27
+ useEffect(() => {
28
+ const unsubscribe = storageAdapterRegistry.subscribe(() => {
29
+ const all = storageAdapterRegistry.getAll();
30
+ setAdapters(all);
31
+ if (!activeAdapterId && all.size > 0) {
32
+ setActiveAdapterId(Array.from(all.keys())[0]);
33
+ }
34
+ });
35
+ const all = storageAdapterRegistry.getAll();
36
+ setAdapters(all);
37
+ if (all.size > 0) setActiveAdapterId(Array.from(all.keys())[0]);
38
+ return unsubscribe;
39
+ }, []);
40
+
41
+ const activeAdapter = activeAdapterId ? adapters.get(activeAdapterId) : null;
42
+
43
+ const loadKeys = useCallback(async () => {
44
+ if (!activeAdapter) return;
45
+ setLoading(true);
46
+ try {
47
+ const allKeys = await activeAdapter.getAllKeys();
48
+ setKeys(allKeys.sort());
49
+ } catch {
50
+ setKeys([]);
51
+ }
52
+ setLoading(false);
53
+ }, [activeAdapter]);
54
+
55
+ useEffect(() => {
56
+ loadKeys();
57
+ }, [loadKeys]);
58
+
59
+ const handleSelectKey = useCallback(
60
+ async (key: string) => {
61
+ if (!activeAdapter) return;
62
+ setSelectedKey(key);
63
+ try {
64
+ const value = await activeAdapter.getItem(key);
65
+ setSelectedValue(value ?? '');
66
+ } catch {
67
+ setSelectedValue('[Error reading value]');
68
+ }
69
+ },
70
+ [activeAdapter],
71
+ );
72
+
73
+ const handleSave = useCallback(async () => {
74
+ if (!activeAdapter || !selectedKey) return;
75
+ try {
76
+ await activeAdapter.setItem(selectedKey, editValue);
77
+ setSelectedValue(editValue);
78
+ setIsEditing(false);
79
+ } catch {
80
+ /* ignore */
81
+ }
82
+ }, [activeAdapter, selectedKey, editValue]);
83
+
84
+ const handleDelete = useCallback(
85
+ async (key: string) => {
86
+ if (!activeAdapter) return;
87
+ Alert.alert('Delete', `Delete "${key}"?`, [
88
+ { text: 'Cancel', style: 'cancel' },
89
+ {
90
+ text: 'Delete',
91
+ style: 'destructive',
92
+ onPress: async () => {
93
+ try {
94
+ await activeAdapter.removeItem(key);
95
+ if (selectedKey === key) {
96
+ setSelectedKey(null);
97
+ setSelectedValue('');
98
+ }
99
+ loadKeys();
100
+ } catch {
101
+ /* ignore */
102
+ }
103
+ },
104
+ },
105
+ ]);
106
+ },
107
+ [activeAdapter, selectedKey, loadKeys],
108
+ );
109
+
110
+ const handleExportAll = useCallback(async () => {
111
+ if (!activeAdapter) return;
112
+ const data: Record<string, string | null> = {};
113
+ for (const key of keys) {
114
+ try {
115
+ data[key] = await activeAdapter.getItem(key);
116
+ } catch {
117
+ data[key] = null;
118
+ }
119
+ }
120
+ copyToClipboard(safeStringify(data));
121
+ }, [activeAdapter, keys]);
122
+
123
+ const filteredKeys = useMemo(() => {
124
+ if (!searchQuery) return keys;
125
+ const q = searchQuery.toLowerCase();
126
+ return keys.filter((k) => k.toLowerCase().includes(q));
127
+ }, [keys, searchQuery]);
128
+
129
+ const formattedValue = useMemo(() => {
130
+ const parsed = safeParse(selectedValue);
131
+ if (parsed !== null && typeof parsed === 'object') return safeStringify(parsed);
132
+ return selectedValue;
133
+ }, [selectedValue]);
134
+
135
+ if (adapters.size === 0) {
136
+ return (
137
+ <View style={styles.emptyContainer}>
138
+ <Text style={styles.emptyIcon}>💾</Text>
139
+ <Text style={[styles.emptyTitle, { color: theme.text }]}>No Storage Adapters</Text>
140
+ <Text style={[styles.emptyDesc, { color: theme.textMuted }]}>
141
+ Register an adapter:{'\n\n'}
142
+ <Text style={{ fontFamily: 'monospace', color: theme.codeText }}>
143
+ {
144
+ 'setStorageAdapter("async", {\n name: "AsyncStorage",\n getAllKeys: () => AsyncStorage.getAllKeys(),\n getItem: (k) => AsyncStorage.getItem(k),\n setItem: (k,v) => AsyncStorage.setItem(k,v),\n removeItem: (k) => AsyncStorage.removeItem(k),\n})'
145
+ }
146
+ </Text>
147
+ </Text>
148
+ </View>
149
+ );
150
+ }
151
+
152
+ if (selectedKey) {
153
+ return (
154
+ <View style={styles.container}>
155
+ <View
156
+ style={[
157
+ styles.detailHeader,
158
+ { backgroundColor: theme.surface, borderBottomColor: theme.border },
159
+ ]}
160
+ >
161
+ <TouchableOpacity
162
+ onPress={() => {
163
+ setSelectedKey(null);
164
+ setIsEditing(false);
165
+ }}
166
+ activeOpacity={0.7}
167
+ >
168
+ <Text style={[styles.backBtn, { color: theme.accent }]}>← Back</Text>
169
+ </TouchableOpacity>
170
+ <View style={styles.detailActions}>
171
+ {!isEditing && (
172
+ <TouchableOpacity
173
+ onPress={() => {
174
+ setEditValue(selectedValue);
175
+ setIsEditing(true);
176
+ }}
177
+ activeOpacity={0.7}
178
+ >
179
+ <Text style={[styles.actionText, { color: theme.accent }]}>Edit</Text>
180
+ </TouchableOpacity>
181
+ )}
182
+ <TouchableOpacity onPress={() => copyToClipboard(selectedValue)} activeOpacity={0.7}>
183
+ <Text style={[styles.actionText, { color: theme.accent }]}>Copy</Text>
184
+ </TouchableOpacity>
185
+ <TouchableOpacity onPress={() => handleDelete(selectedKey)} activeOpacity={0.7}>
186
+ <Text style={[styles.actionText, { color: theme.error }]}>Delete</Text>
187
+ </TouchableOpacity>
188
+ </View>
189
+ </View>
190
+ <View style={[styles.keyDisplay, { backgroundColor: theme.codeBackground }]}>
191
+ <Text style={[styles.keyText, { color: theme.codeText }]} selectable>
192
+ {selectedKey}
193
+ </Text>
194
+ </View>
195
+ {isEditing ? (
196
+ <View style={styles.editSection}>
197
+ <TextInput
198
+ style={[
199
+ styles.editArea,
200
+ { color: theme.text, backgroundColor: theme.surfaceAlt, borderColor: theme.border },
201
+ ]}
202
+ value={editValue}
203
+ onChangeText={setEditValue}
204
+ multiline
205
+ textAlignVertical="top"
206
+ />
207
+ <View style={styles.editBtns}>
208
+ <TouchableOpacity
209
+ onPress={handleSave}
210
+ style={[styles.saveBtn, { backgroundColor: theme.success }]}
211
+ activeOpacity={0.7}
212
+ >
213
+ <Text style={styles.saveBtnText}>Save</Text>
214
+ </TouchableOpacity>
215
+ <TouchableOpacity onPress={() => setIsEditing(false)} activeOpacity={0.7}>
216
+ <Text style={[styles.cancelBtnText, { color: theme.textMuted }]}>Cancel</Text>
217
+ </TouchableOpacity>
218
+ </View>
219
+ </View>
220
+ ) : (
221
+ <ScrollView style={styles.valueScrollView}>
222
+ <View style={[styles.valueBlock, { backgroundColor: theme.codeBackground }]}>
223
+ <Text style={[styles.valueCode, { color: theme.codeText }]} selectable>
224
+ {formattedValue}
225
+ </Text>
226
+ </View>
227
+ </ScrollView>
228
+ )}
229
+ </View>
230
+ );
231
+ }
232
+
233
+ return (
234
+ <View style={styles.container}>
235
+ {/* Adapter Selector */}
236
+ {Array.from(adapters.keys()).length > 1 && (
237
+ <ScrollView
238
+ horizontal
239
+ showsHorizontalScrollIndicator={false}
240
+ style={[styles.adapterBar, { backgroundColor: theme.surface }]}
241
+ contentContainerStyle={styles.adapterBarContent}
242
+ >
243
+ {Array.from(adapters.entries()).map(([id, adapter]) => (
244
+ <TouchableOpacity
245
+ key={id}
246
+ style={[
247
+ styles.adapterChip,
248
+ {
249
+ backgroundColor: id === activeAdapterId ? theme.accent : theme.surfaceAlt,
250
+ borderColor: theme.border,
251
+ },
252
+ ]}
253
+ onPress={() => setActiveAdapterId(id)}
254
+ activeOpacity={0.7}
255
+ >
256
+ <Text
257
+ style={[
258
+ styles.adapterChipText,
259
+ { color: id === activeAdapterId ? '#FFF' : theme.textSecondary },
260
+ ]}
261
+ >
262
+ {adapter.name}
263
+ </Text>
264
+ </TouchableOpacity>
265
+ ))}
266
+ </ScrollView>
267
+ )}
268
+
269
+ <View
270
+ style={[
271
+ styles.actionBar,
272
+ { backgroundColor: theme.surface, borderBottomColor: theme.border },
273
+ ]}
274
+ >
275
+ <Text style={[styles.keyCount, { color: theme.text }]}>{keys.length} keys</Text>
276
+ <View style={styles.actionBarBtns}>
277
+ <TouchableOpacity onPress={loadKeys} activeOpacity={0.7}>
278
+ <Text style={[styles.actionText, { color: theme.accent }]}>↻ Refresh</Text>
279
+ </TouchableOpacity>
280
+ <TouchableOpacity onPress={handleExportAll} activeOpacity={0.7}>
281
+ <Text style={[styles.actionText, { color: theme.accent }]}>Export</Text>
282
+ </TouchableOpacity>
283
+ </View>
284
+ </View>
285
+
286
+ <View style={[styles.searchContainer, { backgroundColor: theme.surface }]}>
287
+ <TextInput
288
+ style={[
289
+ styles.searchInput,
290
+ { color: theme.text, backgroundColor: theme.surfaceAlt, borderColor: theme.border },
291
+ ]}
292
+ placeholder="Search keys..."
293
+ placeholderTextColor={theme.textMuted}
294
+ value={searchQuery}
295
+ onChangeText={setSearchQuery}
296
+ autoCapitalize="none"
297
+ />
298
+ </View>
299
+
300
+ <FlatList
301
+ data={filteredKeys}
302
+ keyExtractor={(item) => item}
303
+ renderItem={({ item }) => (
304
+ <TouchableOpacity
305
+ style={[styles.keyRow, { borderBottomColor: theme.border }]}
306
+ onPress={() => handleSelectKey(item)}
307
+ onLongPress={() => handleDelete(item)}
308
+ activeOpacity={0.7}
309
+ >
310
+ <Text style={[styles.keyName, { color: theme.text }]}>{item}</Text>
311
+ <Text style={[styles.keyArrow, { color: theme.textMuted }]}>›</Text>
312
+ </TouchableOpacity>
313
+ )}
314
+ ListEmptyComponent={
315
+ <View style={styles.emptyListContainer}>
316
+ <Text style={[styles.emptyText, { color: theme.textMuted }]}>
317
+ {loading ? 'Loading...' : 'No storage keys'}
318
+ </Text>
319
+ </View>
320
+ }
321
+ />
322
+ </View>
323
+ );
324
+ };
325
+
326
+ const styles = StyleSheet.create({
327
+ container: { flex: 1 },
328
+ emptyContainer: {
329
+ flex: 1,
330
+ alignItems: 'center',
331
+ justifyContent: 'center',
332
+ paddingHorizontal: 32,
333
+ },
334
+ emptyIcon: { fontSize: 48, marginBottom: 16 },
335
+ emptyTitle: { fontSize: 16, fontWeight: '700', marginBottom: 8 },
336
+ emptyDesc: { fontSize: 13, textAlign: 'center', lineHeight: 20 },
337
+ adapterBar: { maxHeight: 44 },
338
+ adapterBarContent: { paddingHorizontal: 12, paddingVertical: 8, gap: 6 },
339
+ adapterChip: { paddingHorizontal: 12, paddingVertical: 4, borderRadius: 12, borderWidth: 1 },
340
+ adapterChipText: { fontSize: 12, fontWeight: '600' },
341
+ actionBar: {
342
+ flexDirection: 'row',
343
+ justifyContent: 'space-between',
344
+ alignItems: 'center',
345
+ paddingHorizontal: 12,
346
+ paddingVertical: 8,
347
+ borderBottomWidth: StyleSheet.hairlineWidth,
348
+ },
349
+ keyCount: { fontSize: 13, fontWeight: '600' },
350
+ actionBarBtns: { flexDirection: 'row', gap: 12 },
351
+ actionText: { fontSize: 12, fontWeight: '600' },
352
+ searchContainer: { paddingHorizontal: 12, paddingVertical: 8 },
353
+ searchInput: { height: 36, borderRadius: 8, paddingHorizontal: 12, fontSize: 13, borderWidth: 1 },
354
+ keyRow: {
355
+ flexDirection: 'row',
356
+ justifyContent: 'space-between',
357
+ alignItems: 'center',
358
+ paddingHorizontal: 12,
359
+ paddingVertical: 12,
360
+ borderBottomWidth: StyleSheet.hairlineWidth,
361
+ },
362
+ keyName: { fontSize: 13, fontFamily: 'monospace', flex: 1 },
363
+ keyArrow: { fontSize: 18 },
364
+ emptyListContainer: { alignItems: 'center', paddingVertical: 40 },
365
+ emptyText: { fontSize: 13 },
366
+ detailHeader: {
367
+ flexDirection: 'row',
368
+ justifyContent: 'space-between',
369
+ alignItems: 'center',
370
+ paddingHorizontal: 12,
371
+ paddingVertical: 10,
372
+ borderBottomWidth: StyleSheet.hairlineWidth,
373
+ },
374
+ backBtn: { fontSize: 14, fontWeight: '600' },
375
+ detailActions: { flexDirection: 'row', gap: 12 },
376
+ keyDisplay: { padding: 12 },
377
+ keyText: { fontSize: 12, fontFamily: 'monospace' },
378
+ valueScrollView: { flex: 1 },
379
+ valueBlock: { padding: 12, margin: 12, borderRadius: 8 },
380
+ valueCode: { fontSize: 12, fontFamily: 'monospace', lineHeight: 18 },
381
+ editSection: { flex: 1, padding: 12 },
382
+ editArea: {
383
+ flex: 1,
384
+ borderWidth: 1,
385
+ borderRadius: 8,
386
+ padding: 12,
387
+ fontSize: 12,
388
+ fontFamily: 'monospace',
389
+ },
390
+ editBtns: {
391
+ flexDirection: 'row',
392
+ alignItems: 'center',
393
+ gap: 12,
394
+ marginTop: 12,
395
+ justifyContent: 'flex-end',
396
+ },
397
+ saveBtn: { paddingHorizontal: 20, paddingVertical: 8, borderRadius: 8 },
398
+ saveBtnText: { color: '#FFF', fontWeight: '700', fontSize: 13 },
399
+ cancelBtnText: { fontSize: 13 },
400
+ });
401
+
402
+ export function createStorageBrowserPlugin(): DebuggerPlugin {
403
+ return {
404
+ id: 'storage-browser',
405
+ name: 'Storage',
406
+ icon: '💾',
407
+ component: StorageBrowserPanel,
408
+ order: 60,
409
+ };
410
+ }
@@ -0,0 +1,47 @@
1
+ import type { StorageAdapter } from '../../core/types';
2
+
3
+ type Listener = () => void;
4
+
5
+ class StorageAdapterRegistryClass {
6
+ private adapters: Map<string, StorageAdapter> = new Map();
7
+ private listeners: Set<Listener> = new Set();
8
+
9
+ set(id: string, adapter: StorageAdapter): void {
10
+ this.adapters.set(id, adapter);
11
+ this.notify();
12
+ }
13
+
14
+ remove(id: string): void {
15
+ this.adapters.delete(id);
16
+ this.notify();
17
+ }
18
+
19
+ getAll(): Map<string, StorageAdapter> {
20
+ return new Map(this.adapters);
21
+ }
22
+
23
+ subscribe(listener: Listener): () => void {
24
+ this.listeners.add(listener);
25
+ return () => this.listeners.delete(listener);
26
+ }
27
+
28
+ private notify(): void {
29
+ for (const l of this.listeners) {
30
+ try {
31
+ l();
32
+ } catch {
33
+ /* ignore */
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ export const storageAdapterRegistry = new StorageAdapterRegistryClass();
40
+
41
+ export function setStorageAdapter(id: string, adapter: StorageAdapter): void {
42
+ storageAdapterRegistry.set(id, adapter);
43
+ }
44
+
45
+ export function removeStorageAdapter(id: string): void {
46
+ storageAdapterRegistry.remove(id);
47
+ }
@@ -0,0 +1,242 @@
1
+ import React, { useState, useEffect, useCallback, useMemo } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ FlatList,
6
+ TouchableOpacity,
7
+ TextInput,
8
+ ScrollView,
9
+ StyleSheet,
10
+ } from 'react-native';
11
+ import type { PluginComponentProps, TimelineEvent, DebuggerPlugin } from '../../core/types';
12
+ import { timelineStore } from './timelineStore';
13
+ import { formatTimestamp, safeStringify, copyToClipboard } from '../../core/utils';
14
+
15
+ const CATEGORY_COLORS: Record<string, string> = {
16
+ navigation: '#5B8DEF',
17
+ network: '#FF9500',
18
+ state: '#AF52DE',
19
+ user: '#34C759',
20
+ lifecycle: '#FF3B30',
21
+ custom: '#8E8E93',
22
+ };
23
+
24
+ const TimelinePanel: React.FC<PluginComponentProps> = ({ theme }) => {
25
+ const [events, setEvents] = useState<TimelineEvent[]>([]);
26
+ const [searchQuery, setSearchQuery] = useState('');
27
+ const [categoryFilter, setCategoryFilter] = useState<string | null>(null);
28
+ const [expandedId, setExpandedId] = useState<string | null>(null);
29
+
30
+ useEffect(() => {
31
+ const unsub = timelineStore.subscribe(setEvents);
32
+ return unsub;
33
+ }, []);
34
+
35
+ const categories = useMemo(() => {
36
+ const cats = new Set<string>();
37
+ for (const e of events) cats.add(e.category);
38
+ return Array.from(cats);
39
+ }, [events]);
40
+
41
+ const filteredEvents = useMemo(() => {
42
+ let filtered = events;
43
+ if (categoryFilter) {
44
+ filtered = filtered.filter((e) => e.category === categoryFilter);
45
+ }
46
+ if (searchQuery) {
47
+ const q = searchQuery.toLowerCase();
48
+ filtered = filtered.filter(
49
+ (e) => e.title.toLowerCase().includes(q) || e.category.toLowerCase().includes(q),
50
+ );
51
+ }
52
+ return filtered;
53
+ }, [events, categoryFilter, searchQuery]);
54
+
55
+ const handleClear = useCallback(() => {
56
+ timelineStore.clear();
57
+ setExpandedId(null);
58
+ }, []);
59
+
60
+ return (
61
+ <View style={styles.container}>
62
+ {/* Category Filter */}
63
+ <ScrollView
64
+ horizontal
65
+ showsHorizontalScrollIndicator={false}
66
+ style={[styles.filterBar, { backgroundColor: theme.surface }]}
67
+ contentContainerStyle={styles.filterContent}
68
+ >
69
+ <TouchableOpacity
70
+ style={[
71
+ styles.filterChip,
72
+ {
73
+ backgroundColor: !categoryFilter ? theme.accent : theme.surfaceAlt,
74
+ borderColor: theme.border,
75
+ },
76
+ ]}
77
+ onPress={() => setCategoryFilter(null)}
78
+ activeOpacity={0.7}
79
+ >
80
+ <Text
81
+ style={[styles.filterText, { color: !categoryFilter ? '#FFF' : theme.textSecondary }]}
82
+ >
83
+ All ({events.length})
84
+ </Text>
85
+ </TouchableOpacity>
86
+ {categories.map((cat) => (
87
+ <TouchableOpacity
88
+ key={cat}
89
+ style={[
90
+ styles.filterChip,
91
+ {
92
+ backgroundColor:
93
+ categoryFilter === cat ? CATEGORY_COLORS[cat] || theme.accent : theme.surfaceAlt,
94
+ borderColor: theme.border,
95
+ },
96
+ ]}
97
+ onPress={() => setCategoryFilter(categoryFilter === cat ? null : cat)}
98
+ activeOpacity={0.7}
99
+ >
100
+ <Text
101
+ style={[
102
+ styles.filterText,
103
+ {
104
+ color:
105
+ categoryFilter === cat ? '#FFF' : CATEGORY_COLORS[cat] || theme.textSecondary,
106
+ },
107
+ ]}
108
+ >
109
+ {cat}
110
+ </Text>
111
+ </TouchableOpacity>
112
+ ))}
113
+ <TouchableOpacity
114
+ onPress={handleClear}
115
+ style={[
116
+ styles.filterChip,
117
+ { backgroundColor: theme.surfaceAlt, borderColor: theme.error },
118
+ ]}
119
+ activeOpacity={0.7}
120
+ >
121
+ <Text style={[styles.filterText, { color: theme.error }]}>Clear</Text>
122
+ </TouchableOpacity>
123
+ </ScrollView>
124
+
125
+ {/* Search */}
126
+ <View style={[styles.searchContainer, { backgroundColor: theme.surface }]}>
127
+ <TextInput
128
+ style={[
129
+ styles.searchInput,
130
+ { color: theme.text, backgroundColor: theme.surfaceAlt, borderColor: theme.border },
131
+ ]}
132
+ placeholder="Search events..."
133
+ placeholderTextColor={theme.textMuted}
134
+ value={searchQuery}
135
+ onChangeText={setSearchQuery}
136
+ autoCapitalize="none"
137
+ />
138
+ </View>
139
+
140
+ {/* Event List */}
141
+ <FlatList
142
+ data={filteredEvents}
143
+ keyExtractor={(item) => item.id}
144
+ renderItem={({ item, index }) => {
145
+ const catColor = CATEGORY_COLORS[item.category] || theme.textMuted;
146
+ const timeDiff =
147
+ index < filteredEvents.length - 1
148
+ ? item.timestamp - filteredEvents[index + 1].timestamp
149
+ : 0;
150
+
151
+ return (
152
+ <TouchableOpacity
153
+ style={[styles.eventRow, { borderBottomColor: theme.border }]}
154
+ onPress={() => setExpandedId(expandedId === item.id ? null : item.id)}
155
+ activeOpacity={0.7}
156
+ >
157
+ <View style={styles.timelineTrack}>
158
+ <View style={[styles.timelineDot, { backgroundColor: catColor }]} />
159
+ {index < filteredEvents.length - 1 && (
160
+ <View style={[styles.timelineLine, { backgroundColor: theme.border }]} />
161
+ )}
162
+ </View>
163
+ <View style={styles.eventContent}>
164
+ <View style={styles.eventHeader}>
165
+ <View style={[styles.catBadge, { backgroundColor: `${catColor}20` }]}>
166
+ <Text style={[styles.catText, { color: catColor }]}>{item.category}</Text>
167
+ </View>
168
+ <Text style={[styles.eventTime, { color: theme.textMuted }]}>
169
+ {formatTimestamp(item.timestamp)}
170
+ </Text>
171
+ </View>
172
+ <Text style={[styles.eventTitle, { color: theme.text }]}>{item.title}</Text>
173
+ {timeDiff > 0 && (
174
+ <Text style={[styles.timeDiff, { color: theme.textMuted }]}>
175
+ +{timeDiff >= 1000 ? `${(timeDiff / 1000).toFixed(1)}s` : `${timeDiff}ms`}
176
+ </Text>
177
+ )}
178
+ {expandedId === item.id && item.data !== undefined && item.data !== null && (
179
+ <TouchableOpacity
180
+ style={[styles.dataBlock, { backgroundColor: theme.codeBackground }]}
181
+ onLongPress={() => copyToClipboard(safeStringify(item.data))}
182
+ activeOpacity={0.7}
183
+ >
184
+ <Text style={[styles.dataText, { color: theme.codeText }]} selectable>
185
+ {String(safeStringify(item.data))}
186
+ </Text>
187
+ </TouchableOpacity>
188
+ )}
189
+ </View>
190
+ </TouchableOpacity>
191
+ );
192
+ }}
193
+ ListEmptyComponent={
194
+ <View style={styles.emptyContainer}>
195
+ <Text style={[styles.emptyText, { color: theme.textMuted }]}>No events logged</Text>
196
+ </View>
197
+ }
198
+ initialNumToRender={30}
199
+ />
200
+ </View>
201
+ );
202
+ };
203
+
204
+ const styles = StyleSheet.create({
205
+ container: { flex: 1 },
206
+ filterBar: { maxHeight: 44 },
207
+ filterContent: { paddingHorizontal: 12, paddingVertical: 8, gap: 6 },
208
+ filterChip: { paddingHorizontal: 10, paddingVertical: 4, borderRadius: 12, borderWidth: 1 },
209
+ filterText: { fontSize: 11, fontWeight: '600' },
210
+ searchContainer: { paddingHorizontal: 12, paddingBottom: 8 },
211
+ searchInput: { height: 36, borderRadius: 8, paddingHorizontal: 12, fontSize: 13, borderWidth: 1 },
212
+ eventRow: { flexDirection: 'row', borderBottomWidth: StyleSheet.hairlineWidth },
213
+ timelineTrack: { width: 30, alignItems: 'center', paddingTop: 14 },
214
+ timelineDot: { width: 10, height: 10, borderRadius: 5, zIndex: 1 },
215
+ timelineLine: { width: 2, flex: 1, marginTop: -2 },
216
+ eventContent: { flex: 1, paddingVertical: 10, paddingRight: 12 },
217
+ eventHeader: {
218
+ flexDirection: 'row',
219
+ justifyContent: 'space-between',
220
+ alignItems: 'center',
221
+ marginBottom: 4,
222
+ },
223
+ catBadge: { paddingHorizontal: 6, paddingVertical: 2, borderRadius: 4 },
224
+ catText: { fontSize: 9, fontWeight: '800', textTransform: 'uppercase', letterSpacing: 0.5 },
225
+ eventTime: { fontSize: 10 },
226
+ eventTitle: { fontSize: 13, fontWeight: '500' },
227
+ timeDiff: { fontSize: 10, marginTop: 2 },
228
+ dataBlock: { padding: 8, borderRadius: 6, marginTop: 8 },
229
+ dataText: { fontSize: 11, fontFamily: 'monospace', lineHeight: 16 },
230
+ emptyContainer: { alignItems: 'center', paddingVertical: 40 },
231
+ emptyText: { fontSize: 13 },
232
+ });
233
+
234
+ export function createTimelinePlugin(): DebuggerPlugin {
235
+ return {
236
+ id: 'timeline',
237
+ name: 'Timeline',
238
+ icon: '📊',
239
+ component: TimelinePanel,
240
+ order: 130,
241
+ };
242
+ }