react-native-debug-toolkit 0.6.4 → 2.0.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 +150 -212
- package/lib/commonjs/components/ClipboardTab.js +92 -0
- package/lib/commonjs/components/ClipboardTab.js.map +1 -0
- package/lib/commonjs/components/ConsoleLogTab.js +295 -0
- package/lib/commonjs/components/ConsoleLogTab.js.map +1 -0
- package/lib/commonjs/components/EnvironmentTab.js +288 -0
- package/lib/commonjs/components/EnvironmentTab.js.map +1 -0
- package/lib/commonjs/components/FloatPanelView.js +797 -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 +575 -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 +372 -0
- package/lib/commonjs/components/TrackLogTab.js.map +1 -0
- package/lib/commonjs/components/ZustandLogTab.js +451 -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/core/DebugToolkit.js +142 -0
- package/lib/commonjs/core/DebugToolkit.js.map +1 -0
- package/lib/commonjs/core/DebugToolkitProvider.js +64 -0
- package/lib/commonjs/core/DebugToolkitProvider.js.map +1 -0
- package/lib/commonjs/features/ClipboardFeature.js +17 -0
- package/lib/commonjs/features/ClipboardFeature.js.map +1 -0
- package/lib/commonjs/features/ConsoleLogFeature.js +98 -0
- package/lib/commonjs/features/ConsoleLogFeature.js.map +1 -0
- package/lib/commonjs/features/EnvironmentFeature.js +168 -0
- package/lib/commonjs/features/EnvironmentFeature.js.map +1 -0
- package/lib/commonjs/features/NavigationLogFeature.js +60 -0
- package/lib/commonjs/features/NavigationLogFeature.js.map +1 -0
- package/lib/commonjs/features/NetworkFeature.js +328 -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 +55 -0
- package/lib/commonjs/features/TrackFeature.js.map +1 -0
- package/lib/commonjs/features/ZustandLogFeature.js +76 -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 +165 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/initialize.js +161 -0
- package/lib/commonjs/initialize.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/constants.js +135 -0
- package/lib/commonjs/utils/constants.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/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/safeStringify.js +27 -0
- package/lib/commonjs/utils/safeStringify.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 +290 -0
- package/lib/module/components/ConsoleLogTab.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/FloatPanelView.js +791 -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 +570 -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 +367 -0
- package/lib/module/components/TrackLogTab.js.map +1 -0
- package/lib/module/components/ZustandLogTab.js +446 -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/core/DebugToolkit.js +137 -0
- package/lib/module/core/DebugToolkit.js.map +1 -0
- package/lib/module/core/DebugToolkitProvider.js +58 -0
- package/lib/module/core/DebugToolkitProvider.js.map +1 -0
- package/lib/module/features/ClipboardFeature.js +12 -0
- package/lib/module/features/ClipboardFeature.js.map +1 -0
- package/lib/module/features/ConsoleLogFeature.js +93 -0
- package/lib/module/features/ConsoleLogFeature.js.map +1 -0
- package/lib/module/features/EnvironmentFeature.js +164 -0
- package/lib/module/features/EnvironmentFeature.js.map +1 -0
- package/lib/module/features/NavigationLogFeature.js +54 -0
- package/lib/module/features/NavigationLogFeature.js.map +1 -0
- package/lib/module/features/NetworkFeature.js +322 -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 +49 -0
- package/lib/module/features/TrackFeature.js.map +1 -0
- package/lib/module/features/ZustandLogFeature.js +69 -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 +29 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initialize.js +156 -0
- package/lib/module/initialize.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/constants.js +130 -0
- package/lib/module/utils/constants.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/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/safeStringify.js +23 -0
- package/lib/module/utils/safeStringify.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/EnvironmentTab.d.ts +4 -0
- package/lib/typescript/src/components/EnvironmentTab.d.ts.map +1 -0
- package/lib/typescript/src/components/FloatPanelView.d.ts +64 -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/core/DebugToolkit.d.ts +27 -0
- package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -0
- package/lib/typescript/src/core/DebugToolkitProvider.d.ts +18 -0
- package/lib/typescript/src/core/DebugToolkitProvider.d.ts.map +1 -0
- package/lib/typescript/src/features/ClipboardFeature.d.ts +3 -0
- package/lib/typescript/src/features/ClipboardFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/ConsoleLogFeature.d.ts +7 -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 +8 -0
- package/lib/typescript/src/features/NavigationLogFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/NetworkFeature.d.ts +28 -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 +12 -0
- package/lib/typescript/src/features/TrackFeature.d.ts.map +1 -0
- package/lib/typescript/src/features/ZustandLogFeature.d.ts +29 -0
- package/lib/typescript/src/features/ZustandLogFeature.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useNavigationLogger.d.ts +20 -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 +51 -0
- package/lib/typescript/src/initialize.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 +112 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/constants.d.ts +96 -0
- package/lib/typescript/src/utils/constants.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/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/safeStringify.d.ts +6 -0
- package/lib/typescript/src/utils/safeStringify.d.ts.map +1 -0
- package/package.json +63 -24
- package/src/components/ClipboardTab.tsx +81 -0
- package/src/components/ConsoleLogTab.tsx +209 -0
- package/src/components/EnvironmentTab.tsx +276 -0
- package/src/components/FloatPanelView.tsx +714 -0
- package/src/components/NavigationLogTab.tsx +66 -0
- package/src/components/NetworkLogTab.tsx +411 -0
- package/src/components/ThirdPartyLibsTab.tsx +63 -0
- package/src/components/TrackLogTab.tsx +245 -0
- package/src/components/ZustandLogTab.tsx +305 -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/core/DebugToolkit.tsx +174 -0
- package/src/core/DebugToolkitProvider.tsx +89 -0
- package/src/features/ClipboardFeature.ts +11 -0
- package/src/features/ConsoleLogFeature.ts +118 -0
- package/src/features/EnvironmentFeature.ts +194 -0
- package/src/features/NavigationLogFeature.ts +74 -0
- package/src/features/NetworkFeature.ts +488 -0
- package/src/features/ThirdPartyLibsFeature.ts +42 -0
- package/src/features/TrackFeature.ts +69 -0
- package/src/features/ZustandLogFeature.ts +127 -0
- package/src/hooks/useNavigationLogger.ts +107 -0
- package/src/hooks/useSlideDetailAnimation.ts +45 -0
- package/src/index.ts +52 -0
- package/src/initialize.ts +214 -0
- package/src/native/NativeDebugLibs.ts +74 -0
- package/src/types/index.ts +138 -0
- package/src/utils/constants.ts +91 -0
- package/src/utils/copyToComputer.ts +104 -0
- package/src/utils/createEventChannel.ts +22 -0
- package/src/utils/createObservableStore.ts +42 -0
- package/src/utils/safeStringify.ts +25 -0
- package/.cursor/rules/react-native.mdc +0 -41
- package/README.zh-CN.md +0 -230
- 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,138 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
export type DebugFeatureListener = () => void;
|
|
4
|
+
|
|
5
|
+
export type BuiltInFeatureName =
|
|
6
|
+
| 'network'
|
|
7
|
+
| 'console'
|
|
8
|
+
| 'zustand'
|
|
9
|
+
| 'navigation'
|
|
10
|
+
| 'track'
|
|
11
|
+
| 'thirdPartyLibs'
|
|
12
|
+
| 'environment'
|
|
13
|
+
| 'clipboard';
|
|
14
|
+
|
|
15
|
+
export interface DebugFeatureRenderProps<TData = unknown> {
|
|
16
|
+
data: TData[];
|
|
17
|
+
feature: DebugFeature<TData>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type DebugFeatureRenderer<TData = unknown> = ComponentType<
|
|
21
|
+
DebugFeatureRenderProps<TData>
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export type DebugFeatureFactory = () => DebugFeature<any>;
|
|
25
|
+
|
|
26
|
+
export type DebugFeatureInput =
|
|
27
|
+
| BuiltInFeatureName
|
|
28
|
+
| DebugFeature<any>
|
|
29
|
+
| DebugFeatureFactory;
|
|
30
|
+
|
|
31
|
+
/** Base interface all debug features must implement */
|
|
32
|
+
export interface DebugFeature<TData = unknown> {
|
|
33
|
+
name: string;
|
|
34
|
+
label: string;
|
|
35
|
+
setup: () => void;
|
|
36
|
+
getData: () => TData[];
|
|
37
|
+
clear?: () => void;
|
|
38
|
+
cleanup: () => void;
|
|
39
|
+
subscribe?: (listener: DebugFeatureListener) => () => void;
|
|
40
|
+
renderContent?: DebugFeatureRenderer<TData>;
|
|
41
|
+
badge?: () => { label: string; color: string } | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface NetworkLogEntry {
|
|
45
|
+
id: string;
|
|
46
|
+
timestamp: number;
|
|
47
|
+
duration?: number;
|
|
48
|
+
request: {
|
|
49
|
+
url: string;
|
|
50
|
+
method: string;
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
body?: unknown;
|
|
53
|
+
};
|
|
54
|
+
response?: {
|
|
55
|
+
status: number;
|
|
56
|
+
statusText?: string;
|
|
57
|
+
headers?: Record<string, string>;
|
|
58
|
+
data?: unknown;
|
|
59
|
+
success?: boolean;
|
|
60
|
+
};
|
|
61
|
+
error?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ConsoleLogEntry {
|
|
65
|
+
id: string;
|
|
66
|
+
timestamp: number;
|
|
67
|
+
level: 'log' | 'info' | 'warn' | 'error';
|
|
68
|
+
data: unknown[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ZustandLogEntry {
|
|
72
|
+
id: string;
|
|
73
|
+
timestamp: number;
|
|
74
|
+
action: string;
|
|
75
|
+
prevState: unknown;
|
|
76
|
+
nextState: unknown;
|
|
77
|
+
actionCompleteTime?: number;
|
|
78
|
+
storeName?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface NavigationLogEntry {
|
|
82
|
+
id: string;
|
|
83
|
+
timestamp: number;
|
|
84
|
+
action: string;
|
|
85
|
+
from: string;
|
|
86
|
+
to: string;
|
|
87
|
+
startTime?: number;
|
|
88
|
+
duration?: number;
|
|
89
|
+
debugLog?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface TrackLogEntry {
|
|
93
|
+
id: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
eventName: string;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface ThirdPartyLib {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
description: string;
|
|
103
|
+
platform: 'ios' | 'android' | 'both';
|
|
104
|
+
actions: Array<{
|
|
105
|
+
id: string;
|
|
106
|
+
label: string;
|
|
107
|
+
onPress: () => void;
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface EnvironmentConfig {
|
|
112
|
+
id: string;
|
|
113
|
+
label: string;
|
|
114
|
+
host: string;
|
|
115
|
+
color?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface EnvironmentState {
|
|
119
|
+
environments: EnvironmentConfig[];
|
|
120
|
+
currentEnvironmentId: string | null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface DebugToolkitConfig {
|
|
124
|
+
features?: DebugFeatureInput[];
|
|
125
|
+
enabled?: boolean;
|
|
126
|
+
/** Maximum number of log entries per feature (default: 200) */
|
|
127
|
+
maxLogsPerFeature?: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface DebugToolkitAPI {
|
|
131
|
+
readonly features: ReadonlyArray<DebugFeature<any>>;
|
|
132
|
+
addFeature: (feature: DebugFeature<any>) => void;
|
|
133
|
+
removeFeature: (name: string) => void;
|
|
134
|
+
showPanel: () => void;
|
|
135
|
+
hidePanel: () => void;
|
|
136
|
+
clearAll: () => void;
|
|
137
|
+
destroy: () => void;
|
|
138
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Dimensions } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
|
|
4
|
+
|
|
5
|
+
export const Layout = {
|
|
6
|
+
screenWidth,
|
|
7
|
+
screenHeight,
|
|
8
|
+
iconSize: 52,
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
// Apple iOS System Color Palette
|
|
12
|
+
export const Colors = {
|
|
13
|
+
// System
|
|
14
|
+
primary: '#007AFF',
|
|
15
|
+
text: '#1C1C1E',
|
|
16
|
+
textSecondary: '#8E8E93',
|
|
17
|
+
textLight: '#C7C7CC',
|
|
18
|
+
border: '#E5E5EA',
|
|
19
|
+
opaqueSeparator: '#C6C6C8',
|
|
20
|
+
background: '#F2F2F7',
|
|
21
|
+
surface: '#FFFFFF',
|
|
22
|
+
|
|
23
|
+
// Semantic
|
|
24
|
+
success: '#34C759',
|
|
25
|
+
error: '#FF3B30',
|
|
26
|
+
warning: '#FF9500',
|
|
27
|
+
info: '#5AC8FA',
|
|
28
|
+
|
|
29
|
+
// iOS Accent Colors
|
|
30
|
+
blue: '#007AFF',
|
|
31
|
+
green: '#34C759',
|
|
32
|
+
indigo: '#5856D6',
|
|
33
|
+
orange: '#FF9500',
|
|
34
|
+
pink: '#FF2D55',
|
|
35
|
+
purple: '#AF52DE',
|
|
36
|
+
red: '#FF3B30',
|
|
37
|
+
teal: '#5AC8FA',
|
|
38
|
+
yellow: '#FFCC00',
|
|
39
|
+
|
|
40
|
+
// HTTP Method Colors
|
|
41
|
+
get: '#007AFF',
|
|
42
|
+
post: '#34C759',
|
|
43
|
+
put: '#FF9500',
|
|
44
|
+
delete: '#FF3B30',
|
|
45
|
+
patch: '#5AC8FA',
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
export const getMethodColor = (method: string): string => {
|
|
49
|
+
switch (method.toUpperCase()) {
|
|
50
|
+
case 'GET': return Colors.get;
|
|
51
|
+
case 'POST': return Colors.post;
|
|
52
|
+
case 'PUT': return Colors.put;
|
|
53
|
+
case 'DELETE': return Colors.delete;
|
|
54
|
+
case 'PATCH': return Colors.patch;
|
|
55
|
+
default: return Colors.textSecondary;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// iOS 8pt Grid Spacing
|
|
60
|
+
export const Spacing = {
|
|
61
|
+
xs: 4,
|
|
62
|
+
sm: 8,
|
|
63
|
+
md: 12,
|
|
64
|
+
lg: 16,
|
|
65
|
+
xl: 20,
|
|
66
|
+
xxl: 24,
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
// iOS Border Radius
|
|
70
|
+
export const Radius = {
|
|
71
|
+
sm: 8,
|
|
72
|
+
md: 12,
|
|
73
|
+
lg: 16,
|
|
74
|
+
xl: 20,
|
|
75
|
+
full: 999,
|
|
76
|
+
} as const;
|
|
77
|
+
|
|
78
|
+
// iOS Typography Scale
|
|
79
|
+
export const Typography = {
|
|
80
|
+
largeTitle: { fontSize: 34, fontWeight: '700' as const },
|
|
81
|
+
title1: { fontSize: 28, fontWeight: '700' as const },
|
|
82
|
+
title2: { fontSize: 22, fontWeight: '700' as const },
|
|
83
|
+
title3: { fontSize: 20, fontWeight: '600' as const },
|
|
84
|
+
headline: { fontSize: 17, fontWeight: '600' as const },
|
|
85
|
+
body: { fontSize: 17, fontWeight: '400' as const },
|
|
86
|
+
callout: { fontSize: 16, fontWeight: '400' as const },
|
|
87
|
+
subheadline: { fontSize: 15, fontWeight: '400' as const },
|
|
88
|
+
footnote: { fontSize: 13, fontWeight: '400' as const },
|
|
89
|
+
caption1: { fontSize: 12, fontWeight: '400' as const },
|
|
90
|
+
caption2: { fontSize: 11, fontWeight: '400' as const },
|
|
91
|
+
} as const;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
type ClipboardModule = { setString: (value: string) => void };
|
|
2
|
+
|
|
3
|
+
let clipboardModule: ClipboardModule | null = null;
|
|
4
|
+
let clipboardChecked = false;
|
|
5
|
+
|
|
6
|
+
function getClipboardModule(): ClipboardModule | null {
|
|
7
|
+
if (clipboardChecked) return clipboardModule;
|
|
8
|
+
clipboardChecked = true;
|
|
9
|
+
try {
|
|
10
|
+
// Check native module exists first — getEnforcing() inside the clipboard
|
|
11
|
+
// package throws a fatal Invariant Violation that bypasses try/catch.
|
|
12
|
+
const { TurboModuleRegistry } = require('react-native');
|
|
13
|
+
if (!TurboModuleRegistry.get('RNCClipboard')) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
clipboardModule = require('@react-native-clipboard/clipboard').default;
|
|
17
|
+
} catch {
|
|
18
|
+
clipboardModule = null;
|
|
19
|
+
}
|
|
20
|
+
return clipboardModule;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type CopyMethod = 'clipboard' | 'console' | 'none';
|
|
24
|
+
|
|
25
|
+
export interface CopyResult {
|
|
26
|
+
success: boolean;
|
|
27
|
+
method: CopyMethod;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CopyOptions {
|
|
31
|
+
/** Descriptive label for console.log identification */
|
|
32
|
+
label?: string;
|
|
33
|
+
/** If true, only copy to clipboard without console.log */
|
|
34
|
+
silent?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const MAX_LOG_SIZE = 10 * 1024; // 10KB
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Format data for copying (pretty JSON or raw string).
|
|
41
|
+
*/
|
|
42
|
+
export function fmt(data: unknown): string {
|
|
43
|
+
if (!data) return '';
|
|
44
|
+
try {
|
|
45
|
+
return JSON.stringify(typeof data === 'string' ? JSON.parse(data) : data, null, 2);
|
|
46
|
+
} catch {
|
|
47
|
+
return String(data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Log content to console (Metro terminal / DevTools) with a structured prefix.
|
|
53
|
+
* ConsoleLogFeature intercepts console.log but still calls the original first,
|
|
54
|
+
* so output reliably appears in Metro terminal.
|
|
55
|
+
*/
|
|
56
|
+
export function logToComputer(content: string, label?: string): void {
|
|
57
|
+
try {
|
|
58
|
+
const header = label ? `[DebugToolkit:Copy] ─── ${label} ───` : '[DebugToolkit:Copy] ─── Content ───';
|
|
59
|
+
console.log(header);
|
|
60
|
+
|
|
61
|
+
if (content.length > MAX_LOG_SIZE) {
|
|
62
|
+
console.log(content.slice(0, MAX_LOG_SIZE));
|
|
63
|
+
console.log(`[DebugToolkit:Copy] ... truncated (${content.length} bytes total)`);
|
|
64
|
+
} else {
|
|
65
|
+
console.log(content);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log('[DebugToolkit:Copy] ─── END ───');
|
|
69
|
+
} catch {
|
|
70
|
+
// Silently fail — console may not be available in all environments
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Copy content to computer via the best available method.
|
|
76
|
+
*
|
|
77
|
+
* 1. Attempts device clipboard (if @react-native-clipboard/clipboard is installed)
|
|
78
|
+
* 2. Always console.logs with structured prefix (appears in Metro terminal)
|
|
79
|
+
* 3. Returns result indicating what succeeded
|
|
80
|
+
*/
|
|
81
|
+
export function copyToComputer(content: string, options?: CopyOptions): CopyResult {
|
|
82
|
+
let method: CopyMethod = 'none';
|
|
83
|
+
|
|
84
|
+
// Try clipboard
|
|
85
|
+
try {
|
|
86
|
+
const clipboard = getClipboardModule();
|
|
87
|
+
if (clipboard) {
|
|
88
|
+
clipboard.setString(content);
|
|
89
|
+
method = 'clipboard';
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
// Clipboard may fail, continue
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Always log to computer console (unless silent)
|
|
96
|
+
if (!options?.silent) {
|
|
97
|
+
logToComputer(content, options?.label);
|
|
98
|
+
if (method === 'none') {
|
|
99
|
+
method = 'console';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return { success: true, method };
|
|
104
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type EventListener<TEvent> = (event: TEvent) => void;
|
|
2
|
+
|
|
3
|
+
export interface EventChannel<TEvent> {
|
|
4
|
+
emit: (event: TEvent) => void;
|
|
5
|
+
subscribe: (listener: EventListener<TEvent>) => () => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createEventChannel<TEvent>(): EventChannel<TEvent> {
|
|
9
|
+
const listeners = new Set<EventListener<TEvent>>();
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
emit: (event) => {
|
|
13
|
+
listeners.forEach((listener) => listener(event));
|
|
14
|
+
},
|
|
15
|
+
subscribe: (listener) => {
|
|
16
|
+
listeners.add(listener);
|
|
17
|
+
return () => {
|
|
18
|
+
listeners.delete(listener);
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type StoreListener = () => void;
|
|
2
|
+
|
|
3
|
+
export interface ObservableStore<T> {
|
|
4
|
+
getData: () => T[];
|
|
5
|
+
push: (item: T, maxEntries?: number) => void;
|
|
6
|
+
clear: () => void;
|
|
7
|
+
subscribe: (listener: StoreListener) => () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createObservableStore<T>(): ObservableStore<T> {
|
|
11
|
+
let data: T[] = [];
|
|
12
|
+
const listeners = new Set<StoreListener>();
|
|
13
|
+
|
|
14
|
+
const notify = () => {
|
|
15
|
+
listeners.forEach((listener) => listener());
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
getData: () => data,
|
|
20
|
+
push: (item, maxEntries) => {
|
|
21
|
+
if (maxEntries && data.length >= maxEntries) {
|
|
22
|
+
data = [...data.slice(data.length - maxEntries + 1), item];
|
|
23
|
+
} else {
|
|
24
|
+
data = [...data, item];
|
|
25
|
+
}
|
|
26
|
+
notify();
|
|
27
|
+
},
|
|
28
|
+
clear: () => {
|
|
29
|
+
if (data.length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
data = [];
|
|
33
|
+
notify();
|
|
34
|
+
},
|
|
35
|
+
subscribe: (listener) => {
|
|
36
|
+
listeners.add(listener);
|
|
37
|
+
return () => {
|
|
38
|
+
listeners.delete(listener);
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safely stringify a value to JSON, handling circular references
|
|
3
|
+
* and values that can't be serialized.
|
|
4
|
+
*/
|
|
5
|
+
export function safeStringify(value: unknown, space?: number): string {
|
|
6
|
+
try {
|
|
7
|
+
const seen = new WeakSet();
|
|
8
|
+
|
|
9
|
+
return JSON.stringify(
|
|
10
|
+
value,
|
|
11
|
+
(_, val) => {
|
|
12
|
+
if (typeof val === 'object' && val !== null) {
|
|
13
|
+
if (seen.has(val)) {
|
|
14
|
+
return '[Circular]';
|
|
15
|
+
}
|
|
16
|
+
seen.add(val);
|
|
17
|
+
}
|
|
18
|
+
return val;
|
|
19
|
+
},
|
|
20
|
+
space,
|
|
21
|
+
);
|
|
22
|
+
} catch {
|
|
23
|
+
return String(value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description:
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
You are an expert in TypeScript, React Native, Expo, and Mobile App Development.
|
|
8
|
-
|
|
9
|
-
Code Style and Structure:
|
|
10
|
-
- Write concise, type-safe TypeScript code.
|
|
11
|
-
- Use functional components and hooks over class components.
|
|
12
|
-
- Ensure components are modular, reusable, and maintainable.
|
|
13
|
-
- Organize files by feature, grouping related components, hooks, and styles.
|
|
14
|
-
|
|
15
|
-
Naming Conventions:
|
|
16
|
-
- Use camelCase for variable and function names (e.g., `isFetchingData`, `handleUserInput`).
|
|
17
|
-
- Use PascalCase for component names (e.g., `UserProfile`, `ChatScreen`).
|
|
18
|
-
|
|
19
|
-
TypeScript Usage:
|
|
20
|
-
- Use TypeScript for all components, favoring interfaces for props and state.
|
|
21
|
-
- Enable strict typing in `tsconfig.json`.
|
|
22
|
-
- Avoid using `any`; strive for precise types.
|
|
23
|
-
- Utilize `React.FC` for defining functional components with props.
|
|
24
|
-
|
|
25
|
-
Performance Optimization:
|
|
26
|
-
- Minimize `useEffect`, `useState`, and heavy computations inside render methods.
|
|
27
|
-
- Use `React.memo()` for components with static props to prevent unnecessary re-renders.
|
|
28
|
-
- Optimize FlatLists with props like `removeClippedSubviews`, `maxToRenderPerBatch`, and `windowSize`.
|
|
29
|
-
- Use `getItemLayout` for FlatLists when items have a consistent size to improve performance.
|
|
30
|
-
- Avoid anonymous functions in `renderItem` or event handlers to prevent re-renders.
|
|
31
|
-
|
|
32
|
-
UI and Styling:
|
|
33
|
-
- Use consistent styling, either through `StyleSheet.create()` or Styled Components.
|
|
34
|
-
- Ensure responsive design by considering different screen sizes and orientations.
|
|
35
|
-
- Optimize image handling using libraries designed for React Native
|
|
36
|
-
|
|
37
|
-
Best Practices:
|
|
38
|
-
- Follow React Native's threading model to ensure smooth UI performance.
|
|
39
|
-
- Utilize CodePush Build and Updates for continuous deployment and Over-The-Air (OTA) updates.
|
|
40
|
-
- Use React Navigation for handling navigation and deep linking with best practices.
|
|
41
|
-
|
package/README.zh-CN.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# React Native Debug Toolkit 使用文档
|
|
5
|
-
|
|
6
|
-
一个简单但功能强大的React Native调试工具包,提供便捷的开发期浮动界面。
|
|
7
|
-
|
|
8
|
-
## 安装
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install react-native-debug-toolkit
|
|
12
|
-
# 或
|
|
13
|
-
yarn add react-native-debug-toolkit
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### iOS 额外设置
|
|
17
|
-
|
|
18
|
-
该工具包使用FLEX和DoraemonKit提供iOS调试功能。请按以下步骤正确集成:
|
|
19
|
-
|
|
20
|
-
1. 确保项目中已安装CocoaPods
|
|
21
|
-
2. 在Podfile中添加以下依赖:
|
|
22
|
-
|
|
23
|
-
```ruby
|
|
24
|
-
pod 'FLEX', :configurations => ['Debug']
|
|
25
|
-
pod 'DoraemonKit/Core', :git => 'https://github.com/superzcj/DoKit.git', :configurations => ['Debug'] #必选
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
3. 在`didFinishLaunchingWithOptions`方法中的AppDelegate.m文件中添加以下代码:
|
|
29
|
-
|
|
30
|
-
```objc
|
|
31
|
-
#ifdef DEBUG
|
|
32
|
-
#import <DoraemonKit/DoraemonManager.h>
|
|
33
|
-
#endif
|
|
34
|
-
|
|
35
|
-
#ifdef DEBUG
|
|
36
|
-
DoraemonManager *doKit = [DoraemonManager shareInstance];
|
|
37
|
-
doKit.autoDock = false;
|
|
38
|
-
[doKit install];
|
|
39
|
-
[doKit hiddenDoraemon];
|
|
40
|
-
#endif
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
4. 在iOS目录中运行pod install:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
cd ios && pod install
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Android 额外设置
|
|
50
|
-
|
|
51
|
-
1. 在`android/settings.gradle`中添加以下内容:
|
|
52
|
-
|
|
53
|
-
```gradle
|
|
54
|
-
include ':react-native-debug-toolkit'
|
|
55
|
-
project(':react-native-debug-toolkit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-debug-toolkit/android')
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
2. 在`android/app/build.gradle`中添加以下依赖:
|
|
59
|
-
|
|
60
|
-
```gradle
|
|
61
|
-
dependencies {
|
|
62
|
-
// 其他依赖...
|
|
63
|
-
|
|
64
|
-
debugImplementation 'io.github.didi.dokit:dokitx:3.7.1'
|
|
65
|
-
releaseImplementation 'io.github.didi.dokit:dokitx-no-op:3.7.1'
|
|
66
|
-
debugImplementation 'com.android.volley:volley:1.2.0'
|
|
67
|
-
|
|
68
|
-
implementation project(':react-native-debug-toolkit')
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
3. 在`MainApplication.kt`中初始化DoKit:
|
|
73
|
-
|
|
74
|
-
```kotlin
|
|
75
|
-
import com.didichuxing.doraemonkit.DoKit
|
|
76
|
-
import com.reactnative.debuglibs.RNDebugLibsPackage
|
|
77
|
-
|
|
78
|
-
// 在getPackages方法内
|
|
79
|
-
add(RNDebugLibsPackage())
|
|
80
|
-
|
|
81
|
-
// 在onCreate方法内
|
|
82
|
-
if (BuildConfig.DEBUG) {
|
|
83
|
-
DoKit.Builder(this)
|
|
84
|
-
.build()
|
|
85
|
-
DoKit.hide()
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## 使用方法
|
|
90
|
-
|
|
91
|
-
将调试工具包添加到您的应用程序中非常简单,只需一行代码即可启用所有功能:
|
|
92
|
-
|
|
93
|
-
```javascript
|
|
94
|
-
// 在App.js或其他初始化文件中
|
|
95
|
-
import React, { useEffect } from 'react';
|
|
96
|
-
import { initializeDebugToolkit, isDebugMode } from 'react-native-debug-toolkit';
|
|
97
|
-
|
|
98
|
-
function App() {
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
if (isDebugMode) {
|
|
101
|
-
// 使用所有默认功能初始化
|
|
102
|
-
initializeDebugToolkit();
|
|
103
|
-
|
|
104
|
-
// 或选择特定的内置功能
|
|
105
|
-
// initializeDebugToolkit(['network', 'console', 'zustand', 'navigation', 'thirdPartyLibs']);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return () => {
|
|
109
|
-
// 自动清理
|
|
110
|
-
};
|
|
111
|
-
}, []);
|
|
112
|
-
|
|
113
|
-
return <YourApp />;
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
就这么简单!现在您的应用程序将在开发模式下显示一个浮动的调试面板,让您可以访问所有调试功能。
|
|
118
|
-
|
|
119
|
-
## 内置功能
|
|
120
|
-
|
|
121
|
-
通过上面的一行代码初始化,您将自动获得以下所有调试功能:
|
|
122
|
-
|
|
123
|
-
- **网络监控**:跟踪和检查所有网络请求和响应
|
|
124
|
-
- **控制台日志**:在应用内查看所有控制台日志输出
|
|
125
|
-
- **Zustand状态**:监控Zustand状态管理(如果您的应用使用Zustand)
|
|
126
|
-
- **导航跟踪**:自动记录应用内的导航事件
|
|
127
|
-
- **第三方调试工具**:快速访问原生调试工具(iOS的FLEX,iOS和Android的DoraemonKit)
|
|
128
|
-
|
|
129
|
-
## 集成
|
|
130
|
-
|
|
131
|
-
### 高级Axios网络跟踪
|
|
132
|
-
|
|
133
|
-
对于使用Axios的项目,您可以启用更详细的网络请求跟踪:
|
|
134
|
-
|
|
135
|
-
```javascript
|
|
136
|
-
import axios from 'axios';
|
|
137
|
-
import { createNetworkFeature, isDebugMode } from 'react-native-debug-toolkit';
|
|
138
|
-
|
|
139
|
-
// 获取网络功能实例并设置Axios拦截器
|
|
140
|
-
if (isDebugMode) {
|
|
141
|
-
const networkFeature = createNetworkFeature();
|
|
142
|
-
networkFeature.setupAxiosInterceptors(axios);
|
|
143
|
-
|
|
144
|
-
// 可选:排除敏感URL(如认证接口)
|
|
145
|
-
networkFeature.addUrlToBlacklist('api.example.com/auth');
|
|
146
|
-
networkFeature.addUrlToBlacklist(/password/i); // 支持正则表达式
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### 监控Zustand状态(如果您使用Zustand)
|
|
151
|
-
|
|
152
|
-
如果您的应用使用Zustand进行状态管理,只需添加中间件即可跟踪所有状态变化:
|
|
153
|
-
|
|
154
|
-
```javascript
|
|
155
|
-
import { create } from 'zustand';
|
|
156
|
-
import { zustandLogMiddleware } from 'react-native-debug-toolkit';
|
|
157
|
-
|
|
158
|
-
// 只需添加zustandLogMiddleware来包装您的store
|
|
159
|
-
const useStore = create(
|
|
160
|
-
zustandLogMiddleware(
|
|
161
|
-
(set) => ({
|
|
162
|
-
count: 0,
|
|
163
|
-
increment: () => set((state) => ({ count: state.count + 1 })),
|
|
164
|
-
decrement: () => set((state) => ({ count: state.count - 1 })),
|
|
165
|
-
})
|
|
166
|
-
)
|
|
167
|
-
);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### 导航跟踪(React Navigation)
|
|
171
|
-
|
|
172
|
-
如果您使用React Navigation,添加导航跟踪只需一步:
|
|
173
|
-
|
|
174
|
-
```javascript
|
|
175
|
-
import React, { useRef } from 'react';
|
|
176
|
-
import { NavigationContainer } from '@react-navigation/native';
|
|
177
|
-
import { useNavigationLogger } from 'react-native-debug-toolkit';
|
|
178
|
-
|
|
179
|
-
function AppNavigator() {
|
|
180
|
-
const navigationRef = useRef(null);
|
|
181
|
-
|
|
182
|
-
// 添加这一行来启用导航日志
|
|
183
|
-
useNavigationLogger(navigationRef);
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<NavigationContainer ref={navigationRef}>
|
|
187
|
-
{/* 您的导航配置 */}
|
|
188
|
-
</NavigationContainer>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## 自定义配置
|
|
194
|
-
|
|
195
|
-
如果您不需要所有功能,可以选择性地启用特定功能:
|
|
196
|
-
|
|
197
|
-
```javascript
|
|
198
|
-
// 只启用网络和控制台日志功能
|
|
199
|
-
initializeDebugToolkit(['network', 'console']);
|
|
200
|
-
|
|
201
|
-
// 或者指定一组自定义功能
|
|
202
|
-
initializeDebugToolkit([
|
|
203
|
-
'network',
|
|
204
|
-
'console',
|
|
205
|
-
'zustand',
|
|
206
|
-
'navigation',
|
|
207
|
-
'thirdPartyLibs'
|
|
208
|
-
]);
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## 常见问题排除
|
|
212
|
-
|
|
213
|
-
### 调试面板不显示
|
|
214
|
-
- 确保您在开发模式下(`isDebugMode`为true)
|
|
215
|
-
- 检查是否正确调用了`initializeDebugToolkit()`
|
|
216
|
-
|
|
217
|
-
### iOS功能不工作
|
|
218
|
-
- 确认您已将FLEX和DoraemonKit添加到Podfile
|
|
219
|
-
- 在修改后重新运行`pod install`
|
|
220
|
-
- 确保您正在运行Debug构建版本
|
|
221
|
-
|
|
222
|
-
### 网络请求未被捕获
|
|
223
|
-
- 对于Axios,请确保调用了`setupAxiosInterceptors(axios)`
|
|
224
|
-
- 对于fetch请求,工具包会自动拦截,无需额外配置
|
|
225
|
-
|
|
226
|
-
### 应用性能问题
|
|
227
|
-
- 此调试工具包仅适用于开发阶段,请确保生产构建中未包含
|
|
228
|
-
- 如果开发模式下性能受影响,可以尝试只启用特定功能
|
|
229
|
-
|
|
230
|
-
|