react-native-debug-toolkit 2.0.0 → 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/README.md +72 -72
- package/README.zh-CN.md +209 -0
- package/lib/commonjs/components/ClipboardTab.js +15 -16
- package/lib/commonjs/components/ClipboardTab.js.map +1 -1
- package/lib/commonjs/components/ConsoleLogTab.js +69 -202
- package/lib/commonjs/components/ConsoleLogTab.js.map +1 -1
- 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 +22 -23
- package/lib/commonjs/components/EnvironmentTab.js.map +1 -1
- 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 +140 -723
- package/lib/commonjs/components/FloatPanelView.js.map +1 -1
- package/lib/commonjs/components/NavigationLogTab.js +8 -8
- package/lib/commonjs/components/NavigationLogTab.js.map +1 -1
- package/lib/commonjs/components/NetworkLogTab.js +179 -350
- package/lib/commonjs/components/NetworkLogTab.js.map +1 -1
- package/lib/commonjs/components/ThirdPartyLibsTab.js +8 -8
- package/lib/commonjs/components/ThirdPartyLibsTab.js.map +1 -1
- package/lib/commonjs/components/TrackLogTab.js +106 -248
- package/lib/commonjs/components/TrackLogTab.js.map +1 -1
- package/lib/commonjs/components/ZustandLogTab.js +148 -288
- package/lib/commonjs/components/ZustandLogTab.js.map +1 -1
- package/lib/commonjs/components/shared/CollapsibleSection.js +4 -4
- package/lib/commonjs/components/shared/CollapsibleSection.js.map +1 -1
- package/lib/commonjs/components/shared/CopyButton.js +3 -3
- package/lib/commonjs/components/shared/CopyButton.js.map +1 -1
- 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 +92 -112
- package/lib/commonjs/core/DebugToolkit.js.map +1 -1
- package/lib/commonjs/core/DebugToolkitProvider.js +30 -28
- package/lib/commonjs/core/DebugToolkitProvider.js.map +1 -1
- package/lib/commonjs/features/ClipboardFeature.js +6 -2
- package/lib/commonjs/features/ClipboardFeature.js.map +1 -1
- package/lib/commonjs/features/ConsoleLogFeature.js +66 -49
- package/lib/commonjs/features/ConsoleLogFeature.js.map +1 -1
- package/lib/commonjs/features/EnvironmentFeature.js +5 -13
- package/lib/commonjs/features/EnvironmentFeature.js.map +1 -1
- package/lib/commonjs/features/NavigationLogFeature.js +17 -38
- package/lib/commonjs/features/NavigationLogFeature.js.map +1 -1
- package/lib/commonjs/features/NetworkFeature.js +35 -256
- package/lib/commonjs/features/NetworkFeature.js.map +1 -1
- package/lib/commonjs/features/TrackFeature.js +17 -38
- package/lib/commonjs/features/TrackFeature.js.map +1 -1
- package/lib/commonjs/features/ZustandLogFeature.js +21 -38
- package/lib/commonjs/features/ZustandLogFeature.js.map +1 -1
- package/lib/commonjs/hooks/useNavigationLogger.js.map +1 -1
- package/lib/commonjs/index.js +7 -20
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/initialize.js +19 -96
- package/lib/commonjs/initialize.js.map +1 -1
- package/lib/commonjs/interceptors/networkInterceptor.js +466 -0
- package/lib/commonjs/interceptors/networkInterceptor.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/createChannelFeature.js +48 -0
- package/lib/commonjs/utils/createChannelFeature.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/urlRewriterRegistry.js +14 -0
- package/lib/commonjs/utils/urlRewriterRegistry.js.map +1 -0
- package/lib/module/components/ClipboardTab.js +8 -8
- package/lib/module/components/ClipboardTab.js.map +1 -1
- package/lib/module/components/ConsoleLogTab.js +66 -199
- package/lib/module/components/ConsoleLogTab.js.map +1 -1
- 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 +3 -3
- package/lib/module/components/EnvironmentTab.js.map +1 -1
- 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 +141 -723
- package/lib/module/components/FloatPanelView.js.map +1 -1
- package/lib/module/components/NavigationLogTab.js +1 -1
- package/lib/module/components/NavigationLogTab.js.map +1 -1
- package/lib/module/components/NetworkLogTab.js +167 -338
- package/lib/module/components/NetworkLogTab.js.map +1 -1
- package/lib/module/components/ThirdPartyLibsTab.js +1 -1
- package/lib/module/components/ThirdPartyLibsTab.js.map +1 -1
- package/lib/module/components/TrackLogTab.js +94 -236
- package/lib/module/components/TrackLogTab.js.map +1 -1
- package/lib/module/components/ZustandLogTab.js +136 -276
- package/lib/module/components/ZustandLogTab.js.map +1 -1
- package/lib/module/components/shared/CollapsibleSection.js +1 -1
- package/lib/module/components/shared/CollapsibleSection.js.map +1 -1
- package/lib/module/components/shared/CopyButton.js +1 -1
- package/lib/module/components/shared/CopyButton.js.map +1 -1
- 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 +92 -111
- package/lib/module/core/DebugToolkit.js.map +1 -1
- package/lib/module/core/DebugToolkitProvider.js +31 -29
- package/lib/module/core/DebugToolkitProvider.js.map +1 -1
- package/lib/module/features/ClipboardFeature.js +6 -2
- package/lib/module/features/ClipboardFeature.js.map +1 -1
- package/lib/module/features/ConsoleLogFeature.js +65 -49
- package/lib/module/features/ConsoleLogFeature.js.map +1 -1
- package/lib/module/features/EnvironmentFeature.js +5 -13
- package/lib/module/features/EnvironmentFeature.js.map +1 -1
- package/lib/module/features/NavigationLogFeature.js +16 -38
- package/lib/module/features/NavigationLogFeature.js.map +1 -1
- package/lib/module/features/NetworkFeature.js +34 -255
- package/lib/module/features/NetworkFeature.js.map +1 -1
- package/lib/module/features/TrackFeature.js +16 -38
- package/lib/module/features/TrackFeature.js.map +1 -1
- package/lib/module/features/ZustandLogFeature.js +22 -38
- package/lib/module/features/ZustandLogFeature.js.map +1 -1
- package/lib/module/hooks/useNavigationLogger.js.map +1 -1
- package/lib/module/index.js +2 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/initialize.js +19 -95
- package/lib/module/initialize.js.map +1 -1
- package/lib/module/interceptors/networkInterceptor.js +460 -0
- package/lib/module/interceptors/networkInterceptor.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/createChannelFeature.js +44 -0
- package/lib/module/utils/createChannelFeature.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/urlRewriterRegistry.js +10 -0
- package/lib/module/utils/urlRewriterRegistry.js.map +1 -0
- package/lib/typescript/src/components/ClipboardTab.d.ts.map +1 -1
- package/lib/typescript/src/components/ConsoleLogTab.d.ts.map +1 -1
- 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.map +1 -1
- 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 +4 -59
- package/lib/typescript/src/components/FloatPanelView.d.ts.map +1 -1
- package/lib/typescript/src/components/NetworkLogTab.d.ts.map +1 -1
- package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts.map +1 -1
- package/lib/typescript/src/components/TrackLogTab.d.ts.map +1 -1
- package/lib/typescript/src/components/ZustandLogTab.d.ts.map +1 -1
- 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 +11 -18
- package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -1
- package/lib/typescript/src/core/DebugToolkitProvider.d.ts +2 -5
- package/lib/typescript/src/core/DebugToolkitProvider.d.ts.map +1 -1
- package/lib/typescript/src/features/ClipboardFeature.d.ts +4 -0
- package/lib/typescript/src/features/ClipboardFeature.d.ts.map +1 -1
- package/lib/typescript/src/features/ConsoleLogFeature.d.ts +2 -0
- package/lib/typescript/src/features/ConsoleLogFeature.d.ts.map +1 -1
- package/lib/typescript/src/features/EnvironmentFeature.d.ts.map +1 -1
- package/lib/typescript/src/features/NavigationLogFeature.d.ts +2 -0
- package/lib/typescript/src/features/NavigationLogFeature.d.ts.map +1 -1
- package/lib/typescript/src/features/NetworkFeature.d.ts +7 -20
- package/lib/typescript/src/features/NetworkFeature.d.ts.map +1 -1
- package/lib/typescript/src/features/TrackFeature.d.ts +2 -0
- package/lib/typescript/src/features/TrackFeature.d.ts.map +1 -1
- package/lib/typescript/src/features/ZustandLogFeature.d.ts +2 -0
- package/lib/typescript/src/features/ZustandLogFeature.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useNavigationLogger.d.ts +1 -8
- package/lib/typescript/src/hooks/useNavigationLogger.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/initialize.d.ts +3 -22
- package/lib/typescript/src/initialize.d.ts.map +1 -1
- 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/types/index.d.ts +26 -29
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- 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/createChannelFeature.d.ts +18 -0
- package/lib/typescript/src/utils/createChannelFeature.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/urlRewriterRegistry.d.ts +7 -0
- package/lib/typescript/src/utils/urlRewriterRegistry.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/components/ClipboardTab.tsx +8 -8
- package/src/components/ConsoleLogTab.tsx +49 -163
- package/src/components/DebugPanel.tsx +215 -0
- package/src/components/DebugView.tsx +80 -0
- package/src/components/EnvironmentTab.tsx +3 -3
- package/src/components/FeatureTabBar.tsx +204 -0
- package/src/components/FloatIcon.tsx +171 -0
- package/src/components/FloatPanelView.tsx +135 -647
- package/src/components/NavigationLogTab.tsx +1 -1
- package/src/components/NetworkLogTab.tsx +128 -269
- package/src/components/ThirdPartyLibsTab.tsx +3 -3
- package/src/components/TrackLogTab.tsx +53 -188
- package/src/components/ZustandLogTab.tsx +79 -181
- package/src/components/shared/CollapsibleSection.tsx +1 -1
- package/src/components/shared/CopyButton.tsx +1 -1
- package/src/components/shared/LogListScreen.tsx +164 -0
- package/src/core/DebugToolkit.tsx +114 -138
- package/src/core/DebugToolkitProvider.tsx +32 -38
- package/src/features/ClipboardFeature.ts +6 -2
- package/src/features/ConsoleLogFeature.ts +66 -68
- package/src/features/EnvironmentFeature.ts +5 -13
- package/src/features/NavigationLogFeature.ts +12 -42
- package/src/features/NetworkFeature.ts +43 -405
- package/src/features/TrackFeature.ts +14 -49
- package/src/features/ZustandLogFeature.ts +16 -42
- package/src/hooks/useNavigationLogger.ts +1 -6
- package/src/index.ts +5 -9
- package/src/initialize.ts +28 -120
- package/src/interceptors/networkInterceptor.ts +646 -0
- package/src/types/index.ts +25 -36
- package/src/utils/colors.ts +38 -0
- package/src/utils/createChannelFeature.ts +55 -0
- package/src/utils/layout.ts +1 -0
- package/src/utils/urlRewriterRegistry.ts +10 -0
- package/lib/commonjs/utils/constants.js +0 -135
- package/lib/commonjs/utils/constants.js.map +0 -1
- package/lib/module/utils/constants.js +0 -130
- package/lib/module/utils/constants.js.map +0 -1
- package/lib/typescript/src/utils/constants.d.ts +0 -96
- package/lib/typescript/src/utils/constants.d.ts.map +0 -1
- package/src/utils/constants.ts +0 -91
package/src/index.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// Core
|
|
2
2
|
export { DebugToolkit } from './core/DebugToolkit';
|
|
3
3
|
export { DebugToolkitProvider, useDebugToolkit } from './core/DebugToolkitProvider';
|
|
4
|
-
export {
|
|
4
|
+
export { DebugView } from './components/DebugView';
|
|
5
|
+
export type { DebugViewProps } from './components/DebugView';
|
|
6
|
+
export { initializeDebugToolkit } from './initialize';
|
|
5
7
|
export type { InitializeOptions, FeatureConfigs } from './initialize';
|
|
6
8
|
|
|
7
9
|
// Feature factories
|
|
8
10
|
export { createNetworkFeature } from './features/NetworkFeature';
|
|
9
|
-
export type {
|
|
11
|
+
export type { NetworkFeatureConfig, AxiosInstanceLike } from './features/NetworkFeature';
|
|
10
12
|
export { createConsoleLogFeature } from './features/ConsoleLogFeature';
|
|
11
13
|
export type { ConsoleFeatureConfig } from './features/ConsoleLogFeature';
|
|
12
14
|
export { createZustandLogFeature, zustandLogMiddleware, addZustandLog } from './features/ZustandLogFeature';
|
|
@@ -15,14 +17,12 @@ export { createNavigationLogFeature, addNavigationLog } from './features/Navigat
|
|
|
15
17
|
export type { NavigationFeatureConfig } from './features/NavigationLogFeature';
|
|
16
18
|
export { createTrackFeature, addTrackLog } from './features/TrackFeature';
|
|
17
19
|
export type { TrackFeatureConfig, TrackEventData } from './features/TrackFeature';
|
|
18
|
-
export { createThirdPartyLibsFeature } from './features/ThirdPartyLibsFeature';
|
|
19
20
|
export { createEnvironmentFeature } from './features/EnvironmentFeature';
|
|
20
21
|
export type { EnvironmentFeatureAPI } from './features/EnvironmentFeature';
|
|
21
22
|
export { createClipboardFeature } from './features/ClipboardFeature';
|
|
22
23
|
|
|
23
24
|
// Hooks
|
|
24
25
|
export { useNavigationLogger } from './hooks/useNavigationLogger';
|
|
25
|
-
export { useSlideDetailAnimation } from './hooks/useSlideDetailAnimation';
|
|
26
26
|
|
|
27
27
|
// Utilities
|
|
28
28
|
export { safeStringify } from './utils/safeStringify';
|
|
@@ -31,19 +31,15 @@ export type { CopyResult, CopyOptions, CopyMethod } from './utils/copyToComputer
|
|
|
31
31
|
|
|
32
32
|
// Types
|
|
33
33
|
export type {
|
|
34
|
+
AnyDebugFeature,
|
|
34
35
|
BuiltInFeatureName,
|
|
35
36
|
DebugFeature,
|
|
36
|
-
DebugFeatureFactory,
|
|
37
|
-
DebugFeatureInput,
|
|
38
37
|
DebugFeatureRenderProps,
|
|
39
|
-
DebugToolkitConfig,
|
|
40
|
-
DebugToolkitAPI,
|
|
41
38
|
NetworkLogEntry,
|
|
42
39
|
ConsoleLogEntry,
|
|
43
40
|
ZustandLogEntry,
|
|
44
41
|
NavigationLogEntry,
|
|
45
42
|
TrackLogEntry,
|
|
46
|
-
ThirdPartyLib,
|
|
47
43
|
EnvironmentConfig,
|
|
48
44
|
EnvironmentState,
|
|
49
45
|
} from './types';
|
package/src/initialize.ts
CHANGED
|
@@ -9,17 +9,11 @@ import { createNavigationLogFeature } from './features/NavigationLogFeature';
|
|
|
9
9
|
import type { NavigationFeatureConfig } from './features/NavigationLogFeature';
|
|
10
10
|
import { createTrackFeature } from './features/TrackFeature';
|
|
11
11
|
import type { TrackFeatureConfig } from './features/TrackFeature';
|
|
12
|
-
import { createThirdPartyLibsFeature } from './features/ThirdPartyLibsFeature';
|
|
13
12
|
import { createEnvironmentFeature } from './features/EnvironmentFeature';
|
|
14
13
|
import { createClipboardFeature } from './features/ClipboardFeature';
|
|
15
|
-
import {
|
|
16
|
-
import type {
|
|
17
|
-
BuiltInFeatureName,
|
|
18
|
-
DebugFeature,
|
|
19
|
-
DebugFeatureInput,
|
|
20
|
-
} from './types';
|
|
14
|
+
import type { AnyDebugFeature, BuiltInFeatureName } from './types';
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
const isDebugMode = __DEV__;
|
|
23
17
|
|
|
24
18
|
/** Feature-specific configuration map */
|
|
25
19
|
export interface FeatureConfigs {
|
|
@@ -28,25 +22,24 @@ export interface FeatureConfigs {
|
|
|
28
22
|
zustand?: boolean | ZustandFeatureConfig;
|
|
29
23
|
navigation?: boolean | NavigationFeatureConfig;
|
|
30
24
|
track?: boolean | TrackFeatureConfig;
|
|
31
|
-
thirdPartyLibs?: boolean;
|
|
32
25
|
environment?: Parameters<typeof createEnvironmentFeature>[0];
|
|
33
26
|
clipboard?: boolean;
|
|
34
27
|
}
|
|
35
28
|
|
|
36
29
|
export interface InitializeOptions {
|
|
37
|
-
|
|
30
|
+
features?: FeatureConfigs;
|
|
38
31
|
enabled?: boolean;
|
|
39
32
|
}
|
|
40
33
|
|
|
41
34
|
/** Registry mapping feature names to creator functions */
|
|
35
|
+
// Config param requires `any` — each factory accepts a different config type.
|
|
42
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
const featureRegistry: Record<BuiltInFeatureName, (config?: any) =>
|
|
37
|
+
const featureRegistry: Record<BuiltInFeatureName, (config?: any) => AnyDebugFeature> = {
|
|
44
38
|
network: createNetworkFeature,
|
|
45
39
|
console: createConsoleLogFeature,
|
|
46
40
|
zustand: createZustandLogFeature,
|
|
47
41
|
navigation: createNavigationLogFeature,
|
|
48
42
|
track: createTrackFeature,
|
|
49
|
-
thirdPartyLibs: createThirdPartyLibsFeature,
|
|
50
43
|
environment: createEnvironmentFeature,
|
|
51
44
|
clipboard: createClipboardFeature,
|
|
52
45
|
};
|
|
@@ -57,55 +50,14 @@ const DEFAULT_FEATURES: BuiltInFeatureName[] = [
|
|
|
57
50
|
'navigation',
|
|
58
51
|
'zustand',
|
|
59
52
|
'track',
|
|
60
|
-
'thirdPartyLibs',
|
|
61
53
|
'clipboard',
|
|
62
54
|
];
|
|
63
55
|
|
|
64
|
-
function
|
|
65
|
-
features:
|
|
66
|
-
): DebugFeature<any>[] {
|
|
67
|
-
return features.reduce<DebugFeature<any>[]>((resolvedFeatures, identifier) => {
|
|
68
|
-
let feature: DebugFeature<any> | null = null;
|
|
69
|
-
|
|
70
|
-
if (typeof identifier === 'string') {
|
|
71
|
-
const creator = featureRegistry[identifier as BuiltInFeatureName];
|
|
72
|
-
if (!creator) {
|
|
73
|
-
console.warn(`[DebugToolkit] Unknown feature: "${identifier}"`);
|
|
74
|
-
return resolvedFeatures;
|
|
75
|
-
}
|
|
76
|
-
feature = creator();
|
|
77
|
-
} else if (typeof identifier === 'function') {
|
|
78
|
-
try {
|
|
79
|
-
feature = identifier();
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error('[DebugToolkit] Feature creator failed:', error);
|
|
82
|
-
return resolvedFeatures;
|
|
83
|
-
}
|
|
84
|
-
} else if (identifier && typeof identifier === 'object' && identifier.name) {
|
|
85
|
-
feature = identifier;
|
|
86
|
-
} else {
|
|
87
|
-
console.warn('[DebugToolkit] Invalid feature identifier:', identifier);
|
|
88
|
-
return resolvedFeatures;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (feature) {
|
|
92
|
-
resolvedFeatures.push(feature);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return resolvedFeatures;
|
|
96
|
-
}, []);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Resolve feature configs to DebugFeature instances.
|
|
101
|
-
*/
|
|
102
|
-
function resolveFeatureConfigs(configs: FeatureConfigs): DebugFeature<any>[] {
|
|
103
|
-
const features: DebugFeature<any>[] = [];
|
|
104
|
-
|
|
56
|
+
function resolveFeatureConfigs(configs: FeatureConfigs): AnyDebugFeature[] {
|
|
57
|
+
const features: AnyDebugFeature[] = [];
|
|
105
58
|
const entries = Object.entries(configs) as [BuiltInFeatureName, unknown][];
|
|
106
59
|
|
|
107
60
|
for (const [name, config] of entries) {
|
|
108
|
-
// Skip false/explicitly disabled
|
|
109
61
|
if (config === false) continue;
|
|
110
62
|
|
|
111
63
|
const creator = featureRegistry[name];
|
|
@@ -114,7 +66,6 @@ function resolveFeatureConfigs(configs: FeatureConfigs): DebugFeature<any>[] {
|
|
|
114
66
|
continue;
|
|
115
67
|
}
|
|
116
68
|
|
|
117
|
-
// config === true or undefined → use defaults
|
|
118
69
|
if (config === true || config === undefined) {
|
|
119
70
|
features.push(creator());
|
|
120
71
|
} else if (typeof config === 'object') {
|
|
@@ -125,90 +76,47 @@ function resolveFeatureConfigs(configs: FeatureConfigs): DebugFeature<any>[] {
|
|
|
125
76
|
return features;
|
|
126
77
|
}
|
|
127
78
|
|
|
79
|
+
function resolveDefaultFeatures(): AnyDebugFeature[] {
|
|
80
|
+
return DEFAULT_FEATURES.map((name) => featureRegistry[name]!());
|
|
81
|
+
}
|
|
82
|
+
|
|
128
83
|
/**
|
|
129
84
|
* Initialize the debug toolkit.
|
|
130
85
|
*
|
|
131
|
-
* @param featuresOrOptions - Either an array of feature inputs (legacy), or a full config object.
|
|
132
|
-
* @param options - Options when using legacy array mode.
|
|
133
|
-
*
|
|
134
86
|
* @example
|
|
135
|
-
* // Legacy mode (still supported)
|
|
136
|
-
* initializeDebugToolkit(['network', 'console'], { enabled: true });
|
|
137
|
-
*
|
|
138
|
-
* // Config object mode (recommended)
|
|
139
87
|
* initializeDebugToolkit({
|
|
140
|
-
* features: {
|
|
141
|
-
* network: { maxLogs: 100 },
|
|
142
|
-
* console: true,
|
|
143
|
-
* track: true,
|
|
144
|
-
* environment: { environments: [...] },
|
|
145
|
-
* },
|
|
88
|
+
* features: { network: true, console: true },
|
|
146
89
|
* enabled: true,
|
|
147
90
|
* });
|
|
148
91
|
*/
|
|
149
92
|
export function initializeDebugToolkit(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// Determine which mode we're in
|
|
158
|
-
let resolvedFeatures: DebugFeature<any>[];
|
|
159
|
-
let enabled: boolean;
|
|
160
|
-
let doraemonProductId: string | undefined;
|
|
161
|
-
|
|
162
|
-
if (Array.isArray(featuresOrOptions)) {
|
|
163
|
-
// Legacy mode
|
|
164
|
-
resolvedFeatures = resolveFeatures(featuresOrOptions);
|
|
165
|
-
enabled = options.enabled ?? isDebugMode;
|
|
166
|
-
doraemonProductId = options.doraemonProductId;
|
|
167
|
-
} else if (featuresOrOptions && typeof featuresOrOptions === 'object' && !('name' in featuresOrOptions)) {
|
|
168
|
-
// Config object mode
|
|
169
|
-
const config = featuresOrOptions;
|
|
170
|
-
enabled = config.enabled ?? isDebugMode;
|
|
171
|
-
doraemonProductId = config.doraemonProductId;
|
|
172
|
-
|
|
173
|
-
if (config.features) {
|
|
174
|
-
resolvedFeatures = resolveFeatureConfigs(config.features);
|
|
175
|
-
} else {
|
|
176
|
-
resolvedFeatures = resolveFeatures(DEFAULT_FEATURES);
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
// Default - no args or single feature
|
|
180
|
-
resolvedFeatures = resolveFeatures(
|
|
181
|
-
featuresOrOptions ? [featuresOrOptions as DebugFeatureInput] : DEFAULT_FEATURES,
|
|
182
|
-
);
|
|
183
|
-
enabled = options.enabled ?? isDebugMode;
|
|
184
|
-
doraemonProductId = options.doraemonProductId;
|
|
185
|
-
}
|
|
93
|
+
options?: InitializeOptions,
|
|
94
|
+
): typeof DebugToolkit {
|
|
95
|
+
const enabled = options?.enabled ?? isDebugMode;
|
|
96
|
+
|
|
97
|
+
const resolvedFeatures = options?.features
|
|
98
|
+
? resolveFeatureConfigs(options.features)
|
|
99
|
+
: resolveDefaultFeatures();
|
|
186
100
|
|
|
187
101
|
try {
|
|
188
|
-
|
|
189
|
-
toolkit.setEnabled(enabled);
|
|
102
|
+
DebugToolkit.setEnabled(enabled);
|
|
190
103
|
|
|
191
104
|
if (!enabled) {
|
|
192
|
-
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Initialize native debug libs if configured
|
|
197
|
-
if (doraemonProductId) {
|
|
198
|
-
NativeDebugLibs.installDoraemonKit(doraemonProductId);
|
|
105
|
+
DebugToolkit.reset();
|
|
106
|
+
return DebugToolkit;
|
|
199
107
|
}
|
|
200
108
|
|
|
201
|
-
|
|
109
|
+
DebugToolkit.replaceFeatures(resolvedFeatures);
|
|
202
110
|
|
|
203
|
-
if (
|
|
204
|
-
|
|
111
|
+
if (DebugToolkit.hasFeatures()) {
|
|
112
|
+
DebugToolkit.showPanel();
|
|
205
113
|
} else {
|
|
206
|
-
|
|
114
|
+
DebugToolkit.hidePanel();
|
|
207
115
|
}
|
|
208
116
|
|
|
209
|
-
return
|
|
117
|
+
return DebugToolkit;
|
|
210
118
|
} catch (error) {
|
|
211
119
|
console.error('[DebugToolkit] Initialization failed:', error);
|
|
212
|
-
return
|
|
120
|
+
return DebugToolkit;
|
|
213
121
|
}
|
|
214
122
|
}
|