react-native-debug-toolkit 2.0.0 → 2.2.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 (443) hide show
  1. package/README.md +82 -120
  2. package/README.zh-CN.md +171 -0
  3. package/lib/commonjs/core/DebugToolkit.js +117 -115
  4. package/lib/commonjs/core/DebugToolkit.js.map +1 -1
  5. package/lib/commonjs/core/DebugToolkitProvider.js +38 -30
  6. package/lib/commonjs/core/DebugToolkitProvider.js.map +1 -1
  7. package/lib/commonjs/core/initialize.js +84 -0
  8. package/lib/commonjs/core/initialize.js.map +1 -0
  9. package/lib/commonjs/{components → features/clipboard}/ClipboardTab.js +16 -17
  10. package/lib/commonjs/features/clipboard/ClipboardTab.js.map +1 -0
  11. package/lib/commonjs/features/{ClipboardFeature.js → clipboard/index.js} +9 -5
  12. package/lib/commonjs/features/clipboard/index.js.map +1 -0
  13. package/lib/commonjs/features/console/ConsoleLogTab.js +162 -0
  14. package/lib/commonjs/features/console/ConsoleLogTab.js.map +1 -0
  15. package/lib/commonjs/features/console/index.js +118 -0
  16. package/lib/commonjs/features/console/index.js.map +1 -0
  17. package/lib/commonjs/{components → features/environment}/EnvironmentTab.js +24 -25
  18. package/lib/commonjs/features/environment/EnvironmentTab.js.map +1 -0
  19. package/lib/commonjs/features/{EnvironmentFeature.js → environment/index.js} +22 -25
  20. package/lib/commonjs/features/environment/index.js.map +1 -0
  21. package/lib/commonjs/{components → features/navigation}/NavigationLogTab.js +11 -10
  22. package/lib/commonjs/features/navigation/NavigationLogTab.js.map +1 -0
  23. package/lib/commonjs/features/navigation/index.js +39 -0
  24. package/lib/commonjs/features/navigation/index.js.map +1 -0
  25. package/lib/commonjs/{hooks → features/navigation}/useNavigationLogger.js +3 -3
  26. package/lib/commonjs/features/navigation/useNavigationLogger.js.map +1 -0
  27. package/lib/commonjs/features/network/NetworkLogTab.js +405 -0
  28. package/lib/commonjs/features/network/NetworkLogTab.js.map +1 -0
  29. package/lib/commonjs/features/network/index.js +96 -0
  30. package/lib/commonjs/features/network/index.js.map +1 -0
  31. package/lib/commonjs/features/network/networkInterceptor.js +261 -0
  32. package/lib/commonjs/features/network/networkInterceptor.js.map +1 -0
  33. package/lib/commonjs/{components → features/thirdPartyLibs}/ThirdPartyLibsTab.js +10 -9
  34. package/lib/commonjs/features/thirdPartyLibs/ThirdPartyLibsTab.js.map +1 -0
  35. package/lib/commonjs/features/{ThirdPartyLibsFeature.js → thirdPartyLibs/index.js} +8 -8
  36. package/lib/commonjs/features/thirdPartyLibs/index.js.map +1 -0
  37. package/lib/commonjs/{native/NativeDebugLibs.js → features/thirdPartyLibs/nativeDebugLibs.js} +1 -1
  38. package/lib/commonjs/features/thirdPartyLibs/nativeDebugLibs.js.map +1 -0
  39. package/lib/commonjs/features/track/TrackLogTab.js +230 -0
  40. package/lib/commonjs/features/track/TrackLogTab.js.map +1 -0
  41. package/lib/commonjs/features/track/index.js +39 -0
  42. package/lib/commonjs/features/track/index.js.map +1 -0
  43. package/lib/commonjs/features/zustand/ZustandLogTab.js +311 -0
  44. package/lib/commonjs/features/zustand/ZustandLogTab.js.map +1 -0
  45. package/lib/commonjs/features/zustand/index.js +59 -0
  46. package/lib/commonjs/features/zustand/index.js.map +1 -0
  47. package/lib/commonjs/index.js +27 -40
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/types/environment.js +2 -0
  50. package/lib/commonjs/types/environment.js.map +1 -0
  51. package/lib/commonjs/types/feature.js +6 -0
  52. package/lib/commonjs/types/feature.js.map +1 -0
  53. package/lib/commonjs/types/index.js +0 -4
  54. package/lib/commonjs/types/logs.js +2 -0
  55. package/lib/commonjs/types/logs.js.map +1 -0
  56. package/lib/commonjs/types/navigation.js +2 -0
  57. package/lib/commonjs/types/navigation.js.map +1 -0
  58. package/lib/commonjs/types/thirdPartyLibs.js +2 -0
  59. package/lib/commonjs/types/thirdPartyLibs.js.map +1 -0
  60. package/lib/commonjs/ui/DebugView.js +66 -0
  61. package/lib/commonjs/ui/DebugView.js.map +1 -0
  62. package/lib/commonjs/ui/floating/FloatIcon.js +240 -0
  63. package/lib/commonjs/ui/floating/FloatIcon.js.map +1 -0
  64. package/lib/commonjs/ui/panel/DebugPanel.js +230 -0
  65. package/lib/commonjs/ui/panel/DebugPanel.js.map +1 -0
  66. package/lib/commonjs/ui/panel/FeatureTabBar.js +182 -0
  67. package/lib/commonjs/ui/panel/FeatureTabBar.js.map +1 -0
  68. package/lib/commonjs/ui/panel/FloatPanelView.js +238 -0
  69. package/lib/commonjs/ui/panel/FloatPanelView.js.map +1 -0
  70. package/lib/commonjs/{components → ui}/shared/CollapsibleSection.js +4 -4
  71. package/lib/commonjs/ui/shared/CollapsibleSection.js.map +1 -0
  72. package/lib/commonjs/{components → ui}/shared/CopyButton.js +3 -3
  73. package/lib/commonjs/ui/shared/CopyButton.js.map +1 -0
  74. package/lib/commonjs/ui/shared/JsonView.js.map +1 -0
  75. package/lib/commonjs/ui/shared/LogListScreen.js +174 -0
  76. package/lib/commonjs/ui/shared/LogListScreen.js.map +1 -0
  77. package/lib/commonjs/ui/shared/useSlideDetailAnimation.js.map +1 -0
  78. package/lib/commonjs/ui/theme/colors.js +43 -0
  79. package/lib/commonjs/ui/theme/colors.js.map +1 -0
  80. package/lib/commonjs/ui/theme/layout.js +8 -0
  81. package/lib/commonjs/ui/theme/layout.js.map +1 -0
  82. package/lib/commonjs/utils/createChannelFeature.js +62 -0
  83. package/lib/commonjs/utils/createChannelFeature.js.map +1 -0
  84. package/lib/commonjs/utils/createObservableStore.js +5 -0
  85. package/lib/commonjs/utils/createObservableStore.js.map +1 -1
  86. package/lib/commonjs/utils/createPersistedObservableStore.js +71 -0
  87. package/lib/commonjs/utils/createPersistedObservableStore.js.map +1 -0
  88. package/lib/commonjs/utils/debugPreferences.js +52 -0
  89. package/lib/commonjs/utils/debugPreferences.js.map +1 -0
  90. package/lib/commonjs/utils/urlRewriterRegistry.js +14 -0
  91. package/lib/commonjs/utils/urlRewriterRegistry.js.map +1 -0
  92. package/lib/module/core/DebugToolkit.js +117 -114
  93. package/lib/module/core/DebugToolkit.js.map +1 -1
  94. package/lib/module/core/DebugToolkitProvider.js +39 -31
  95. package/lib/module/core/DebugToolkitProvider.js.map +1 -1
  96. package/lib/module/core/initialize.js +80 -0
  97. package/lib/module/core/initialize.js.map +1 -0
  98. package/lib/module/{components → features/clipboard}/ClipboardTab.js +9 -9
  99. package/lib/module/features/clipboard/ClipboardTab.js.map +1 -0
  100. package/lib/module/features/clipboard/index.js +16 -0
  101. package/lib/module/features/clipboard/index.js.map +1 -0
  102. package/lib/module/features/console/ConsoleLogTab.js +157 -0
  103. package/lib/module/features/console/ConsoleLogTab.js.map +1 -0
  104. package/lib/module/features/console/index.js +112 -0
  105. package/lib/module/features/console/index.js.map +1 -0
  106. package/lib/module/{components → features/environment}/EnvironmentTab.js +5 -5
  107. package/lib/module/features/environment/EnvironmentTab.js.map +1 -0
  108. package/lib/module/features/{EnvironmentFeature.js → environment/index.js} +22 -25
  109. package/lib/module/features/environment/index.js.map +1 -0
  110. package/lib/module/{components → features/navigation}/NavigationLogTab.js +4 -3
  111. package/lib/module/features/navigation/NavigationLogTab.js.map +1 -0
  112. package/lib/module/features/navigation/index.js +32 -0
  113. package/lib/module/features/navigation/index.js.map +1 -0
  114. package/lib/module/{hooks → features/navigation}/useNavigationLogger.js +2 -2
  115. package/lib/module/features/navigation/useNavigationLogger.js.map +1 -0
  116. package/lib/module/features/network/NetworkLogTab.js +400 -0
  117. package/lib/module/features/network/NetworkLogTab.js.map +1 -0
  118. package/lib/module/features/network/index.js +90 -0
  119. package/lib/module/features/network/index.js.map +1 -0
  120. package/lib/module/features/network/networkInterceptor.js +256 -0
  121. package/lib/module/features/network/networkInterceptor.js.map +1 -0
  122. package/lib/module/{components → features/thirdPartyLibs}/ThirdPartyLibsTab.js +3 -2
  123. package/lib/module/features/thirdPartyLibs/ThirdPartyLibsTab.js.map +1 -0
  124. package/lib/module/features/{ThirdPartyLibsFeature.js → thirdPartyLibs/index.js} +4 -4
  125. package/lib/module/features/thirdPartyLibs/index.js.map +1 -0
  126. package/lib/module/{native/NativeDebugLibs.js → features/thirdPartyLibs/nativeDebugLibs.js} +1 -1
  127. package/lib/module/features/thirdPartyLibs/nativeDebugLibs.js.map +1 -0
  128. package/lib/module/features/track/TrackLogTab.js +225 -0
  129. package/lib/module/features/track/TrackLogTab.js.map +1 -0
  130. package/lib/module/features/track/index.js +32 -0
  131. package/lib/module/features/track/index.js.map +1 -0
  132. package/lib/module/features/zustand/ZustandLogTab.js +306 -0
  133. package/lib/module/features/zustand/ZustandLogTab.js.map +1 -0
  134. package/lib/module/features/zustand/index.js +53 -0
  135. package/lib/module/features/zustand/index.js.map +1 -0
  136. package/lib/module/index.js +11 -12
  137. package/lib/module/index.js.map +1 -1
  138. package/lib/module/types/environment.js +2 -0
  139. package/lib/module/types/environment.js.map +1 -0
  140. package/lib/module/types/feature.js +4 -0
  141. package/lib/module/types/feature.js.map +1 -0
  142. package/lib/module/types/index.js +0 -2
  143. package/lib/module/types/logs.js +2 -0
  144. package/lib/module/types/logs.js.map +1 -0
  145. package/lib/module/types/navigation.js +2 -0
  146. package/lib/module/types/navigation.js.map +1 -0
  147. package/lib/module/types/thirdPartyLibs.js +2 -0
  148. package/lib/module/types/thirdPartyLibs.js.map +1 -0
  149. package/lib/module/ui/DebugView.js +61 -0
  150. package/lib/module/ui/DebugView.js.map +1 -0
  151. package/lib/module/ui/floating/FloatIcon.js +235 -0
  152. package/lib/module/ui/floating/FloatIcon.js.map +1 -0
  153. package/lib/module/ui/panel/DebugPanel.js +225 -0
  154. package/lib/module/ui/panel/DebugPanel.js.map +1 -0
  155. package/lib/module/ui/panel/FeatureTabBar.js +177 -0
  156. package/lib/module/ui/panel/FeatureTabBar.js.map +1 -0
  157. package/lib/module/ui/panel/FloatPanelView.js +233 -0
  158. package/lib/module/ui/panel/FloatPanelView.js.map +1 -0
  159. package/lib/module/{components → ui}/shared/CollapsibleSection.js +1 -1
  160. package/lib/module/ui/shared/CollapsibleSection.js.map +1 -0
  161. package/lib/module/{components → ui}/shared/CopyButton.js +1 -1
  162. package/lib/module/ui/shared/CopyButton.js.map +1 -0
  163. package/lib/module/ui/shared/JsonView.js.map +1 -0
  164. package/lib/module/ui/shared/LogListScreen.js +169 -0
  165. package/lib/module/ui/shared/LogListScreen.js.map +1 -0
  166. package/lib/module/ui/shared/useSlideDetailAnimation.js.map +1 -0
  167. package/lib/module/ui/theme/colors.js +38 -0
  168. package/lib/module/ui/theme/colors.js.map +1 -0
  169. package/lib/module/ui/theme/layout.js +4 -0
  170. package/lib/module/ui/theme/layout.js.map +1 -0
  171. package/lib/module/utils/createChannelFeature.js +58 -0
  172. package/lib/module/utils/createChannelFeature.js.map +1 -0
  173. package/lib/module/utils/createObservableStore.js +5 -0
  174. package/lib/module/utils/createObservableStore.js.map +1 -1
  175. package/lib/module/utils/createPersistedObservableStore.js +67 -0
  176. package/lib/module/utils/createPersistedObservableStore.js.map +1 -0
  177. package/lib/module/utils/debugPreferences.js +46 -0
  178. package/lib/module/utils/debugPreferences.js.map +1 -0
  179. package/lib/module/utils/urlRewriterRegistry.js +10 -0
  180. package/lib/module/utils/urlRewriterRegistry.js.map +1 -0
  181. package/lib/typescript/src/core/DebugToolkit.d.ts +17 -20
  182. package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -1
  183. package/lib/typescript/src/core/DebugToolkitProvider.d.ts +4 -7
  184. package/lib/typescript/src/core/DebugToolkitProvider.d.ts.map +1 -1
  185. package/lib/typescript/src/core/initialize.d.ts +32 -0
  186. package/lib/typescript/src/core/initialize.d.ts.map +1 -0
  187. package/lib/typescript/src/features/clipboard/ClipboardTab.d.ts +4 -0
  188. package/lib/typescript/src/features/clipboard/ClipboardTab.d.ts.map +1 -0
  189. package/lib/typescript/src/features/clipboard/index.d.ts +7 -0
  190. package/lib/typescript/src/features/clipboard/index.d.ts.map +1 -0
  191. package/lib/typescript/src/{components → features/console}/ConsoleLogTab.d.ts +2 -2
  192. package/lib/typescript/src/features/console/ConsoleLogTab.d.ts.map +1 -0
  193. package/lib/typescript/src/features/console/index.d.ts +9 -0
  194. package/lib/typescript/src/features/console/index.d.ts.map +1 -0
  195. package/lib/typescript/src/{components → features/environment}/EnvironmentTab.d.ts +1 -1
  196. package/lib/typescript/src/features/environment/EnvironmentTab.d.ts.map +1 -0
  197. package/lib/typescript/src/features/{EnvironmentFeature.d.ts → environment/index.d.ts} +2 -2
  198. package/lib/typescript/src/features/environment/index.d.ts.map +1 -0
  199. package/lib/typescript/src/{components → features/navigation}/NavigationLogTab.d.ts +2 -2
  200. package/lib/typescript/src/features/navigation/NavigationLogTab.d.ts.map +1 -0
  201. package/lib/typescript/src/features/{NavigationLogFeature.d.ts → navigation/index.d.ts} +5 -3
  202. package/lib/typescript/src/features/navigation/index.d.ts.map +1 -0
  203. package/lib/typescript/src/{hooks → features/navigation}/useNavigationLogger.d.ts +1 -8
  204. package/lib/typescript/src/features/navigation/useNavigationLogger.d.ts.map +1 -0
  205. package/lib/typescript/src/{components → features/network}/NetworkLogTab.d.ts +2 -2
  206. package/lib/typescript/src/features/network/NetworkLogTab.d.ts.map +1 -0
  207. package/lib/typescript/src/features/network/index.d.ts +15 -0
  208. package/lib/typescript/src/features/network/index.d.ts.map +1 -0
  209. package/lib/typescript/src/features/network/networkInterceptor.d.ts +19 -0
  210. package/lib/typescript/src/features/network/networkInterceptor.d.ts.map +1 -0
  211. package/lib/typescript/src/{components → features/thirdPartyLibs}/ThirdPartyLibsTab.d.ts +2 -2
  212. package/lib/typescript/src/features/thirdPartyLibs/ThirdPartyLibsTab.d.ts.map +1 -0
  213. package/lib/typescript/src/features/thirdPartyLibs/index.d.ts +3 -0
  214. package/lib/typescript/src/features/thirdPartyLibs/index.d.ts.map +1 -0
  215. package/lib/typescript/src/{native/NativeDebugLibs.d.ts → features/thirdPartyLibs/nativeDebugLibs.d.ts} +1 -1
  216. package/lib/typescript/src/features/thirdPartyLibs/nativeDebugLibs.d.ts.map +1 -0
  217. package/lib/typescript/src/{components → features/track}/TrackLogTab.d.ts +2 -2
  218. package/lib/typescript/src/features/track/TrackLogTab.d.ts.map +1 -0
  219. package/lib/typescript/src/features/{TrackFeature.d.ts → track/index.d.ts} +5 -3
  220. package/lib/typescript/src/features/track/index.d.ts.map +1 -0
  221. package/lib/typescript/src/{components → features/zustand}/ZustandLogTab.d.ts +2 -2
  222. package/lib/typescript/src/features/zustand/ZustandLogTab.d.ts.map +1 -0
  223. package/lib/typescript/src/features/{ZustandLogFeature.d.ts → zustand/index.d.ts} +5 -3
  224. package/lib/typescript/src/features/zustand/index.d.ts.map +1 -0
  225. package/lib/typescript/src/index.d.ts +20 -20
  226. package/lib/typescript/src/index.d.ts.map +1 -1
  227. package/lib/typescript/src/types/environment.d.ts +11 -0
  228. package/lib/typescript/src/types/environment.d.ts.map +1 -0
  229. package/lib/typescript/src/types/feature.d.ts +23 -0
  230. package/lib/typescript/src/types/feature.d.ts.map +1 -0
  231. package/lib/typescript/src/types/index.d.ts +5 -111
  232. package/lib/typescript/src/types/index.d.ts.map +1 -1
  233. package/lib/typescript/src/types/logs.d.ts +51 -0
  234. package/lib/typescript/src/types/logs.d.ts.map +1 -0
  235. package/lib/typescript/src/types/navigation.d.ts +8 -0
  236. package/lib/typescript/src/types/navigation.d.ts.map +1 -0
  237. package/lib/typescript/src/types/thirdPartyLibs.d.ts +13 -0
  238. package/lib/typescript/src/types/thirdPartyLibs.d.ts.map +1 -0
  239. package/lib/typescript/src/ui/DebugView.d.ts +19 -0
  240. package/lib/typescript/src/ui/DebugView.d.ts.map +1 -0
  241. package/lib/typescript/src/ui/floating/FloatIcon.d.ts +12 -0
  242. package/lib/typescript/src/ui/floating/FloatIcon.d.ts.map +1 -0
  243. package/lib/typescript/src/ui/panel/DebugPanel.d.ts +9 -0
  244. package/lib/typescript/src/ui/panel/DebugPanel.d.ts.map +1 -0
  245. package/lib/typescript/src/ui/panel/FeatureTabBar.d.ts +13 -0
  246. package/lib/typescript/src/ui/panel/FeatureTabBar.d.ts.map +1 -0
  247. package/lib/typescript/src/ui/panel/FloatPanelView.d.ts +12 -0
  248. package/lib/typescript/src/ui/panel/FloatPanelView.d.ts.map +1 -0
  249. package/lib/typescript/src/ui/shared/CollapsibleSection.d.ts.map +1 -0
  250. package/lib/typescript/src/ui/shared/CopyButton.d.ts.map +1 -0
  251. package/lib/typescript/src/ui/shared/JsonView.d.ts.map +1 -0
  252. package/lib/typescript/src/ui/shared/LogListScreen.d.ts +21 -0
  253. package/lib/typescript/src/ui/shared/LogListScreen.d.ts.map +1 -0
  254. package/lib/typescript/src/ui/shared/useSlideDetailAnimation.d.ts.map +1 -0
  255. package/lib/typescript/src/ui/theme/colors.d.ts +21 -0
  256. package/lib/typescript/src/ui/theme/colors.d.ts.map +1 -0
  257. package/lib/typescript/src/ui/theme/layout.d.ts +2 -0
  258. package/lib/typescript/src/ui/theme/layout.d.ts.map +1 -0
  259. package/lib/typescript/src/utils/createChannelFeature.d.ts +27 -0
  260. package/lib/typescript/src/utils/createChannelFeature.d.ts.map +1 -0
  261. package/lib/typescript/src/utils/createObservableStore.d.ts +1 -0
  262. package/lib/typescript/src/utils/createObservableStore.d.ts.map +1 -1
  263. package/lib/typescript/src/utils/createPersistedObservableStore.d.ts +15 -0
  264. package/lib/typescript/src/utils/createPersistedObservableStore.d.ts.map +1 -0
  265. package/lib/typescript/src/utils/debugPreferences.d.ts +10 -0
  266. package/lib/typescript/src/utils/debugPreferences.d.ts.map +1 -0
  267. package/lib/typescript/src/utils/urlRewriterRegistry.d.ts +7 -0
  268. package/lib/typescript/src/utils/urlRewriterRegistry.d.ts.map +1 -0
  269. package/package.json +5 -1
  270. package/src/core/DebugToolkit.tsx +144 -142
  271. package/src/core/DebugToolkitProvider.tsx +44 -43
  272. package/src/core/initialize.ts +122 -0
  273. package/src/{components → features/clipboard}/ClipboardTab.tsx +10 -10
  274. package/src/features/clipboard/index.ts +15 -0
  275. package/src/features/console/ConsoleLogTab.tsx +95 -0
  276. package/src/features/console/index.ts +119 -0
  277. package/src/{components → features/environment}/EnvironmentTab.tsx +7 -7
  278. package/src/features/{EnvironmentFeature.ts → environment/index.ts} +27 -25
  279. package/src/{components → features/navigation}/NavigationLogTab.tsx +6 -5
  280. package/src/features/navigation/index.ts +44 -0
  281. package/src/{hooks → features/navigation}/useNavigationLogger.ts +3 -8
  282. package/src/features/network/NetworkLogTab.tsx +271 -0
  283. package/src/features/network/index.ts +113 -0
  284. package/src/features/network/networkInterceptor.ts +311 -0
  285. package/src/{components → features/thirdPartyLibs}/ThirdPartyLibsTab.tsx +6 -5
  286. package/src/features/{ThirdPartyLibsFeature.ts → thirdPartyLibs/index.ts} +5 -5
  287. package/src/features/track/TrackLogTab.tsx +110 -0
  288. package/src/features/track/index.ts +41 -0
  289. package/src/features/zustand/ZustandLogTab.tsx +203 -0
  290. package/src/features/{ZustandLogFeature.ts → zustand/index.ts} +19 -45
  291. package/src/index.ts +20 -24
  292. package/src/types/environment.ts +11 -0
  293. package/src/types/feature.ts +32 -0
  294. package/src/types/index.ts +29 -138
  295. package/src/types/logs.ts +54 -0
  296. package/src/types/navigation.ts +5 -0
  297. package/src/types/thirdPartyLibs.ts +13 -0
  298. package/src/ui/DebugView.tsx +80 -0
  299. package/src/ui/floating/FloatIcon.tsx +202 -0
  300. package/src/ui/panel/DebugPanel.tsx +215 -0
  301. package/src/ui/panel/FeatureTabBar.tsx +204 -0
  302. package/src/ui/panel/FloatPanelView.tsx +227 -0
  303. package/src/{components → ui}/shared/CollapsibleSection.tsx +1 -1
  304. package/src/{components → ui}/shared/CopyButton.tsx +1 -1
  305. package/src/ui/shared/LogListScreen.tsx +164 -0
  306. package/src/ui/theme/colors.ts +33 -0
  307. package/src/ui/theme/layout.ts +1 -0
  308. package/src/utils/createChannelFeature.ts +80 -0
  309. package/src/utils/createObservableStore.ts +6 -0
  310. package/src/utils/createPersistedObservableStore.ts +76 -0
  311. package/src/utils/debugPreferences.ts +48 -0
  312. package/src/utils/urlRewriterRegistry.ts +10 -0
  313. package/lib/commonjs/components/ClipboardTab.js.map +0 -1
  314. package/lib/commonjs/components/ConsoleLogTab.js +0 -295
  315. package/lib/commonjs/components/ConsoleLogTab.js.map +0 -1
  316. package/lib/commonjs/components/EnvironmentTab.js.map +0 -1
  317. package/lib/commonjs/components/FloatPanelView.js +0 -797
  318. package/lib/commonjs/components/FloatPanelView.js.map +0 -1
  319. package/lib/commonjs/components/NavigationLogTab.js.map +0 -1
  320. package/lib/commonjs/components/NetworkLogTab.js +0 -575
  321. package/lib/commonjs/components/NetworkLogTab.js.map +0 -1
  322. package/lib/commonjs/components/ThirdPartyLibsTab.js.map +0 -1
  323. package/lib/commonjs/components/TrackLogTab.js +0 -372
  324. package/lib/commonjs/components/TrackLogTab.js.map +0 -1
  325. package/lib/commonjs/components/ZustandLogTab.js +0 -451
  326. package/lib/commonjs/components/ZustandLogTab.js.map +0 -1
  327. package/lib/commonjs/components/shared/CollapsibleSection.js.map +0 -1
  328. package/lib/commonjs/components/shared/CopyButton.js.map +0 -1
  329. package/lib/commonjs/components/shared/JsonView.js.map +0 -1
  330. package/lib/commonjs/features/ClipboardFeature.js.map +0 -1
  331. package/lib/commonjs/features/ConsoleLogFeature.js +0 -98
  332. package/lib/commonjs/features/ConsoleLogFeature.js.map +0 -1
  333. package/lib/commonjs/features/EnvironmentFeature.js.map +0 -1
  334. package/lib/commonjs/features/NavigationLogFeature.js +0 -60
  335. package/lib/commonjs/features/NavigationLogFeature.js.map +0 -1
  336. package/lib/commonjs/features/NetworkFeature.js +0 -328
  337. package/lib/commonjs/features/NetworkFeature.js.map +0 -1
  338. package/lib/commonjs/features/ThirdPartyLibsFeature.js.map +0 -1
  339. package/lib/commonjs/features/TrackFeature.js +0 -55
  340. package/lib/commonjs/features/TrackFeature.js.map +0 -1
  341. package/lib/commonjs/features/ZustandLogFeature.js +0 -76
  342. package/lib/commonjs/features/ZustandLogFeature.js.map +0 -1
  343. package/lib/commonjs/hooks/useNavigationLogger.js.map +0 -1
  344. package/lib/commonjs/hooks/useSlideDetailAnimation.js.map +0 -1
  345. package/lib/commonjs/initialize.js +0 -161
  346. package/lib/commonjs/initialize.js.map +0 -1
  347. package/lib/commonjs/native/NativeDebugLibs.js.map +0 -1
  348. package/lib/commonjs/utils/constants.js +0 -135
  349. package/lib/commonjs/utils/constants.js.map +0 -1
  350. package/lib/module/components/ClipboardTab.js.map +0 -1
  351. package/lib/module/components/ConsoleLogTab.js +0 -290
  352. package/lib/module/components/ConsoleLogTab.js.map +0 -1
  353. package/lib/module/components/EnvironmentTab.js.map +0 -1
  354. package/lib/module/components/FloatPanelView.js +0 -791
  355. package/lib/module/components/FloatPanelView.js.map +0 -1
  356. package/lib/module/components/NavigationLogTab.js.map +0 -1
  357. package/lib/module/components/NetworkLogTab.js +0 -570
  358. package/lib/module/components/NetworkLogTab.js.map +0 -1
  359. package/lib/module/components/ThirdPartyLibsTab.js.map +0 -1
  360. package/lib/module/components/TrackLogTab.js +0 -367
  361. package/lib/module/components/TrackLogTab.js.map +0 -1
  362. package/lib/module/components/ZustandLogTab.js +0 -446
  363. package/lib/module/components/ZustandLogTab.js.map +0 -1
  364. package/lib/module/components/shared/CollapsibleSection.js.map +0 -1
  365. package/lib/module/components/shared/CopyButton.js.map +0 -1
  366. package/lib/module/components/shared/JsonView.js.map +0 -1
  367. package/lib/module/features/ClipboardFeature.js +0 -12
  368. package/lib/module/features/ClipboardFeature.js.map +0 -1
  369. package/lib/module/features/ConsoleLogFeature.js +0 -93
  370. package/lib/module/features/ConsoleLogFeature.js.map +0 -1
  371. package/lib/module/features/EnvironmentFeature.js.map +0 -1
  372. package/lib/module/features/NavigationLogFeature.js +0 -54
  373. package/lib/module/features/NavigationLogFeature.js.map +0 -1
  374. package/lib/module/features/NetworkFeature.js +0 -322
  375. package/lib/module/features/NetworkFeature.js.map +0 -1
  376. package/lib/module/features/ThirdPartyLibsFeature.js.map +0 -1
  377. package/lib/module/features/TrackFeature.js +0 -49
  378. package/lib/module/features/TrackFeature.js.map +0 -1
  379. package/lib/module/features/ZustandLogFeature.js +0 -69
  380. package/lib/module/features/ZustandLogFeature.js.map +0 -1
  381. package/lib/module/hooks/useNavigationLogger.js.map +0 -1
  382. package/lib/module/hooks/useSlideDetailAnimation.js.map +0 -1
  383. package/lib/module/initialize.js +0 -156
  384. package/lib/module/initialize.js.map +0 -1
  385. package/lib/module/native/NativeDebugLibs.js.map +0 -1
  386. package/lib/module/utils/constants.js +0 -130
  387. package/lib/module/utils/constants.js.map +0 -1
  388. package/lib/typescript/src/components/ClipboardTab.d.ts +0 -4
  389. package/lib/typescript/src/components/ClipboardTab.d.ts.map +0 -1
  390. package/lib/typescript/src/components/ConsoleLogTab.d.ts.map +0 -1
  391. package/lib/typescript/src/components/EnvironmentTab.d.ts.map +0 -1
  392. package/lib/typescript/src/components/FloatPanelView.d.ts +0 -64
  393. package/lib/typescript/src/components/FloatPanelView.d.ts.map +0 -1
  394. package/lib/typescript/src/components/NavigationLogTab.d.ts.map +0 -1
  395. package/lib/typescript/src/components/NetworkLogTab.d.ts.map +0 -1
  396. package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts.map +0 -1
  397. package/lib/typescript/src/components/TrackLogTab.d.ts.map +0 -1
  398. package/lib/typescript/src/components/ZustandLogTab.d.ts.map +0 -1
  399. package/lib/typescript/src/components/shared/CollapsibleSection.d.ts.map +0 -1
  400. package/lib/typescript/src/components/shared/CopyButton.d.ts.map +0 -1
  401. package/lib/typescript/src/components/shared/JsonView.d.ts.map +0 -1
  402. package/lib/typescript/src/features/ClipboardFeature.d.ts +0 -3
  403. package/lib/typescript/src/features/ClipboardFeature.d.ts.map +0 -1
  404. package/lib/typescript/src/features/ConsoleLogFeature.d.ts +0 -7
  405. package/lib/typescript/src/features/ConsoleLogFeature.d.ts.map +0 -1
  406. package/lib/typescript/src/features/EnvironmentFeature.d.ts.map +0 -1
  407. package/lib/typescript/src/features/NavigationLogFeature.d.ts.map +0 -1
  408. package/lib/typescript/src/features/NetworkFeature.d.ts +0 -28
  409. package/lib/typescript/src/features/NetworkFeature.d.ts.map +0 -1
  410. package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts +0 -3
  411. package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts.map +0 -1
  412. package/lib/typescript/src/features/TrackFeature.d.ts.map +0 -1
  413. package/lib/typescript/src/features/ZustandLogFeature.d.ts.map +0 -1
  414. package/lib/typescript/src/hooks/useNavigationLogger.d.ts.map +0 -1
  415. package/lib/typescript/src/hooks/useSlideDetailAnimation.d.ts.map +0 -1
  416. package/lib/typescript/src/initialize.d.ts +0 -51
  417. package/lib/typescript/src/initialize.d.ts.map +0 -1
  418. package/lib/typescript/src/native/NativeDebugLibs.d.ts.map +0 -1
  419. package/lib/typescript/src/utils/constants.d.ts +0 -96
  420. package/lib/typescript/src/utils/constants.d.ts.map +0 -1
  421. package/src/components/ConsoleLogTab.tsx +0 -209
  422. package/src/components/FloatPanelView.tsx +0 -714
  423. package/src/components/NetworkLogTab.tsx +0 -411
  424. package/src/components/TrackLogTab.tsx +0 -245
  425. package/src/components/ZustandLogTab.tsx +0 -305
  426. package/src/features/ClipboardFeature.ts +0 -11
  427. package/src/features/ConsoleLogFeature.ts +0 -118
  428. package/src/features/NavigationLogFeature.ts +0 -74
  429. package/src/features/NetworkFeature.ts +0 -488
  430. package/src/features/TrackFeature.ts +0 -69
  431. package/src/initialize.ts +0 -214
  432. package/src/utils/constants.ts +0 -91
  433. /package/lib/commonjs/{components → ui}/shared/JsonView.js +0 -0
  434. /package/lib/commonjs/{hooks → ui/shared}/useSlideDetailAnimation.js +0 -0
  435. /package/lib/module/{components → ui}/shared/JsonView.js +0 -0
  436. /package/lib/module/{hooks → ui/shared}/useSlideDetailAnimation.js +0 -0
  437. /package/lib/typescript/src/{components → ui}/shared/CollapsibleSection.d.ts +0 -0
  438. /package/lib/typescript/src/{components → ui}/shared/CopyButton.d.ts +0 -0
  439. /package/lib/typescript/src/{components → ui}/shared/JsonView.d.ts +0 -0
  440. /package/lib/typescript/src/{hooks → ui/shared}/useSlideDetailAnimation.d.ts +0 -0
  441. /package/src/{native/NativeDebugLibs.ts → features/thirdPartyLibs/nativeDebugLibs.ts} +0 -0
  442. /package/src/{components → ui}/shared/JsonView.tsx +0 -0
  443. /package/src/{hooks → ui/shared}/useSlideDetailAnimation.ts +0 -0
@@ -0,0 +1,271 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ TextInput,
7
+ ScrollView,
8
+ } from 'react-native';
9
+ import { Colors, getMethodColor } from '../../ui/theme/colors';
10
+ import { CollapsibleSection } from '../../ui/shared/CollapsibleSection';
11
+ import { JsonView } from '../../ui/shared/JsonView';
12
+ import { CopyButton } from '../../ui/shared/CopyButton';
13
+ import { fmt } from '../../utils/copyToComputer';
14
+ import { LogListScreen } from '../../ui/shared/LogListScreen';
15
+ import type { DebugFeatureRenderProps, NetworkLogEntry } from '../../types';
16
+
17
+ const formatSize = (data: unknown): string => {
18
+ if (!data) return '';
19
+ try {
20
+ const len = (typeof data === 'string' ? data : JSON.stringify(data)).length;
21
+ if (len < 1024) return `(${len} B)`;
22
+ if (len < 1024 * 1024) return `(${(len / 1024).toFixed(1)} KB)`;
23
+ return `(${(len / (1024 * 1024)).toFixed(1)} MB)`;
24
+ } catch {
25
+ return '';
26
+ }
27
+ };
28
+
29
+ const buildCurl = (log: NetworkLogEntry): string => {
30
+ let c = `curl -X ${log.request.method} '${log.request.url}'`;
31
+ if (log.request.headers) {
32
+ Object.entries(log.request.headers).forEach(([k, v]) => (c += ` \\\n -H '${k}: ${v}'`));
33
+ }
34
+ if (log.request.body) {
35
+ c += ` \\\n -d '${typeof log.request.body === 'string' ? log.request.body : JSON.stringify(log.request.body)}'`;
36
+ }
37
+ return c;
38
+ };
39
+
40
+ export const NetworkLogTab: React.FC<DebugFeatureRenderProps<NetworkLogEntry[]>> = React.memo(({
41
+ snapshot,
42
+ }) => {
43
+ const [search, setSearch] = useState('');
44
+ const data = snapshot;
45
+
46
+ const filtered = search
47
+ ? data.filter(
48
+ (l) =>
49
+ l.request.url.toLowerCase().includes(search.toLowerCase()) ||
50
+ l.request.method.toLowerCase().includes(search.toLowerCase()),
51
+ )
52
+ : data;
53
+
54
+ const sorted = [...filtered].sort((a, b) => b.timestamp - a.timestamp);
55
+
56
+ return (
57
+ <LogListScreen
58
+ data={sorted}
59
+ reversed={false}
60
+ emptyText="No HTTP requests logged"
61
+ renderListHeader={() => (
62
+ <View style={s.searchContainer}>
63
+ <View style={s.searchBar}>
64
+ <Text style={s.searchIcon}>⌕</Text>
65
+ <TextInput
66
+ style={s.search}
67
+ placeholder="Search URLs..."
68
+ placeholderTextColor={Colors.textLight}
69
+ value={search}
70
+ onChangeText={setSearch}
71
+ />
72
+ </View>
73
+ </View>
74
+ )}
75
+ renderRow={(item) => {
76
+ const ok = !item.error && (!item.response || item.response.status < 400);
77
+ const sc = ok ? Colors.success : Colors.error;
78
+ return (
79
+ <View style={s.cardRow}>
80
+ <View style={[s.statusIndicator, { backgroundColor: sc }]} />
81
+ <View style={s.cardBody}>
82
+ <View style={s.cardMeta}>
83
+ <Text style={[s.methodText, { color: getMethodColor(item.request.method) }]}>
84
+ {item.request.method}
85
+ </Text>
86
+ <View style={[s.miniPill, { backgroundColor: sc }]}>
87
+ <Text style={s.miniPillText}>{item.response?.status ?? 'ERR'}</Text>
88
+ </View>
89
+ {item.duration != null && <Text style={s.durationText}>{item.duration}ms</Text>}
90
+ </View>
91
+ <Text style={[s.url, !ok && { color: Colors.error }]} numberOfLines={2}>
92
+ {item.request.url}
93
+ </Text>
94
+ <Text style={s.time}>{new Date(item.timestamp).toLocaleTimeString()}</Text>
95
+ </View>
96
+ </View>
97
+ );
98
+ }}
99
+ renderDetailHeader={(log) => {
100
+ const statusColor = log.error || (log.response && log.response.status >= 400) ? Colors.error : Colors.success;
101
+ return (
102
+ <View style={s.detailHeaderCenter}>
103
+ <View style={[s.methodBadge, { backgroundColor: getMethodColor(log.request.method) }]}>
104
+ <Text style={s.methodBadgeText}>{log.request.method}</Text>
105
+ </View>
106
+ <View style={[s.statusPill, { backgroundColor: statusColor }]}>
107
+ <Text style={s.statusPillText}>{log.response?.status ?? 'ERR'}</Text>
108
+ </View>
109
+ {log.duration != null && <Text style={s.durationText}>{log.duration}ms</Text>}
110
+ </View>
111
+ );
112
+ }}
113
+ renderDetailBody={(log) => {
114
+ const curlStr = buildCurl(log);
115
+ return (
116
+ <ScrollView style={s.detailBody} contentContainerStyle={s.detailBodyContent}>
117
+ <View style={s.urlCard}>
118
+ <Text style={s.urlText} selectable numberOfLines={3}>{log.request.url}</Text>
119
+ <CopyButton text={log.request.url} label="URL" />
120
+ </View>
121
+
122
+ <CollapsibleSection title="Request Body" initiallyExpanded>
123
+ {log.request.body != null ? (
124
+ <View style={s.sectionWithCopy}>
125
+ <CopyButton text={fmt(log.request.body)} label="Request Body" />
126
+ <JsonView data={log.request.body} maxHeight={250} />
127
+ </View>
128
+ ) : (
129
+ <Text style={s.emptySection}>No request body</Text>
130
+ )}
131
+ </CollapsibleSection>
132
+
133
+ <CollapsibleSection title="Request Headers">
134
+ {log.request.headers ? (
135
+ <View style={s.sectionWithCopy}>
136
+ <CopyButton text={fmt(log.request.headers)} label="Request Headers" />
137
+ <JsonView data={log.request.headers} maxHeight={200} />
138
+ </View>
139
+ ) : (
140
+ <Text style={s.emptySection}>No headers</Text>
141
+ )}
142
+ </CollapsibleSection>
143
+
144
+ <CollapsibleSection title={`Response ${formatSize(log.response?.data)}`} initiallyExpanded>
145
+ {log.error && (
146
+ <View style={s.errorBox}>
147
+ <Text style={s.errorIcon}>⚠</Text>
148
+ <Text style={s.errorText}>{log.error}</Text>
149
+ </View>
150
+ )}
151
+ {log.response?.data != null ? (
152
+ <View style={s.sectionWithCopy}>
153
+ <CopyButton text={fmt(log.response.data)} label="Response Body" />
154
+ <JsonView data={log.response.data} maxHeight={300} />
155
+ </View>
156
+ ) : (
157
+ <Text style={s.emptySection}>No response body</Text>
158
+ )}
159
+ </CollapsibleSection>
160
+
161
+ {log.response?.headers && (
162
+ <CollapsibleSection title="Response Headers">
163
+ <View style={s.sectionWithCopy}>
164
+ <CopyButton text={fmt(log.response.headers)} label="Response Headers" />
165
+ <JsonView data={log.response.headers} maxHeight={200} />
166
+ </View>
167
+ </CollapsibleSection>
168
+ )}
169
+
170
+ <CollapsibleSection title="cURL">
171
+ <View style={s.sectionWithCopy}>
172
+ <CopyButton text={curlStr} label="cURL" />
173
+ <View style={s.codeBlock}>
174
+ <Text style={s.codeText} selectable>{curlStr}</Text>
175
+ </View>
176
+ </View>
177
+ </CollapsibleSection>
178
+ </ScrollView>
179
+ );
180
+ }}
181
+ />
182
+ );
183
+ });
184
+
185
+ const s = StyleSheet.create({
186
+ // Search
187
+ searchContainer: {
188
+ paddingHorizontal: 12,
189
+ paddingTop: 10,
190
+ paddingBottom: 6,
191
+ backgroundColor: Colors.background,
192
+ },
193
+ searchBar: {
194
+ flexDirection: 'row',
195
+ alignItems: 'center',
196
+ backgroundColor: Colors.surface,
197
+ borderRadius: 10,
198
+ paddingHorizontal: 10,
199
+ height: 38,
200
+ },
201
+ searchIcon: { fontSize: 16, color: Colors.textLight, marginRight: 6 },
202
+ search: {
203
+ flex: 1,
204
+ fontSize: 14,
205
+ color: Colors.text,
206
+ padding: 0,
207
+ },
208
+
209
+ // Row
210
+ cardRow: { flexDirection: 'row', padding: 14 },
211
+ statusIndicator: { width: 3, borderRadius: 2, marginRight: 12 },
212
+ cardBody: { flex: 1 },
213
+ cardMeta: { flexDirection: 'row', alignItems: 'center', marginBottom: 6, gap: 6 },
214
+ methodText: { fontSize: 13, fontWeight: '700' },
215
+ miniPill: { paddingHorizontal: 7, paddingVertical: 2, borderRadius: 4 },
216
+ miniPillText: { color: '#FFF', fontSize: 10, fontWeight: '700' },
217
+ durationText: { fontSize: 12, color: Colors.textSecondary, fontWeight: '500' },
218
+ url: { fontSize: 13, color: Colors.textSecondary, marginBottom: 4, lineHeight: 18 },
219
+ time: { fontSize: 11, color: Colors.textLight },
220
+
221
+ // Detail header
222
+ detailHeaderCenter: {
223
+ flexDirection: 'row',
224
+ alignItems: 'center',
225
+ gap: 8,
226
+ flex: 1,
227
+ },
228
+ methodBadge: {
229
+ paddingHorizontal: 10,
230
+ paddingVertical: 4,
231
+ borderRadius: 6,
232
+ },
233
+ methodBadgeText: { color: '#FFF', fontSize: 12, fontWeight: '700' },
234
+ statusPill: { paddingHorizontal: 9, paddingVertical: 3, borderRadius: 6 },
235
+ statusPillText: { color: '#FFF', fontSize: 11, fontWeight: '700' },
236
+
237
+ // Detail body
238
+ detailBody: { flex: 1 },
239
+ detailBodyContent: { padding: 12, paddingBottom: 40 },
240
+ urlCard: {
241
+ flexDirection: 'row',
242
+ alignItems: 'center',
243
+ backgroundColor: Colors.surface,
244
+ borderRadius: 12,
245
+ padding: 14,
246
+ marginBottom: 8,
247
+ gap: 8,
248
+ },
249
+ urlText: { flex: 1, fontSize: 13, color: Colors.textSecondary, lineHeight: 18 },
250
+ sectionWithCopy: { gap: 8 },
251
+ emptySection: { fontSize: 13, color: Colors.textLight, paddingVertical: 4 },
252
+ errorBox: {
253
+ backgroundColor: 'rgba(255,59,48,0.06)',
254
+ borderWidth: 1,
255
+ borderColor: 'rgba(255,59,48,0.15)',
256
+ borderRadius: 10,
257
+ padding: 12,
258
+ marginBottom: 10,
259
+ flexDirection: 'row',
260
+ alignItems: 'flex-start',
261
+ gap: 8,
262
+ },
263
+ errorIcon: { fontSize: 14, color: Colors.error },
264
+ errorText: { flex: 1, fontSize: 13, color: Colors.error, lineHeight: 18 },
265
+ codeBlock: {
266
+ backgroundColor: '#1E1E2E',
267
+ borderRadius: 12,
268
+ padding: 12,
269
+ },
270
+ codeText: { fontFamily: 'Courier', fontSize: 12, color: '#CDD6F4', lineHeight: 18 },
271
+ });
@@ -0,0 +1,113 @@
1
+ import { NetworkLogTab } from './NetworkLogTab';
2
+
3
+ export type { AxiosInstanceLike } from './networkInterceptor';
4
+ import type { DebugFeature, NetworkLogEntry } from '../../types';
5
+ import { createEventChannel } from '../../utils/createEventChannel';
6
+ import { createPersistedObservableStore } from '../../utils/createPersistedObservableStore';
7
+ import { KEYS } from '../../utils/debugPreferences';
8
+ import { urlRewriter } from '../../utils/urlRewriterRegistry';
9
+ import type { AxiosInstanceLike } from './networkInterceptor';
10
+ import {
11
+ startFetch,
12
+ startAxios,
13
+ resetInterceptors,
14
+ } from './networkInterceptor';
15
+
16
+ type NetworkLogPayload = Omit<NetworkLogEntry, 'id'>;
17
+
18
+ // ─── Utilities ────────────────────────────────────────
19
+
20
+ function isUrlBlacklisted(
21
+ url: string,
22
+ blacklist: Array<string | RegExp>,
23
+ ): boolean {
24
+ if (!url) {
25
+ return false;
26
+ }
27
+ return blacklist.some((pattern) =>
28
+ pattern instanceof RegExp ? pattern.test(url) : url.includes(pattern),
29
+ );
30
+ }
31
+
32
+ // ─── Channel (shared pub-sub backbone) ─────────────────
33
+
34
+ let networkChannel = createEventChannel<NetworkLogPayload>();
35
+
36
+ function emitNetworkLog(entry: NetworkLogPayload): void {
37
+ networkChannel.emit(entry);
38
+ }
39
+
40
+ // ─── Feature factory ──────────────────────────────────
41
+
42
+ const DEFAULT_MAX_LOGS = 200;
43
+
44
+ export interface NetworkFeatureConfig {
45
+ /** Maximum number of network logs to keep (default: 200) */
46
+ maxLogs?: number;
47
+ /** URLs to filter out from logging */
48
+ blacklist?: Array<string | RegExp>;
49
+ /** Axios instance to intercept. Pass your axios.create() instance to capture axios requests. */
50
+ axiosInstance?: AxiosInstanceLike;
51
+ }
52
+
53
+ export const createNetworkFeature = (config?: NetworkFeatureConfig): DebugFeature<NetworkLogEntry[]> => {
54
+ const maxLogs = config?.maxLogs ?? DEFAULT_MAX_LOGS;
55
+ const blacklist: Array<string | RegExp> = config?.blacklist ? [...config.blacklist] : [];
56
+ const logStore = createPersistedObservableStore<NetworkLogEntry>({
57
+ storageKey: KEYS.networkLogs,
58
+ maxPersist: 30,
59
+ });
60
+ let initialized = false;
61
+ let unsubscribeLogs: (() => void) | null = null;
62
+ let stopFetchFn: (() => void) | null = null;
63
+ let stopAxiosFn: (() => void) | null = null;
64
+
65
+ const handleLog = (entry: NetworkLogPayload) => {
66
+ if (isUrlBlacklisted(entry.request.url, blacklist)) {
67
+ return;
68
+ }
69
+ logStore.push({ ...entry, id: logStore.nextId() }, maxLogs);
70
+ };
71
+
72
+ return {
73
+ name: 'network',
74
+ label: 'Network',
75
+ renderContent: NetworkLogTab,
76
+ setup: () => {
77
+ if (initialized) {
78
+ return;
79
+ }
80
+ unsubscribeLogs = networkChannel.subscribe(handleLog);
81
+ stopFetchFn = startFetch(emitNetworkLog);
82
+ if (config?.axiosInstance) {
83
+ stopAxiosFn = startAxios(config.axiosInstance, emitNetworkLog);
84
+ }
85
+ initialized = true;
86
+ },
87
+ getSnapshot: () => logStore.getData(),
88
+ clear: () => {
89
+ logStore.clear();
90
+ },
91
+ cleanup: () => {
92
+ if (!initialized) {
93
+ return;
94
+ }
95
+ urlRewriter.set(null);
96
+ unsubscribeLogs?.();
97
+ unsubscribeLogs = null;
98
+ stopFetchFn?.();
99
+ stopFetchFn = null;
100
+ stopAxiosFn?.();
101
+ stopAxiosFn = null;
102
+ logStore.clear();
103
+ initialized = false;
104
+ },
105
+ subscribe: (listener) => logStore.subscribe(listener),
106
+ };
107
+ };
108
+
109
+ /** Reset module-level state for testing */
110
+ export function _resetNetworkForTesting(): void {
111
+ networkChannel = createEventChannel<NetworkLogPayload>();
112
+ resetInterceptors();
113
+ }
@@ -0,0 +1,311 @@
1
+ import type { NetworkLogEntry } from '../../types';
2
+ import { urlRewriter } from '../../utils/urlRewriterRegistry';
3
+
4
+ type NetworkLogPayload = Omit<NetworkLogEntry, 'id'>;
5
+
6
+ // Intercepts fetch requests and optionally axios via interceptors.
7
+ // Axios response data is captured directly through interceptor callbacks,
8
+ // avoiding the unreliable XHR response interception in React Native.
9
+
10
+ // ─── Minimal axios interface (no hard dependency) ──────
11
+
12
+ export interface AxiosInstanceLike {
13
+ interceptors: {
14
+ request: {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ use(onFulfilled?: (config: any) => any, onRejected?: (error: any) => any): number;
17
+ eject(id: number): void;
18
+ };
19
+ response: {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ use(onFulfilled?: (response: any) => any, onRejected?: (error: any) => any): number;
22
+ eject(id: number): void;
23
+ };
24
+ };
25
+ }
26
+
27
+ // ─── Shared helpers ────────────────────────────────────
28
+
29
+ function rewriteUrl(url: string): string {
30
+ const rewriter = urlRewriter.get();
31
+ if (!rewriter) {
32
+ return url;
33
+ }
34
+ try {
35
+ return rewriter(url);
36
+ } catch {
37
+ return url;
38
+ }
39
+ }
40
+
41
+ function headersToObject(
42
+ headers: Record<string, string> | Headers | undefined,
43
+ ): Record<string, string> {
44
+ const result: Record<string, string> = {};
45
+ if (!headers) {
46
+ return result;
47
+ }
48
+ if (typeof (headers as Headers).forEach === 'function') {
49
+ (headers as Headers).forEach((value: string, key: string) => {
50
+ result[key] = value;
51
+ });
52
+ return result;
53
+ }
54
+ Object.keys(headers).forEach((key) => {
55
+ result[key] = (headers as Record<string, string>)[key]!;
56
+ });
57
+ return result;
58
+ }
59
+
60
+ function getRequestSnapshot(
61
+ input: unknown,
62
+ init?: RequestInit,
63
+ ): NetworkLogEntry['request'] {
64
+ const request = input instanceof Request ? input : null;
65
+ return {
66
+ url: typeof input === 'string' ? input : request?.url ?? String(input),
67
+ method: (init?.method || request?.method || 'GET').toUpperCase(),
68
+ headers: init?.headers
69
+ ? headersToObject(init.headers as Record<string, string> | Headers)
70
+ : request?.headers
71
+ ? headersToObject(request.headers)
72
+ : undefined,
73
+ body: init?.body,
74
+ };
75
+ }
76
+
77
+ async function parseResponseBody(response: Response): Promise<unknown> {
78
+ const raw = await response.clone().text();
79
+ if (!raw) {
80
+ return undefined;
81
+ }
82
+ try {
83
+ return JSON.parse(raw);
84
+ } catch {
85
+ return raw;
86
+ }
87
+ }
88
+
89
+ function normalizeAxiosHeaders(
90
+ headers: unknown,
91
+ ): Record<string, string> | undefined {
92
+ if (!headers || typeof headers !== 'object') {
93
+ return undefined;
94
+ }
95
+ // AxiosHeaders instance
96
+ if (typeof (headers as Record<string, unknown>).forEach === 'function') {
97
+ const result: Record<string, string> = {};
98
+ (headers as { forEach(fn: (value: string, key: string) => void): void }).forEach(
99
+ (value, key) => {
100
+ result[key] = value;
101
+ },
102
+ );
103
+ return Object.keys(result).length > 0 ? result : undefined;
104
+ }
105
+ // Plain object
106
+ const result: Record<string, string> = {};
107
+ const obj = headers as Record<string, unknown>;
108
+ for (const key of Object.keys(obj)) {
109
+ const val = obj[key];
110
+ if (typeof val === 'string') {
111
+ result[key] = val;
112
+ }
113
+ }
114
+ return Object.keys(result).length > 0 ? result : undefined;
115
+ }
116
+
117
+ function buildFullUrl(config: {
118
+ baseURL?: string;
119
+ url?: string;
120
+ }): string {
121
+ const base = config.baseURL ?? '';
122
+ const url = config.url ?? '';
123
+ if (!base || url.startsWith('http')) {
124
+ return url;
125
+ }
126
+ return base.replace(/\/$/, '') + '/' + url.replace(/^\//, '');
127
+ }
128
+
129
+ // ─── Fetch interceptor ─────────────────────────────────
130
+
131
+ let originalFetch: typeof globalThis.fetch | null = null;
132
+ let fetchRefCount = 0;
133
+
134
+ function stopFetch(): void {
135
+ fetchRefCount = Math.max(0, fetchRefCount - 1);
136
+ if (fetchRefCount === 0 && originalFetch) {
137
+ globalThis.fetch = originalFetch;
138
+ originalFetch = null;
139
+ }
140
+ }
141
+
142
+ export function startFetch(emit: (entry: NetworkLogPayload) => void): () => void {
143
+ fetchRefCount += 1;
144
+ if (originalFetch) {
145
+ return () => {
146
+ stopFetch();
147
+ };
148
+ }
149
+
150
+ originalFetch = globalThis.fetch;
151
+
152
+ globalThis.fetch = async function interceptedFetch(
153
+ input: Parameters<typeof fetch>[0],
154
+ init?: Parameters<typeof fetch>[1],
155
+ ) {
156
+ const startTime = Date.now();
157
+
158
+ let rewrittenInput: typeof input = input;
159
+ if (urlRewriter.get()) {
160
+ if (typeof input === 'string') {
161
+ rewrittenInput = rewriteUrl(input);
162
+ } else if (input instanceof Request) {
163
+ rewrittenInput = new Request(rewriteUrl(input.url), input as RequestInit);
164
+ }
165
+ }
166
+
167
+ const request = getRequestSnapshot(rewrittenInput, init);
168
+
169
+ try {
170
+ const response = await originalFetch!.call(globalThis, rewrittenInput, init);
171
+ const duration = Date.now() - startTime;
172
+
173
+ try {
174
+ const data = await parseResponseBody(response);
175
+ emit({
176
+ timestamp: startTime,
177
+ duration,
178
+ request,
179
+ response: { status: response.status, statusText: response.statusText, data },
180
+ });
181
+ } catch {
182
+ emit({
183
+ timestamp: startTime,
184
+ duration,
185
+ request,
186
+ response: { status: response.status, statusText: response.statusText },
187
+ });
188
+ }
189
+
190
+ return response;
191
+ } catch (error) {
192
+ emit({
193
+ timestamp: startTime,
194
+ duration: Date.now() - startTime,
195
+ request,
196
+ error: error instanceof Error ? error.message : String(error),
197
+ });
198
+ throw error;
199
+ }
200
+ };
201
+
202
+ return () => {
203
+ stopFetch();
204
+ };
205
+ }
206
+
207
+ // ─── Axios interceptor ─────────────────────────────────
208
+
209
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
210
+ const pendingAxiosRequests = new WeakMap<any, { startTime: number; timestamp: number }>();
211
+
212
+ export function startAxios(
213
+ axiosInstance: AxiosInstanceLike,
214
+ emit: (entry: NetworkLogPayload) => void,
215
+ ): () => void {
216
+ const requestInterceptorId = axiosInstance.interceptors.request.use(
217
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
218
+ (config: any) => {
219
+ const now = Date.now();
220
+ pendingAxiosRequests.set(config, { startTime: now, timestamp: now });
221
+
222
+ if (urlRewriter.get() && config.url) {
223
+ const fullUrl = buildFullUrl(config);
224
+ const rewritten = rewriteUrl(fullUrl);
225
+ if (rewritten !== fullUrl) {
226
+ config.url = rewritten;
227
+ if (config.baseURL) {
228
+ config.baseURL = undefined;
229
+ }
230
+ }
231
+ }
232
+
233
+ return config;
234
+ },
235
+ );
236
+
237
+ const responseInterceptorId = axiosInstance.interceptors.response.use(
238
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
239
+ (response: any) => {
240
+ const config = response.config;
241
+ const pending = config ? pendingAxiosRequests.get(config) : undefined;
242
+ const startTime = pending?.timestamp ?? Date.now();
243
+
244
+ emit({
245
+ timestamp: startTime,
246
+ duration: Date.now() - startTime,
247
+ request: {
248
+ url: buildFullUrl(config),
249
+ method: (config?.method ?? 'GET').toUpperCase(),
250
+ headers: normalizeAxiosHeaders(config?.headers),
251
+ body: config?.data,
252
+ },
253
+ response: {
254
+ status: response.status,
255
+ statusText: response.statusText,
256
+ headers: normalizeAxiosHeaders(response.headers),
257
+ data: response.data,
258
+ success: response.status >= 200 && response.status < 300,
259
+ },
260
+ });
261
+
262
+ return response;
263
+ },
264
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
265
+ (error: any) => {
266
+ const config = error.config;
267
+ const pending = config ? pendingAxiosRequests.get(config) : undefined;
268
+ const startTime = pending?.timestamp ?? Date.now();
269
+
270
+ if (config) {
271
+ emit({
272
+ timestamp: startTime,
273
+ duration: Date.now() - startTime,
274
+ request: {
275
+ url: buildFullUrl(config),
276
+ method: (config.method ?? 'GET').toUpperCase(),
277
+ headers: normalizeAxiosHeaders(config.headers),
278
+ body: config.data,
279
+ },
280
+ response: error.response
281
+ ? {
282
+ status: error.response.status,
283
+ statusText: error.response.statusText,
284
+ headers: normalizeAxiosHeaders(error.response.headers),
285
+ data: error.response.data,
286
+ success: false,
287
+ }
288
+ : undefined,
289
+ error: error.message ?? String(error),
290
+ });
291
+ }
292
+
293
+ return Promise.reject(error);
294
+ },
295
+ );
296
+
297
+ return () => {
298
+ axiosInstance.interceptors.request.eject(requestInterceptorId);
299
+ axiosInstance.interceptors.response.eject(responseInterceptorId);
300
+ };
301
+ }
302
+
303
+ // ─── Cleanup ───────────────────────────────────────────
304
+
305
+ export function resetInterceptors(): void {
306
+ if (originalFetch) {
307
+ globalThis.fetch = originalFetch;
308
+ originalFetch = null;
309
+ }
310
+ fetchRefCount = 0;
311
+ }