react-native-inapp-inspector 2.2.9 → 2.3.1

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 (105) hide show
  1. package/dist/commonjs/components/AppHeaderLogo.js +45 -12
  2. package/dist/commonjs/components/BrandSquareIcon.js +92 -49
  3. package/dist/commonjs/components/EmptyState.d.ts +7 -2
  4. package/dist/commonjs/components/EmptyState.js +11 -5
  5. package/dist/commonjs/components/Inspector/AnalyticsTab.js +29 -18
  6. package/dist/commonjs/components/Inspector/ConsoleTab.js +6 -1
  7. package/dist/commonjs/components/Inspector/CrashDetail.js +43 -9
  8. package/dist/commonjs/components/Inspector/CrashTab.js +34 -3
  9. package/dist/commonjs/components/Inspector/DeviceInfoTab.js +80 -16
  10. package/dist/commonjs/components/Inspector/InspectorHeader.js +16 -3
  11. package/dist/commonjs/components/Inspector/MainScreen.js +7 -11
  12. package/dist/commonjs/components/Inspector/NetworkDetail.js +3 -2
  13. package/dist/commonjs/components/Inspector/NetworkTab.js +103 -4
  14. package/dist/commonjs/components/Inspector/ReduxTab.js +19 -3
  15. package/dist/commonjs/components/Inspector/SettingsPanel.js +4 -4
  16. package/dist/commonjs/components/Inspector/StorageTab.js +123 -92
  17. package/dist/commonjs/components/JsonViewer.js +2 -0
  18. package/dist/commonjs/components/MetaAccordion.js +15 -3
  19. package/dist/commonjs/components/SkeletonPlaceholder.d.ts +6 -0
  20. package/dist/commonjs/components/SkeletonPlaceholder.js +208 -0
  21. package/dist/commonjs/constants/version.d.ts +1 -1
  22. package/dist/commonjs/constants/version.js +1 -1
  23. package/dist/commonjs/customHooks/networkLogger.d.ts +3 -0
  24. package/dist/commonjs/customHooks/networkLogger.js +10 -1
  25. package/dist/commonjs/customHooks/storageInspector.d.ts +2 -2
  26. package/dist/commonjs/customHooks/storageInspector.js +17 -13
  27. package/dist/commonjs/helpers/index.d.ts +6 -0
  28. package/dist/commonjs/helpers/index.js +196 -6
  29. package/dist/commonjs/helpers/searchQueryParser.js +62 -20
  30. package/dist/commonjs/i18n/index.d.ts +13 -0
  31. package/dist/commonjs/i18n/index.js +35 -2
  32. package/dist/commonjs/index.d.ts +3 -0
  33. package/dist/commonjs/index.js +108 -35
  34. package/dist/commonjs/styles/AppColors.d.ts +4 -0
  35. package/dist/commonjs/styles/AppColors.js +11 -1
  36. package/dist/commonjs/styles/AppFonts.d.ts +11 -0
  37. package/dist/commonjs/styles/AppFonts.js +11 -1
  38. package/dist/commonjs/types/interfaces.d.ts +2 -2
  39. package/dist/esm/components/AppHeaderLogo.js +45 -12
  40. package/dist/esm/components/BrandSquareIcon.js +92 -49
  41. package/dist/esm/components/EmptyState.d.ts +7 -2
  42. package/dist/esm/components/EmptyState.js +11 -5
  43. package/dist/esm/components/Inspector/AnalyticsTab.js +30 -19
  44. package/dist/esm/components/Inspector/ConsoleTab.js +6 -1
  45. package/dist/esm/components/Inspector/CrashDetail.js +43 -9
  46. package/dist/esm/components/Inspector/CrashTab.js +34 -3
  47. package/dist/esm/components/Inspector/DeviceInfoTab.js +80 -16
  48. package/dist/esm/components/Inspector/InspectorHeader.js +17 -4
  49. package/dist/esm/components/Inspector/MainScreen.js +8 -12
  50. package/dist/esm/components/Inspector/NetworkDetail.js +3 -2
  51. package/dist/esm/components/Inspector/NetworkTab.js +103 -4
  52. package/dist/esm/components/Inspector/ReduxTab.js +19 -3
  53. package/dist/esm/components/Inspector/SettingsPanel.js +4 -4
  54. package/dist/esm/components/Inspector/StorageTab.js +124 -93
  55. package/dist/esm/components/JsonViewer.js +2 -0
  56. package/dist/esm/components/MetaAccordion.js +15 -3
  57. package/dist/esm/components/SkeletonPlaceholder.d.ts +6 -0
  58. package/dist/esm/components/SkeletonPlaceholder.js +173 -0
  59. package/dist/esm/constants/version.d.ts +1 -1
  60. package/dist/esm/constants/version.js +1 -1
  61. package/dist/esm/customHooks/networkLogger.d.ts +3 -0
  62. package/dist/esm/customHooks/networkLogger.js +8 -0
  63. package/dist/esm/customHooks/storageInspector.d.ts +2 -2
  64. package/dist/esm/customHooks/storageInspector.js +17 -13
  65. package/dist/esm/helpers/index.d.ts +6 -0
  66. package/dist/esm/helpers/index.js +193 -5
  67. package/dist/esm/helpers/searchQueryParser.js +62 -20
  68. package/dist/esm/i18n/index.d.ts +13 -0
  69. package/dist/esm/i18n/index.js +33 -3
  70. package/dist/esm/index.d.ts +3 -0
  71. package/dist/esm/index.js +97 -37
  72. package/dist/esm/styles/AppColors.d.ts +4 -0
  73. package/dist/esm/styles/AppColors.js +9 -0
  74. package/dist/esm/styles/AppFonts.d.ts +11 -0
  75. package/dist/esm/styles/AppFonts.js +9 -0
  76. package/dist/esm/types/interfaces.d.ts +2 -2
  77. package/package.json +1 -1
  78. package/src/components/AppHeaderLogo.tsx +46 -12
  79. package/src/components/BrandSquareIcon.tsx +127 -78
  80. package/src/components/EmptyState.tsx +27 -5
  81. package/src/components/Inspector/AnalyticsTab.tsx +48 -27
  82. package/src/components/Inspector/ConsoleTab.tsx +10 -0
  83. package/src/components/Inspector/CrashDetail.tsx +65 -9
  84. package/src/components/Inspector/CrashTab.tsx +41 -3
  85. package/src/components/Inspector/DeviceInfoTab.tsx +87 -16
  86. package/src/components/Inspector/InspectorHeader.tsx +24 -4
  87. package/src/components/Inspector/MainScreen.tsx +7 -11
  88. package/src/components/Inspector/NetworkDetail.tsx +4 -4
  89. package/src/components/Inspector/NetworkTab.tsx +129 -4
  90. package/src/components/Inspector/ReduxTab.tsx +26 -8
  91. package/src/components/Inspector/SettingsPanel.tsx +4 -4
  92. package/src/components/Inspector/StorageTab.tsx +191 -117
  93. package/src/components/JsonViewer.tsx +2 -0
  94. package/src/components/MetaAccordion.tsx +18 -3
  95. package/src/components/SkeletonPlaceholder.tsx +206 -0
  96. package/src/constants/version.ts +1 -1
  97. package/src/customHooks/networkLogger.ts +15 -0
  98. package/src/customHooks/storageInspector.ts +18 -14
  99. package/src/helpers/index.ts +213 -5
  100. package/src/helpers/searchQueryParser.ts +63 -20
  101. package/src/i18n/index.ts +38 -3
  102. package/src/index.tsx +124 -37
  103. package/src/styles/AppColors.ts +9 -0
  104. package/src/styles/AppFonts.ts +16 -0
  105. package/src/types/interfaces.ts +2 -2
package/src/index.tsx CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  import {
27
27
  formatDisplayUrl,
28
28
  getNavigationInfo,
29
+ getLogPageName,
29
30
  deduplicateLogs,
30
31
  getDomainColor,
31
32
  getEventCategory,
@@ -55,6 +56,7 @@ import {
55
56
  subscribeNetworkLogs,
56
57
  setNetworkModuleEnabled,
57
58
  setMaxNetworkLogsLimit,
59
+ setRouteInfoProvider,
58
60
  } from './customHooks/networkLogger';
59
61
 
60
62
  // Console
@@ -144,14 +146,13 @@ import {toggleGlobalTheme} from './styles';
144
146
 
145
147
  const NetworkInspector = ({
146
148
  enabled = true,
147
- isEnabled = true,
148
149
  storage,
149
150
  navigationRef,
150
151
  appIcon,
151
152
  environment,
152
- initialVisible,
153
+ initialVisible = false,
153
154
  visible: controlledVisible,
154
- }: NetworkInspectorProps): React.JSX.Element => {
155
+ }: NetworkInspectorProps): React.JSX.Element | null => {
155
156
  // Set custom storage synchronously during render phase
156
157
  setCustomStorage(storage || null);
157
158
 
@@ -168,7 +169,7 @@ const NetworkInspector = ({
168
169
 
169
170
  const [logs, setLogs] = useState<NetworkLog[]>([]);
170
171
  const [visible, setVisible] = useState<boolean>(
171
- initialVisible ?? controlledVisible ?? false,
172
+ controlledVisible ?? initialVisible ?? false,
172
173
  );
173
174
 
174
175
  useEffect(() => {
@@ -357,8 +358,8 @@ const NetworkInspector = ({
357
358
  bundle: false,
358
359
  performance: false,
359
360
  crash: false,
360
- device: true,
361
- storage: true,
361
+ device: false,
362
+ storage: false,
362
363
  });
363
364
 
364
365
  const [maxNetworkLogs, setMaxNetworkLogs] = useState<number>(100);
@@ -419,8 +420,8 @@ const NetworkInspector = ({
419
420
  bundle: false,
420
421
  performance: false,
421
422
  crash: false,
422
- device: true,
423
- storage: true,
423
+ device: false,
424
+ storage: false,
424
425
  });
425
426
  setDefaultTab('apis');
426
427
  setIsAutoRamLimitEnabled(true);
@@ -490,6 +491,8 @@ const NetworkInspector = ({
490
491
  bundle: false,
491
492
  performance: false,
492
493
  crash: false,
494
+ device: false,
495
+ storage: false,
493
496
  },
494
497
  ...(saved.tabVisibility || {}),
495
498
  apis: true,
@@ -708,12 +711,23 @@ const NetworkInspector = ({
708
711
  const hasNavigationContext = navigationContext !== undefined;
709
712
 
710
713
  const currentRouteRef = useRef<RouteInfo>({
711
- path: 'Navigators',
714
+ path: '',
712
715
  params: null,
713
716
  });
717
+
718
+ useEffect(() => {
719
+ setRouteInfoProvider(() => currentRouteRef.current);
720
+ return () => {
721
+ setRouteInfoProvider(null);
722
+ };
723
+ }, []);
724
+
714
725
  useEffect(() => {
715
726
  if (navState) {
716
- currentRouteRef.current = getNavigationInfo(navState);
727
+ const info = getNavigationInfo(navState);
728
+ if (info?.path) {
729
+ currentRouteRef.current = info;
730
+ }
717
731
  }
718
732
  }, [navState]);
719
733
 
@@ -723,9 +737,22 @@ const NetworkInspector = ({
723
737
  const updateState = () => {
724
738
  try {
725
739
  if (typeof navigationRef.isReady === 'function' && navigationRef.isReady()) {
740
+ const currentRoute = typeof navigationRef.getCurrentRoute === 'function'
741
+ ? navigationRef.getCurrentRoute()
742
+ : null;
743
+ if (currentRoute?.name) {
744
+ currentRouteRef.current = {
745
+ path: currentRoute.name,
746
+ params: currentRoute.params || null,
747
+ };
748
+ }
726
749
  const state = navigationRef.getRootState();
727
750
  if (state) {
728
751
  setNavState(state);
752
+ const routeInfo = getNavigationInfo(state);
753
+ if (routeInfo?.path) {
754
+ currentRouteRef.current = routeInfo;
755
+ }
729
756
  }
730
757
  }
731
758
  } catch (err) {
@@ -917,24 +944,29 @@ const NetworkInspector = ({
917
944
 
918
945
  // 100% Native Main-Thread Floating Button Lifecycle
919
946
  useEffect(() => {
920
- if (!useNativeFab || !isEnabled || !enabled) {
947
+ if (!useNativeFab || !enabled) {
921
948
  if (useNativeFab) {
922
- hideNativeFloatingButton();
949
+ hideNativeFloatingButton().catch(() => {});
923
950
  }
924
951
  return;
925
952
  }
926
953
 
927
954
  if (visible) {
928
- hideNativeFloatingButton();
955
+ hideNativeFloatingButton().catch(() => {});
929
956
  } else {
930
- showNativeFloatingButton();
957
+ showNativeFloatingButton().catch(() => {});
931
958
  setNativeFloatingButtonBadge(
932
959
  logs.length > 0 || analyticsEvents.length > 0,
933
- );
960
+ ).catch(() => {});
934
961
  }
962
+
963
+ return () => {
964
+ if (useNativeFab) {
965
+ hideNativeFloatingButton().catch(() => {});
966
+ }
967
+ };
935
968
  }, [
936
969
  useNativeFab,
937
- isEnabled,
938
970
  enabled,
939
971
  visible,
940
972
  logs.length,
@@ -999,21 +1031,12 @@ const NetworkInspector = ({
999
1031
  if (freshCrashes.length > 0) {
1000
1032
  setCrashRecords(freshCrashes);
1001
1033
  }
1002
- }
1003
- // eslint-disable-next-line react-hooks/exhaustive-deps
1004
- }, [visible]);
1005
1034
 
1006
- useEffect(() => {
1007
- if (visible) {
1008
- const task = InteractionManager.runAfterInteractions(() => {
1035
+ const frame = requestAnimationFrame(() => {
1009
1036
  setIsReady(true);
1010
1037
  });
1011
- const fallbackTimer = setTimeout(() => {
1012
- setIsReady(true);
1013
- }, 350);
1014
1038
  return () => {
1015
- task.cancel();
1016
- clearTimeout(fallbackTimer);
1039
+ cancelAnimationFrame(frame);
1017
1040
  };
1018
1041
  } else {
1019
1042
  setIsReady(false);
@@ -1077,7 +1100,10 @@ const NetworkInspector = ({
1077
1100
  if (freshIds.size > 0) {
1078
1101
  freshIds.forEach(id => {
1079
1102
  if (!logRouteMapRef.current.has(id)) {
1080
- logRouteMapRef.current.set(id, currentRouteRef.current);
1103
+ const matchedLog = deduped.find(l => l.id === id);
1104
+ const resolvedRoute =
1105
+ (matchedLog as any)?.routeInfo || currentRouteRef.current;
1106
+ logRouteMapRef.current.set(id, resolvedRoute);
1081
1107
  }
1082
1108
  });
1083
1109
  setNewLogIds(freshIds);
@@ -1091,6 +1117,13 @@ const NetworkInspector = ({
1091
1117
  const deduped = deduplicateLogs(raw);
1092
1118
  const incoming = new Set(deduped.map(l => l.id));
1093
1119
  prevLogIdsRef.current = incoming;
1120
+ deduped.forEach(l => {
1121
+ if (!logRouteMapRef.current.has(l.id)) {
1122
+ const resolvedRoute =
1123
+ (l as any)?.routeInfo || currentRouteRef.current;
1124
+ logRouteMapRef.current.set(l.id, resolvedRoute);
1125
+ }
1126
+ });
1094
1127
  setLogs(deduped);
1095
1128
  } else {
1096
1129
  timeoutId = setTimeout(updateNetworkState, 250);
@@ -1378,8 +1411,9 @@ const NetworkInspector = ({
1378
1411
 
1379
1412
  for (let i = 0; i < filteredLogs.length; i++) {
1380
1413
  const log = filteredLogs[i];
1381
- const routeInfo = logRouteMapRef.current.get(log.id);
1382
- const pageName = routeInfo?.path || 'Navigators';
1414
+ const routeInfo =
1415
+ logRouteMapRef.current.get(log.id) || (log as any)?.routeInfo;
1416
+ const pageName = getLogPageName(log, routeInfo);
1383
1417
 
1384
1418
  if (
1385
1419
  groups.length === 0 ||
@@ -1680,7 +1714,23 @@ const NetworkInspector = ({
1680
1714
  log.sourceMethod || '',
1681
1715
  ].join(' ').toLowerCase();
1682
1716
 
1683
- return queryTokens.every(token => searchTarget.includes(token));
1717
+ return queryTokens.every(token => {
1718
+ if (token.startsWith('level:') || token.startsWith('is:') || token.startsWith('type:')) {
1719
+ const flag = token.replace(/^(level:|is:|type:)/, '').trim();
1720
+ if (flag === 'error' || flag === 'err') return log.type === 'error';
1721
+ if (flag === 'warn' || flag === 'warning') return log.type === 'warn';
1722
+ if (flag === 'info') return log.type === 'info';
1723
+ if (flag === 'log') return log.sourceMethod === 'log';
1724
+ if (flag === 'analytics') return (log.message || '').toLowerCase().includes('[analytics');
1725
+ }
1726
+ if (token === 'error' || token === 'err') {
1727
+ return log.type === 'error' || searchTarget.includes(token);
1728
+ }
1729
+ if (token === 'warn' || token === 'warning') {
1730
+ return log.type === 'warn' || searchTarget.includes(token);
1731
+ }
1732
+ return searchTarget.includes(token);
1733
+ });
1684
1734
  });
1685
1735
  }
1686
1736
 
@@ -1927,7 +1977,8 @@ const NetworkInspector = ({
1927
1977
  setVisible,
1928
1978
  closeModal,
1929
1979
  isReady,
1930
- isEnabled,
1980
+ enabled,
1981
+ isEnabled: enabled,
1931
1982
  appIcon,
1932
1983
  environment,
1933
1984
  modalHeightPercent,
@@ -2118,16 +2169,29 @@ const NetworkInspector = ({
2118
2169
  };
2119
2170
 
2120
2171
  const NetworkInspectorWrapper = (props: NetworkInspectorProps) => {
2121
- // If running in production release build and not explicitly force-enabled (e.g. for QA builds),
2122
- // return null immediately for 0-overhead production stubbing.
2123
- if (typeof __DEV__ !== 'undefined' && !__DEV__ && !props?.forceEnable) {
2172
+ const enabled = props?.enabled ?? true;
2173
+
2174
+ useEffect(() => {
2175
+ if (!enabled) {
2176
+ hideNativeFloatingButton().catch(() => {});
2177
+ }
2178
+ return () => {
2179
+ hideNativeFloatingButton().catch(() => {});
2180
+ };
2181
+ }, [enabled]);
2182
+
2183
+ // If enabled is false, return null immediately with 0 overhead
2184
+ if (!enabled) {
2124
2185
  return null;
2125
2186
  }
2126
2187
 
2127
2188
  return (
2128
2189
  <I18nextProvider i18n={i18n}>
2129
2190
  <ErrorBoundary fallbackType="inline">
2130
- <NetworkInspector {...props} />
2191
+ <NetworkInspector
2192
+ {...props}
2193
+ enabled={enabled}
2194
+ />
2131
2195
  </ErrorBoundary>
2132
2196
  </I18nextProvider>
2133
2197
  );
@@ -2331,4 +2395,27 @@ export {
2331
2395
  CrashDetailSubTab,
2332
2396
  CrashFilterType,
2333
2397
  BreadcrumbType,
2334
- } from './types';
2398
+ } from './types';
2399
+
2400
+ export {
2401
+ AppFonts,
2402
+ setAppFonts,
2403
+ type AppFontConfig,
2404
+ } from './styles/AppFonts';
2405
+
2406
+ export {
2407
+ AppColors,
2408
+ setAppColors,
2409
+ getThemeColors,
2410
+ updateAppColorsTheme,
2411
+ } from './styles/AppColors';
2412
+
2413
+ export {
2414
+ t,
2415
+ i18n,
2416
+ useTranslation,
2417
+ setLanguage,
2418
+ addTranslations,
2419
+ setTranslations,
2420
+ I18nextProvider,
2421
+ } from './i18n';
@@ -405,4 +405,13 @@ export const updateAppColorsTheme = (isDark: boolean) => {
405
405
  Object.assign(AppColors, getThemeColors(isDark));
406
406
  };
407
407
 
408
+ /**
409
+ * Configure or override specific color tokens used throughout the inspector.
410
+ */
411
+ export const setAppColors = (customColors: Partial<typeof LightColors>): void => {
412
+ if (!customColors || typeof customColors !== 'object') return;
413
+ Object.assign(AppColors, customColors);
414
+ Object.assign(LightColors, customColors);
415
+ };
416
+
408
417
  export default AppColors;
@@ -1,3 +1,10 @@
1
+ export interface AppFontConfig {
2
+ interRegular?: string;
3
+ interMedium?: string;
4
+ interBold?: string;
5
+ Sfprotext?: string;
6
+ }
7
+
1
8
  export const AppFonts = {
2
9
  interRegular: 'Inter-Regular',
3
10
  interMedium: 'Inter-Medium',
@@ -5,4 +12,13 @@ export const AppFonts = {
5
12
  Sfprotext: 'Inter-Regular',
6
13
  };
7
14
 
15
+ /**
16
+ * Configure or override font families used across all inspector screens.
17
+ * Useful when integrating into apps with custom font setups or system fonts.
18
+ */
19
+ export const setAppFonts = (customFonts: Partial<typeof AppFonts>): void => {
20
+ if (!customFonts || typeof customFonts !== 'object') return;
21
+ Object.assign(AppFonts, customFonts);
22
+ };
23
+
8
24
  export default AppFonts;
@@ -128,6 +128,7 @@ export interface NetworkLog {
128
128
  /** Client identifier: axios, fetch, xhr, apollo, etc. */
129
129
  client?: 'axios' | 'fetch' | 'xhr' | 'apollo' | 'graphql' | string;
130
130
  caller?: string;
131
+ routeInfo?: RouteInfo;
131
132
  }
132
133
 
133
134
  export interface RouteInfo {
@@ -185,8 +186,6 @@ export interface PersistedSettings {
185
186
 
186
187
  export interface NetworkInspectorProps {
187
188
  enabled?: boolean;
188
- isEnabled?: boolean;
189
- forceEnable?: boolean;
190
189
  storage?: InspectorStorage;
191
190
  navigationRef?: any;
192
191
  appIcon?: any;
@@ -205,6 +204,7 @@ export interface InspectorContextValue {
205
204
  setVisible: React.Dispatch<React.SetStateAction<boolean>>;
206
205
  closeModal: () => void;
207
206
  isReady: boolean;
207
+ enabled: boolean;
208
208
  isEnabled: boolean;
209
209
  appIcon?: any;
210
210
  environment?: string;