react-native-inapp-inspector 2.3.18 → 2.3.20

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 (358) hide show
  1. package/android/src/main/java/com/inappinspector/NetworkInspectorModule.kt +57 -0
  2. package/dist/commonjs/analytics.js +1 -24
  3. package/dist/commonjs/bundle.js +1 -16
  4. package/dist/commonjs/capture.d.ts +2 -0
  5. package/dist/commonjs/capture.js +1 -32
  6. package/dist/commonjs/components/AnalyticsDetail.js +92 -623
  7. package/dist/commonjs/components/AnalyticsEventCard.js +54 -350
  8. package/dist/commonjs/components/AnalyticsGraph.js +70 -370
  9. package/dist/commonjs/components/AnimatedEntrance.js +1 -11
  10. package/dist/commonjs/components/AppHeaderLogo.js +7 -134
  11. package/dist/commonjs/components/BrandCircleIcon.js +73 -118
  12. package/dist/commonjs/components/BrandSquareIcon.js +63 -108
  13. package/dist/commonjs/components/CodeSnippet.js +48 -623
  14. package/dist/commonjs/components/ConsoleLogCard.js +63 -537
  15. package/dist/commonjs/components/CopyButton.js +3 -89
  16. package/dist/commonjs/components/DiffViewer.js +19 -83
  17. package/dist/commonjs/components/DomainHeader.js +27 -127
  18. package/dist/commonjs/components/EmptyState.d.ts +1 -0
  19. package/dist/commonjs/components/EmptyState.js +10 -87
  20. package/dist/commonjs/components/EndOfListFooter.js +7 -81
  21. package/dist/commonjs/components/ErrorBoundary.js +72 -566
  22. package/dist/commonjs/components/HeadersSection.js +31 -110
  23. package/dist/commonjs/components/HighlightText.js +17 -58
  24. package/dist/commonjs/components/Inspector/AboutModal.d.ts +6 -0
  25. package/dist/commonjs/components/Inspector/AboutModal.js +351 -0
  26. package/dist/commonjs/components/Inspector/AnalyticsFilterModal.js +98 -797
  27. package/dist/commonjs/components/Inspector/AnalyticsTab.js +284 -930
  28. package/dist/commonjs/components/Inspector/BundleTab.js +551 -2918
  29. package/dist/commonjs/components/Inspector/ConsoleTab.js +79 -492
  30. package/dist/commonjs/components/Inspector/CrashDetail.js +123 -672
  31. package/dist/commonjs/components/Inspector/CrashFilterModal.js +66 -498
  32. package/dist/commonjs/components/Inspector/CrashTab.js +98 -670
  33. package/dist/commonjs/components/Inspector/DebuggingTab.js +64 -871
  34. package/dist/commonjs/components/Inspector/DeviceInfoTab.js +143 -907
  35. package/dist/commonjs/components/Inspector/FabLauncher.js +85 -54
  36. package/dist/commonjs/components/Inspector/FeatureUnderDevNotice.js +6 -99
  37. package/dist/commonjs/components/Inspector/FeedbackModal.d.ts +9 -0
  38. package/dist/commonjs/components/Inspector/FeedbackModal.js +167 -521
  39. package/dist/commonjs/components/Inspector/InspectorContext.js +1 -21
  40. package/dist/commonjs/components/Inspector/InspectorHeader.js +219 -1093
  41. package/dist/commonjs/components/Inspector/LogDetail.js +168 -994
  42. package/dist/commonjs/components/Inspector/MainScreen.js +60 -332
  43. package/dist/commonjs/components/Inspector/MediaGalleryTab.js +136 -278
  44. package/dist/commonjs/components/Inspector/MediaPreviewModal.js +134 -361
  45. package/dist/commonjs/components/Inspector/NavigationTracker.js +1 -12
  46. package/dist/commonjs/components/Inspector/NetworkDetail.js +96 -432
  47. package/dist/commonjs/components/Inspector/NetworkFilterModal.js +60 -576
  48. package/dist/commonjs/components/Inspector/NetworkTab.js +84 -514
  49. package/dist/commonjs/components/Inspector/NpmStarPrompt.js +17 -433
  50. package/dist/commonjs/components/Inspector/NpmUpdateToast.js +25 -298
  51. package/dist/commonjs/components/Inspector/PerformanceTab.js +182 -1397
  52. package/dist/commonjs/components/Inspector/ReduxDetail.js +188 -1089
  53. package/dist/commonjs/components/Inspector/ReduxTab.js +85 -701
  54. package/dist/commonjs/components/Inspector/SettingsPanel.js +431 -3431
  55. package/dist/commonjs/components/Inspector/SkeletonPlaceholder.js +11 -180
  56. package/dist/commonjs/components/Inspector/StorageTab.js +93 -826
  57. package/dist/commonjs/components/Inspector/TabBar.js +47 -183
  58. package/dist/commonjs/components/Inspector/UpdateAvailableModal.js +34 -408
  59. package/dist/commonjs/components/JsonViewer.js +168 -380
  60. package/dist/commonjs/components/LogCard.js +57 -567
  61. package/dist/commonjs/components/LogSyntaxHighlighter.js +11 -130
  62. package/dist/commonjs/components/MetaAccordion.js +69 -238
  63. package/dist/commonjs/components/MiniBarChart.js +3 -56
  64. package/dist/commonjs/components/MiniLineChart.js +3 -58
  65. package/dist/commonjs/components/NetworkIcons.d.ts +7 -0
  66. package/dist/commonjs/components/NetworkIcons.js +479 -997
  67. package/dist/commonjs/components/QRCodeView.js +5 -79
  68. package/dist/commonjs/components/SectionHeader.js +15 -37
  69. package/dist/commonjs/components/SegmentedTabs.js +7 -61
  70. package/dist/commonjs/components/SkeletonPlaceholder.js +11 -180
  71. package/dist/commonjs/components/Slider.js +15 -243
  72. package/dist/commonjs/components/SourcePageCard.js +30 -89
  73. package/dist/commonjs/components/Toast.js +5 -147
  74. package/dist/commonjs/components/TouchableScale.js +3 -24
  75. package/dist/commonjs/components/TreeNode.js +55 -130
  76. package/dist/commonjs/console.js +1 -16
  77. package/dist/commonjs/constants/index.js +1 -32
  78. package/dist/commonjs/constants/telemetryConfig.js +1 -6
  79. package/dist/commonjs/constants/version.d.ts +1 -1
  80. package/dist/commonjs/constants/version.js +1 -4
  81. package/dist/commonjs/crash.js +1 -23
  82. package/dist/commonjs/customHooks/analyticsLogger.js +1 -250
  83. package/dist/commonjs/customHooks/bundleAnalyzer.js +1 -957
  84. package/dist/commonjs/customHooks/consoleLogger.js +6 -445
  85. package/dist/commonjs/customHooks/crashHandler.js +7 -656
  86. package/dist/commonjs/customHooks/logFilters.js +1 -23
  87. package/dist/commonjs/customHooks/networkLogger.js +2 -536
  88. package/dist/commonjs/customHooks/performanceTracker.js +63 -750
  89. package/dist/commonjs/customHooks/reduxLogger.js +2 -313
  90. package/dist/commonjs/customHooks/storageInspector.js +1 -435
  91. package/dist/commonjs/customHooks/useAccordion.js +1 -18
  92. package/dist/commonjs/decorators/index.js +1 -100
  93. package/dist/commonjs/helpers/gaAnalyticsRegistry.js +1 -148
  94. package/dist/commonjs/helpers/index.js +8 -921
  95. package/dist/commonjs/helpers/memoryManager.js +1 -99
  96. package/dist/commonjs/helpers/qrGenerator.js +1 -367
  97. package/dist/commonjs/helpers/remoteConfig.js +1 -165
  98. package/dist/commonjs/helpers/searchQueryParser.js +1 -62
  99. package/dist/commonjs/helpers/settingsStore.js +1 -144
  100. package/dist/commonjs/helpers/telemetry.js +1 -501
  101. package/dist/commonjs/helpers/toast.js +1 -20
  102. package/dist/commonjs/i18n/index.js +1 -90
  103. package/dist/commonjs/i18n/locales/en.json +1 -1122
  104. package/dist/commonjs/index.js +5 -2153
  105. package/dist/commonjs/metro.js +6 -468
  106. package/dist/commonjs/native/NativeInspector.d.ts +3 -0
  107. package/dist/commonjs/native/NativeInspector.js +1 -402
  108. package/dist/commonjs/native/NativeNetworkInspector.d.ts +1 -0
  109. package/dist/commonjs/native/NativeNetworkInspector.js +1 -4
  110. package/dist/commonjs/network.js +1 -13
  111. package/dist/commonjs/performance.js +1 -29
  112. package/dist/commonjs/redux.js +1 -20
  113. package/dist/commonjs/storage.js +1 -14
  114. package/dist/commonjs/styles/AppColors.js +1 -423
  115. package/dist/commonjs/styles/AppFonts.js +1 -17
  116. package/dist/commonjs/styles/common.js +1 -190
  117. package/dist/commonjs/styles/index.d.ts +6 -0
  118. package/dist/commonjs/styles/index.js +1 -1589
  119. package/dist/commonjs/types/enums.d.ts +2 -1
  120. package/dist/commonjs/types/enums.js +1 -150
  121. package/dist/commonjs/types/index.js +1 -18
  122. package/dist/commonjs/types/interfaces.d.ts +7 -0
  123. package/dist/commonjs/types/interfaces.js +1 -2
  124. package/dist/esm/analytics.js +1 -2
  125. package/dist/esm/bundle.js +1 -2
  126. package/dist/esm/capture.d.ts +2 -0
  127. package/dist/esm/capture.js +1 -29
  128. package/dist/esm/components/AnalyticsDetail.js +171 -664
  129. package/dist/esm/components/AnalyticsEventCard.js +77 -335
  130. package/dist/esm/components/AnalyticsGraph.js +95 -357
  131. package/dist/esm/components/AnimatedEntrance.js +1 -6
  132. package/dist/esm/components/AppHeaderLogo.js +7 -94
  133. package/dist/esm/components/BrandCircleIcon.js +114 -119
  134. package/dist/esm/components/BrandSquareIcon.js +73 -78
  135. package/dist/esm/components/CodeSnippet.js +58 -595
  136. package/dist/esm/components/ConsoleLogCard.js +91 -526
  137. package/dist/esm/components/CopyButton.js +3 -51
  138. package/dist/esm/components/DiffViewer.js +22 -48
  139. package/dist/esm/components/DomainHeader.js +43 -138
  140. package/dist/esm/components/EmptyState.d.ts +1 -0
  141. package/dist/esm/components/EmptyState.js +17 -56
  142. package/dist/esm/components/EndOfListFooter.js +15 -83
  143. package/dist/esm/components/ErrorBoundary.js +125 -582
  144. package/dist/esm/components/HeadersSection.js +52 -93
  145. package/dist/esm/components/HighlightText.js +17 -53
  146. package/dist/esm/components/Inspector/AboutModal.d.ts +6 -0
  147. package/dist/esm/components/Inspector/AboutModal.js +351 -0
  148. package/dist/esm/components/Inspector/AnalyticsFilterModal.js +225 -886
  149. package/dist/esm/components/Inspector/AnalyticsTab.js +296 -904
  150. package/dist/esm/components/Inspector/BundleTab.js +1175 -3502
  151. package/dist/esm/components/Inspector/ConsoleTab.js +113 -488
  152. package/dist/esm/components/Inspector/CrashDetail.js +236 -747
  153. package/dist/esm/components/Inspector/CrashFilterModal.js +149 -541
  154. package/dist/esm/components/Inspector/CrashTab.js +177 -711
  155. package/dist/esm/components/Inspector/DebuggingTab.js +156 -923
  156. package/dist/esm/components/Inspector/DeviceInfoTab.js +199 -924
  157. package/dist/esm/components/Inspector/FabLauncher.js +85 -49
  158. package/dist/esm/components/Inspector/FeatureUnderDevNotice.js +14 -70
  159. package/dist/esm/components/Inspector/FeedbackModal.d.ts +9 -0
  160. package/dist/esm/components/Inspector/FeedbackModal.js +182 -499
  161. package/dist/esm/components/Inspector/InspectorContext.js +1 -12
  162. package/dist/esm/components/Inspector/InspectorHeader.js +309 -1145
  163. package/dist/esm/components/Inspector/LogDetail.js +235 -1023
  164. package/dist/esm/components/Inspector/MainScreen.js +86 -320
  165. package/dist/esm/components/Inspector/MediaGalleryTab.js +157 -259
  166. package/dist/esm/components/Inspector/MediaPreviewModal.js +153 -340
  167. package/dist/esm/components/Inspector/NavigationTracker.js +1 -10
  168. package/dist/esm/components/Inspector/NetworkDetail.js +141 -472
  169. package/dist/esm/components/Inspector/NetworkFilterModal.js +122 -597
  170. package/dist/esm/components/Inspector/NetworkTab.js +125 -517
  171. package/dist/esm/components/Inspector/NpmStarPrompt.js +58 -434
  172. package/dist/esm/components/Inspector/NpmUpdateToast.js +45 -281
  173. package/dist/esm/components/Inspector/PerformanceTab.js +393 -1570
  174. package/dist/esm/components/Inspector/ReduxDetail.js +307 -1170
  175. package/dist/esm/components/Inspector/ReduxTab.js +144 -722
  176. package/dist/esm/components/Inspector/SettingsPanel.js +647 -3609
  177. package/dist/esm/components/Inspector/SkeletonPlaceholder.js +30 -163
  178. package/dist/esm/components/Inspector/StorageTab.js +172 -866
  179. package/dist/esm/components/Inspector/TabBar.js +52 -183
  180. package/dist/esm/components/Inspector/UpdateAvailableModal.js +79 -416
  181. package/dist/esm/components/JsonViewer.js +179 -353
  182. package/dist/esm/components/LogCard.js +93 -565
  183. package/dist/esm/components/LogSyntaxHighlighter.js +11 -123
  184. package/dist/esm/components/MetaAccordion.js +136 -267
  185. package/dist/esm/components/MiniBarChart.js +3 -18
  186. package/dist/esm/components/MiniLineChart.js +3 -20
  187. package/dist/esm/components/NetworkIcons.d.ts +7 -0
  188. package/dist/esm/components/NetworkIcons.js +481 -817
  189. package/dist/esm/components/QRCodeView.js +8 -45
  190. package/dist/esm/components/SectionHeader.js +22 -39
  191. package/dist/esm/components/SegmentedTabs.js +8 -57
  192. package/dist/esm/components/SkeletonPlaceholder.js +30 -163
  193. package/dist/esm/components/Slider.js +24 -213
  194. package/dist/esm/components/SourcePageCard.js +65 -86
  195. package/dist/esm/components/Toast.js +10 -117
  196. package/dist/esm/components/TouchableScale.js +3 -19
  197. package/dist/esm/components/TreeNode.js +58 -95
  198. package/dist/esm/console.js +1 -2
  199. package/dist/esm/constants/index.js +1 -28
  200. package/dist/esm/constants/telemetryConfig.js +1 -3
  201. package/dist/esm/constants/version.d.ts +1 -1
  202. package/dist/esm/constants/version.js +1 -1
  203. package/dist/esm/crash.js +1 -2
  204. package/dist/esm/customHooks/analyticsLogger.js +1 -230
  205. package/dist/esm/customHooks/bundleAnalyzer.js +1 -944
  206. package/dist/esm/customHooks/consoleLogger.js +6 -432
  207. package/dist/esm/customHooks/crashHandler.js +7 -630
  208. package/dist/esm/customHooks/logFilters.js +1 -20
  209. package/dist/esm/customHooks/networkLogger.js +2 -519
  210. package/dist/esm/customHooks/performanceTracker.js +63 -723
  211. package/dist/esm/customHooks/reduxLogger.js +2 -293
  212. package/dist/esm/customHooks/storageInspector.js +1 -418
  213. package/dist/esm/customHooks/useAccordion.js +1 -16
  214. package/dist/esm/decorators/index.js +1 -95
  215. package/dist/esm/helpers/gaAnalyticsRegistry.js +1 -143
  216. package/dist/esm/helpers/index.js +8 -861
  217. package/dist/esm/helpers/memoryManager.js +1 -91
  218. package/dist/esm/helpers/qrGenerator.js +1 -364
  219. package/dist/esm/helpers/remoteConfig.js +1 -160
  220. package/dist/esm/helpers/searchQueryParser.js +1 -59
  221. package/dist/esm/helpers/settingsStore.js +1 -134
  222. package/dist/esm/helpers/telemetry.js +1 -489
  223. package/dist/esm/helpers/toast.js +1 -15
  224. package/dist/esm/i18n/index.js +1 -78
  225. package/dist/esm/i18n/locales/en.json +1 -1122
  226. package/dist/esm/index.js +7 -1967
  227. package/dist/esm/metro.js +6 -459
  228. package/dist/esm/native/NativeInspector.d.ts +3 -0
  229. package/dist/esm/native/NativeInspector.js +1 -370
  230. package/dist/esm/native/NativeNetworkInspector.d.ts +1 -0
  231. package/dist/esm/native/NativeNetworkInspector.js +1 -2
  232. package/dist/esm/network.js +1 -1
  233. package/dist/esm/performance.js +1 -2
  234. package/dist/esm/redux.js +1 -1
  235. package/dist/esm/storage.js +1 -1
  236. package/dist/esm/styles/AppColors.js +1 -417
  237. package/dist/esm/styles/AppFonts.js +1 -13
  238. package/dist/esm/styles/common.js +1 -186
  239. package/dist/esm/styles/index.d.ts +6 -0
  240. package/dist/esm/styles/index.js +1 -1551
  241. package/dist/esm/types/enums.d.ts +2 -1
  242. package/dist/esm/types/enums.js +1 -147
  243. package/dist/esm/types/index.js +1 -2
  244. package/dist/esm/types/interfaces.d.ts +7 -0
  245. package/dist/esm/types/interfaces.js +1 -1
  246. package/ios/NetworkInspectorModule.mm +253 -136
  247. package/package.json +5 -3
  248. package/react-native-inapp-inspector.podspec +1 -1
  249. package/src/native/NativeInspector.ts +17 -0
  250. package/src/native/NativeNetworkInspector.ts +1 -0
  251. package/src/analytics.ts +0 -35
  252. package/src/bundle.ts +0 -25
  253. package/src/capture.ts +0 -101
  254. package/src/components/AnalyticsDetail.tsx +0 -870
  255. package/src/components/AnalyticsEventCard.tsx +0 -444
  256. package/src/components/AnalyticsGraph.tsx +0 -583
  257. package/src/components/AnimatedEntrance.tsx +0 -20
  258. package/src/components/AppHeaderLogo.tsx +0 -143
  259. package/src/components/BrandCircleIcon.tsx +0 -144
  260. package/src/components/BrandSquareIcon.tsx +0 -184
  261. package/src/components/CodeSnippet.tsx +0 -725
  262. package/src/components/ConsoleLogCard.tsx +0 -679
  263. package/src/components/CopyButton.tsx +0 -87
  264. package/src/components/DiffViewer.tsx +0 -82
  265. package/src/components/DomainHeader.tsx +0 -224
  266. package/src/components/EmptyState.tsx +0 -95
  267. package/src/components/EndOfListFooter.tsx +0 -100
  268. package/src/components/ErrorBoundary.tsx +0 -688
  269. package/src/components/HeadersSection.tsx +0 -172
  270. package/src/components/HighlightText.tsx +0 -100
  271. package/src/components/Inspector/AnalyticsFilterModal.tsx +0 -1250
  272. package/src/components/Inspector/AnalyticsTab.tsx +0 -1362
  273. package/src/components/Inspector/BundleTab.tsx +0 -4768
  274. package/src/components/Inspector/ConsoleTab.tsx +0 -726
  275. package/src/components/Inspector/CrashDetail.tsx +0 -997
  276. package/src/components/Inspector/CrashFilterModal.tsx +0 -721
  277. package/src/components/Inspector/CrashTab.tsx +0 -933
  278. package/src/components/Inspector/DebuggingTab.tsx +0 -1103
  279. package/src/components/Inspector/DeviceInfoTab.tsx +0 -1397
  280. package/src/components/Inspector/FabLauncher.tsx +0 -80
  281. package/src/components/Inspector/FeatureUnderDevNotice.tsx +0 -94
  282. package/src/components/Inspector/FeedbackModal.tsx +0 -626
  283. package/src/components/Inspector/InspectorContext.tsx +0 -28
  284. package/src/components/Inspector/InspectorHeader.tsx +0 -1545
  285. package/src/components/Inspector/LogDetail.tsx +0 -1431
  286. package/src/components/Inspector/MainScreen.tsx +0 -459
  287. package/src/components/Inspector/MediaGalleryTab.tsx +0 -355
  288. package/src/components/Inspector/MediaPreviewModal.tsx +0 -435
  289. package/src/components/Inspector/NavigationTracker.tsx +0 -13
  290. package/src/components/Inspector/NetworkDetail.tsx +0 -795
  291. package/src/components/Inspector/NetworkFilterModal.tsx +0 -730
  292. package/src/components/Inspector/NetworkTab.tsx +0 -820
  293. package/src/components/Inspector/NpmStarPrompt.tsx +0 -532
  294. package/src/components/Inspector/NpmUpdateToast.tsx +0 -387
  295. package/src/components/Inspector/PerformanceTab.tsx +0 -1967
  296. package/src/components/Inspector/ReduxDetail.tsx +0 -1651
  297. package/src/components/Inspector/ReduxTab.tsx +0 -987
  298. package/src/components/Inspector/SettingsPanel.tsx +0 -4580
  299. package/src/components/Inspector/SkeletonPlaceholder.tsx +0 -206
  300. package/src/components/Inspector/StorageTab.tsx +0 -1159
  301. package/src/components/Inspector/TabBar.tsx +0 -263
  302. package/src/components/Inspector/UpdateAvailableModal.tsx +0 -555
  303. package/src/components/JsonViewer.tsx +0 -547
  304. package/src/components/LogCard.tsx +0 -694
  305. package/src/components/LogSyntaxHighlighter.tsx +0 -178
  306. package/src/components/MetaAccordion.tsx +0 -355
  307. package/src/components/MiniBarChart.tsx +0 -42
  308. package/src/components/MiniLineChart.tsx +0 -33
  309. package/src/components/NetworkIcons.tsx +0 -2599
  310. package/src/components/QRCodeView.tsx +0 -75
  311. package/src/components/SectionHeader.tsx +0 -101
  312. package/src/components/SegmentedTabs.tsx +0 -83
  313. package/src/components/SkeletonPlaceholder.tsx +0 -206
  314. package/src/components/Slider.tsx +0 -300
  315. package/src/components/SourcePageCard.tsx +0 -150
  316. package/src/components/Toast.tsx +0 -131
  317. package/src/components/TouchableScale.tsx +0 -61
  318. package/src/components/TreeNode.tsx +0 -171
  319. package/src/console.ts +0 -24
  320. package/src/constants/index.ts +0 -41
  321. package/src/constants/telemetryConfig.ts +0 -4
  322. package/src/constants/version.ts +0 -3
  323. package/src/crash.ts +0 -32
  324. package/src/customHooks/analyticsLogger.ts +0 -336
  325. package/src/customHooks/bundleAnalyzer.ts +0 -1256
  326. package/src/customHooks/consoleLogger.ts +0 -530
  327. package/src/customHooks/crashHandler.ts +0 -944
  328. package/src/customHooks/logFilters.ts +0 -32
  329. package/src/customHooks/networkLogger.ts +0 -624
  330. package/src/customHooks/performanceTracker.ts +0 -1014
  331. package/src/customHooks/reduxLogger.ts +0 -406
  332. package/src/customHooks/storageInspector.ts +0 -513
  333. package/src/customHooks/useAccordion.tsx +0 -27
  334. package/src/decorators/index.ts +0 -184
  335. package/src/helpers/gaAnalyticsRegistry.ts +0 -204
  336. package/src/helpers/index.ts +0 -1092
  337. package/src/helpers/memoryManager.ts +0 -138
  338. package/src/helpers/qrGenerator.ts +0 -430
  339. package/src/helpers/remoteConfig.ts +0 -212
  340. package/src/helpers/searchQueryParser.ts +0 -84
  341. package/src/helpers/settingsStore.ts +0 -171
  342. package/src/helpers/telemetry.ts +0 -568
  343. package/src/helpers/toast.ts +0 -17
  344. package/src/i18n/index.ts +0 -104
  345. package/src/i18n/locales/en.json +0 -1125
  346. package/src/index.tsx +0 -2635
  347. package/src/metro.ts +0 -598
  348. package/src/network.ts +0 -22
  349. package/src/performance.ts +0 -38
  350. package/src/redux.ts +0 -23
  351. package/src/storage.ts +0 -18
  352. package/src/styles/AppColors.ts +0 -455
  353. package/src/styles/AppFonts.ts +0 -26
  354. package/src/styles/common.ts +0 -209
  355. package/src/styles/index.ts +0 -1606
  356. package/src/types/enums.ts +0 -208
  357. package/src/types/index.ts +0 -34
  358. package/src/types/interfaces.ts +0 -530
@@ -1,1092 +0,0 @@
1
- import {
2
- Platform,
3
- ToastAndroid,
4
- Alert,
5
- NativeModules,
6
- Linking,
7
- } from 'react-native';
8
- import Clipboard from '@react-native-clipboard/clipboard';
9
- import {showToast} from './toast';
10
-
11
- // Stylesheet
12
- import {AppColors} from '../styles/AppColors';
13
-
14
- // Constants
15
- import {DOMAIN_COLORS, DURATION_FAST_MS, DURATION_SLOW_MS} from '../constants';
16
-
17
- // Type Definition
18
- import {
19
- NetworkLog,
20
- RouteInfo,
21
- DiffResult,
22
- JsonContent,
23
- StackFrameType,
24
- } from '../types';
25
- export * from './searchQueryParser';
26
- export * from './memoryManager';
27
- export * from './toast';
28
-
29
- /**
30
- * Returns true if running in local debug environment (connected to Metro/dev server, __DEV__ is true).
31
- * Returns false in standalone release / signed APKs.
32
- */
33
- export const isLocalDebugEnvironment = (): boolean => {
34
- const isDev = typeof __DEV__ !== 'undefined' && Boolean(__DEV__);
35
- const scriptURL: string = NativeModules.SourceCode?.scriptURL || '';
36
- const hasDevServer =
37
- scriptURL.startsWith('http://') ||
38
- scriptURL.startsWith('https://') ||
39
- scriptURL.includes(':8081') ||
40
- scriptURL.includes(':8082');
41
- return isDev || hasDevServer;
42
- };
43
-
44
- export const getDomainColor = (domain: string): string => {
45
- if (!domain) return DOMAIN_COLORS[0];
46
- let hash = 0;
47
- for (let i = 0; i < domain.length; i++) {
48
- hash = domain.charCodeAt(i) + ((hash << 5) - hash);
49
- }
50
- return DOMAIN_COLORS[Math.abs(hash) % DOMAIN_COLORS.length];
51
- };
52
-
53
- export const formatDateTime = (timestamp: number): string => {
54
- const date = new Date(timestamp);
55
- const pad = (n: number, len = 2) => String(n).padStart(len, '0');
56
- const day = pad(date.getDate());
57
- const month = pad(date.getMonth() + 1);
58
- const year = date.getFullYear();
59
- const hours = pad(date.getHours());
60
- const minutes = pad(date.getMinutes());
61
- const seconds = pad(date.getSeconds());
62
- return `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;
63
- };
64
-
65
- export const formatTimestamp = (timestamp: number): string => {
66
- try {
67
- const date = new Date(timestamp);
68
- const hours = date.getHours().toString().padStart(2, '0');
69
- const minutes = date.getMinutes().toString().padStart(2, '0');
70
- const seconds = date.getSeconds().toString().padStart(2, '0');
71
- const ms = date.getMilliseconds().toString().padStart(3, '0');
72
- return `${hours}:${minutes}:${seconds}.${ms}`;
73
- } catch {
74
- return '—';
75
- }
76
- };
77
-
78
- export const getStatusColor = (status: number | null): string => {
79
- if (!status || status === 0) return AppColors.errorColor;
80
- if (status >= 500) return AppColors.errorColor;
81
- if (status >= 400) return AppColors.darkOrange;
82
- if (status >= 300) return AppColors.warningIconGold;
83
- return AppColors.greenColor;
84
- };
85
-
86
- export const getDurationColor = (duration: number | null): string => {
87
- if (duration == null) return AppColors.grayTextWeak;
88
- if (duration < DURATION_FAST_MS) return AppColors.greenColor;
89
- if (duration < DURATION_SLOW_MS) return AppColors.lightOrange;
90
- return AppColors.errorColor;
91
- };
92
-
93
- export const getSize = (data: unknown): string => {
94
- try {
95
- const bytes = JSON.stringify(data)?.length ?? 0;
96
- return bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
97
- } catch {
98
- return '—';
99
- }
100
- };
101
-
102
- export const formatBytes = (bytes: number): string => {
103
- if (bytes === 0 || !bytes || isNaN(bytes)) return '0 B';
104
- const k = 1024;
105
- const sizes = ['B', 'KB', 'MB', 'GB'];
106
- const i = Math.floor(Math.log(bytes) / Math.log(k));
107
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i] || 'B'}`;
108
- };
109
-
110
- export const copyToClipboard = (value: unknown, label?: string): void => {
111
-
112
- const resolved = typeof value === 'function' ? (value as Function)() : value;
113
- let textToCopy = '';
114
- if (typeof resolved === 'string') {
115
- textToCopy = resolved;
116
- } else {
117
- try {
118
- textToCopy = JSON.stringify(resolved, null, 2);
119
- } catch {
120
- textToCopy = String(resolved);
121
- }
122
- }
123
-
124
- // Use @react-native-clipboard/clipboard npm package
125
- try {
126
- if (typeof Clipboard?.setString === 'function') {
127
- Clipboard.setString(textToCopy);
128
- } else if (typeof (Clipboard as any)?.default?.setString === 'function') {
129
- (Clipboard as any).default.setString(textToCopy);
130
- }
131
- } catch (err) {
132
- if (__DEV__) {
133
- console.warn('[NetworkInspector] Clipboard.setString failed:', err);
134
- }
135
- }
136
-
137
- // Trigger floating in-app bottom toast notification
138
- try {
139
- showToast(label ? `${label} copied to clipboard` : 'Copied to clipboard');
140
- } catch {}
141
-
142
- // Native Android Toast fallback
143
- try {
144
- if (Platform.OS === 'android' && ToastAndroid?.show) {
145
- ToastAndroid.show(
146
- label ? `${label} copied to clipboard` : 'Copied to clipboard',
147
- ToastAndroid.SHORT,
148
- );
149
- }
150
- } catch {}
151
- };
152
-
153
- export const getPath = (url: string): string => {
154
- try {
155
- const u = new URL(url);
156
- return u.pathname + (u.search ? u.search : '');
157
- } catch {
158
- const withoutDomain = url.replace(/^https?:\/\/[^/?#]+/, '');
159
- return withoutDomain || '/';
160
- }
161
- };
162
-
163
- export const getBaseUrl = (url: string): string => {
164
- try {
165
- const u = new URL(url);
166
- return `${u.protocol}//${u.host}`;
167
- } catch {
168
- const match = url.match(/^(https?:\/\/[^/]+)/);
169
- return match ? match[1] : '';
170
- }
171
- };
172
-
173
- export const getCurlCommand = (log: NetworkLog): string => {
174
- let cmd = `curl -X ${log.method} "${log.url}"`;
175
- if (log.requestHeaders) {
176
- Object.entries(log.requestHeaders).forEach(([k, v]) => {
177
- cmd += ` \\\n -H "${k}: ${v}"`;
178
- });
179
- }
180
- if (log.request && log.method !== 'GET') {
181
- const body =
182
- typeof log.request === 'string'
183
- ? log.request
184
- : JSON.stringify(log.request);
185
- cmd += ` \\\n -d '${body.replace(/'/g, "'\\''")}'`;
186
- }
187
- return cmd;
188
- };
189
-
190
- export const getFetchCommand = (log: NetworkLog): string => {
191
- const opts: Record<string, unknown> = {method: log.method};
192
- if (log.requestHeaders && Object.keys(log.requestHeaders).length > 0) {
193
- opts.headers = log.requestHeaders;
194
- }
195
- if (log.request && log.method !== 'GET') {
196
- opts.body = JSON.stringify(log.request);
197
- }
198
- return `fetch("${log.url}", ${JSON.stringify(opts, null, 2)})`;
199
- };
200
-
201
- export const deduplicateLogs = (raw: NetworkLog[]): NetworkLog[] => {
202
- const map = new Map<number, NetworkLog>();
203
- raw.forEach(entry => {
204
- if (!map.has(entry.id)) {
205
- map.set(entry.id, entry);
206
- } else {
207
- const existing = map.get(entry.id)!;
208
- if (existing.status == null && entry.status != null) {
209
- map.set(entry.id, entry);
210
- } else if ((entry.startTime ?? 0) >= (existing.startTime ?? 0)) {
211
- map.set(entry.id, entry);
212
- }
213
- }
214
- });
215
- return Array.from(map.values()).sort((a, b) => b.id - a.id);
216
- };
217
-
218
- export const escapeRegex = (str: string): string => {
219
- return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
220
- };
221
-
222
- export const getNavigationInfo = (
223
- state: any,
224
- path: string[] = [],
225
- ): RouteInfo => {
226
- if (!state) {
227
- return {
228
- path: path.length > 0 ? path.join(' ➔ ') : '',
229
- params: null,
230
- };
231
- }
232
- if (state.name && !state.routes) {
233
- const fullPath =
234
- path.length > 0 ? [...path, state.name].join(' ➔ ') : state.name;
235
- return {path: fullPath, params: state.params || null};
236
- }
237
- if (
238
- !state.routes ||
239
- !Array.isArray(state.routes) ||
240
- state.routes.length === 0
241
- ) {
242
- return {
243
- path: path.length > 0 ? path.join(' ➔ ') : '',
244
- params: null,
245
- };
246
- }
247
- const index =
248
- typeof state.index === 'number' &&
249
- state.index >= 0 &&
250
- state.index < state.routes.length
251
- ? state.index
252
- : 0;
253
- const route = state.routes[index];
254
- if (!route) {
255
- return {
256
- path: path.length > 0 ? path.join(' ➔ ') : '',
257
- params: null,
258
- };
259
- }
260
- const currentPath = route.name ? [...path, route.name] : path;
261
-
262
- if (route?.state) {
263
- return getNavigationInfo(route.state, currentPath);
264
- }
265
- const resolved =
266
- currentPath.length > 0 ? currentPath.join(' ➔ ') : route.name || '';
267
- return {path: resolved, params: route.params || null};
268
- };
269
-
270
- export const getLogPageName = (
271
- log: NetworkLog,
272
- routeInfo?: RouteInfo | null,
273
- ): string => {
274
- // 1. If routeInfo has a valid path, resolve the leaf screen name
275
- const effectiveRoute = routeInfo || (log as any)?.routeInfo;
276
- if (
277
- effectiveRoute &&
278
- effectiveRoute.path &&
279
- effectiveRoute.path !== 'Navigators'
280
- ) {
281
- const parts = effectiveRoute.path
282
- .split(' ➔ ')
283
- .map((s: string) => s.trim())
284
- .filter(Boolean);
285
- if (parts.length > 0) {
286
- return parts[parts.length - 1]; // Leaf screen name, e.g. "HomeScreen", "ProfileScreen"
287
- }
288
- return effectiveRoute.path;
289
- }
290
-
291
- // 2. Extract screen / component name from log.caller stack trace
292
- if (log.caller && log.caller !== 'Unknown') {
293
- try {
294
- const match = log.caller.match(/([^/\\]+)\.(tsx|jsx|ts|js)/i);
295
- if (match && match[1]) {
296
- const file = match[1];
297
- const ignored = [
298
- 'networklogger',
299
- 'fetch',
300
- 'axios',
301
- 'apiclient',
302
- 'request',
303
- 'http',
304
- 'index',
305
- 'nativeinspector',
306
- 'inappinspector',
307
- 'bundleanalyzer',
308
- ];
309
- if (!ignored.includes(file.toLowerCase())) {
310
- return file;
311
- }
312
- }
313
- } catch (e) {}
314
- }
315
-
316
- // 3. Fallback to API resource / endpoint category from URL
317
- if (log.url) {
318
- try {
319
- const cleanUrl = log.url.split('?')[0].split('#')[0];
320
- const withoutProto = cleanUrl.replace(/^https?:\/\//i, '');
321
- const slashIdx = withoutProto.indexOf('/');
322
- if (slashIdx !== -1) {
323
- const pathSegments = withoutProto
324
- .substring(slashIdx + 1)
325
- .split('/')
326
- .filter(Boolean);
327
- const ignoredSegments = [
328
- 'api',
329
- 'v1',
330
- 'v2',
331
- 'v3',
332
- 'v4',
333
- 'rest',
334
- 'graphql',
335
- 'json',
336
- 'data',
337
- 'service',
338
- 'app',
339
- ];
340
- const meaningful = pathSegments.filter(
341
- s => !ignoredSegments.includes(s.toLowerCase()),
342
- );
343
- if (meaningful.length > 0) {
344
- const seg = meaningful[0];
345
- return seg.charAt(0).toUpperCase() + seg.slice(1);
346
- }
347
- }
348
- const host = withoutProto.split('/')[0];
349
- if (host) return host;
350
- } catch (e) {}
351
- }
352
-
353
- return 'General';
354
- };
355
-
356
- export const flattenObject = (obj: any, prefix = ''): Record<string, any> => {
357
- let result: Record<string, any> = {};
358
- if (typeof obj === 'object' && obj !== null) {
359
- if (Array.isArray(obj)) {
360
- obj.forEach((v, i) => {
361
- Object.assign(
362
- result,
363
- flattenObject(v, prefix ? `${prefix}[${i}]` : `[${i}]`),
364
- );
365
- });
366
- } else {
367
- Object.keys(obj).forEach(k => {
368
- Object.assign(
369
- result,
370
- flattenObject(obj[k], prefix ? `${prefix}.${k}` : k),
371
- );
372
- });
373
- }
374
- } else {
375
- result[prefix || 'root'] = obj;
376
- }
377
- return result;
378
- };
379
-
380
- export const getDiff = (oldObj: any, newObj: any): DiffResult[] => {
381
- const oldFlat = flattenObject(oldObj);
382
- const newFlat = flattenObject(newObj);
383
- const diff: DiffResult[] = [];
384
-
385
- const allKeys = new Set([...Object.keys(oldFlat), ...Object.keys(newFlat)]);
386
- allKeys.forEach(k => {
387
- if (!(k in oldFlat)) {
388
- diff.push({type: 'added', path: k, newVal: newFlat[k]});
389
- } else if (!(k in newFlat)) {
390
- diff.push({type: 'removed', path: k, oldVal: oldFlat[k]});
391
- } else if (oldFlat[k] !== newFlat[k]) {
392
- diff.push({
393
- type: 'changed',
394
- path: k,
395
- oldVal: oldFlat[k],
396
- newVal: newFlat[k],
397
- });
398
- }
399
- });
400
- return diff.sort((a, b) => a.path.localeCompare(b.path));
401
- };
402
-
403
- export const formatDisplayUrl = (url: string) => {
404
- if (!url) return '';
405
- if (url.startsWith('http://') || url.startsWith('https://')) return url;
406
- return `https://${url}`;
407
- };
408
-
409
- export const getLocalizedFilePath = (
410
- path: string | any,
411
- country: string | any,
412
- language: string | any,
413
- ) => {
414
- const url = path.replace(
415
- 'country-language',
416
- `${country?.toLowerCase()}-${language?.toLowerCase()}`,
417
- );
418
- return url;
419
- };
420
-
421
- export const getLocalizedFilePathWithSlash = (
422
- path: string | any,
423
- country: string | any,
424
- language: string | any,
425
- ) => {
426
- const url = path.replace(
427
- 'country/language',
428
- `${country?.toLowerCase()}/${language?.toLowerCase()}`,
429
- );
430
- return url;
431
- };
432
-
433
- export const isAllValuesEmpty = (obj: Record<string, any>) => {
434
- if (!obj || typeof obj !== 'object') return true;
435
-
436
- return Object.values(obj).every(
437
- value =>
438
- value &&
439
- typeof value === 'object' &&
440
- !Array.isArray(value) &&
441
- Object.keys(value).length === 0,
442
- );
443
- };
444
-
445
- export const formatDateTimeToAnalytics = (ts: number): string => {
446
- const d = new Date(ts);
447
-
448
- return d?.toLocaleString(undefined, {
449
- month: 'short',
450
- day: 'numeric',
451
- hour: '2-digit',
452
- minute: '2-digit',
453
- second: '2-digit',
454
- });
455
- };
456
-
457
- export const getBundleIdentifier = (): string => {
458
- const RNDeviceInfo = NativeModules.RNDeviceInfo;
459
- if (RNDeviceInfo && typeof RNDeviceInfo.bundleId === 'string') {
460
- return RNDeviceInfo.bundleId;
461
- }
462
- if (RNDeviceInfo && typeof RNDeviceInfo.getBundleId === 'function') {
463
- try {
464
- const res = RNDeviceInfo.getBundleId();
465
- if (typeof res === 'string') return res;
466
- } catch (e) {}
467
- }
468
-
469
- const ExponentConstants = NativeModules.ExponentConstants;
470
- if (ExponentConstants && ExponentConstants.manifest) {
471
- const manifest = ExponentConstants.manifest;
472
- if (manifest.ios && manifest.ios.bundleIdentifier) {
473
- return manifest.ios.bundleIdentifier;
474
- }
475
- if (manifest.android && manifest.android.package) {
476
- return manifest.android.package;
477
- }
478
- }
479
-
480
- const ExpoApplication = NativeModules.ExpoApplication;
481
- if (ExpoApplication && typeof ExpoApplication.applicationId === 'string') {
482
- return ExpoApplication.applicationId;
483
- }
484
-
485
- const SourceCode = NativeModules.SourceCode;
486
- if (SourceCode && typeof SourceCode.scriptURL === 'string') {
487
- const url = SourceCode.scriptURL;
488
- if (url.includes('assets/')) {
489
- try {
490
- const match = url.match(/assets\/([^/?#]+)/);
491
- if (match && match[1]) {
492
- return match[1];
493
- }
494
- } catch (e) {}
495
- }
496
- }
497
-
498
- return 'org.reactjs.native.example';
499
- };
500
-
501
- export const getAppName = (): string => {
502
- // Try iOS via PlatformConstants
503
- const constants = NativeModules.PlatformConstants;
504
- if (constants && typeof constants.interfaceIdiom === 'string') {
505
- // Fallback: try to parse from SourceCode
506
- }
507
-
508
- // Try react-native-device-info
509
- const RNDeviceInfo = NativeModules.RNDeviceInfo;
510
- if (RNDeviceInfo && typeof RNDeviceInfo.appName === 'string') {
511
- return RNDeviceInfo.appName;
512
- }
513
-
514
- // Try Expo
515
- const ExpoApplication = NativeModules.ExpoApplication;
516
- if (ExpoApplication && typeof ExpoApplication.applicationName === 'string') {
517
- return ExpoApplication.applicationName;
518
- }
519
-
520
- const ExponentConstants = NativeModules.ExponentConstants;
521
- if (ExponentConstants && ExponentConstants.manifest) {
522
- const manifest = ExponentConstants.manifest;
523
- if (manifest.name) return manifest.name;
524
- }
525
-
526
- // Android: try to get from AndroidInfoModule
527
- const AppInfo = NativeModules.AppInfo;
528
- if (AppInfo && typeof AppInfo.appName === 'string') {
529
- return AppInfo.appName;
530
- }
531
-
532
- // Fallback: derive from bundle ID (last segment, cleaned up)
533
- const bundleId = getBundleIdentifier();
534
- if (bundleId && bundleId !== 'org.reactjs.native.example') {
535
- const parts = bundleId.split('.');
536
- const last = parts[parts.length - 1];
537
- // Capitalize first letter
538
- return last ? last.charAt(0).toUpperCase() + last.slice(1) : 'App';
539
- }
540
-
541
- return 'App';
542
- };
543
-
544
- export const getAppVersionAndBuild = (): {
545
- version: string;
546
- build: string;
547
- formatted: string;
548
- } => {
549
- let version = '';
550
- let build = '';
551
-
552
- // 1. Try ExpoApplication / ExponentConstants
553
- const ExpoApplication = NativeModules.ExpoApplication;
554
- if (ExpoApplication) {
555
- if (typeof ExpoApplication.nativeAppVersion === 'string') {
556
- version = ExpoApplication.nativeAppVersion;
557
- }
558
- if (typeof ExpoApplication.nativeBuildVersion === 'string') {
559
- build = ExpoApplication.nativeBuildVersion;
560
- }
561
- }
562
-
563
- const ExponentConstants = NativeModules.ExponentConstants;
564
- if (ExponentConstants) {
565
- const manifest = ExponentConstants.manifest || ExponentConstants.expoConfig;
566
- if (manifest) {
567
- if (!version && manifest.version) {
568
- version = String(manifest.version);
569
- }
570
- if (!build) {
571
- if (manifest.ios?.buildNumber) {
572
- build = String(manifest.ios.buildNumber);
573
- } else if (manifest.android?.versionCode) {
574
- build = String(manifest.android.versionCode);
575
- }
576
- }
577
- }
578
- }
579
-
580
- // 2. Try react-native-device-info
581
- const RNDeviceInfo = NativeModules.RNDeviceInfo;
582
- if (RNDeviceInfo) {
583
- if (!version) {
584
- if (typeof RNDeviceInfo.appVersion === 'string') {
585
- version = RNDeviceInfo.appVersion;
586
- } else if (typeof RNDeviceInfo.getVersion === 'function') {
587
- try {
588
- version = RNDeviceInfo.getVersion();
589
- } catch (e) {}
590
- }
591
- }
592
- if (!build) {
593
- if (typeof RNDeviceInfo.buildNumber === 'string') {
594
- build = RNDeviceInfo.buildNumber;
595
- } else if (typeof RNDeviceInfo.getBuildNumber === 'function') {
596
- try {
597
- build = RNDeviceInfo.getBuildNumber();
598
- } catch (e) {}
599
- }
600
- }
601
- }
602
-
603
- // 3. Try PlatformConstants / Platform.constants
604
- const constants =
605
- (Platform.constants as any) || NativeModules.PlatformConstants;
606
- if (constants) {
607
- if (
608
- !version &&
609
- constants.Version &&
610
- typeof constants.Version === 'string' &&
611
- constants.Version.includes('.')
612
- ) {
613
- version = constants.Version;
614
- }
615
- if (!version && constants.reactNativeVersion) {
616
- const rnv = constants.reactNativeVersion;
617
- if (rnv.major !== undefined) {
618
- version = `${rnv.major}.${rnv.minor}.${rnv.patch}`;
619
- }
620
- }
621
- }
622
-
623
- // 4. Try Android AppInfo
624
- const AppInfo = NativeModules.AppInfo;
625
- if (AppInfo) {
626
- if (!version && typeof AppInfo.versionName === 'string') {
627
- version = AppInfo.versionName;
628
- }
629
- if (!build && typeof AppInfo.versionCode === 'string') {
630
- build = AppInfo.versionCode;
631
- }
632
- }
633
-
634
- // Fallbacks
635
- if (!version) version = '1.0.0';
636
- if (!build) build = '1';
637
-
638
- return {
639
- version,
640
- build,
641
- formatted: `${version} (${build})`,
642
- };
643
- };
644
-
645
- export const handleOpenExternalLink = (url: string): void => {
646
- if (!url) return;
647
- const openUrl = formatDisplayUrl(url);
648
- Alert.alert(
649
- 'Open Link',
650
- `Do you want to open this link in your web browser?\n\n${openUrl}`,
651
- [
652
- {text: 'Cancel', style: 'cancel'},
653
- {
654
- text: 'Open',
655
- onPress: () => {
656
- Linking.openURL(openUrl).catch(() => {});
657
- },
658
- },
659
- ],
660
- );
661
- };
662
-
663
- /** Formats a timestamp as HH:MM:SS (no milliseconds). */
664
- export const formatTimeShort = (ts: number): string => {
665
- const d = new Date(ts);
666
- const hh = String(d.getHours()).padStart(2, '0');
667
- const mm = String(d.getMinutes()).padStart(2, '0');
668
- const ss = String(d.getSeconds()).padStart(2, '0');
669
- return `${hh}:${mm}:${ss}`;
670
- };
671
-
672
- /** Formats a timestamp as HH:MM:SS.mmm (with milliseconds). */
673
- export const formatTime = (ts: number): string => {
674
- const d = new Date(ts);
675
- const hh = String(d.getHours()).padStart(2, '0');
676
- const mm = String(d.getMinutes()).padStart(2, '0');
677
- const ss = String(d.getSeconds()).padStart(2, '0');
678
- const ms = String(d.getMilliseconds()).padStart(3, '0');
679
- return `${hh}:${mm}:${ss}.${ms}`;
680
- };
681
-
682
- /** Formats a relative gap like "+2s" / "+1m 5s" / "+350ms". */
683
- export const formatGap = (ms: number): string => {
684
- if (ms < 1000) return `+${ms}ms`;
685
- const s = Math.round(ms / 1000);
686
- if (s < 60) return `+${s}s`;
687
- const m = Math.floor(s / 60);
688
- const rem = s % 60;
689
- return rem > 0 ? `+${m}m ${rem}s` : `+${m}m`;
690
- };
691
-
692
- /** Finds the first JSON object/array embedded anywhere in a log message. */
693
- export const getJsonContent = (message: string): JsonContent | null => {
694
- if (!message) return null;
695
-
696
- const indices: number[] = [];
697
- for (let i = 0; i < message.length; i++) {
698
- if (message[i] === '{' || message[i] === '[') {
699
- indices.push(i);
700
- }
701
- }
702
-
703
- for (const index of indices) {
704
- const candidate = message.substring(index).trim();
705
- try {
706
- const parsed = JSON.parse(candidate);
707
- if (parsed !== null && typeof parsed === 'object') {
708
- const header = message.substring(0, index).trim();
709
- return {header, data: parsed};
710
- }
711
- } catch (e) {
712
- // Ignore
713
- }
714
- }
715
-
716
- return null;
717
- };
718
-
719
- /** Pretty-prints JSON data showing 3-4 lines with trailing "..." */
720
- export const getJsonPreviewText = (
721
- data: any,
722
- maxLines = 4,
723
- ): {text: string; hasMore: boolean} => {
724
- try {
725
- const formatted = JSON.stringify(data, null, 2);
726
- const lines = formatted.split('\n');
727
- if (lines.length > maxLines) {
728
- return {
729
- text: lines.slice(0, maxLines).join('\n') + '\n...',
730
- hasMore: true,
731
- };
732
- }
733
- return {
734
- text: formatted,
735
- hasMore: false,
736
- };
737
- } catch (e) {
738
- return {
739
- text: String(data),
740
- hasMore: false,
741
- };
742
- }
743
- };
744
-
745
- export interface ParsedStackFrame {
746
- raw: string;
747
- functionName: string;
748
- fileName: string;
749
- fullPath: string;
750
- fileExt: string;
751
- frameType: StackFrameType | 'app' | 'dependency' | 'runtime' | 'native';
752
- isUserCode: boolean;
753
- isRuntimeNoise: boolean;
754
- rawFilePath?: string;
755
- lineNumber?: string;
756
- columnNumber?: string;
757
- isOrigin?: boolean;
758
- copyableLocation: string;
759
- }
760
-
761
- /** Parses a stack trace line to extract function name, file name, extension (.tsx/.jsx/.ts), line, and column numbers */
762
- export const parseStackLine = (
763
- rawLine: string,
764
- isOrigin = false,
765
- ): ParsedStackFrame => {
766
- let line = rawLine.trim().replace(/^at /, '');
767
-
768
- // Format: func@file:line:col (JSC / Hermes format)
769
- if (line.includes('@')) {
770
- const atIndex = line.indexOf('@');
771
- const funcPart = line.substring(0, atIndex).trim();
772
- const pathPart = line.substring(atIndex + 1).trim();
773
- line = funcPart ? `${funcPart} (${pathPart})` : pathPart;
774
- }
775
-
776
- // Check for "func (path:line:col)" or "path:line:col"
777
- const parenMatch = line.match(/^(.*?)\s*\((.*?)\)$/);
778
- let functionName = '<anonymous>';
779
- let locationPart = line;
780
-
781
- if (parenMatch) {
782
- functionName = parenMatch[1].trim() || '<anonymous>';
783
- locationPart = parenMatch[2].trim();
784
- }
785
-
786
- // Clean Babel/Hermes artifacts in function names like ?anon_0_, _callee$, etc.
787
- if (functionName.startsWith('?anon_') || functionName === '?') {
788
- functionName = 'anonymous';
789
- }
790
-
791
- // Remove "address at " prefix if present in Hermes
792
- locationPart = locationPart.replace(/^address at /, '');
793
-
794
- // Extract file, line, and col from locationPart (e.g. "path/to/file.tsx:42:15" or "http://...:42:15")
795
- const locMatch = locationPart.match(/^(.*?):(\d+):(\d+)$/);
796
- let fullPath = locationPart;
797
- let lineNumber: string | undefined;
798
- let columnNumber: string | undefined;
799
-
800
- if (locMatch) {
801
- fullPath = locMatch[1];
802
- lineNumber = locMatch[2];
803
- columnNumber = locMatch[3];
804
- }
805
-
806
- // Clean file name (remove query strings, packager urls, and parent paths)
807
- let cleanPath = fullPath
808
- .split('?')[0]
809
- .split('&')[0]
810
- .replace(/[)]+$/, '')
811
- .replace(/\/\/+$/, '');
812
- // Remove protocol prefixes
813
- cleanPath = cleanPath.replace(
814
- /^(?:https?:\/\/[^\/]+\/|file:\/\/\/|webpack:\/\/\/?)/,
815
- '',
816
- );
817
- const fileName = cleanPath.split('/').filter(Boolean).pop() || cleanPath;
818
-
819
- // Determine file extension (.tsx, .jsx, .ts, .js)
820
- const extMatch = fileName.match(/\.([a-z0-9]+)$/i);
821
- const ext = extMatch ? extMatch[1].toLowerCase() : '';
822
- const fileExt: 'tsx' | 'jsx' | 'ts' | 'js' | 'other' =
823
- ext === 'tsx' || ext === 'jsx' || ext === 'ts' || ext === 'js'
824
- ? (ext as 'tsx' | 'jsx' | 'ts' | 'js')
825
- : 'other';
826
-
827
- const isNative = locationPart === 'native' || cleanPath === 'native';
828
- const isInternalBytecode =
829
- cleanPath.includes('InternalBytecode') ||
830
- cleanPath.includes('metro-runtime') ||
831
- cleanPath.includes('regenerator-runtime') ||
832
- functionName === 'tryCallOne' ||
833
- functionName === 'asyncGeneratorStep' ||
834
- functionName === '_next' ||
835
- (functionName === 'next' && isNative);
836
-
837
- const isDependency =
838
- cleanPath.includes('node_modules') ||
839
- cleanPath.includes('react-native/Libraries') ||
840
- (cleanPath.includes('react-native-inapp-inspector') &&
841
- !cleanPath.includes('/example/'));
842
-
843
- const isUserCode =
844
- !isNative &&
845
- !isInternalBytecode &&
846
- !isDependency &&
847
- (fileExt === 'tsx' ||
848
- fileExt === 'jsx' ||
849
- fileExt === 'ts' ||
850
- fileExt === 'js' ||
851
- !fileName.includes('.bundle'));
852
-
853
- const frameType: 'app' | 'dependency' | 'runtime' | 'native' = isUserCode
854
- ? 'app'
855
- : isDependency
856
- ? 'dependency'
857
- : isNative
858
- ? 'native'
859
- : 'runtime';
860
-
861
- const isRuntimeNoise =
862
- isInternalBytecode ||
863
- isNative ||
864
- functionName === 'asyncGeneratorStep' ||
865
- functionName === '_next';
866
-
867
- // Format clean relative project path
868
- let relativePath = cleanPath;
869
- if (relativePath.includes('/example/')) {
870
- relativePath = relativePath.substring(
871
- relativePath.indexOf('/example/') + 9,
872
- );
873
- } else if (relativePath.includes('/src/')) {
874
- relativePath = relativePath.substring(relativePath.indexOf('/src/') + 1);
875
- } else if (relativePath.includes('/node_modules/')) {
876
- relativePath = relativePath.substring(
877
- relativePath.indexOf('/node_modules/') + 14,
878
- );
879
- }
880
-
881
- const copyableLocation = lineNumber
882
- ? `${fileName}:${lineNumber}${columnNumber ? `:${columnNumber}` : ''}`
883
- : fileName;
884
-
885
- return {
886
- raw: rawLine,
887
- functionName,
888
- fileName,
889
- fullPath: relativePath,
890
- rawFilePath: fullPath,
891
- fileExt,
892
- frameType,
893
- isUserCode,
894
- isRuntimeNoise,
895
- lineNumber,
896
- columnNumber,
897
- isOrigin,
898
- copyableLocation,
899
- };
900
- };
901
-
902
- /** Opens a file and line number directly in VS Code / system editor */
903
- export const openInVSCode = (
904
- filePath: string,
905
- lineNumber?: string | number,
906
- columnNumber?: string | number,
907
- ) => {
908
- const numLine = lineNumber ? Number(lineNumber) : 1;
909
- const numCol = columnNumber ? Number(columnNumber) : 1;
910
- const line = lineNumber ? `:${lineNumber}` : '';
911
- const col = columnNumber ? `:${columnNumber}` : '';
912
- const cleanPath = filePath.replace(/^file:\/\//, '');
913
-
914
- // 1. Notify Metro dev server on host to launch editor directly on local system
915
- let extractedOrigin: string | null = null;
916
- try {
917
- const scriptURL =
918
- (NativeModules?.SourceCode as any)?.scriptURL ||
919
- (NativeModules?.PlatformConstants as any)?.serverHost ||
920
- (NativeModules?.DevSettings as any)?.serverHost;
921
- if (typeof scriptURL === 'string' && scriptURL.length > 0) {
922
- const match = scriptURL.match(/^(https?:\/\/[^/]+)/);
923
- if (match) {
924
- extractedOrigin = match[1];
925
- } else if (!scriptURL.startsWith('http') && scriptURL.includes(':')) {
926
- extractedOrigin = `http://${scriptURL}`;
927
- }
928
- }
929
- } catch {}
930
-
931
- const metroHosts = Array.from(
932
- new Set([
933
- ...(extractedOrigin ? [extractedOrigin] : []),
934
- 'http://localhost:8081',
935
- 'http://127.0.0.1:8081',
936
- 'http://10.0.2.2:8081',
937
- ]),
938
- );
939
-
940
- metroHosts.forEach(host => {
941
- try {
942
- fetch(`${host}/open-stack-frame`, {
943
- method: 'POST',
944
- headers: {'Content-Type': 'application/json'},
945
- body: JSON.stringify({
946
- file: cleanPath,
947
- lineNumber: numLine,
948
- column: numCol,
949
- }),
950
- }).catch(() => {});
951
- } catch {}
952
- });
953
-
954
- // 2. Also invoke native URL scheme handlers
955
- const vscodeUrl = `vscode://file/${cleanPath.replace(/^\/+/, '')}${line}${col}`;
956
- const cursorUrl = `cursor://file/${cleanPath.replace(/^\/+/, '')}${line}${col}`;
957
- const vscodeInsidersUrl = `vscode-insiders://file/${cleanPath.replace(/^\/+/, '')}${line}${col}`;
958
-
959
- Linking.openURL(vscodeUrl).catch(() => {
960
- Linking.openURL(cursorUrl).catch(() => {
961
- Linking.openURL(vscodeInsidersUrl).catch(() => {
962
- // Fallback: Copy to clipboard so user can jump immediately
963
- copyToClipboard(`${cleanPath}${line}${col}`, 'Location');
964
- });
965
- });
966
- });
967
- };
968
-
969
- // ─── Analytics Helpers ────────────────────────────────────────────────────────
970
-
971
- export const ANALYTICS_EVENT_PALETTE = [
972
- AppColors.googleBlue,
973
- AppColors.googleGreen,
974
- AppColors.googlePurple,
975
- AppColors.googleTeal,
976
- AppColors.googleRed,
977
- AppColors.googleOrange,
978
- AppColors.blue700,
979
- AppColors.materialGreen,
980
- ];
981
-
982
- export const getEventColor = (name: string): string => {
983
- const safeName = typeof name === 'string' ? name : String(name || '');
984
- let hash = 0;
985
- for (let i = 0; i < safeName.length; i++) {
986
- hash = (hash * 31 + safeName.charCodeAt(i)) | 0;
987
- }
988
- return ANALYTICS_EVENT_PALETTE[
989
- Math.abs(hash) % ANALYTICS_EVENT_PALETTE.length
990
- ];
991
- };
992
-
993
- export {
994
- getEventCategory,
995
- registerGAPlugin,
996
- type GAEventCategory,
997
- type GAPlugin,
998
- } from './gaAnalyticsRegistry';
999
-
1000
- export const getCategoryColors = (category: string) => {
1001
- switch (category) {
1002
- case 'page_view':
1003
- case 'Page View':
1004
- return {
1005
- bg: AppColors.blueBg,
1006
- border: AppColors.blueBorder,
1007
- text: AppColors.blue800,
1008
- };
1009
- case 'ecommerce':
1010
- case 'Ecommerce':
1011
- return {
1012
- bg: AppColors.greenBg,
1013
- border: AppColors.greenBorder,
1014
- text: AppColors.materialGreen,
1015
- };
1016
- case 'system':
1017
- case 'System':
1018
- return {
1019
- bg: AppColors.greyBg,
1020
- border: AppColors.greyBorder,
1021
- text: AppColors.grey600,
1022
- };
1023
- default:
1024
- return {
1025
- bg: AppColors.purpleBg,
1026
- border: AppColors.purpleBorder,
1027
- text: AppColors.purpleText,
1028
- };
1029
- }
1030
- };
1031
-
1032
- export interface RuntimeDiagnostics {
1033
- engineType: 'hermes' | 'v8' | 'jsc';
1034
- archType: 'fabric' | 'paper';
1035
- usedHeapMb: number;
1036
- totalAllocMb: number;
1037
- }
1038
-
1039
- export const getRuntimeDiagnostics = (): RuntimeDiagnostics => {
1040
- const isHermes = typeof (global as any).HermesInternal !== 'undefined';
1041
- const isV8 = typeof (global as any)._v8runtime !== 'undefined';
1042
- const engineType: 'hermes' | 'v8' | 'jsc' = isHermes
1043
- ? 'hermes'
1044
- : isV8
1045
- ? 'v8'
1046
- : 'jsc';
1047
-
1048
- const isFabric =
1049
- typeof (global as any).nativeFabricUIManager !== 'undefined' ||
1050
- Boolean((global as any).__turboModuleProxy);
1051
- const archType: 'fabric' | 'paper' = isFabric ? 'fabric' : 'paper';
1052
-
1053
- let usedHeapMb = 32.4;
1054
- let totalAllocMb = 64.0;
1055
-
1056
- try {
1057
- const hermesStats = (
1058
- global as any
1059
- ).HermesInternal?.getInstrumentedStats?.();
1060
- if (hermesStats?.js_heap_size) {
1061
- usedHeapMb = Number(
1062
- (hermesStats.js_heap_size / (1024 * 1024)).toFixed(1),
1063
- );
1064
- totalAllocMb = Number(
1065
- (
1066
- (hermesStats.js_allocated_bytes || hermesStats.js_heap_size * 1.6) /
1067
- (1024 * 1024)
1068
- ).toFixed(1),
1069
- );
1070
- } else if ((global as any).performance?.memory?.usedJSHeapSize) {
1071
- usedHeapMb = Number(
1072
- (
1073
- (global as any).performance.memory.usedJSHeapSize /
1074
- (1024 * 1024)
1075
- ).toFixed(1),
1076
- );
1077
- totalAllocMb = Number(
1078
- (
1079
- (global as any).performance.memory.totalJSHeapSize /
1080
- (1024 * 1024)
1081
- ).toFixed(1),
1082
- );
1083
- }
1084
- } catch {}
1085
-
1086
- return {
1087
- engineType,
1088
- archType,
1089
- usedHeapMb,
1090
- totalAllocMb,
1091
- };
1092
- };