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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NavigationLogTab } from '../components/NavigationLogTab';
|
|
2
|
+
import type { DebugFeature, NavigationLogEntry } from '../types';
|
|
3
|
+
import { createEventChannel } from '../utils/createEventChannel';
|
|
4
|
+
import { createChannelFeature } from '../utils/createChannelFeature';
|
|
5
|
+
|
|
6
|
+
type NavigationLogPayload = Omit<NavigationLogEntry, 'id'>;
|
|
7
|
+
|
|
8
|
+
let navigationChannel = createEventChannel<NavigationLogPayload>();
|
|
9
|
+
|
|
10
|
+
export const addNavigationLog = (
|
|
11
|
+
action: string,
|
|
12
|
+
from: string,
|
|
13
|
+
to: string,
|
|
14
|
+
startTime?: number,
|
|
15
|
+
duration?: number,
|
|
16
|
+
debugLog?: string,
|
|
17
|
+
): void => {
|
|
18
|
+
navigationChannel.emit({
|
|
19
|
+
timestamp: Date.now(),
|
|
20
|
+
action,
|
|
21
|
+
from,
|
|
22
|
+
to,
|
|
23
|
+
startTime,
|
|
24
|
+
duration,
|
|
25
|
+
debugLog,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export interface NavigationFeatureConfig {
|
|
30
|
+
/** Maximum number of navigation logs to keep (default: 200) */
|
|
31
|
+
maxLogs?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const createNavigationLogFeature = (config?: NavigationFeatureConfig): DebugFeature<NavigationLogEntry> =>
|
|
35
|
+
createChannelFeature(
|
|
36
|
+
() => navigationChannel,
|
|
37
|
+
(payload, id) => ({ ...payload, id }),
|
|
38
|
+
{ name: 'navigation', label: 'Navigation', renderContent: NavigationLogTab, maxLogs: config?.maxLogs },
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
/** Reset module-level state for testing */
|
|
42
|
+
export function _resetNavigationForTesting(): void {
|
|
43
|
+
navigationChannel = createEventChannel<NavigationLogPayload>();
|
|
44
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { NetworkLogTab } from '../components/NetworkLogTab';
|
|
2
|
+
import type { DebugFeature, NetworkLogEntry } from '../types';
|
|
3
|
+
import { createEventChannel } from '../utils/createEventChannel';
|
|
4
|
+
import { createObservableStore } from '../utils/createObservableStore';
|
|
5
|
+
import { urlRewriter } from '../utils/urlRewriterRegistry';
|
|
6
|
+
import {
|
|
7
|
+
startFetch,
|
|
8
|
+
startXMLHttpRequest,
|
|
9
|
+
setupAxios,
|
|
10
|
+
resetInterceptors,
|
|
11
|
+
} from '../interceptors/networkInterceptor';
|
|
12
|
+
import type { AxiosInstanceLike } from '../interceptors/networkInterceptor';
|
|
13
|
+
|
|
14
|
+
type NetworkLogPayload = Omit<NetworkLogEntry, 'id'>;
|
|
15
|
+
|
|
16
|
+
// ─── Utilities ────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
function isUrlBlacklisted(
|
|
19
|
+
url: string,
|
|
20
|
+
blacklist: Array<string | RegExp>,
|
|
21
|
+
): boolean {
|
|
22
|
+
if (!url) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return blacklist.some((pattern) =>
|
|
26
|
+
pattern instanceof RegExp ? pattern.test(url) : url.includes(pattern),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ─── Channel (shared pub-sub backbone) ─────────────────
|
|
31
|
+
|
|
32
|
+
let networkChannel = createEventChannel<NetworkLogPayload>();
|
|
33
|
+
|
|
34
|
+
function emitNetworkLog(entry: NetworkLogPayload): void {
|
|
35
|
+
networkChannel.emit(entry);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ─── Feature factory ──────────────────────────────────
|
|
39
|
+
|
|
40
|
+
const DEFAULT_MAX_LOGS = 200;
|
|
41
|
+
|
|
42
|
+
export type { AxiosInstanceLike };
|
|
43
|
+
|
|
44
|
+
export interface NetworkFeatureConfig {
|
|
45
|
+
/** Maximum number of network logs to keep (default: 200) */
|
|
46
|
+
maxLogs?: number;
|
|
47
|
+
/** URLs to filter out from logging */
|
|
48
|
+
blacklist?: Array<string | RegExp>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const createNetworkFeature = (config?: NetworkFeatureConfig): DebugFeature<NetworkLogEntry> & {
|
|
52
|
+
setupAxiosInterceptors: (axiosInstance: AxiosInstanceLike) => () => void;
|
|
53
|
+
} => {
|
|
54
|
+
const maxLogs = config?.maxLogs ?? DEFAULT_MAX_LOGS;
|
|
55
|
+
const blacklist: Array<string | RegExp> = config?.blacklist ? [...config.blacklist] : [];
|
|
56
|
+
const logStore = createObservableStore<NetworkLogEntry>();
|
|
57
|
+
const axiosCleanupMap = new Map<AxiosInstanceLike, () => void>();
|
|
58
|
+
|
|
59
|
+
let nextId = 0;
|
|
60
|
+
let initialized = false;
|
|
61
|
+
let unsubscribeLogs: (() => void) | null = null;
|
|
62
|
+
let stopFetchFn: (() => void) | null = null;
|
|
63
|
+
let stopXMLHttpRequestFn: (() => void) | null = null;
|
|
64
|
+
|
|
65
|
+
const handleLog = (entry: NetworkLogPayload) => {
|
|
66
|
+
if (isUrlBlacklisted(entry.request.url, blacklist)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
logStore.push({ ...entry, id: String(nextId++) }, maxLogs);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
name: 'network',
|
|
74
|
+
label: 'Network',
|
|
75
|
+
renderContent: NetworkLogTab,
|
|
76
|
+
setup: () => {
|
|
77
|
+
if (initialized) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
unsubscribeLogs = networkChannel.subscribe(handleLog);
|
|
81
|
+
stopFetchFn = startFetch(emitNetworkLog);
|
|
82
|
+
stopXMLHttpRequestFn = startXMLHttpRequest(emitNetworkLog);
|
|
83
|
+
initialized = true;
|
|
84
|
+
},
|
|
85
|
+
getData: () => logStore.getData(),
|
|
86
|
+
clear: () => {
|
|
87
|
+
logStore.clear();
|
|
88
|
+
},
|
|
89
|
+
cleanup: () => {
|
|
90
|
+
if (!initialized) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
urlRewriter.set(null);
|
|
94
|
+
unsubscribeLogs?.();
|
|
95
|
+
unsubscribeLogs = null;
|
|
96
|
+
stopFetchFn?.();
|
|
97
|
+
stopFetchFn = null;
|
|
98
|
+
stopXMLHttpRequestFn?.();
|
|
99
|
+
stopXMLHttpRequestFn = null;
|
|
100
|
+
axiosCleanupMap.forEach((c) => c());
|
|
101
|
+
axiosCleanupMap.clear();
|
|
102
|
+
logStore.clear();
|
|
103
|
+
initialized = false;
|
|
104
|
+
},
|
|
105
|
+
subscribe: (listener) => logStore.subscribe(listener),
|
|
106
|
+
setupAxiosInterceptors: (axiosInstance) => {
|
|
107
|
+
const existingCleanup = axiosCleanupMap.get(axiosInstance);
|
|
108
|
+
if (existingCleanup) {
|
|
109
|
+
return existingCleanup;
|
|
110
|
+
}
|
|
111
|
+
const cleanup = setupAxios(axiosInstance, emitNetworkLog);
|
|
112
|
+
const trackedCleanup = () => {
|
|
113
|
+
cleanup();
|
|
114
|
+
axiosCleanupMap.delete(axiosInstance);
|
|
115
|
+
};
|
|
116
|
+
axiosCleanupMap.set(axiosInstance, trackedCleanup);
|
|
117
|
+
return trackedCleanup;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** Reset module-level state for testing */
|
|
123
|
+
export function _resetNetworkForTesting(): void {
|
|
124
|
+
networkChannel = createEventChannel<NetworkLogPayload>();
|
|
125
|
+
resetInterceptors();
|
|
126
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { ThirdPartyLibsTab } from '../components/ThirdPartyLibsTab';
|
|
3
|
+
import { NativeDebugLibs } from '../native/NativeDebugLibs';
|
|
4
|
+
import type { DebugFeature, ThirdPartyLib } from '../types';
|
|
5
|
+
|
|
6
|
+
const availableLibs: ThirdPartyLib[] = [
|
|
7
|
+
{
|
|
8
|
+
id: 'flex',
|
|
9
|
+
name: 'FLEX',
|
|
10
|
+
description: 'In-app debugging and exploration tool for iOS',
|
|
11
|
+
platform: 'ios',
|
|
12
|
+
actions: [
|
|
13
|
+
{ id: 'showExplorer', label: 'Show Explorer', onPress: NativeDebugLibs.showExplorer },
|
|
14
|
+
{ id: 'hideExplorer', label: 'Hide Explorer', onPress: NativeDebugLibs.hideExplorer },
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'doraemonkit',
|
|
19
|
+
name: 'DoraemonKit',
|
|
20
|
+
description: 'A full-featured iOS & Android development assistant',
|
|
21
|
+
platform: 'both',
|
|
22
|
+
actions: [
|
|
23
|
+
{ id: 'showDoraemonKit', label: 'Show DoraemonKit', onPress: NativeDebugLibs.showDoraemonKit },
|
|
24
|
+
{ id: 'hideDoraemonKit', label: 'Hide DoraemonKit', onPress: NativeDebugLibs.hideDoraemonKit },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
function getPlatformLibs(): ThirdPartyLib[] {
|
|
30
|
+
return availableLibs.filter(
|
|
31
|
+
(lib) => lib.platform === 'both' || lib.platform === Platform.OS,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const createThirdPartyLibsFeature = (): DebugFeature<ThirdPartyLib> => ({
|
|
36
|
+
name: 'thirdPartyLibs',
|
|
37
|
+
label: 'Debug Libraries',
|
|
38
|
+
renderContent: ThirdPartyLibsTab,
|
|
39
|
+
setup: () => {},
|
|
40
|
+
getData: () => getPlatformLibs(),
|
|
41
|
+
cleanup: () => {},
|
|
42
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TrackLogTab } from '../components/TrackLogTab';
|
|
2
|
+
import type { DebugFeature, TrackLogEntry } from '../types';
|
|
3
|
+
import { createEventChannel } from '../utils/createEventChannel';
|
|
4
|
+
import { createChannelFeature } from '../utils/createChannelFeature';
|
|
5
|
+
|
|
6
|
+
export interface TrackEventData {
|
|
7
|
+
eventName: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type TrackLogPayload = TrackEventData & { timestamp: number };
|
|
12
|
+
|
|
13
|
+
let trackChannel = createEventChannel<TrackLogPayload>();
|
|
14
|
+
|
|
15
|
+
export const addTrackLog = (eventData: TrackEventData): void => {
|
|
16
|
+
trackChannel.emit({ timestamp: Date.now(), ...eventData });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface TrackFeatureConfig {
|
|
20
|
+
/** Maximum number of track events to keep (default: 200) */
|
|
21
|
+
maxLogs?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const createTrackFeature = (config?: TrackFeatureConfig): DebugFeature<TrackLogEntry> =>
|
|
25
|
+
createChannelFeature(
|
|
26
|
+
() => trackChannel,
|
|
27
|
+
(payload, id) => ({ ...payload, id }),
|
|
28
|
+
{ name: 'track', label: 'Track', renderContent: TrackLogTab, maxLogs: config?.maxLogs },
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
/** Reset module-level state for testing */
|
|
32
|
+
export function _resetTrackForTesting(): void {
|
|
33
|
+
trackChannel = createEventChannel<TrackLogPayload>();
|
|
34
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ZustandLogTab } from '../components/ZustandLogTab';
|
|
2
|
+
import type { DebugFeature, ZustandLogEntry } from '../types';
|
|
3
|
+
import { createEventChannel } from '../utils/createEventChannel';
|
|
4
|
+
import { createChannelFeature } from '../utils/createChannelFeature';
|
|
5
|
+
|
|
6
|
+
type ZustandLogPayload = Omit<ZustandLogEntry, 'id'>;
|
|
7
|
+
|
|
8
|
+
let zustandChannel = createEventChannel<ZustandLogPayload>();
|
|
9
|
+
|
|
10
|
+
export const addZustandLog = (
|
|
11
|
+
action: string,
|
|
12
|
+
prevState: unknown,
|
|
13
|
+
nextState: unknown,
|
|
14
|
+
actionCompleteTime?: number,
|
|
15
|
+
storeName?: string,
|
|
16
|
+
): void => {
|
|
17
|
+
zustandChannel.emit({
|
|
18
|
+
timestamp: Date.now(),
|
|
19
|
+
action,
|
|
20
|
+
prevState,
|
|
21
|
+
nextState,
|
|
22
|
+
actionCompleteTime,
|
|
23
|
+
storeName,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// ─── Zustand middleware (remains here — it's user-facing API) ──────────
|
|
28
|
+
|
|
29
|
+
type ZustandSetState<T> = (
|
|
30
|
+
partial: T | Partial<T> | ((state: T) => Partial<T> | T),
|
|
31
|
+
replace?: boolean | undefined,
|
|
32
|
+
action?: string | { type: unknown } | undefined,
|
|
33
|
+
) => void;
|
|
34
|
+
|
|
35
|
+
type ZustandGetState<T> = () => T;
|
|
36
|
+
|
|
37
|
+
interface ZustandStoreApi<T> {
|
|
38
|
+
getState: () => T;
|
|
39
|
+
setState: ZustandSetState<T>;
|
|
40
|
+
subscribe: (listener: (state: T, prevState: T) => void) => () => void;
|
|
41
|
+
name?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type ZustandConfig<T> = (
|
|
45
|
+
set: ZustandSetState<T>,
|
|
46
|
+
get: ZustandGetState<T>,
|
|
47
|
+
api: ZustandStoreApi<T>,
|
|
48
|
+
) => T;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Zustand middleware that logs all state changes to the debug toolkit.
|
|
52
|
+
*
|
|
53
|
+
* Usage:
|
|
54
|
+
* ```ts
|
|
55
|
+
* const useStore = create(zustandLogMiddleware((set) => ({ ... })))
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export const zustandLogMiddleware = <T>(config: ZustandConfig<T>) => (
|
|
59
|
+
set: ZustandSetState<T>,
|
|
60
|
+
get: ZustandGetState<T>,
|
|
61
|
+
api: ZustandStoreApi<T>,
|
|
62
|
+
) =>
|
|
63
|
+
config(
|
|
64
|
+
(args: Parameters<ZustandSetState<T>>[0], replace?: boolean, actionName?: string | { type: unknown }) => {
|
|
65
|
+
const prevState = get();
|
|
66
|
+
const startTime = Date.now();
|
|
67
|
+
set(args, replace, actionName);
|
|
68
|
+
const duration = Date.now() - startTime;
|
|
69
|
+
const label = typeof actionName === 'string'
|
|
70
|
+
? actionName
|
|
71
|
+
: typeof args === 'function' ? 'setState' : 'object-set';
|
|
72
|
+
addZustandLog(
|
|
73
|
+
label,
|
|
74
|
+
prevState,
|
|
75
|
+
get(),
|
|
76
|
+
duration,
|
|
77
|
+
api.name,
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
get,
|
|
81
|
+
api,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// ─── Feature factory ──────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
export interface ZustandFeatureConfig {
|
|
87
|
+
/** Maximum number of zustand state changes to keep (default: 200) */
|
|
88
|
+
maxLogs?: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const createZustandLogFeature = (config?: ZustandFeatureConfig): DebugFeature<ZustandLogEntry> =>
|
|
92
|
+
createChannelFeature(
|
|
93
|
+
() => zustandChannel,
|
|
94
|
+
(payload, id) => ({ ...payload, id }),
|
|
95
|
+
{ name: 'zustand', label: 'Zustand', renderContent: ZustandLogTab, maxLogs: config?.maxLogs },
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
/** Reset module-level state for testing */
|
|
99
|
+
export function _resetZustandForTesting(): void {
|
|
100
|
+
zustandChannel = createEventChannel<ZustandLogPayload>();
|
|
101
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { addNavigationLog } from '../features/NavigationLogFeature';
|
|
3
|
+
import { safeStringify } from '../utils/safeStringify';
|
|
4
|
+
import type { NavigationContainerRef } from '../types';
|
|
5
|
+
|
|
6
|
+
function getActiveRouteName(state: unknown): string {
|
|
7
|
+
let currentState = state as
|
|
8
|
+
| {
|
|
9
|
+
index?: number;
|
|
10
|
+
routes?: Array<{ name?: string; state?: unknown }>;
|
|
11
|
+
}
|
|
12
|
+
| undefined;
|
|
13
|
+
|
|
14
|
+
while (currentState?.routes && typeof currentState.index === 'number') {
|
|
15
|
+
const route = currentState.routes[currentState.index];
|
|
16
|
+
if (!route) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
if (!route.state) {
|
|
20
|
+
return route.name ?? '';
|
|
21
|
+
}
|
|
22
|
+
currentState = route.state as typeof currentState;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Hook to automatically log React Navigation events.
|
|
31
|
+
*
|
|
32
|
+
* Usage:
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const navigationRef = useRef<NavigationContainerRef>(null);
|
|
35
|
+
* useNavigationLogger(navigationRef);
|
|
36
|
+
* return <NavigationContainer ref={navigationRef}>...</NavigationContainer>;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function useNavigationLogger(navigationRef: React.RefObject<NavigationContainerRef | null>) {
|
|
40
|
+
const previousRouteNameRef = useRef('');
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
|
44
|
+
let unsubscribe: (() => void) | undefined;
|
|
45
|
+
let disposed = false;
|
|
46
|
+
|
|
47
|
+
const attachListener = () => {
|
|
48
|
+
if (disposed) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const ref = navigationRef.current;
|
|
53
|
+
if (!ref || typeof ref.addListener !== 'function') {
|
|
54
|
+
timeoutId = setTimeout(attachListener, 250);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const currentRouteName =
|
|
59
|
+
ref.getCurrentRoute?.()?.name ||
|
|
60
|
+
getActiveRouteName(ref.getRootState?.());
|
|
61
|
+
if (currentRouteName) {
|
|
62
|
+
previousRouteNameRef.current = currentRouteName;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
unsubscribe = ref.addListener('state', () => {
|
|
66
|
+
try {
|
|
67
|
+
const navState = ref.getRootState?.();
|
|
68
|
+
const nextRouteName =
|
|
69
|
+
ref.getCurrentRoute?.()?.name ||
|
|
70
|
+
getActiveRouteName(navState);
|
|
71
|
+
|
|
72
|
+
if (!nextRouteName || nextRouteName === previousRouteNameRef.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
addNavigationLog(
|
|
77
|
+
'navigate',
|
|
78
|
+
previousRouteNameRef.current,
|
|
79
|
+
nextRouteName,
|
|
80
|
+
undefined,
|
|
81
|
+
undefined,
|
|
82
|
+
safeStringify(navState),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
previousRouteNameRef.current = nextRouteName;
|
|
86
|
+
} catch {
|
|
87
|
+
// Navigation state may not be ready
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
attachListener();
|
|
93
|
+
|
|
94
|
+
return () => {
|
|
95
|
+
disposed = true;
|
|
96
|
+
if (timeoutId) {
|
|
97
|
+
clearTimeout(timeoutId);
|
|
98
|
+
}
|
|
99
|
+
unsubscribe?.();
|
|
100
|
+
};
|
|
101
|
+
}, [navigationRef]);
|
|
102
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared slide-in/out animation for tab detail views.
|
|
6
|
+
* Returns animated styles for the detail overlay and the list behind it.
|
|
7
|
+
*/
|
|
8
|
+
export function useSlideDetailAnimation<T>(
|
|
9
|
+
selected: T | null,
|
|
10
|
+
): {
|
|
11
|
+
detailTranslateX: Animated.AnimatedInterpolation<number>;
|
|
12
|
+
listTranslateX: Animated.AnimatedInterpolation<number>;
|
|
13
|
+
listOpacity: Animated.AnimatedInterpolation<number>;
|
|
14
|
+
} {
|
|
15
|
+
const slideAnim = useRef(new Animated.Value(0)).current;
|
|
16
|
+
const listSlideAnim = useRef(new Animated.Value(0)).current;
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (selected) {
|
|
20
|
+
listSlideAnim.setValue(0);
|
|
21
|
+
Animated.parallel([
|
|
22
|
+
Animated.spring(slideAnim, { toValue: 1, friction: 9, tension: 60, useNativeDriver: true }),
|
|
23
|
+
Animated.spring(listSlideAnim, { toValue: 1, friction: 9, tension: 60, useNativeDriver: true }),
|
|
24
|
+
]).start();
|
|
25
|
+
} else {
|
|
26
|
+
slideAnim.setValue(0);
|
|
27
|
+
listSlideAnim.setValue(0);
|
|
28
|
+
}
|
|
29
|
+
}, [selected, slideAnim, listSlideAnim]);
|
|
30
|
+
|
|
31
|
+
const detailTranslateX = slideAnim.interpolate({
|
|
32
|
+
inputRange: [0, 1],
|
|
33
|
+
outputRange: [300, 0],
|
|
34
|
+
});
|
|
35
|
+
const listTranslateX = listSlideAnim.interpolate({
|
|
36
|
+
inputRange: [0, 1],
|
|
37
|
+
outputRange: [0, -60],
|
|
38
|
+
});
|
|
39
|
+
const listOpacity = listSlideAnim.interpolate({
|
|
40
|
+
inputRange: [0, 1],
|
|
41
|
+
outputRange: [1, 0],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return { detailTranslateX, listTranslateX, listOpacity };
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Core
|
|
2
|
+
export { DebugToolkit } from './core/DebugToolkit';
|
|
3
|
+
export { DebugToolkitProvider, useDebugToolkit } from './core/DebugToolkitProvider';
|
|
4
|
+
export { DebugView } from './components/DebugView';
|
|
5
|
+
export type { DebugViewProps } from './components/DebugView';
|
|
6
|
+
export { initializeDebugToolkit } from './initialize';
|
|
7
|
+
export type { InitializeOptions, FeatureConfigs } from './initialize';
|
|
8
|
+
|
|
9
|
+
// Feature factories
|
|
10
|
+
export { createNetworkFeature } from './features/NetworkFeature';
|
|
11
|
+
export type { NetworkFeatureConfig, AxiosInstanceLike } from './features/NetworkFeature';
|
|
12
|
+
export { createConsoleLogFeature } from './features/ConsoleLogFeature';
|
|
13
|
+
export type { ConsoleFeatureConfig } from './features/ConsoleLogFeature';
|
|
14
|
+
export { createZustandLogFeature, zustandLogMiddleware, addZustandLog } from './features/ZustandLogFeature';
|
|
15
|
+
export type { ZustandFeatureConfig } from './features/ZustandLogFeature';
|
|
16
|
+
export { createNavigationLogFeature, addNavigationLog } from './features/NavigationLogFeature';
|
|
17
|
+
export type { NavigationFeatureConfig } from './features/NavigationLogFeature';
|
|
18
|
+
export { createTrackFeature, addTrackLog } from './features/TrackFeature';
|
|
19
|
+
export type { TrackFeatureConfig, TrackEventData } from './features/TrackFeature';
|
|
20
|
+
export { createEnvironmentFeature } from './features/EnvironmentFeature';
|
|
21
|
+
export type { EnvironmentFeatureAPI } from './features/EnvironmentFeature';
|
|
22
|
+
export { createClipboardFeature } from './features/ClipboardFeature';
|
|
23
|
+
|
|
24
|
+
// Hooks
|
|
25
|
+
export { useNavigationLogger } from './hooks/useNavigationLogger';
|
|
26
|
+
|
|
27
|
+
// Utilities
|
|
28
|
+
export { safeStringify } from './utils/safeStringify';
|
|
29
|
+
export { copyToComputer, logToComputer, fmt } from './utils/copyToComputer';
|
|
30
|
+
export type { CopyResult, CopyOptions, CopyMethod } from './utils/copyToComputer';
|
|
31
|
+
|
|
32
|
+
// Types
|
|
33
|
+
export type {
|
|
34
|
+
AnyDebugFeature,
|
|
35
|
+
BuiltInFeatureName,
|
|
36
|
+
DebugFeature,
|
|
37
|
+
DebugFeatureRenderProps,
|
|
38
|
+
NetworkLogEntry,
|
|
39
|
+
ConsoleLogEntry,
|
|
40
|
+
ZustandLogEntry,
|
|
41
|
+
NavigationLogEntry,
|
|
42
|
+
TrackLogEntry,
|
|
43
|
+
EnvironmentConfig,
|
|
44
|
+
EnvironmentState,
|
|
45
|
+
} from './types';
|
|
46
|
+
|
|
47
|
+
// Default export for convenience
|
|
48
|
+
export { initializeDebugToolkit as default } from './initialize';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { DebugToolkit } from './core/DebugToolkit';
|
|
2
|
+
import { createNetworkFeature } from './features/NetworkFeature';
|
|
3
|
+
import type { NetworkFeatureConfig } from './features/NetworkFeature';
|
|
4
|
+
import { createConsoleLogFeature } from './features/ConsoleLogFeature';
|
|
5
|
+
import type { ConsoleFeatureConfig } from './features/ConsoleLogFeature';
|
|
6
|
+
import { createZustandLogFeature } from './features/ZustandLogFeature';
|
|
7
|
+
import type { ZustandFeatureConfig } from './features/ZustandLogFeature';
|
|
8
|
+
import { createNavigationLogFeature } from './features/NavigationLogFeature';
|
|
9
|
+
import type { NavigationFeatureConfig } from './features/NavigationLogFeature';
|
|
10
|
+
import { createTrackFeature } from './features/TrackFeature';
|
|
11
|
+
import type { TrackFeatureConfig } from './features/TrackFeature';
|
|
12
|
+
import { createEnvironmentFeature } from './features/EnvironmentFeature';
|
|
13
|
+
import { createClipboardFeature } from './features/ClipboardFeature';
|
|
14
|
+
import type { AnyDebugFeature, BuiltInFeatureName } from './types';
|
|
15
|
+
|
|
16
|
+
const isDebugMode = __DEV__;
|
|
17
|
+
|
|
18
|
+
/** Feature-specific configuration map */
|
|
19
|
+
export interface FeatureConfigs {
|
|
20
|
+
network?: boolean | NetworkFeatureConfig;
|
|
21
|
+
console?: boolean | ConsoleFeatureConfig;
|
|
22
|
+
zustand?: boolean | ZustandFeatureConfig;
|
|
23
|
+
navigation?: boolean | NavigationFeatureConfig;
|
|
24
|
+
track?: boolean | TrackFeatureConfig;
|
|
25
|
+
environment?: Parameters<typeof createEnvironmentFeature>[0];
|
|
26
|
+
clipboard?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface InitializeOptions {
|
|
30
|
+
features?: FeatureConfigs;
|
|
31
|
+
enabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Registry mapping feature names to creator functions */
|
|
35
|
+
// Config param requires `any` — each factory accepts a different config type.
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
const featureRegistry: Record<BuiltInFeatureName, (config?: any) => AnyDebugFeature> = {
|
|
38
|
+
network: createNetworkFeature,
|
|
39
|
+
console: createConsoleLogFeature,
|
|
40
|
+
zustand: createZustandLogFeature,
|
|
41
|
+
navigation: createNavigationLogFeature,
|
|
42
|
+
track: createTrackFeature,
|
|
43
|
+
environment: createEnvironmentFeature,
|
|
44
|
+
clipboard: createClipboardFeature,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const DEFAULT_FEATURES: BuiltInFeatureName[] = [
|
|
48
|
+
'network',
|
|
49
|
+
'console',
|
|
50
|
+
'navigation',
|
|
51
|
+
'zustand',
|
|
52
|
+
'track',
|
|
53
|
+
'clipboard',
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
function resolveFeatureConfigs(configs: FeatureConfigs): AnyDebugFeature[] {
|
|
57
|
+
const features: AnyDebugFeature[] = [];
|
|
58
|
+
const entries = Object.entries(configs) as [BuiltInFeatureName, unknown][];
|
|
59
|
+
|
|
60
|
+
for (const [name, config] of entries) {
|
|
61
|
+
if (config === false) continue;
|
|
62
|
+
|
|
63
|
+
const creator = featureRegistry[name];
|
|
64
|
+
if (!creator) {
|
|
65
|
+
console.warn(`[DebugToolkit] Unknown feature: "${name}"`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (config === true || config === undefined) {
|
|
70
|
+
features.push(creator());
|
|
71
|
+
} else if (typeof config === 'object') {
|
|
72
|
+
features.push(creator(config as Record<string, unknown>));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return features;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function resolveDefaultFeatures(): AnyDebugFeature[] {
|
|
80
|
+
return DEFAULT_FEATURES.map((name) => featureRegistry[name]!());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Initialize the debug toolkit.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* initializeDebugToolkit({
|
|
88
|
+
* features: { network: true, console: true },
|
|
89
|
+
* enabled: true,
|
|
90
|
+
* });
|
|
91
|
+
*/
|
|
92
|
+
export function initializeDebugToolkit(
|
|
93
|
+
options?: InitializeOptions,
|
|
94
|
+
): typeof DebugToolkit {
|
|
95
|
+
const enabled = options?.enabled ?? isDebugMode;
|
|
96
|
+
|
|
97
|
+
const resolvedFeatures = options?.features
|
|
98
|
+
? resolveFeatureConfigs(options.features)
|
|
99
|
+
: resolveDefaultFeatures();
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
DebugToolkit.setEnabled(enabled);
|
|
103
|
+
|
|
104
|
+
if (!enabled) {
|
|
105
|
+
DebugToolkit.reset();
|
|
106
|
+
return DebugToolkit;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
DebugToolkit.replaceFeatures(resolvedFeatures);
|
|
110
|
+
|
|
111
|
+
if (DebugToolkit.hasFeatures()) {
|
|
112
|
+
DebugToolkit.showPanel();
|
|
113
|
+
} else {
|
|
114
|
+
DebugToolkit.hidePanel();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return DebugToolkit;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('[DebugToolkit] Initialization failed:', error);
|
|
120
|
+
return DebugToolkit;
|
|
121
|
+
}
|
|
122
|
+
}
|