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,211 @@
1
+ import React, { createContext, useState, useCallback, useEffect, useMemo, useRef } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import type { DebuggerConfig, DebuggerContextValue, DebuggerPlugin, ChildrenProp } from './types';
4
+ import { createTheme } from './theme';
5
+ import { PluginRegistry } from './PluginRegistry';
6
+ import { DebugBubble } from './DebugBubble';
7
+ import { DebugOverlay } from './DebugOverlay';
8
+ import { GestureDetector } from './GestureDetector';
9
+
10
+ // ─── Built-in Plugin Registrations ──────────────────────────────────────────
11
+ import { createNetworkInspectorPlugin } from '../plugins/network/NetworkInspectorPlugin';
12
+ import { createStateInspectorPlugin } from '../plugins/stateInspector/StateInspectorPlugin';
13
+ import { createFeatureFlagsPlugin } from '../plugins/featureFlags/FeatureFlagsPlugin';
14
+ import { createRemoteConfigPlugin } from '../plugins/remoteConfig/RemoteConfigPlugin';
15
+ import { createConsoleViewerPlugin } from '../plugins/console/ConsoleViewerPlugin';
16
+ import { createStorageBrowserPlugin } from '../plugins/storageBrowser/StorageBrowserPlugin';
17
+ import { createPerformanceMonitorPlugin } from '../plugins/performance/PerformanceMonitorPlugin';
18
+ import { createDeviceInfoPlugin } from '../plugins/deviceInfo/DeviceInfoPlugin';
19
+ import { createNavigationInspectorPlugin } from '../plugins/navigationInspector/NavigationInspectorPlugin';
20
+ import { createCrashReporterPlugin } from '../plugins/crashReporter/CrashReporterPlugin';
21
+ import { createCustomActionsPlugin } from '../plugins/customActions/CustomActionsPlugin';
22
+ import { createDeepLinkTesterPlugin } from '../plugins/deepLinkTester/DeepLinkTesterPlugin';
23
+ import { createTimelinePlugin } from '../plugins/timeline/TimelinePlugin';
24
+
25
+ // ─── Context ────────────────────────────────────────────────────────────────
26
+
27
+ export const DebuggerContext = createContext<DebuggerContextValue | null>(null);
28
+
29
+ // ─── Default Config ─────────────────────────────────────────────────────────
30
+
31
+ const DEFAULT_CONFIG: Required<DebuggerConfig> = {
32
+ enabled: true,
33
+ gesture: 'threeFingerLongPress',
34
+ longPressDuration: 800,
35
+ numberOfFingers: 3,
36
+ interceptConsole: true,
37
+ interceptNetwork: true,
38
+ interceptCrashes: true,
39
+ maxNetworkRequests: 500,
40
+ maxConsoleEntries: 1000,
41
+ maxTimelineEvents: 2000,
42
+ appVersion: '',
43
+ buildNumber: '',
44
+ bundleId: '',
45
+ theme: {},
46
+ disabledPlugins: [],
47
+ bubblePosition: { x: -1, y: -1 },
48
+ bubbleSize: 50,
49
+ };
50
+
51
+ // ─── Provider ───────────────────────────────────────────────────────────────
52
+
53
+ interface DebuggerProviderProps extends ChildrenProp {
54
+ config?: DebuggerConfig;
55
+ }
56
+
57
+ /**
58
+ * DebuggerProvider — Wrap your app with this to enable the production debugger.
59
+ *
60
+ * @example
61
+ * ```tsx
62
+ * import { DebuggerProvider } from 'react-native-prod-debugger';
63
+ *
64
+ * export default function App() {
65
+ * return (
66
+ * <DebuggerProvider config={{ appVersion: '1.2.3' }}>
67
+ * <YourApp />
68
+ * </DebuggerProvider>
69
+ * );
70
+ * }
71
+ * ```
72
+ */
73
+ export const DebuggerProvider: React.FC<DebuggerProviderProps> = ({
74
+ children,
75
+ config: userConfig,
76
+ }) => {
77
+ const mergedConfig = useMemo<Required<DebuggerConfig>>(
78
+ () => ({
79
+ ...DEFAULT_CONFIG,
80
+ ...userConfig,
81
+ theme: { ...DEFAULT_CONFIG.theme, ...(userConfig?.theme || {}) },
82
+ }),
83
+ [userConfig],
84
+ );
85
+
86
+ const theme = useMemo(() => createTheme(mergedConfig.theme), [mergedConfig.theme]);
87
+
88
+ const [isVisible, setIsVisible] = useState(false);
89
+ const [showOverlay, setShowOverlay] = useState(false);
90
+ const [plugins, setPlugins] = useState<DebuggerPlugin[]>([]);
91
+ const initialized = useRef(false);
92
+
93
+ // Register built-in plugins on mount
94
+ useEffect(() => {
95
+ if (!mergedConfig.enabled || initialized.current) return;
96
+ initialized.current = true;
97
+
98
+ const disabled = new Set(mergedConfig.disabledPlugins);
99
+
100
+ const builtInPlugins = [
101
+ createNetworkInspectorPlugin(),
102
+ createConsoleViewerPlugin(),
103
+ createStateInspectorPlugin(),
104
+ createFeatureFlagsPlugin(),
105
+ createRemoteConfigPlugin(),
106
+ createStorageBrowserPlugin(),
107
+ createPerformanceMonitorPlugin(),
108
+ createDeviceInfoPlugin(),
109
+ createNavigationInspectorPlugin(),
110
+ createCrashReporterPlugin(),
111
+ createCustomActionsPlugin(),
112
+ createDeepLinkTesterPlugin(),
113
+ createTimelinePlugin(),
114
+ ];
115
+
116
+ for (const plugin of builtInPlugins) {
117
+ if (!disabled.has(plugin.id)) {
118
+ PluginRegistry.register(plugin);
119
+ }
120
+ }
121
+
122
+ PluginRegistry.initAll();
123
+ setPlugins(PluginRegistry.getAll());
124
+
125
+ // Subscribe to registry changes (for custom plugins added later)
126
+ const unsubscribe = PluginRegistry.subscribe(() => {
127
+ setPlugins(PluginRegistry.getAll());
128
+ });
129
+
130
+ return () => {
131
+ unsubscribe();
132
+ PluginRegistry.destroyAll();
133
+ };
134
+ }, [mergedConfig.enabled, mergedConfig.disabledPlugins]);
135
+
136
+ const show = useCallback(() => {
137
+ setIsVisible(true);
138
+ setShowOverlay(false);
139
+ }, []);
140
+
141
+ const hide = useCallback(() => {
142
+ setIsVisible(false);
143
+ setShowOverlay(false);
144
+ }, []);
145
+
146
+ const toggle = useCallback(() => {
147
+ setIsVisible((prev) => !prev);
148
+ setShowOverlay(false);
149
+ }, []);
150
+
151
+ const handleBubblePress = useCallback(() => {
152
+ setShowOverlay(true);
153
+ }, []);
154
+
155
+ const handleOverlayClose = useCallback(() => {
156
+ setShowOverlay(false);
157
+ }, []);
158
+
159
+ const contextValue = useMemo<DebuggerContextValue>(
160
+ () => ({
161
+ isVisible,
162
+ toggle,
163
+ show,
164
+ hide,
165
+ config: mergedConfig,
166
+ theme,
167
+ plugins,
168
+ }),
169
+ [isVisible, toggle, show, hide, mergedConfig, theme, plugins],
170
+ );
171
+
172
+ if (!mergedConfig.enabled) {
173
+ return <>{children}</>;
174
+ }
175
+
176
+ return (
177
+ <DebuggerContext.Provider value={contextValue}>
178
+ <View style={styles.root}>
179
+ <GestureDetector
180
+ gesture={mergedConfig.gesture}
181
+ numberOfFingers={mergedConfig.numberOfFingers}
182
+ longPressDuration={mergedConfig.longPressDuration}
183
+ onActivate={toggle}
184
+ >
185
+ {children}
186
+ </GestureDetector>
187
+
188
+ {isVisible && !showOverlay && (
189
+ <DebugBubble
190
+ onPress={handleBubblePress}
191
+ theme={theme}
192
+ size={mergedConfig.bubbleSize}
193
+ initialPosition={
194
+ mergedConfig.bubblePosition.x >= 0 ? mergedConfig.bubblePosition : undefined
195
+ }
196
+ />
197
+ )}
198
+
199
+ {isVisible && showOverlay && (
200
+ <DebugOverlay plugins={plugins} theme={theme} onClose={handleOverlayClose} />
201
+ )}
202
+ </View>
203
+ </DebuggerContext.Provider>
204
+ );
205
+ };
206
+
207
+ const styles = StyleSheet.create({
208
+ root: {
209
+ flex: 1,
210
+ },
211
+ });
@@ -0,0 +1,95 @@
1
+ import React, { useRef, useCallback } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import type { GestureType, ChildrenProp } from './types';
4
+
5
+ interface GestureDetectorProps extends ChildrenProp {
6
+ gesture: GestureType;
7
+ numberOfFingers: number;
8
+ longPressDuration: number;
9
+ onActivate: () => void;
10
+ }
11
+
12
+ /**
13
+ * GestureDetector — Invisible wrapper that detects multi-touch gestures.
14
+ *
15
+ * Supported gestures:
16
+ * - `threeFingerLongPress`: N fingers held down for duration ms
17
+ * - `twoFingerTripleTap`: 2 fingers tapped 3 times quickly
18
+ * - `shake`: (detected elsewhere — React Native DevMenu shim)
19
+ * - `custom`: (no built-in behavior — consumers control programmatically)
20
+ */
21
+ export const GestureDetector: React.FC<GestureDetectorProps> = ({
22
+ children,
23
+ gesture,
24
+ numberOfFingers,
25
+ longPressDuration,
26
+ onActivate,
27
+ }) => {
28
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
29
+ const tapCountRef = useRef(0);
30
+ const tapTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
31
+
32
+ const clearTimer = useCallback(() => {
33
+ if (timerRef.current) {
34
+ clearTimeout(timerRef.current);
35
+ timerRef.current = null;
36
+ }
37
+ }, []);
38
+
39
+ const handleTouchStart = useCallback(
40
+ (event: { nativeEvent: { touches: unknown[] } }) => {
41
+ const touchCount = event.nativeEvent.touches?.length ?? 0;
42
+
43
+ if (gesture === 'threeFingerLongPress') {
44
+ if (touchCount >= numberOfFingers) {
45
+ clearTimer();
46
+ timerRef.current = setTimeout(() => {
47
+ onActivate();
48
+ }, longPressDuration);
49
+ }
50
+ }
51
+
52
+ if (gesture === 'twoFingerTripleTap') {
53
+ if (touchCount >= 2) {
54
+ tapCountRef.current += 1;
55
+
56
+ if (tapTimerRef.current) clearTimeout(tapTimerRef.current);
57
+ tapTimerRef.current = setTimeout(() => {
58
+ tapCountRef.current = 0;
59
+ }, 600); // Reset tap count after 600ms idle
60
+
61
+ if (tapCountRef.current >= 3) {
62
+ tapCountRef.current = 0;
63
+ onActivate();
64
+ }
65
+ }
66
+ }
67
+ },
68
+ [gesture, numberOfFingers, longPressDuration, onActivate, clearTimer],
69
+ );
70
+
71
+ const handleTouchEnd = useCallback(() => {
72
+ if (gesture === 'threeFingerLongPress') {
73
+ clearTimer();
74
+ }
75
+ }, [gesture, clearTimer]);
76
+
77
+ if (gesture === 'custom' || gesture === 'shake') {
78
+ return <View style={styles.flex}>{children}</View>;
79
+ }
80
+
81
+ return (
82
+ <View
83
+ style={styles.flex}
84
+ onTouchStart={handleTouchStart}
85
+ onTouchEnd={handleTouchEnd}
86
+ onTouchCancel={handleTouchEnd}
87
+ >
88
+ {children}
89
+ </View>
90
+ );
91
+ };
92
+
93
+ const styles = StyleSheet.create({
94
+ flex: { flex: 1 },
95
+ });
@@ -0,0 +1,118 @@
1
+ import type { DebuggerPlugin } from './types';
2
+
3
+ /**
4
+ * PluginRegistry — Central registry for all debugger plugins.
5
+ *
6
+ * Plugins are stored in a static array and sorted by their `order` property.
7
+ * Built-in plugins are registered automatically by DebuggerProvider.
8
+ * Custom plugins can be registered by consumers at any time.
9
+ */
10
+ class PluginRegistryClass {
11
+ private plugins: Map<string, DebuggerPlugin> = new Map();
12
+ private listeners: Set<() => void> = new Set();
13
+
14
+ /** Register a plugin. Replaces existing plugin with the same ID. */
15
+ register(plugin: DebuggerPlugin): void {
16
+ this.plugins.set(plugin.id, {
17
+ ...plugin,
18
+ order: plugin.order ?? 100,
19
+ });
20
+ this.notify();
21
+ }
22
+
23
+ /** Unregister a plugin by ID. */
24
+ unregister(id: string): void {
25
+ const plugin = this.plugins.get(id);
26
+ if (plugin?.onDestroy) {
27
+ try {
28
+ plugin.onDestroy();
29
+ } catch {
30
+ // Silently handle cleanup errors
31
+ }
32
+ }
33
+ this.plugins.delete(id);
34
+ this.notify();
35
+ }
36
+
37
+ /** Get all registered plugins, sorted by order. */
38
+ getAll(): DebuggerPlugin[] {
39
+ return Array.from(this.plugins.values()).sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
40
+ }
41
+
42
+ /** Get a plugin by ID. */
43
+ get(id: string): DebuggerPlugin | undefined {
44
+ return this.plugins.get(id);
45
+ }
46
+
47
+ /** Check if a plugin is registered. */
48
+ has(id: string): boolean {
49
+ return this.plugins.has(id);
50
+ }
51
+
52
+ /** Get the count of registered plugins. */
53
+ get count(): number {
54
+ return this.plugins.size;
55
+ }
56
+
57
+ /** Subscribe to registry changes. Returns unsubscribe function. */
58
+ subscribe(listener: () => void): () => void {
59
+ this.listeners.add(listener);
60
+ return () => this.listeners.delete(listener);
61
+ }
62
+
63
+ /** Initialize all plugins (called by DebuggerProvider on mount). */
64
+ initAll(): void {
65
+ for (const plugin of this.plugins.values()) {
66
+ if (plugin.onInit) {
67
+ try {
68
+ plugin.onInit();
69
+ } catch (error) {
70
+ console.warn(`[ProdDebugger] Plugin "${plugin.id}" init failed:`, error);
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ /** Destroy all plugins (called by DebuggerProvider on unmount). */
77
+ destroyAll(): void {
78
+ for (const plugin of this.plugins.values()) {
79
+ if (plugin.onDestroy) {
80
+ try {
81
+ plugin.onDestroy();
82
+ } catch {
83
+ // Silently handle cleanup errors
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ /** Clear all plugins from the registry. */
90
+ clear(): void {
91
+ this.destroyAll();
92
+ this.plugins.clear();
93
+ this.notify();
94
+ }
95
+
96
+ private notify(): void {
97
+ for (const listener of this.listeners) {
98
+ try {
99
+ listener();
100
+ } catch {
101
+ // Silently handle listener errors
102
+ }
103
+ }
104
+ }
105
+ }
106
+
107
+ /** Singleton plugin registry instance. */
108
+ export const PluginRegistry = new PluginRegistryClass();
109
+
110
+ /** Register a custom plugin. Convenience function. */
111
+ export function registerPlugin(plugin: DebuggerPlugin): void {
112
+ PluginRegistry.register(plugin);
113
+ }
114
+
115
+ /** Unregister a plugin by ID. Convenience function. */
116
+ export function unregisterPlugin(id: string): void {
117
+ PluginRegistry.unregister(id);
118
+ }
@@ -0,0 +1,41 @@
1
+ import type { DebuggerTheme } from './types';
2
+
3
+ /**
4
+ * Default dark theme — designed for optimal readability on top of any app UI.
5
+ * High-contrast text, muted backgrounds with alpha transparency for the overlay.
6
+ */
7
+ export const darkTheme: DebuggerTheme = {
8
+ background: '#0D0D0D',
9
+ surface: '#1A1A2E',
10
+ surfaceAlt: '#16213E',
11
+ text: '#EAEAEA',
12
+ textSecondary: '#A0A0B0',
13
+ textMuted: '#6B6B80',
14
+ accent: '#7C3AED',
15
+ accentLight: '#A78BFA',
16
+ success: '#10B981',
17
+ warning: '#F59E0B',
18
+ error: '#EF4444',
19
+ info: '#3B82F6',
20
+ border: '#2A2A3E',
21
+ overlay: 'rgba(0, 0, 0, 0.85)',
22
+ bubbleBackground: '#7C3AED',
23
+ bubbleIcon: '#FFFFFF',
24
+ codeBackground: '#111122',
25
+ codeText: '#A5D6FF',
26
+ headerBackground: '#0F0F23',
27
+ tabActive: '#7C3AED',
28
+ tabInactive: '#4A4A5E',
29
+ statusBarOk: '#10B981',
30
+ statusBarWarn: '#F59E0B',
31
+ statusBarError: '#EF4444',
32
+ shadow: 'rgba(0, 0, 0, 0.5)',
33
+ };
34
+
35
+ /**
36
+ * Merge user theme overrides with the default dark theme.
37
+ */
38
+ export function createTheme(overrides?: Partial<DebuggerTheme>): DebuggerTheme {
39
+ if (!overrides) return darkTheme;
40
+ return { ...darkTheme, ...overrides };
41
+ }