react-native-debug-toolkit 0.6.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -212
  3. package/lib/commonjs/components/ClipboardTab.js +92 -0
  4. package/lib/commonjs/components/ClipboardTab.js.map +1 -0
  5. package/lib/commonjs/components/ConsoleLogTab.js +295 -0
  6. package/lib/commonjs/components/ConsoleLogTab.js.map +1 -0
  7. package/lib/commonjs/components/EnvironmentTab.js +288 -0
  8. package/lib/commonjs/components/EnvironmentTab.js.map +1 -0
  9. package/lib/commonjs/components/FloatPanelView.js +797 -0
  10. package/lib/commonjs/components/FloatPanelView.js.map +1 -0
  11. package/lib/commonjs/components/NavigationLogTab.js +131 -0
  12. package/lib/commonjs/components/NavigationLogTab.js.map +1 -0
  13. package/lib/commonjs/components/NetworkLogTab.js +575 -0
  14. package/lib/commonjs/components/NetworkLogTab.js.map +1 -0
  15. package/lib/commonjs/components/ThirdPartyLibsTab.js +97 -0
  16. package/lib/commonjs/components/ThirdPartyLibsTab.js.map +1 -0
  17. package/lib/commonjs/components/TrackLogTab.js +372 -0
  18. package/lib/commonjs/components/TrackLogTab.js.map +1 -0
  19. package/lib/commonjs/components/ZustandLogTab.js +451 -0
  20. package/lib/commonjs/components/ZustandLogTab.js.map +1 -0
  21. package/lib/commonjs/components/shared/CollapsibleSection.js +84 -0
  22. package/lib/commonjs/components/shared/CollapsibleSection.js.map +1 -0
  23. package/lib/commonjs/components/shared/CopyButton.js +64 -0
  24. package/lib/commonjs/components/shared/CopyButton.js.map +1 -0
  25. package/lib/commonjs/components/shared/JsonView.js +157 -0
  26. package/lib/commonjs/components/shared/JsonView.js.map +1 -0
  27. package/lib/commonjs/core/DebugToolkit.js +142 -0
  28. package/lib/commonjs/core/DebugToolkit.js.map +1 -0
  29. package/lib/commonjs/core/DebugToolkitProvider.js +64 -0
  30. package/lib/commonjs/core/DebugToolkitProvider.js.map +1 -0
  31. package/lib/commonjs/features/ClipboardFeature.js +17 -0
  32. package/lib/commonjs/features/ClipboardFeature.js.map +1 -0
  33. package/lib/commonjs/features/ConsoleLogFeature.js +98 -0
  34. package/lib/commonjs/features/ConsoleLogFeature.js.map +1 -0
  35. package/lib/commonjs/features/EnvironmentFeature.js +168 -0
  36. package/lib/commonjs/features/EnvironmentFeature.js.map +1 -0
  37. package/lib/commonjs/features/NavigationLogFeature.js +60 -0
  38. package/lib/commonjs/features/NavigationLogFeature.js.map +1 -0
  39. package/lib/commonjs/features/NetworkFeature.js +328 -0
  40. package/lib/commonjs/features/NetworkFeature.js.map +1 -0
  41. package/lib/commonjs/features/ThirdPartyLibsFeature.js +51 -0
  42. package/lib/commonjs/features/ThirdPartyLibsFeature.js.map +1 -0
  43. package/lib/commonjs/features/TrackFeature.js +55 -0
  44. package/lib/commonjs/features/TrackFeature.js.map +1 -0
  45. package/lib/commonjs/features/ZustandLogFeature.js +76 -0
  46. package/lib/commonjs/features/ZustandLogFeature.js.map +1 -0
  47. package/lib/commonjs/hooks/useNavigationLogger.js +78 -0
  48. package/lib/commonjs/hooks/useNavigationLogger.js.map +1 -0
  49. package/lib/commonjs/hooks/useSlideDetailAnimation.js +53 -0
  50. package/lib/commonjs/hooks/useSlideDetailAnimation.js.map +1 -0
  51. package/lib/commonjs/index.js +165 -0
  52. package/lib/commonjs/index.js.map +1 -0
  53. package/lib/commonjs/initialize.js +161 -0
  54. package/lib/commonjs/initialize.js.map +1 -0
  55. package/lib/commonjs/native/NativeDebugLibs.js +58 -0
  56. package/lib/commonjs/native/NativeDebugLibs.js.map +1 -0
  57. package/lib/commonjs/package.json +1 -0
  58. package/lib/commonjs/types/index.js +6 -0
  59. package/lib/commonjs/types/index.js.map +1 -0
  60. package/lib/commonjs/utils/constants.js +135 -0
  61. package/lib/commonjs/utils/constants.js.map +1 -0
  62. package/lib/commonjs/utils/copyToComputer.js +97 -0
  63. package/lib/commonjs/utils/copyToComputer.js.map +1 -0
  64. package/lib/commonjs/utils/createEventChannel.js +21 -0
  65. package/lib/commonjs/utils/createEventChannel.js.map +1 -0
  66. package/lib/commonjs/utils/createObservableStore.js +38 -0
  67. package/lib/commonjs/utils/createObservableStore.js.map +1 -0
  68. package/lib/commonjs/utils/safeStringify.js +27 -0
  69. package/lib/commonjs/utils/safeStringify.js.map +1 -0
  70. package/lib/module/components/ClipboardTab.js +86 -0
  71. package/lib/module/components/ClipboardTab.js.map +1 -0
  72. package/lib/module/components/ConsoleLogTab.js +290 -0
  73. package/lib/module/components/ConsoleLogTab.js.map +1 -0
  74. package/lib/module/components/EnvironmentTab.js +282 -0
  75. package/lib/module/components/EnvironmentTab.js.map +1 -0
  76. package/lib/module/components/FloatPanelView.js +791 -0
  77. package/lib/module/components/FloatPanelView.js.map +1 -0
  78. package/lib/module/components/NavigationLogTab.js +126 -0
  79. package/lib/module/components/NavigationLogTab.js.map +1 -0
  80. package/lib/module/components/NetworkLogTab.js +570 -0
  81. package/lib/module/components/NetworkLogTab.js.map +1 -0
  82. package/lib/module/components/ThirdPartyLibsTab.js +91 -0
  83. package/lib/module/components/ThirdPartyLibsTab.js.map +1 -0
  84. package/lib/module/components/TrackLogTab.js +367 -0
  85. package/lib/module/components/TrackLogTab.js.map +1 -0
  86. package/lib/module/components/ZustandLogTab.js +446 -0
  87. package/lib/module/components/ZustandLogTab.js.map +1 -0
  88. package/lib/module/components/shared/CollapsibleSection.js +78 -0
  89. package/lib/module/components/shared/CollapsibleSection.js.map +1 -0
  90. package/lib/module/components/shared/CopyButton.js +58 -0
  91. package/lib/module/components/shared/CopyButton.js.map +1 -0
  92. package/lib/module/components/shared/JsonView.js +152 -0
  93. package/lib/module/components/shared/JsonView.js.map +1 -0
  94. package/lib/module/core/DebugToolkit.js +137 -0
  95. package/lib/module/core/DebugToolkit.js.map +1 -0
  96. package/lib/module/core/DebugToolkitProvider.js +58 -0
  97. package/lib/module/core/DebugToolkitProvider.js.map +1 -0
  98. package/lib/module/features/ClipboardFeature.js +12 -0
  99. package/lib/module/features/ClipboardFeature.js.map +1 -0
  100. package/lib/module/features/ConsoleLogFeature.js +93 -0
  101. package/lib/module/features/ConsoleLogFeature.js.map +1 -0
  102. package/lib/module/features/EnvironmentFeature.js +164 -0
  103. package/lib/module/features/EnvironmentFeature.js.map +1 -0
  104. package/lib/module/features/NavigationLogFeature.js +54 -0
  105. package/lib/module/features/NavigationLogFeature.js.map +1 -0
  106. package/lib/module/features/NetworkFeature.js +322 -0
  107. package/lib/module/features/NetworkFeature.js.map +1 -0
  108. package/lib/module/features/ThirdPartyLibsFeature.js +46 -0
  109. package/lib/module/features/ThirdPartyLibsFeature.js.map +1 -0
  110. package/lib/module/features/TrackFeature.js +49 -0
  111. package/lib/module/features/TrackFeature.js.map +1 -0
  112. package/lib/module/features/ZustandLogFeature.js +69 -0
  113. package/lib/module/features/ZustandLogFeature.js.map +1 -0
  114. package/lib/module/hooks/useNavigationLogger.js +74 -0
  115. package/lib/module/hooks/useNavigationLogger.js.map +1 -0
  116. package/lib/module/hooks/useSlideDetailAnimation.js +50 -0
  117. package/lib/module/hooks/useSlideDetailAnimation.js.map +1 -0
  118. package/lib/module/index.js +29 -0
  119. package/lib/module/index.js.map +1 -0
  120. package/lib/module/initialize.js +156 -0
  121. package/lib/module/initialize.js.map +1 -0
  122. package/lib/module/native/NativeDebugLibs.js +54 -0
  123. package/lib/module/native/NativeDebugLibs.js.map +1 -0
  124. package/lib/module/package.json +1 -0
  125. package/lib/module/types/index.js +4 -0
  126. package/lib/module/types/index.js.map +1 -0
  127. package/lib/module/utils/constants.js +130 -0
  128. package/lib/module/utils/constants.js.map +1 -0
  129. package/lib/module/utils/copyToComputer.js +91 -0
  130. package/lib/module/utils/copyToComputer.js.map +1 -0
  131. package/lib/module/utils/createEventChannel.js +17 -0
  132. package/lib/module/utils/createEventChannel.js.map +1 -0
  133. package/lib/module/utils/createObservableStore.js +34 -0
  134. package/lib/module/utils/createObservableStore.js.map +1 -0
  135. package/lib/module/utils/safeStringify.js +23 -0
  136. package/lib/module/utils/safeStringify.js.map +1 -0
  137. package/lib/typescript/src/components/ClipboardTab.d.ts +4 -0
  138. package/lib/typescript/src/components/ClipboardTab.d.ts.map +1 -0
  139. package/lib/typescript/src/components/ConsoleLogTab.d.ts +4 -0
  140. package/lib/typescript/src/components/ConsoleLogTab.d.ts.map +1 -0
  141. package/lib/typescript/src/components/EnvironmentTab.d.ts +4 -0
  142. package/lib/typescript/src/components/EnvironmentTab.d.ts.map +1 -0
  143. package/lib/typescript/src/components/FloatPanelView.d.ts +64 -0
  144. package/lib/typescript/src/components/FloatPanelView.d.ts.map +1 -0
  145. package/lib/typescript/src/components/NavigationLogTab.d.ts +4 -0
  146. package/lib/typescript/src/components/NavigationLogTab.d.ts.map +1 -0
  147. package/lib/typescript/src/components/NetworkLogTab.d.ts +4 -0
  148. package/lib/typescript/src/components/NetworkLogTab.d.ts.map +1 -0
  149. package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts +4 -0
  150. package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts.map +1 -0
  151. package/lib/typescript/src/components/TrackLogTab.d.ts +4 -0
  152. package/lib/typescript/src/components/TrackLogTab.d.ts.map +1 -0
  153. package/lib/typescript/src/components/ZustandLogTab.d.ts +4 -0
  154. package/lib/typescript/src/components/ZustandLogTab.d.ts.map +1 -0
  155. package/lib/typescript/src/components/shared/CollapsibleSection.d.ts +9 -0
  156. package/lib/typescript/src/components/shared/CollapsibleSection.d.ts.map +1 -0
  157. package/lib/typescript/src/components/shared/CopyButton.d.ts +12 -0
  158. package/lib/typescript/src/components/shared/CopyButton.d.ts.map +1 -0
  159. package/lib/typescript/src/components/shared/JsonView.d.ts +6 -0
  160. package/lib/typescript/src/components/shared/JsonView.d.ts.map +1 -0
  161. package/lib/typescript/src/core/DebugToolkit.d.ts +27 -0
  162. package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -0
  163. package/lib/typescript/src/core/DebugToolkitProvider.d.ts +18 -0
  164. package/lib/typescript/src/core/DebugToolkitProvider.d.ts.map +1 -0
  165. package/lib/typescript/src/features/ClipboardFeature.d.ts +3 -0
  166. package/lib/typescript/src/features/ClipboardFeature.d.ts.map +1 -0
  167. package/lib/typescript/src/features/ConsoleLogFeature.d.ts +7 -0
  168. package/lib/typescript/src/features/ConsoleLogFeature.d.ts.map +1 -0
  169. package/lib/typescript/src/features/EnvironmentFeature.d.ts +8 -0
  170. package/lib/typescript/src/features/EnvironmentFeature.d.ts.map +1 -0
  171. package/lib/typescript/src/features/NavigationLogFeature.d.ts +8 -0
  172. package/lib/typescript/src/features/NavigationLogFeature.d.ts.map +1 -0
  173. package/lib/typescript/src/features/NetworkFeature.d.ts +28 -0
  174. package/lib/typescript/src/features/NetworkFeature.d.ts.map +1 -0
  175. package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts +3 -0
  176. package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts.map +1 -0
  177. package/lib/typescript/src/features/TrackFeature.d.ts +12 -0
  178. package/lib/typescript/src/features/TrackFeature.d.ts.map +1 -0
  179. package/lib/typescript/src/features/ZustandLogFeature.d.ts +29 -0
  180. package/lib/typescript/src/features/ZustandLogFeature.d.ts.map +1 -0
  181. package/lib/typescript/src/hooks/useNavigationLogger.d.ts +20 -0
  182. package/lib/typescript/src/hooks/useNavigationLogger.d.ts.map +1 -0
  183. package/lib/typescript/src/hooks/useSlideDetailAnimation.d.ts +11 -0
  184. package/lib/typescript/src/hooks/useSlideDetailAnimation.d.ts.map +1 -0
  185. package/lib/typescript/src/index.d.ts +26 -0
  186. package/lib/typescript/src/index.d.ts.map +1 -0
  187. package/lib/typescript/src/initialize.d.ts +51 -0
  188. package/lib/typescript/src/initialize.d.ts.map +1 -0
  189. package/lib/typescript/src/native/NativeDebugLibs.d.ts +11 -0
  190. package/lib/typescript/src/native/NativeDebugLibs.d.ts.map +1 -0
  191. package/lib/typescript/src/types/index.d.ts +112 -0
  192. package/lib/typescript/src/types/index.d.ts.map +1 -0
  193. package/lib/typescript/src/utils/constants.d.ts +96 -0
  194. package/lib/typescript/src/utils/constants.d.ts.map +1 -0
  195. package/lib/typescript/src/utils/copyToComputer.d.ts +30 -0
  196. package/lib/typescript/src/utils/copyToComputer.d.ts.map +1 -0
  197. package/lib/typescript/src/utils/createEventChannel.d.ts +7 -0
  198. package/lib/typescript/src/utils/createEventChannel.d.ts.map +1 -0
  199. package/lib/typescript/src/utils/createObservableStore.d.ts +9 -0
  200. package/lib/typescript/src/utils/createObservableStore.d.ts.map +1 -0
  201. package/lib/typescript/src/utils/safeStringify.d.ts +6 -0
  202. package/lib/typescript/src/utils/safeStringify.d.ts.map +1 -0
  203. package/package.json +63 -24
  204. package/src/components/ClipboardTab.tsx +81 -0
  205. package/src/components/ConsoleLogTab.tsx +209 -0
  206. package/src/components/EnvironmentTab.tsx +276 -0
  207. package/src/components/FloatPanelView.tsx +714 -0
  208. package/src/components/NavigationLogTab.tsx +66 -0
  209. package/src/components/NetworkLogTab.tsx +411 -0
  210. package/src/components/ThirdPartyLibsTab.tsx +63 -0
  211. package/src/components/TrackLogTab.tsx +245 -0
  212. package/src/components/ZustandLogTab.tsx +305 -0
  213. package/src/components/shared/CollapsibleSection.tsx +78 -0
  214. package/src/components/shared/CopyButton.tsx +68 -0
  215. package/src/components/shared/JsonView.tsx +125 -0
  216. package/src/core/DebugToolkit.tsx +174 -0
  217. package/src/core/DebugToolkitProvider.tsx +89 -0
  218. package/src/features/ClipboardFeature.ts +11 -0
  219. package/src/features/ConsoleLogFeature.ts +118 -0
  220. package/src/features/EnvironmentFeature.ts +194 -0
  221. package/src/features/NavigationLogFeature.ts +74 -0
  222. package/src/features/NetworkFeature.ts +488 -0
  223. package/src/features/ThirdPartyLibsFeature.ts +42 -0
  224. package/src/features/TrackFeature.ts +69 -0
  225. package/src/features/ZustandLogFeature.ts +127 -0
  226. package/src/hooks/useNavigationLogger.ts +107 -0
  227. package/src/hooks/useSlideDetailAnimation.ts +45 -0
  228. package/src/index.ts +52 -0
  229. package/src/initialize.ts +214 -0
  230. package/src/native/NativeDebugLibs.ts +74 -0
  231. package/src/types/index.ts +138 -0
  232. package/src/utils/constants.ts +91 -0
  233. package/src/utils/copyToComputer.ts +104 -0
  234. package/src/utils/createEventChannel.ts +22 -0
  235. package/src/utils/createObservableStore.ts +42 -0
  236. package/src/utils/safeStringify.ts +25 -0
  237. package/.cursor/rules/react-native.mdc +0 -41
  238. package/README.zh-CN.md +0 -230
  239. package/index.js +0 -41
  240. package/ios/BuildTypeModule.h +0 -9
  241. package/ios/BuildTypeModule.m +0 -42
  242. package/ios/RNDebugLibs.h +0 -10
  243. package/ios/RNDebugLibs.m +0 -79
  244. package/lib/DebugToolKit.js +0 -126
  245. package/lib/EnvironmentManager.ts +0 -80
  246. package/lib/NativeDebugLibs.js +0 -67
  247. package/lib/features/ConsoleLogFeature.js +0 -70
  248. package/lib/features/NavigationLogFeature.js +0 -45
  249. package/lib/features/NetworkFeature.js +0 -389
  250. package/lib/features/PerformanceFeature.js +0 -390
  251. package/lib/features/ThirdPartyLibsFeature.js +0 -63
  252. package/lib/features/TrackFeature.js +0 -94
  253. package/lib/features/ZustandLogFeature.js +0 -44
  254. package/lib/hooks/useNavigationLogger.js +0 -92
  255. package/lib/index.js +0 -114
  256. package/lib/navigation/NavigationLogger.js +0 -1
  257. package/lib/types/TrackTypes.ts +0 -92
  258. package/lib/utils/DebugConst.js +0 -67
  259. package/lib/utils/StorageUtils.js +0 -80
  260. package/lib/views/ConsoleLogDetails.js +0 -314
  261. package/lib/views/FloatPanelView.js +0 -697
  262. package/lib/views/HttpLogDetails.js +0 -648
  263. package/lib/views/NavigationLogDetails.js +0 -302
  264. package/lib/views/RestartModal.js +0 -75
  265. package/lib/views/SubViewConsoleLogs.js +0 -209
  266. package/lib/views/SubViewEnvironment.js +0 -73
  267. package/lib/views/SubViewHTTPLogs.js +0 -235
  268. package/lib/views/SubViewNavigationLogs.js +0 -199
  269. package/lib/views/SubViewPerformance.js +0 -515
  270. package/lib/views/SubViewThirdPartyLibs.js +0 -239
  271. package/lib/views/SubViewTrackLogs.js +0 -318
  272. package/lib/views/SubViewZustandLogs.js +0 -279
  273. package/lib/views/TabView.js +0 -66
  274. package/lib/views/TrackLogDetails.js +0 -481
  275. package/lib/views/ZustandLogDetails.js +0 -355
  276. package/react-native-debug-toolkit.podspec +0 -25
  277. package/react-native.config.js +0 -18
@@ -1,697 +0,0 @@
1
- import React, { Component } from 'react'
2
- import {
3
- View,
4
- Text,
5
- StyleSheet,
6
- Animated,
7
- PanResponder,
8
- Dimensions,
9
- Pressable,
10
- SafeAreaView,
11
- ScrollView,
12
- TouchableOpacity,
13
- Modal,
14
- FlatList,
15
- } from 'react-native'
16
- // import AsyncStorage from '@react-native-async-storage/async-storage'
17
- import { IconRadius, DebugColors } from '../utils/DebugConst'
18
- import SubViewHTTPLogs from './SubViewHTTPLogs'
19
- // import SubViewPerformance from './SubViewPerformance'
20
- import SubViewConsoleLogs from './SubViewConsoleLogs'
21
- import SubViewZustandLogs from './SubViewZustandLogs'
22
- import SubViewNavigationLogs from './SubViewNavigationLogs'
23
- import SubViewThirdPartyLibs from './SubViewThirdPartyLibs'
24
- import SubViewTrackLogs from './SubViewTrackLogs'
25
-
26
- const { width: screenWidth, height: screenHeight } = Dimensions.get('window')
27
-
28
- export default class FloatPanelView extends Component {
29
- constructor(props) {
30
- super(props)
31
-
32
- // Calculate initial position (right edge, middle of screen)
33
- const initialPosition = {
34
- x: screenWidth - IconRadius - 20,
35
- y: screenHeight / 2 - IconRadius / 2,
36
- }
37
-
38
- this.state = {
39
- isOpen: false,
40
- toFloat: true,
41
- pan: new Animated.ValueXY(initialPosition),
42
- scale: new Animated.Value(1),
43
- lastPosition: initialPosition,
44
- activeTab: 0,
45
- panelTranslateY: new Animated.Value(screenHeight),
46
- backdropOpacity: new Animated.Value(0),
47
- isTabMenuVisible: false,
48
- panelLayout: { width: 0, height: 0 },
49
- }
50
-
51
- this.tabScrollViewRef = React.createRef()
52
-
53
- this.gestureResponder = PanResponder.create({
54
- onStartShouldSetPanResponder: () => true,
55
- onMoveShouldSetPanResponder: () => true,
56
- onPanResponderGrant: this._handlePanResponderGrant,
57
- onPanResponderMove: this._handlePanResponderMove,
58
- onPanResponderRelease: this._handlePanResponderRelease,
59
- onPanResponderTerminate: this._handlePanResponderRelease,
60
- })
61
-
62
- this.panelResponder = PanResponder.create({
63
- onStartShouldSetPanResponder: () => true,
64
- onMoveShouldSetPanResponder: (_, gestureState) => {
65
- // Only respond to downward swipes
66
- return gestureState.dy > 5
67
- },
68
- onPanResponderMove: (_, gestureState) => {
69
- if (gestureState.dy > 0) {
70
- this.state.panelTranslateY.setValue(gestureState.dy)
71
- // Fade backdrop based on drag distance
72
- const newOpacity = Math.max(0, 1 - gestureState.dy / 200)
73
- this.state.backdropOpacity.setValue(newOpacity)
74
- }
75
- },
76
- onPanResponderRelease: (_, gestureState) => {
77
- if (gestureState.dy > 100) {
78
- this._closePanel()
79
- } else {
80
- Animated.spring(this.state.panelTranslateY, {
81
- toValue: 0,
82
- friction: 8,
83
- tension: 50,
84
- useNativeDriver: true,
85
- }).start()
86
-
87
- Animated.timing(this.state.backdropOpacity, {
88
- toValue: 1,
89
- duration: 200,
90
- useNativeDriver: true,
91
- }).start()
92
- }
93
- },
94
- })
95
- }
96
-
97
- async componentDidMount() {
98
- try {
99
- // const savedPosition = await AsyncStorage.getItem('@debug_toolkit_position')
100
-
101
- // if (savedPosition) {
102
- // const position = JSON.parse(savedPosition)
103
-
104
- // // Ensure position is within bounds
105
- // const boundedPosition = {
106
- // x: Math.max(0, Math.min(position.x, screenWidth - IconRadius)),
107
- // y: Math.max(0, Math.min(position.y, screenHeight - IconRadius)),
108
- // }
109
-
110
- // this.setState({ lastPosition: boundedPosition })
111
- // this.state.pan.setValue(boundedPosition)
112
- // }
113
- } catch (error) {
114
- console.error('Failed to load debug toolkit position:', error)
115
- }
116
- }
117
-
118
- _handlePanResponderGrant = () => {
119
- this.setState({ toFloat: true })
120
- Animated.spring(this.state.scale, {
121
- toValue: 1.2,
122
- friction: 5,
123
- useNativeDriver: true,
124
- }).start()
125
- }
126
-
127
- _handlePanResponderMove = (e, gestureState) => {
128
- const { dx, dy } = gestureState
129
- const newX = this.state.lastPosition.x + dx
130
- const newY = this.state.lastPosition.y + dy
131
-
132
- // Keep within screen bounds while dragging
133
- const boundedX = Math.max(0, Math.min(newX, screenWidth - IconRadius))
134
- const boundedY = Math.max(0, Math.min(newY, screenHeight - IconRadius))
135
-
136
- this.state.pan.setValue({
137
- x: boundedX,
138
- y: boundedY,
139
- })
140
- }
141
-
142
- _handlePanResponderRelease = async (e, gestureState) => {
143
- const { dx, dy } = gestureState
144
-
145
- // If it's a tap (minimal movement)
146
- if (Math.abs(dx) < 5 && Math.abs(dy) < 5) {
147
- this._togglePanel()
148
- return
149
- }
150
-
151
- // Animate button scale back to normal
152
- Animated.spring(this.state.scale, {
153
- toValue: 1,
154
- friction: 5,
155
- useNativeDriver: true,
156
- }).start()
157
-
158
- // Calculate final position
159
- let newX = this.state.lastPosition.x + dx
160
- let newY = this.state.lastPosition.y + dy
161
-
162
- // Keep within screen bounds
163
- newX = Math.max(0, Math.min(newX, screenWidth - IconRadius))
164
- newY = Math.max(0, Math.min(newY, screenHeight - IconRadius))
165
-
166
- const newPosition = { x: newX, y: newY }
167
-
168
- // Save position
169
- try {
170
- // await AsyncStorage.setItem('@debug_toolkit_position', JSON.stringify(newPosition))
171
- } catch (error) {
172
- console.error('Failed to save debug toolkit position:', error)
173
- }
174
-
175
- this.setState({
176
- lastPosition: newPosition,
177
- toFloat: true,
178
- })
179
- }
180
-
181
- _togglePanel = () => {
182
- const { isOpen } = this.state
183
-
184
- if (isOpen) {
185
- this._closePanel()
186
- } else {
187
- this._openPanel()
188
- }
189
- }
190
-
191
- _openPanel = () => {
192
- this.setState({ isOpen: true, toFloat: false }, () => {
193
- Animated.parallel([
194
- Animated.spring(this.state.panelTranslateY, {
195
- toValue: 0,
196
- friction: 8,
197
- tension: 65,
198
- useNativeDriver: true,
199
- }),
200
- Animated.timing(this.state.backdropOpacity, {
201
- toValue: 1,
202
- duration: 250,
203
- useNativeDriver: true,
204
- }),
205
- ]).start()
206
- })
207
- }
208
-
209
- _closePanel = () => {
210
- this.setState({ isTabMenuVisible: false })
211
-
212
- Animated.parallel([
213
- Animated.spring(this.state.panelTranslateY, {
214
- toValue: screenHeight,
215
- friction: 8,
216
- tension: 65,
217
- useNativeDriver: true,
218
- }),
219
- Animated.timing(this.state.backdropOpacity, {
220
- toValue: 0,
221
- duration: 200,
222
- useNativeDriver: true,
223
- }),
224
- ]).start(() => {
225
- this.setState({ isOpen: false, toFloat: true })
226
- })
227
- }
228
-
229
- _toggleTabMenu = () => {
230
- this.setState(prevState => ({ isTabMenuVisible: !prevState.isTabMenuVisible }))
231
- }
232
-
233
- _handleTabChange = (index) => {
234
- this.setState({
235
- activeTab: index,
236
- isTabMenuVisible: false
237
- }, () => {
238
- // Scroll to make active tab visible
239
- if (this.tabScrollViewRef.current) {
240
- const tabWidth = 80; // Approximate tab width
241
- this.tabScrollViewRef.current.scrollTo({
242
- x: Math.max(0, index * tabWidth - 50), // Center the tab
243
- animated: true
244
- });
245
- }
246
- })
247
- }
248
-
249
- renderFloatBtn() {
250
- const { isOpen, toFloat } = this.state
251
-
252
- if (!isOpen && toFloat) {
253
- return (
254
- <Animated.View
255
- {...this.gestureResponder.panHandlers}
256
- style={[
257
- styles.floatBtn,
258
- {
259
- transform: [
260
- { translateX: this.state.pan.x },
261
- { translateY: this.state.pan.y },
262
- { scale: this.state.scale },
263
- ],
264
- },
265
- ]}>
266
- <Pressable onPress={this._togglePanel} style={styles.floatBtnInner}>
267
- <View style={styles.indicatorDot} />
268
- </Pressable>
269
- </Animated.View>
270
- )
271
- }
272
-
273
- return null
274
- }
275
-
276
- getFeatureTabs() {
277
- const { features } = this.props
278
-
279
- if (!features || !features.length) {
280
- return []
281
- }
282
-
283
- return features.map((feature) => ({
284
- label: feature.label,
285
- id: feature.name,
286
- }))
287
- }
288
-
289
- renderFeatureContent(featureId) {
290
- const { features } = this.props
291
-
292
- if (!features || !features.length) {
293
- return <Text style={styles.emptyText}>No features available</Text>
294
- }
295
-
296
- const feature = features.find((f) => f.name === featureId)
297
-
298
- if (!feature) {
299
- return <Text style={styles.emptyText}>Feature not found</Text>
300
- }
301
-
302
- const data = feature.getData()
303
-
304
- // Special handling for network logs
305
- if (feature.name === 'network') {
306
- return <SubViewHTTPLogs logs={data} />
307
- }
308
-
309
- // Special handling for performance view
310
- // if (feature.name === 'performance') {
311
- // return <SubViewPerformance />
312
- // }
313
-
314
- if (feature.name === 'console') {
315
- return <SubViewConsoleLogs logs={data} />
316
- }
317
-
318
- if (feature.name === 'zustand') {
319
- return <SubViewZustandLogs logs={data} />
320
- }
321
-
322
- if (feature.name === 'navigation') {
323
- return <SubViewNavigationLogs logs={data} />
324
- }
325
-
326
- if (feature.name === 'track') {
327
- return <SubViewTrackLogs logs={data} />
328
- }
329
-
330
- if (feature.name === 'thirdPartyLibs') {
331
- return <SubViewThirdPartyLibs libraries={data} />
332
- }
333
-
334
- // Generic fallback for other feature types
335
- return (
336
- <View style={styles.genericContent}>
337
- <View style={styles.contentHeader}>
338
- <Text style={styles.contentTitle}>{feature.label}</Text>
339
- </View>
340
- <Text style={styles.jsonContent}>{JSON.stringify(data, null, 2)}</Text>
341
- </View>
342
- )
343
- }
344
-
345
- renderContent() {
346
- const tabs = this.getFeatureTabs()
347
- const { activeTab } = this.state
348
-
349
- if (!tabs.length) {
350
- return <Text style={styles.emptyText}>No debug features available</Text>
351
- }
352
-
353
- return this.renderFeatureContent(tabs[activeTab].id)
354
- }
355
-
356
- renderTabBar() {
357
- const tabs = this.getFeatureTabs()
358
- const { activeTab } = this.state
359
-
360
- if (!tabs.length) return null
361
-
362
- return (
363
- <View style={styles.tabBarContainer}>
364
- <View style={styles.tabsRow}>
365
- <ScrollView
366
- ref={this.tabScrollViewRef}
367
- horizontal
368
- showsHorizontalScrollIndicator={false}
369
- contentContainerStyle={styles.tabsScrollContainer}>
370
- {tabs.map((tab, index) => {
371
- const isActive = index === activeTab
372
-
373
- return (
374
- <TouchableOpacity
375
- key={`tab-${tab.id}`}
376
- style={[styles.tab, isActive && styles.activeTab]}
377
- onPress={() => this._handleTabChange(index)}>
378
- <Text
379
- style={[styles.tabText, isActive && styles.activeTabText]}
380
- numberOfLines={1}
381
- ellipsizeMode="tail">
382
- {tab.label}
383
- </Text>
384
- </TouchableOpacity>
385
- )
386
- })}
387
- </ScrollView>
388
-
389
- </View>
390
- </View>
391
- )
392
- }
393
-
394
- renderPanel() {
395
- const { isOpen, panelTranslateY, backdropOpacity } = this.state
396
- const { clearAll } = this.props
397
-
398
-
399
- if (!isOpen) {
400
- return null
401
- }
402
-
403
- return (
404
- <View style={styles.panelContainer}>
405
- <Animated.View style={[styles.backdrop, { opacity: backdropOpacity }]}>
406
- <Pressable
407
- style={styles.backdropPressable}
408
- onPress={this._closePanel}
409
- />
410
- </Animated.View>
411
- <Animated.View
412
- style={[
413
- styles.panel,
414
- { transform: [{ translateY: panelTranslateY }] },
415
- ]}
416
- onLayout={(e) => {
417
- const { width, height } = e.nativeEvent.layout
418
- this.setState({ panelLayout: { width, height } })
419
- }}>
420
- <View {...this.panelResponder.panHandlers} style={styles.dragHandle}>
421
- <View style={styles.dragIndicator} />
422
- </View>
423
- <SafeAreaView style={styles.panelContent}>
424
- <View style={styles.header}>
425
- <Text style={styles.headerTitle}>Debug Toolkit</Text>
426
- <View style={styles.headerButtons}>
427
- {clearAll && (
428
- <TouchableOpacity
429
- onPress={() => {
430
- clearAll()
431
- this._closePanel()
432
- }}
433
- style={[styles.clearButton, styles.clearAllButton]}
434
- >
435
- <Text style={styles.clearButtonText}>Clear & Close</Text>
436
- </TouchableOpacity>
437
- )}
438
- <Pressable onPress={this._closePanel} style={styles.closeButton}>
439
- <Text style={styles.closeButtonText}>×</Text>
440
- </Pressable>
441
- </View>
442
- </View>
443
-
444
- {this.renderTabBar()}
445
-
446
- <View style={styles.contentContainer}>
447
- {this.renderContent()}
448
- </View>
449
- </SafeAreaView>
450
- </Animated.View>
451
- </View>
452
- )
453
- }
454
-
455
- render() {
456
- return (
457
- <View style={styles.container} pointerEvents='box-none'>
458
- {this.renderFloatBtn()}
459
- {this.renderPanel()}
460
- </View>
461
- )
462
- }
463
- }
464
-
465
- const styles = StyleSheet.create({
466
- container: {
467
- position: 'absolute',
468
- top: 0,
469
- left: 0,
470
- right: 0,
471
- bottom: 0,
472
- zIndex: 999,
473
- },
474
- floatBtn: {
475
- position: 'absolute',
476
- width: IconRadius,
477
- height: IconRadius,
478
- borderRadius: IconRadius / 2,
479
- backgroundColor: 'rgba(255, 255, 255, 0.7)',
480
- borderWidth: 1,
481
- borderColor: DebugColors.blue,
482
- elevation: 5,
483
- shadowColor: '#000',
484
- shadowOffset: { width: 0, height: 2 },
485
- shadowOpacity: 0.25,
486
- shadowRadius: 3.84,
487
- },
488
- floatBtnInner: {
489
- width: '100%',
490
- height: '100%',
491
- alignItems: 'center',
492
- justifyContent: 'center',
493
- },
494
- indicatorDot: {
495
- width: 12,
496
- height: 12,
497
- borderRadius: 6,
498
- backgroundColor: DebugColors.blue,
499
- },
500
- panelContainer: {
501
- position: 'absolute',
502
- top: 0,
503
- left: 0,
504
- right: 0,
505
- bottom: 0,
506
- justifyContent: 'flex-end',
507
- },
508
- backdrop: {
509
- position: 'absolute',
510
- top: 0,
511
- left: 0,
512
- right: 0,
513
- bottom: 0,
514
- backgroundColor: 'rgba(0,0,0,0.5)',
515
- },
516
- backdropPressable: {
517
- flex: 1,
518
- },
519
- panel: {
520
- width: '100%',
521
- height: '90%',
522
- backgroundColor: DebugColors.white,
523
- borderTopLeftRadius: 24,
524
- borderTopRightRadius: 24,
525
- overflow: 'hidden',
526
- elevation: 24,
527
- shadowColor: '#000',
528
- shadowOffset: { width: 0, height: -5 },
529
- shadowOpacity: 0.3,
530
- shadowRadius: 10.0,
531
- },
532
- dragHandle: {
533
- width: '100%',
534
- height: 30,
535
- alignItems: 'center',
536
- justifyContent: 'center',
537
- backgroundColor: DebugColors.white,
538
- },
539
- dragIndicator: {
540
- width: 40,
541
- height: 5,
542
- borderRadius: 3,
543
- backgroundColor: '#CCCCCC',
544
- },
545
- panelContent: {
546
- flex: 1,
547
- },
548
- contentContainer: {
549
- flex: 1,
550
- },
551
- header: {
552
- flexDirection: 'row',
553
- justifyContent: 'space-between',
554
- alignItems: 'center',
555
- paddingHorizontal: 15,
556
- paddingVertical: 12,
557
- borderBottomWidth: 1,
558
- borderBottomColor: '#e5e5e5',
559
- backgroundColor: '#f9f9f9',
560
- shadowColor: "#000",
561
- shadowOffset: {
562
- width: 0,
563
- height: 1,
564
- },
565
- shadowOpacity: 0.1,
566
- shadowRadius: 1.5,
567
- elevation: 1,
568
- },
569
- headerTitle: {
570
- fontSize: 18,
571
- fontWeight: '700',
572
- color: '#2c3e50',
573
- },
574
- headerButtons: {
575
- flexDirection: 'row',
576
- alignItems: 'center',
577
- },
578
- clearButton: {
579
- backgroundColor: DebugColors.blue,
580
- paddingHorizontal: 10,
581
- paddingVertical: 5,
582
- borderRadius: 4,
583
- marginRight: 10,
584
- },
585
- clearAllButton: {
586
- backgroundColor: '#3498db',
587
- paddingHorizontal: 14,
588
- paddingVertical: 9,
589
- borderRadius: 6,
590
- marginRight: 12,
591
- shadowColor: "#000",
592
- shadowOffset: {
593
- width: 0,
594
- height: 1,
595
- },
596
- shadowOpacity: 0.12,
597
- shadowRadius: 1,
598
- elevation: 2,
599
- },
600
- clearButtonText: {
601
- color: '#fff',
602
- fontSize: 13,
603
- fontWeight: '600',
604
- },
605
- closeButton: {
606
- width: 30,
607
- height: 30,
608
- borderRadius: 15,
609
- backgroundColor: '#ecf0f1',
610
- alignItems: 'center',
611
- justifyContent: 'center',
612
- shadowColor: "#000",
613
- shadowOffset: {
614
- width: 0,
615
- height: 1,
616
- },
617
- shadowOpacity: 0.1,
618
- shadowRadius: 1,
619
- elevation: 1,
620
- },
621
- closeButtonText: {
622
- fontSize: 20,
623
- fontWeight: 'bold',
624
- color: '#34495e',
625
- lineHeight: 20,
626
- },
627
- tabBarContainer: {
628
- borderBottomWidth: 1,
629
- borderBottomColor: DebugColors.border,
630
- backgroundColor: DebugColors.background,
631
- },
632
- tabsRow: {
633
- flexDirection: 'row',
634
- alignItems: 'center',
635
- },
636
- tabsScrollContainer: {
637
- paddingHorizontal: 15,
638
- flexDirection: 'row',
639
- alignItems: 'center',
640
- },
641
- tab: {
642
- paddingVertical: 12,
643
- paddingHorizontal: 8,
644
- marginRight: 4,
645
- alignItems: 'center',
646
- justifyContent: 'center',
647
- minWidth: 50,
648
- },
649
- activeTab: {
650
- borderBottomWidth: 2,
651
- borderBottomColor: DebugColors.blue,
652
- },
653
- tabText: {
654
- fontSize: 13,
655
- color: DebugColors.textLight,
656
- textAlign: 'center',
657
- },
658
- activeTabText: {
659
- color: DebugColors.blue,
660
- fontWeight: '600',
661
- },
662
- emptyText: {
663
- padding: 20,
664
- textAlign: 'center',
665
- color: '#999',
666
- },
667
- genericContent: {
668
- padding: 15,
669
- flex: 1,
670
- },
671
- contentHeader: {
672
- flexDirection: 'row',
673
- justifyContent: 'space-between',
674
- alignItems: 'center',
675
- marginBottom: 10,
676
- },
677
- contentTitle: {
678
- fontSize: 16,
679
- fontWeight: 'bold',
680
- color: DebugColors.text,
681
- },
682
- copyButton: {
683
- paddingHorizontal: 12,
684
- paddingVertical: 6,
685
- backgroundColor: DebugColors.blue,
686
- borderRadius: 4,
687
- },
688
- copyButtonText: {
689
- color: '#FFF',
690
- fontSize: 14,
691
- },
692
- jsonContent: {
693
- fontFamily: 'monospace',
694
- fontSize: 12,
695
- color: DebugColors.text,
696
- }
697
- })