react-native-debug-toolkit 0.6.4 → 2.1.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.
- package/LICENSE +21 -0
- package/README.md +149 -211
- package/README.zh-CN.md +150 -171
- package/lib/commonjs/components/ClipboardTab.js +91 -0
- package/lib/commonjs/components/ClipboardTab.js.map +1 -0
- package/lib/commonjs/components/ConsoleLogTab.js +162 -0
- package/lib/commonjs/components/ConsoleLogTab.js.map +1 -0
- package/lib/commonjs/components/DebugPanel.js +230 -0
- package/lib/commonjs/components/DebugPanel.js.map +1 -0
- package/lib/commonjs/components/DebugView.js +66 -0
- package/lib/commonjs/components/DebugView.js.map +1 -0
- package/lib/commonjs/components/EnvironmentTab.js +287 -0
- package/lib/commonjs/components/EnvironmentTab.js.map +1 -0
- package/lib/commonjs/components/FeatureTabBar.js +182 -0
- package/lib/commonjs/components/FeatureTabBar.js.map +1 -0
- package/lib/commonjs/components/FloatIcon.js +187 -0
- package/lib/commonjs/components/FloatIcon.js.map +1 -0
- package/lib/commonjs/components/FloatPanelView.js +214 -0
- package/lib/commonjs/components/FloatPanelView.js.map +1 -0
- package/lib/commonjs/components/NavigationLogTab.js +131 -0
- package/lib/commonjs/components/NavigationLogTab.js.map +1 -0
- package/lib/commonjs/components/NetworkLogTab.js +404 -0
- package/lib/commonjs/components/NetworkLogTab.js.map +1 -0
- package/lib/commonjs/components/ThirdPartyLibsTab.js +97 -0
- package/lib/commonjs/components/ThirdPartyLibsTab.js.map +1 -0
- package/lib/commonjs/components/TrackLogTab.js +230 -0
- package/lib/commonjs/components/TrackLogTab.js.map +1 -0
- package/lib/commonjs/components/ZustandLogTab.js +311 -0
- package/lib/commonjs/components/ZustandLogTab.js.map +1 -0
- package/lib/commonjs/components/shared/CollapsibleSection.js +84 -0
- package/lib/commonjs/components/shared/CollapsibleSection.js.map +1 -0
- package/lib/commonjs/components/shared/CopyButton.js +64 -0
- package/lib/commonjs/components/shared/CopyButton.js.map +1 -0
- package/lib/commonjs/components/shared/JsonView.js +157 -0
- package/lib/commonjs/components/shared/JsonView.js.map +1 -0
- package/lib/commonjs/components/shared/LogListScreen.js +174 -0
- package/lib/commonjs/components/shared/LogListScreen.js.map +1 -0
- package/lib/commonjs/core/DebugToolkit.js +122 -0
- package/lib/commonjs/core/DebugToolkit.js.map +1 -0
- package/lib/commonjs/core/DebugToolkitProvider.js +66 -0
- package/lib/commonjs/core/DebugToolkitProvider.js.map +1 -0
- package/lib/commonjs/features/ClipboardFeature.js +21 -0
- package/lib/commonjs/features/ClipboardFeature.js.map +1 -0
- package/lib/commonjs/features/ConsoleLogFeature.js +115 -0
- package/lib/commonjs/features/ConsoleLogFeature.js.map +1 -0
- package/lib/commonjs/features/EnvironmentFeature.js +160 -0
- package/lib/commonjs/features/EnvironmentFeature.js.map +1 -0
- package/lib/commonjs/features/NavigationLogFeature.js +39 -0
- package/lib/commonjs/features/NavigationLogFeature.js.map +1 -0
- package/lib/commonjs/features/NetworkFeature.js +107 -0
- package/lib/commonjs/features/NetworkFeature.js.map +1 -0
- package/lib/commonjs/features/ThirdPartyLibsFeature.js +51 -0
- package/lib/commonjs/features/ThirdPartyLibsFeature.js.map +1 -0
- package/lib/commonjs/features/TrackFeature.js +34 -0
- package/lib/commonjs/features/TrackFeature.js.map +1 -0
- package/lib/commonjs/features/ZustandLogFeature.js +59 -0
- package/lib/commonjs/features/ZustandLogFeature.js.map +1 -0
- package/lib/commonjs/hooks/useNavigationLogger.js +78 -0
- package/lib/commonjs/hooks/useNavigationLogger.js.map +1 -0
- package/lib/commonjs/hooks/useSlideDetailAnimation.js +53 -0
- package/lib/commonjs/hooks/useSlideDetailAnimation.js.map +1 -0
- package/lib/commonjs/index.js +152 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/initialize.js +84 -0
- package/lib/commonjs/initialize.js.map +1 -0
- package/lib/commonjs/interceptors/networkInterceptor.js +466 -0
- package/lib/commonjs/interceptors/networkInterceptor.js.map +1 -0
- package/lib/commonjs/native/NativeDebugLibs.js +58 -0
- package/lib/commonjs/native/NativeDebugLibs.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/index.js +6 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/colors.js +48 -0
- package/lib/commonjs/utils/colors.js.map +1 -0
- package/lib/commonjs/utils/copyToComputer.js +97 -0
- package/lib/commonjs/utils/copyToComputer.js.map +1 -0
- package/lib/commonjs/utils/createChannelFeature.js +48 -0
- package/lib/commonjs/utils/createChannelFeature.js.map +1 -0
- package/lib/commonjs/utils/createEventChannel.js +21 -0
- package/lib/commonjs/utils/createEventChannel.js.map +1 -0
- package/lib/commonjs/utils/createObservableStore.js +38 -0
- package/lib/commonjs/utils/createObservableStore.js.map +1 -0
- package/lib/commonjs/utils/layout.js +8 -0
- package/lib/commonjs/utils/layout.js.map +1 -0
- package/lib/commonjs/utils/safeStringify.js +27 -0
- package/lib/commonjs/utils/safeStringify.js.map +1 -0
- package/lib/commonjs/utils/urlRewriterRegistry.js +14 -0
- package/lib/commonjs/utils/urlRewriterRegistry.js.map +1 -0
- package/lib/module/components/ClipboardTab.js +86 -0
- package/lib/module/components/ClipboardTab.js.map +1 -0
- package/lib/module/components/ConsoleLogTab.js +157 -0
- package/lib/module/components/ConsoleLogTab.js.map +1 -0
- package/lib/module/components/DebugPanel.js +225 -0
- package/lib/module/components/DebugPanel.js.map +1 -0
- package/lib/module/components/DebugView.js +61 -0
- package/lib/module/components/DebugView.js.map +1 -0
- package/lib/module/components/EnvironmentTab.js +282 -0
- package/lib/module/components/EnvironmentTab.js.map +1 -0
- package/lib/module/components/FeatureTabBar.js +177 -0
- package/lib/module/components/FeatureTabBar.js.map +1 -0
- package/lib/module/components/FloatIcon.js +182 -0
- package/lib/module/components/FloatIcon.js.map +1 -0
- package/lib/module/components/FloatPanelView.js +209 -0
- package/lib/module/components/FloatPanelView.js.map +1 -0
- package/lib/module/components/NavigationLogTab.js +126 -0
- package/lib/module/components/NavigationLogTab.js.map +1 -0
- package/lib/module/components/NetworkLogTab.js +399 -0
- package/lib/module/components/NetworkLogTab.js.map +1 -0
- package/lib/module/components/ThirdPartyLibsTab.js +91 -0
- package/lib/module/components/ThirdPartyLibsTab.js.map +1 -0
- package/lib/module/components/TrackLogTab.js +225 -0
- package/lib/module/components/TrackLogTab.js.map +1 -0
- package/lib/module/components/ZustandLogTab.js +306 -0
- package/lib/module/components/ZustandLogTab.js.map +1 -0
- package/lib/module/components/shared/CollapsibleSection.js +78 -0
- package/lib/module/components/shared/CollapsibleSection.js.map +1 -0
- package/lib/module/components/shared/CopyButton.js +58 -0
- package/lib/module/components/shared/CopyButton.js.map +1 -0
- package/lib/module/components/shared/JsonView.js +152 -0
- package/lib/module/components/shared/JsonView.js.map +1 -0
- package/lib/module/components/shared/LogListScreen.js +169 -0
- package/lib/module/components/shared/LogListScreen.js.map +1 -0
- package/lib/module/core/DebugToolkit.js +118 -0
- package/lib/module/core/DebugToolkit.js.map +1 -0
- package/lib/module/core/DebugToolkitProvider.js +60 -0
- package/lib/module/core/DebugToolkitProvider.js.map +1 -0
- package/lib/module/features/ClipboardFeature.js +16 -0
- package/lib/module/features/ClipboardFeature.js.map +1 -0
- package/lib/module/features/ConsoleLogFeature.js +109 -0
- package/lib/module/features/ConsoleLogFeature.js.map +1 -0
- package/lib/module/features/EnvironmentFeature.js +156 -0
- package/lib/module/features/EnvironmentFeature.js.map +1 -0
- package/lib/module/features/NavigationLogFeature.js +32 -0
- package/lib/module/features/NavigationLogFeature.js.map +1 -0
- package/lib/module/features/NetworkFeature.js +101 -0
- package/lib/module/features/NetworkFeature.js.map +1 -0
- package/lib/module/features/ThirdPartyLibsFeature.js +46 -0
- package/lib/module/features/ThirdPartyLibsFeature.js.map +1 -0
- package/lib/module/features/TrackFeature.js +27 -0
- package/lib/module/features/TrackFeature.js.map +1 -0
- package/lib/module/features/ZustandLogFeature.js +53 -0
- package/lib/module/features/ZustandLogFeature.js.map +1 -0
- package/lib/module/hooks/useNavigationLogger.js +74 -0
- package/lib/module/hooks/useNavigationLogger.js.map +1 -0
- package/lib/module/hooks/useSlideDetailAnimation.js +50 -0
- package/lib/module/hooks/useSlideDetailAnimation.js.map +1 -0
- package/lib/module/index.js +28 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initialize.js +80 -0
- package/lib/module/initialize.js.map +1 -0
- package/lib/module/interceptors/networkInterceptor.js +460 -0
- package/lib/module/interceptors/networkInterceptor.js.map +1 -0
- package/lib/module/native/NativeDebugLibs.js +54 -0
- package/lib/module/native/NativeDebugLibs.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/colors.js +43 -0
- package/lib/module/utils/colors.js.map +1 -0
- package/lib/module/utils/copyToComputer.js +91 -0
- package/lib/module/utils/copyToComputer.js.map +1 -0
- package/lib/module/utils/createChannelFeature.js +44 -0
- package/lib/module/utils/createChannelFeature.js.map +1 -0
- package/lib/module/utils/createEventChannel.js +17 -0
- package/lib/module/utils/createEventChannel.js.map +1 -0
- package/lib/module/utils/createObservableStore.js +34 -0
- package/lib/module/utils/createObservableStore.js.map +1 -0
- package/lib/module/utils/layout.js +4 -0
- package/lib/module/utils/layout.js.map +1 -0
- package/lib/module/utils/safeStringify.js +23 -0
- package/lib/module/utils/safeStringify.js.map +1 -0
- package/lib/module/utils/urlRewriterRegistry.js +10 -0
- package/lib/module/utils/urlRewriterRegistry.js.map +1 -0
- package/lib/typescript/src/components/ClipboardTab.d.ts +4 -0
- package/lib/typescript/src/components/ClipboardTab.d.ts.map +1 -0
- package/lib/typescript/src/components/ConsoleLogTab.d.ts +4 -0
- package/lib/typescript/src/components/ConsoleLogTab.d.ts.map +1 -0
- package/lib/typescript/src/components/DebugPanel.d.ts +9 -0
- package/lib/typescript/src/components/DebugPanel.d.ts.map +1 -0
- package/lib/typescript/src/components/DebugView.d.ts +19 -0
- package/lib/typescript/src/components/DebugView.d.ts.map +1 -0
- package/lib/typescript/src/components/EnvironmentTab.d.ts +4 -0
- package/lib/typescript/src/components/EnvironmentTab.d.ts.map +1 -0
- package/lib/typescript/src/components/FeatureTabBar.d.ts +13 -0
- package/lib/typescript/src/components/FeatureTabBar.d.ts.map +1 -0
- package/lib/typescript/src/components/FloatIcon.d.ts +12 -0
- package/lib/typescript/src/components/FloatIcon.d.ts.map +1 -0
- package/lib/typescript/src/components/FloatPanelView.d.ts +9 -0
- package/lib/typescript/src/components/FloatPanelView.d.ts.map +1 -0
- package/lib/typescript/src/components/NavigationLogTab.d.ts +4 -0
- package/lib/typescript/src/components/NavigationLogTab.d.ts.map +1 -0
- package/lib/typescript/src/components/NetworkLogTab.d.ts +4 -0
- package/lib/typescript/src/components/NetworkLogTab.d.ts.map +1 -0
- package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts +4 -0
- package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts.map +1 -0
- package/lib/typescript/src/components/TrackLogTab.d.ts +4 -0
- package/lib/typescript/src/components/TrackLogTab.d.ts.map +1 -0
- package/lib/typescript/src/components/ZustandLogTab.d.ts +4 -0
- package/lib/typescript/src/components/ZustandLogTab.d.ts.map +1 -0
- package/lib/typescript/src/components/shared/CollapsibleSection.d.ts +9 -0
- package/lib/typescript/src/components/shared/CollapsibleSection.d.ts.map +1 -0
- package/lib/typescript/src/components/shared/CopyButton.d.ts +12 -0
- package/lib/typescript/src/components/shared/CopyButton.d.ts.map +1 -0
- package/lib/typescript/src/components/shared/JsonView.d.ts +6 -0
- package/lib/typescript/src/components/shared/JsonView.d.ts.map +1 -0
- package/lib/typescript/src/components/shared/LogListScreen.d.ts +21 -0
- package/lib/typescript/src/components/shared/LogListScreen.d.ts.map +1 -0
- package/lib/typescript/src/core/DebugToolkit.d.ts +20 -0
- package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -0
- package/lib/typescript/src/core/DebugToolkitProvider.d.ts +15 -0
- package/lib/typescript/src/core/DebugToolkitProvider.d.ts.map +1 -0
- package/lib/typescript/src/features/ClipboardFeature.d.ts +7 -0
- package/lib/typescript/src/features/ClipboardFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/ConsoleLogFeature.d.ts +9 -0
- package/lib/typescript/src/features/ConsoleLogFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/EnvironmentFeature.d.ts +8 -0
- package/lib/typescript/src/features/EnvironmentFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/NavigationLogFeature.d.ts +10 -0
- package/lib/typescript/src/features/NavigationLogFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/NetworkFeature.d.ts +15 -0
- package/lib/typescript/src/features/NetworkFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts +3 -0
- package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/TrackFeature.d.ts +14 -0
- package/lib/typescript/src/features/TrackFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/ZustandLogFeature.d.ts +31 -0
- package/lib/typescript/src/features/ZustandLogFeature.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useNavigationLogger.d.ts +13 -0
- package/lib/typescript/src/hooks/useNavigationLogger.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useSlideDetailAnimation.d.ts +11 -0
- package/lib/typescript/src/hooks/useSlideDetailAnimation.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +26 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/initialize.d.ts +32 -0
- package/lib/typescript/src/initialize.d.ts.map +1 -0
- package/lib/typescript/src/interceptors/networkInterceptor.d.ts +18 -0
- package/lib/typescript/src/interceptors/networkInterceptor.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeDebugLibs.d.ts +11 -0
- package/lib/typescript/src/native/NativeDebugLibs.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +109 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/colors.d.ts +21 -0
- package/lib/typescript/src/utils/colors.d.ts.map +1 -0
- package/lib/typescript/src/utils/copyToComputer.d.ts +30 -0
- package/lib/typescript/src/utils/copyToComputer.d.ts.map +1 -0
- package/lib/typescript/src/utils/createChannelFeature.d.ts +18 -0
- package/lib/typescript/src/utils/createChannelFeature.d.ts.map +1 -0
- package/lib/typescript/src/utils/createEventChannel.d.ts +7 -0
- package/lib/typescript/src/utils/createEventChannel.d.ts.map +1 -0
- package/lib/typescript/src/utils/createObservableStore.d.ts +9 -0
- package/lib/typescript/src/utils/createObservableStore.d.ts.map +1 -0
- package/lib/typescript/src/utils/layout.d.ts +2 -0
- package/lib/typescript/src/utils/layout.d.ts.map +1 -0
- package/lib/typescript/src/utils/safeStringify.d.ts +6 -0
- package/lib/typescript/src/utils/safeStringify.d.ts.map +1 -0
- package/lib/typescript/src/utils/urlRewriterRegistry.d.ts +7 -0
- package/lib/typescript/src/utils/urlRewriterRegistry.d.ts.map +1 -0
- package/package.json +67 -24
- package/src/components/ClipboardTab.tsx +81 -0
- package/src/components/ConsoleLogTab.tsx +95 -0
- package/src/components/DebugPanel.tsx +215 -0
- package/src/components/DebugView.tsx +80 -0
- package/src/components/EnvironmentTab.tsx +276 -0
- package/src/components/FeatureTabBar.tsx +204 -0
- package/src/components/FloatIcon.tsx +171 -0
- package/src/components/FloatPanelView.tsx +202 -0
- package/src/components/NavigationLogTab.tsx +66 -0
- package/src/components/NetworkLogTab.tsx +270 -0
- package/src/components/ThirdPartyLibsTab.tsx +63 -0
- package/src/components/TrackLogTab.tsx +110 -0
- package/src/components/ZustandLogTab.tsx +203 -0
- package/src/components/shared/CollapsibleSection.tsx +78 -0
- package/src/components/shared/CopyButton.tsx +68 -0
- package/src/components/shared/JsonView.tsx +125 -0
- package/src/components/shared/LogListScreen.tsx +164 -0
- package/src/core/DebugToolkit.tsx +150 -0
- package/src/core/DebugToolkitProvider.tsx +83 -0
- package/src/features/ClipboardFeature.ts +15 -0
- package/src/features/ConsoleLogFeature.ts +116 -0
- package/src/features/EnvironmentFeature.ts +186 -0
- package/src/features/NavigationLogFeature.ts +44 -0
- package/src/features/NetworkFeature.ts +126 -0
- package/src/features/ThirdPartyLibsFeature.ts +42 -0
- package/src/features/TrackFeature.ts +34 -0
- package/src/features/ZustandLogFeature.ts +101 -0
- package/src/hooks/useNavigationLogger.ts +102 -0
- package/src/hooks/useSlideDetailAnimation.ts +45 -0
- package/src/index.ts +48 -0
- package/src/initialize.ts +122 -0
- package/src/interceptors/networkInterceptor.ts +646 -0
- package/src/native/NativeDebugLibs.ts +74 -0
- package/src/types/index.ts +127 -0
- package/src/utils/colors.ts +38 -0
- package/src/utils/copyToComputer.ts +104 -0
- package/src/utils/createChannelFeature.ts +55 -0
- package/src/utils/createEventChannel.ts +22 -0
- package/src/utils/createObservableStore.ts +42 -0
- package/src/utils/layout.ts +1 -0
- package/src/utils/safeStringify.ts +25 -0
- package/src/utils/urlRewriterRegistry.ts +10 -0
- package/.cursor/rules/react-native.mdc +0 -41
- package/index.js +0 -41
- package/ios/BuildTypeModule.h +0 -9
- package/ios/BuildTypeModule.m +0 -42
- package/ios/RNDebugLibs.h +0 -10
- package/ios/RNDebugLibs.m +0 -79
- package/lib/DebugToolKit.js +0 -126
- package/lib/EnvironmentManager.ts +0 -80
- package/lib/NativeDebugLibs.js +0 -67
- package/lib/features/ConsoleLogFeature.js +0 -70
- package/lib/features/NavigationLogFeature.js +0 -45
- package/lib/features/NetworkFeature.js +0 -389
- package/lib/features/PerformanceFeature.js +0 -390
- package/lib/features/ThirdPartyLibsFeature.js +0 -63
- package/lib/features/TrackFeature.js +0 -94
- package/lib/features/ZustandLogFeature.js +0 -44
- package/lib/hooks/useNavigationLogger.js +0 -92
- package/lib/index.js +0 -114
- package/lib/navigation/NavigationLogger.js +0 -1
- package/lib/types/TrackTypes.ts +0 -92
- package/lib/utils/DebugConst.js +0 -67
- package/lib/utils/StorageUtils.js +0 -80
- package/lib/views/ConsoleLogDetails.js +0 -314
- package/lib/views/FloatPanelView.js +0 -697
- package/lib/views/HttpLogDetails.js +0 -648
- package/lib/views/NavigationLogDetails.js +0 -302
- package/lib/views/RestartModal.js +0 -75
- package/lib/views/SubViewConsoleLogs.js +0 -209
- package/lib/views/SubViewEnvironment.js +0 -73
- package/lib/views/SubViewHTTPLogs.js +0 -235
- package/lib/views/SubViewNavigationLogs.js +0 -199
- package/lib/views/SubViewPerformance.js +0 -515
- package/lib/views/SubViewThirdPartyLibs.js +0 -239
- package/lib/views/SubViewTrackLogs.js +0 -318
- package/lib/views/SubViewZustandLogs.js +0 -279
- package/lib/views/TabView.js +0 -66
- package/lib/views/TrackLogDetails.js +0 -481
- package/lib/views/ZustandLogDetails.js +0 -355
- package/react-native-debug-toolkit.podspec +0 -25
- package/react-native.config.js +0 -18
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
// import SubViewPerformance from '../views/SubViewPerformance';
|
|
2
|
-
import performance, {
|
|
3
|
-
setResourceLoggingEnabled,
|
|
4
|
-
PerformanceObserver
|
|
5
|
-
} from 'react-native-performance';
|
|
6
|
-
|
|
7
|
-
class PerformanceFeature {
|
|
8
|
-
static instance = null;
|
|
9
|
-
static MAX_ENTRIES = 100;
|
|
10
|
-
|
|
11
|
-
// Native mark names based on vanilla example
|
|
12
|
-
static NATIVE_MARKS = {
|
|
13
|
-
NATIVE_LAUNCH_START: 'nativeLaunchStart',
|
|
14
|
-
NATIVE_LAUNCH_END: 'nativeLaunchEnd',
|
|
15
|
-
RUN_JS_BUNDLE_START: 'runJsBundleStart',
|
|
16
|
-
RUN_JS_BUNDLE_END: 'runJsBundleEnd',
|
|
17
|
-
CONTENT_APPEARED: 'contentAppeared'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
if (PerformanceFeature.instance) {
|
|
22
|
-
return PerformanceFeature.instance;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
this.name = 'performance';
|
|
26
|
-
this.label = 'Performance';
|
|
27
|
-
this.performanceData = {
|
|
28
|
-
measures: [],
|
|
29
|
-
metrics: [],
|
|
30
|
-
resources: [],
|
|
31
|
-
nativeMarks: []
|
|
32
|
-
};
|
|
33
|
-
this.observers = [];
|
|
34
|
-
this.isSetup = false;
|
|
35
|
-
this.thresholds = new Map(); // Performance thresholds for alerts
|
|
36
|
-
this.timeOrigin = performance.timeOrigin;
|
|
37
|
-
this.resourceLoggingEnabled = false;
|
|
38
|
-
|
|
39
|
-
PerformanceFeature.instance = this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setup(options = {}) {
|
|
43
|
-
if (this.isSetup) {
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const { enableResourceLogging = true } = options;
|
|
48
|
-
|
|
49
|
-
// Enable resource logging if specified
|
|
50
|
-
if (enableResourceLogging) {
|
|
51
|
-
setResourceLoggingEnabled(true);
|
|
52
|
-
this.resourceLoggingEnabled = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Mark when the feature is initialized
|
|
56
|
-
performance.mark('DebugToolkit.Init');
|
|
57
|
-
|
|
58
|
-
// Setup observers for different entry types
|
|
59
|
-
this._setupObservers();
|
|
60
|
-
|
|
61
|
-
// Measure app launch metrics
|
|
62
|
-
this._setupAppLaunchMeasurements();
|
|
63
|
-
|
|
64
|
-
this.isSetup = true;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
_setupObservers() {
|
|
69
|
-
// Use the same pattern as in the vanilla example App.tsx
|
|
70
|
-
const setupObserver = (type, dataKey) => {
|
|
71
|
-
try {
|
|
72
|
-
const observer = new PerformanceObserver((list) => {
|
|
73
|
-
// Get entries and sort them by startTime as in the example
|
|
74
|
-
const entries = list.getEntries().sort((a, b) => a.startTime - b.startTime);
|
|
75
|
-
|
|
76
|
-
// Store entries
|
|
77
|
-
this._addEntries(dataKey, entries);
|
|
78
|
-
|
|
79
|
-
// Check thresholds for measures
|
|
80
|
-
if (type === 'measure') {
|
|
81
|
-
this._checkThresholds(entries);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Observe with buffered set to true to get existing entries
|
|
86
|
-
observer.observe({ type, buffered: true });
|
|
87
|
-
this.observers.push(observer);
|
|
88
|
-
} catch (e) {
|
|
89
|
-
console.error(`Failed to setup PerformanceObserver for type "${type}":`, e);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// Setup observers for all entry types
|
|
94
|
-
setupObserver('mark', 'marks');
|
|
95
|
-
setupObserver('measure', 'measures');
|
|
96
|
-
setupObserver('metric', 'metrics');
|
|
97
|
-
setupObserver('resource', 'resources');
|
|
98
|
-
setupObserver('react-native-mark', 'nativeMarks');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
_setupAppLaunchMeasurements() {
|
|
102
|
-
// Create a one-time observer for app launch measurements
|
|
103
|
-
try {
|
|
104
|
-
const observer = new PerformanceObserver((list, obs) => {
|
|
105
|
-
const entries = list.getEntries();
|
|
106
|
-
if (entries.some(entry => entry.name === PerformanceFeature.NATIVE_MARKS.RUN_JS_BUNDLE_END)) {
|
|
107
|
-
this._createLaunchMeasurements();
|
|
108
|
-
|
|
109
|
-
obs.disconnect();
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
observer.observe({ type: 'react-native-mark', buffered: true });
|
|
113
|
-
} catch (e) {
|
|
114
|
-
console.error('Failed to setup app launch measurements:', e);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
_createLaunchMeasurements() {
|
|
119
|
-
const {
|
|
120
|
-
NATIVE_LAUNCH_START,
|
|
121
|
-
NATIVE_LAUNCH_END,
|
|
122
|
-
RUN_JS_BUNDLE_START,
|
|
123
|
-
RUN_JS_BUNDLE_END,
|
|
124
|
-
CONTENT_APPEARED
|
|
125
|
-
} = PerformanceFeature.NATIVE_MARKS;
|
|
126
|
-
|
|
127
|
-
// Measure app launch time (native initialization)
|
|
128
|
-
if (this.hasMark(NATIVE_LAUNCH_START) && this.hasMark(NATIVE_LAUNCH_END)) {
|
|
129
|
-
this.measure('nativeLaunch', NATIVE_LAUNCH_START, NATIVE_LAUNCH_END);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Measure JS bundle execution time
|
|
133
|
-
if (this.hasMark(RUN_JS_BUNDLE_START) && this.hasMark(RUN_JS_BUNDLE_END)) {
|
|
134
|
-
this.measure('runJsBundle', RUN_JS_BUNDLE_START, RUN_JS_BUNDLE_END);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Measure time to first render if content appeared mark exists
|
|
138
|
-
if (this.hasMark(NATIVE_LAUNCH_START) && this.hasMark(CONTENT_APPEARED)) {
|
|
139
|
-
this.measure('timeToContent', NATIVE_LAUNCH_START, CONTENT_APPEARED);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
_addEntries(type, entries) {
|
|
144
|
-
if (!entries || entries.length === 0) return;
|
|
145
|
-
|
|
146
|
-
// Keep only the last MAX_ENTRIES entries
|
|
147
|
-
this.performanceData[type] = [
|
|
148
|
-
...entries,
|
|
149
|
-
...this.performanceData[type]
|
|
150
|
-
].slice(0, PerformanceFeature.MAX_ENTRIES);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
_checkThresholds(entries) {
|
|
154
|
-
if (!entries || entries.length === 0 || this.thresholds.size === 0) return;
|
|
155
|
-
|
|
156
|
-
entries.forEach(entry => {
|
|
157
|
-
const threshold = this.thresholds.get(entry.name);
|
|
158
|
-
if (threshold && entry.duration > threshold.value) {
|
|
159
|
-
console.warn(`Performance threshold exceeded: ${entry.name} took ${entry.duration}ms (threshold: ${threshold.value}ms)`);
|
|
160
|
-
if (threshold.callback) {
|
|
161
|
-
threshold.callback(entry);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
hasMark(name) {
|
|
168
|
-
try {
|
|
169
|
-
return performance.getEntriesByName(name, 'mark').length > 0 ||
|
|
170
|
-
performance.getEntriesByName(name, 'react-native-mark').length > 0;
|
|
171
|
-
} catch (e) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Convert performance timestamp to unix epoch timestamp
|
|
177
|
-
// Based on example: Date.now() - performance.timeOrigin + entry.startTime
|
|
178
|
-
getUnixTimestamp(entry) {
|
|
179
|
-
if (!entry || typeof entry.startTime !== 'number') return null;
|
|
180
|
-
return Date.now() - this.timeOrigin + entry.startTime;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Enable or disable resource logging at runtime
|
|
184
|
-
setResourceLoggingEnabled(enabled) {
|
|
185
|
-
if (this.resourceLoggingEnabled !== enabled) {
|
|
186
|
-
setResourceLoggingEnabled(enabled);
|
|
187
|
-
this.resourceLoggingEnabled = enabled;
|
|
188
|
-
}
|
|
189
|
-
return this;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Threshold management
|
|
193
|
-
setThreshold(name, value, callback) {
|
|
194
|
-
this.thresholds.set(name, { value, callback });
|
|
195
|
-
return this;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
removeThreshold(name) {
|
|
199
|
-
this.thresholds.delete(name);
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
clearThresholds() {
|
|
204
|
-
this.thresholds.clear();
|
|
205
|
-
return this;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Mark events (following pattern from vanilla example)
|
|
209
|
-
mark(name, detail = {}) {
|
|
210
|
-
if (!this.isSetup) return this;
|
|
211
|
-
|
|
212
|
-
if (typeof detail !== 'object') {
|
|
213
|
-
detail = { value: detail };
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
performance.mark(name, { detail });
|
|
217
|
-
return this;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
measure(name, startMarkOrOptions, endMark, detail = {}) {
|
|
221
|
-
if (!this.isSetup) return this;
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
if (typeof startMarkOrOptions === 'string' && endMark) {
|
|
225
|
-
performance.measure(name, startMarkOrOptions, endMark, { detail });
|
|
226
|
-
} else if (typeof startMarkOrOptions === 'object') {
|
|
227
|
-
performance.measure(name, startMarkOrOptions);
|
|
228
|
-
} else {
|
|
229
|
-
performance.measure(name, { detail });
|
|
230
|
-
}
|
|
231
|
-
} catch (e) {
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return this;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Record custom metrics (following pattern from vanilla example)
|
|
238
|
-
metric(name, value, detail = {}) {
|
|
239
|
-
if (!this.isSetup) return this;
|
|
240
|
-
|
|
241
|
-
if (typeof detail !== 'object') {
|
|
242
|
-
detail = { info: detail };
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
performance.metric(name, value, { detail });
|
|
246
|
-
return this;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Measure execution time of a function
|
|
250
|
-
measureFunction(name, fn, ...args) {
|
|
251
|
-
if (!this.isSetup) {
|
|
252
|
-
return fn(...args);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const markName = `${name}_start`;
|
|
256
|
-
this.mark(markName);
|
|
257
|
-
|
|
258
|
-
try {
|
|
259
|
-
const result = fn(...args);
|
|
260
|
-
|
|
261
|
-
// Handle promises
|
|
262
|
-
if (result instanceof Promise) {
|
|
263
|
-
return result.finally(() => {
|
|
264
|
-
this.measure(name, markName);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Handle synchronous functions
|
|
269
|
-
this.measure(name, markName);
|
|
270
|
-
return result;
|
|
271
|
-
} catch (e) {
|
|
272
|
-
this.measure(`${name}_error`, markName, undefined, { error: e.message });
|
|
273
|
-
throw e;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Get formatted performance data
|
|
278
|
-
getData() {
|
|
279
|
-
return this.performanceData;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
getTimingData(options = {}) {
|
|
283
|
-
const { includeMarks = true, includeMeasures = true, filterByName } = options;
|
|
284
|
-
|
|
285
|
-
let data = [];
|
|
286
|
-
|
|
287
|
-
if (includeMarks) {
|
|
288
|
-
data = [...data, ...this.performanceData.marks, ...this.performanceData.nativeMarks];
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (includeMeasures) {
|
|
292
|
-
data = [...data, ...this.performanceData.measures];
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (filterByName) {
|
|
296
|
-
if (filterByName instanceof RegExp) {
|
|
297
|
-
data = data.filter(entry => filterByName.test(entry.name));
|
|
298
|
-
} else if (typeof filterByName === 'string') {
|
|
299
|
-
data = data.filter(entry => entry.name.includes(filterByName));
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return data.sort((a, b) => a.startTime - b.startTime);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Get network resource data (similar to the demo pattern)
|
|
307
|
-
getResourceData() {
|
|
308
|
-
return this.performanceData.resources.sort((a, b) => a.startTime - b.startTime);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Trigger a test network request (for demo purposes)
|
|
312
|
-
generateTestNetworkRequest() {
|
|
313
|
-
if (!this.isSetup || !this.resourceLoggingEnabled) return this;
|
|
314
|
-
|
|
315
|
-
// Similar to the fetch in the vanilla example
|
|
316
|
-
fetch('https://jsonplaceholder.typicode.com/todos/1', { cache: 'no-cache' })
|
|
317
|
-
.catch(err => console.error('Test network request failed:', err));
|
|
318
|
-
|
|
319
|
-
return this;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// Clear specific type of entries
|
|
323
|
-
clear(type) {
|
|
324
|
-
if (this.performanceData[type]) {
|
|
325
|
-
this.performanceData[type] = [];
|
|
326
|
-
}
|
|
327
|
-
return this;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Clear all performance data
|
|
331
|
-
clearAll() {
|
|
332
|
-
Object.keys(this.performanceData).forEach(key => {
|
|
333
|
-
this.performanceData[key] = [];
|
|
334
|
-
});
|
|
335
|
-
return this;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
cleanup() {
|
|
339
|
-
// Disconnect all observers
|
|
340
|
-
this.observers.forEach(observer => {
|
|
341
|
-
observer.disconnect();
|
|
342
|
-
});
|
|
343
|
-
this.observers = [];
|
|
344
|
-
|
|
345
|
-
// Disable resource logging if it was enabled
|
|
346
|
-
if (this.resourceLoggingEnabled) {
|
|
347
|
-
setResourceLoggingEnabled(false);
|
|
348
|
-
this.resourceLoggingEnabled = false;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// Clear stored data
|
|
352
|
-
this.clearAll();
|
|
353
|
-
this.clearThresholds();
|
|
354
|
-
|
|
355
|
-
this.isSetup = false;
|
|
356
|
-
return this;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export const createPerformanceFeature = () => {
|
|
361
|
-
const feature = new PerformanceFeature();
|
|
362
|
-
|
|
363
|
-
return {
|
|
364
|
-
name: feature.name,
|
|
365
|
-
label: feature.label,
|
|
366
|
-
setup: (options) => feature.setup(options),
|
|
367
|
-
getData: () => feature.getData(),
|
|
368
|
-
getTimingData: (options) => feature.getTimingData(options),
|
|
369
|
-
getResourceData: () => feature.getResourceData(),
|
|
370
|
-
getUnixTimestamp: (entry) => feature.getUnixTimestamp(entry),
|
|
371
|
-
hasMark: (name) => feature.hasMark(name),
|
|
372
|
-
setResourceLoggingEnabled: (enabled) => feature.setResourceLoggingEnabled(enabled),
|
|
373
|
-
generateTestNetworkRequest: () => feature.generateTestNetworkRequest(),
|
|
374
|
-
cleanup: () => feature.cleanup(),
|
|
375
|
-
mark: (name, detail) => feature.mark(name, detail),
|
|
376
|
-
measure: (name, startMarkOrOptions, endMark, detail) =>
|
|
377
|
-
feature.measure(name, startMarkOrOptions, endMark, detail),
|
|
378
|
-
metric: (name, value, detail) => feature.metric(name, value, detail),
|
|
379
|
-
measureFunction: (name, fn, ...args) => feature.measureFunction(name, fn, ...args),
|
|
380
|
-
clear: (type) => feature.clear(type),
|
|
381
|
-
clearAll: () => feature.clearAll(),
|
|
382
|
-
setThreshold: (name, value, callback) => feature.setThreshold(name, value, callback),
|
|
383
|
-
removeThreshold: (name) => feature.removeThreshold(name),
|
|
384
|
-
clearThresholds: () => feature.clearThresholds(),
|
|
385
|
-
};
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
// For backward compatibility
|
|
389
|
-
const instance = new PerformanceFeature();
|
|
390
|
-
export default instance;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import NativeDebugLibs from '../NativeDebugLibs';
|
|
3
|
-
|
|
4
|
-
// Define available third-party debug libraries
|
|
5
|
-
const availableLibs = [
|
|
6
|
-
{
|
|
7
|
-
id: 'flex',
|
|
8
|
-
name: 'FLEX',
|
|
9
|
-
description: 'In-app debugging and exploration tool for iOS',
|
|
10
|
-
platform: 'ios',
|
|
11
|
-
icon: 'tools',
|
|
12
|
-
actions: [
|
|
13
|
-
{ id: 'showExplorer', label: 'Show Explorer', method: NativeDebugLibs.showExplorer },
|
|
14
|
-
{ id: 'hideExplorer', label: 'Hide Explorer', method: NativeDebugLibs.hideExplorer },
|
|
15
|
-
]
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: 'doraemonkit',
|
|
19
|
-
name: 'DoraemonKit',
|
|
20
|
-
description: 'A full-featured iOS & Android development assistant',
|
|
21
|
-
platform: 'both',
|
|
22
|
-
icon: 'box',
|
|
23
|
-
actions: [
|
|
24
|
-
{ id: 'showDoraemonKit', label: 'Show DoraemonKit', method: NativeDebugLibs.showDoraemonKit },
|
|
25
|
-
{ id: 'hideDoraemonKit', label: 'Hide DoraemonKit', method: NativeDebugLibs.hideDoraemonKit },
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
// Get libraries available for current platform
|
|
31
|
-
const getPlatformLibs = () => {
|
|
32
|
-
const currentPlatform = Platform.OS;
|
|
33
|
-
return availableLibs.filter(lib =>
|
|
34
|
-
lib.platform === 'both' || lib.platform === currentPlatform
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Setup function is minimal since we're just presenting UI options
|
|
39
|
-
const setup = () => {
|
|
40
|
-
|
|
41
|
-
// No additional setup needed beyond initialization
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// Get data - return available libraries for this platform
|
|
45
|
-
const getData = () => {
|
|
46
|
-
return getPlatformLibs();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Cleanup function (if needed)
|
|
50
|
-
const cleanup = () => {
|
|
51
|
-
// Nothing specific to clean up
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Export the feature factory function
|
|
55
|
-
export const createThirdPartyLibsFeature = () => {
|
|
56
|
-
return {
|
|
57
|
-
name: 'thirdPartyLibs',
|
|
58
|
-
label: 'Debug Libraries',
|
|
59
|
-
setup,
|
|
60
|
-
getData,
|
|
61
|
-
cleanup
|
|
62
|
-
};
|
|
63
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const MAX_LOGS = 200; // Max number of track events to store
|
|
2
|
-
const logs = [];
|
|
3
|
-
|
|
4
|
-
const setup = () => {
|
|
5
|
-
|
|
6
|
-
// Note: Actual event tracking will be done in the main app code
|
|
7
|
-
// This is just a setup function for compatibility with the feature API
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// Function to add track event log
|
|
11
|
-
export const addTrackLog = (eventData) => {
|
|
12
|
-
|
|
13
|
-
// Store log data
|
|
14
|
-
const logEntry = {
|
|
15
|
-
timestamp: new Date(),
|
|
16
|
-
eventName: eventData.eventName || 'unknown_event',
|
|
17
|
-
entityType: eventData.entityType,
|
|
18
|
-
entityName: eventData.entityName,
|
|
19
|
-
pageId: eventData.pageId,
|
|
20
|
-
objId: eventData.objId,
|
|
21
|
-
entityPath: eventData.entityPath,
|
|
22
|
-
objType: eventData.objType,
|
|
23
|
-
objPt: eventData.objPt,
|
|
24
|
-
refPageLocation: eventData.refPageLocation,
|
|
25
|
-
position: eventData.position,
|
|
26
|
-
entityLocation: eventData.entityLocation,
|
|
27
|
-
frontOperation: eventData.frontOperation,
|
|
28
|
-
sessionId: eventData.sessionId,
|
|
29
|
-
requestId: eventData.requestId,
|
|
30
|
-
searchKeywored: eventData.searchKeywored,
|
|
31
|
-
enSearchKeywored: eventData.enSearchKeywored,
|
|
32
|
-
// Include any additional custom properties
|
|
33
|
-
...eventData
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
logs.push(logEntry);
|
|
37
|
-
|
|
38
|
-
// Trim logs if they exceed the maximum limit
|
|
39
|
-
if (logs.length > MAX_LOGS) {
|
|
40
|
-
logs.splice(0, logs.length - MAX_LOGS);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// Get event statistics
|
|
45
|
-
export const getEventStats = () => {
|
|
46
|
-
const stats = {};
|
|
47
|
-
logs.forEach(log => {
|
|
48
|
-
const eventName = log.eventName;
|
|
49
|
-
if (!stats[eventName]) {
|
|
50
|
-
stats[eventName] = {
|
|
51
|
-
count: 0,
|
|
52
|
-
lastSeen: log.timestamp,
|
|
53
|
-
entityTypes: new Set(),
|
|
54
|
-
operations: new Set()
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
stats[eventName].count++;
|
|
58
|
-
if (log.timestamp > stats[eventName].lastSeen) {
|
|
59
|
-
stats[eventName].lastSeen = log.timestamp;
|
|
60
|
-
}
|
|
61
|
-
if (log.entityType) {
|
|
62
|
-
stats[eventName].entityTypes.add(log.entityType);
|
|
63
|
-
}
|
|
64
|
-
if (log.frontOperation) {
|
|
65
|
-
stats[eventName].operations.add(log.frontOperation);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Convert Sets to Arrays for display
|
|
70
|
-
Object.keys(stats).forEach(eventName => {
|
|
71
|
-
stats[eventName].entityTypes = Array.from(stats[eventName].entityTypes);
|
|
72
|
-
stats[eventName].operations = Array.from(stats[eventName].operations);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return stats;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const getData = () => {
|
|
79
|
-
return logs;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const cleanup = () => {
|
|
83
|
-
logs.length = 0; // Clear array
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const createTrackFeature = () => {
|
|
87
|
-
return {
|
|
88
|
-
name: 'track',
|
|
89
|
-
label: 'Track Events',
|
|
90
|
-
setup: setup,
|
|
91
|
-
getData: getData,
|
|
92
|
-
cleanup: cleanup,
|
|
93
|
-
};
|
|
94
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const MAX_LOGS = 200; // Max number of Zustand logs to store
|
|
2
|
-
const logs = [];
|
|
3
|
-
|
|
4
|
-
// Zustand middleware to capture state changes
|
|
5
|
-
export const addZustandLog = (action, prevState, nextState, actionCompleteTime, storeName) => {
|
|
6
|
-
// Store log data
|
|
7
|
-
logs.push({
|
|
8
|
-
timestamp: new Date(),
|
|
9
|
-
action: action,
|
|
10
|
-
prevState: prevState,
|
|
11
|
-
nextState: nextState,
|
|
12
|
-
actionCompleteTime: actionCompleteTime,
|
|
13
|
-
storeName: storeName,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// Trim logs if they exceed the maximum limit
|
|
17
|
-
if (logs.length > MAX_LOGS) {
|
|
18
|
-
logs.splice(0, logs.length - MAX_LOGS);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const setup = () => {
|
|
23
|
-
|
|
24
|
-
// Note: The actual middleware setup happens in the store creation
|
|
25
|
-
// This function is mainly for compatibility with the feature API
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getData = () => {
|
|
29
|
-
return logs;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const cleanup = () => {
|
|
33
|
-
logs.length = 0; // Clear array
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const createZustandLogFeature = () => {
|
|
37
|
-
return {
|
|
38
|
-
name: 'zustand',
|
|
39
|
-
label: 'Zustand Logs',
|
|
40
|
-
setup: setup,
|
|
41
|
-
getData: getData,
|
|
42
|
-
cleanup: cleanup,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { addNavigationLog } from '../features/NavigationLogFeature';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to log React Navigation events for debugging
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
*
|
|
9
|
-
* // In your navigation container
|
|
10
|
-
* import { useNavigationLogger } from 'react-native-debug-toolkit';
|
|
11
|
-
*
|
|
12
|
-
* function App() {
|
|
13
|
-
* const navigationRef = useRef();
|
|
14
|
-
*
|
|
15
|
-
* // Enable navigation logging
|
|
16
|
-
* useNavigationLogger(navigationRef);
|
|
17
|
-
*
|
|
18
|
-
* return (
|
|
19
|
-
* <NavigationContainer ref={navigationRef}>
|
|
20
|
-
* // ... your navigation structure
|
|
21
|
-
* </NavigationContainer>
|
|
22
|
-
* );
|
|
23
|
-
* }
|
|
24
|
-
*/
|
|
25
|
-
export function useNavigationLogger(navigationRef) {
|
|
26
|
-
// Track previous state
|
|
27
|
-
const routeRef = useRef(null);
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (!navigationRef.current) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Create listeners for navigation events
|
|
35
|
-
const unsubscribeReady = navigationRef.current?.addListener('state', (e) => {
|
|
36
|
-
if (!navigationRef.current) return;
|
|
37
|
-
|
|
38
|
-
const state = navigationRef.current.getRootState();
|
|
39
|
-
if (!state) return;
|
|
40
|
-
|
|
41
|
-
const currentRoute = navigationRef.current.getCurrentRoute();
|
|
42
|
-
|
|
43
|
-
if (!currentRoute) return;
|
|
44
|
-
|
|
45
|
-
// First render won't have a previous state
|
|
46
|
-
if (!routeRef.current) {
|
|
47
|
-
routeRef.current = currentRoute;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Determine the navigation action
|
|
52
|
-
let action = 'navigate';
|
|
53
|
-
|
|
54
|
-
// Check if this was a push (adding to history) or replace
|
|
55
|
-
const routes = state.routes;
|
|
56
|
-
if (routes.length > 0) {
|
|
57
|
-
const prevIndex = routes.findIndex(route => route.key === routeRef.current.key);
|
|
58
|
-
const currentIndex = routes.findIndex(route => route.key === currentRoute.key);
|
|
59
|
-
|
|
60
|
-
if (currentIndex > prevIndex) {
|
|
61
|
-
action = 'push';
|
|
62
|
-
} else if (currentIndex < prevIndex) {
|
|
63
|
-
action = 'pop';
|
|
64
|
-
} else if (currentIndex === prevIndex) {
|
|
65
|
-
action = 'replace';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Log the navigation
|
|
70
|
-
addNavigationLog(
|
|
71
|
-
action,
|
|
72
|
-
{
|
|
73
|
-
name: routeRef.current.name,
|
|
74
|
-
params: routeRef.current.params,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: currentRoute.name,
|
|
78
|
-
params: currentRoute.params,
|
|
79
|
-
},
|
|
80
|
-
performance.now(), // Approximate time
|
|
81
|
-
0 // No duration measurement available for this event type
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
// Update the reference
|
|
85
|
-
routeRef.current = currentRoute;
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return () => {
|
|
89
|
-
unsubscribeReady && unsubscribeReady();
|
|
90
|
-
};
|
|
91
|
-
}, [navigationRef]);
|
|
92
|
-
}
|