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.
Files changed (228) hide show
  1. package/README.md +72 -72
  2. package/README.zh-CN.md +209 -0
  3. package/lib/commonjs/components/ClipboardTab.js +15 -16
  4. package/lib/commonjs/components/ClipboardTab.js.map +1 -1
  5. package/lib/commonjs/components/ConsoleLogTab.js +69 -202
  6. package/lib/commonjs/components/ConsoleLogTab.js.map +1 -1
  7. package/lib/commonjs/components/DebugPanel.js +230 -0
  8. package/lib/commonjs/components/DebugPanel.js.map +1 -0
  9. package/lib/commonjs/components/DebugView.js +66 -0
  10. package/lib/commonjs/components/DebugView.js.map +1 -0
  11. package/lib/commonjs/components/EnvironmentTab.js +22 -23
  12. package/lib/commonjs/components/EnvironmentTab.js.map +1 -1
  13. package/lib/commonjs/components/FeatureTabBar.js +182 -0
  14. package/lib/commonjs/components/FeatureTabBar.js.map +1 -0
  15. package/lib/commonjs/components/FloatIcon.js +187 -0
  16. package/lib/commonjs/components/FloatIcon.js.map +1 -0
  17. package/lib/commonjs/components/FloatPanelView.js +140 -723
  18. package/lib/commonjs/components/FloatPanelView.js.map +1 -1
  19. package/lib/commonjs/components/NavigationLogTab.js +8 -8
  20. package/lib/commonjs/components/NavigationLogTab.js.map +1 -1
  21. package/lib/commonjs/components/NetworkLogTab.js +179 -350
  22. package/lib/commonjs/components/NetworkLogTab.js.map +1 -1
  23. package/lib/commonjs/components/ThirdPartyLibsTab.js +8 -8
  24. package/lib/commonjs/components/ThirdPartyLibsTab.js.map +1 -1
  25. package/lib/commonjs/components/TrackLogTab.js +106 -248
  26. package/lib/commonjs/components/TrackLogTab.js.map +1 -1
  27. package/lib/commonjs/components/ZustandLogTab.js +148 -288
  28. package/lib/commonjs/components/ZustandLogTab.js.map +1 -1
  29. package/lib/commonjs/components/shared/CollapsibleSection.js +4 -4
  30. package/lib/commonjs/components/shared/CollapsibleSection.js.map +1 -1
  31. package/lib/commonjs/components/shared/CopyButton.js +3 -3
  32. package/lib/commonjs/components/shared/CopyButton.js.map +1 -1
  33. package/lib/commonjs/components/shared/LogListScreen.js +174 -0
  34. package/lib/commonjs/components/shared/LogListScreen.js.map +1 -0
  35. package/lib/commonjs/core/DebugToolkit.js +92 -112
  36. package/lib/commonjs/core/DebugToolkit.js.map +1 -1
  37. package/lib/commonjs/core/DebugToolkitProvider.js +30 -28
  38. package/lib/commonjs/core/DebugToolkitProvider.js.map +1 -1
  39. package/lib/commonjs/features/ClipboardFeature.js +6 -2
  40. package/lib/commonjs/features/ClipboardFeature.js.map +1 -1
  41. package/lib/commonjs/features/ConsoleLogFeature.js +66 -49
  42. package/lib/commonjs/features/ConsoleLogFeature.js.map +1 -1
  43. package/lib/commonjs/features/EnvironmentFeature.js +5 -13
  44. package/lib/commonjs/features/EnvironmentFeature.js.map +1 -1
  45. package/lib/commonjs/features/NavigationLogFeature.js +17 -38
  46. package/lib/commonjs/features/NavigationLogFeature.js.map +1 -1
  47. package/lib/commonjs/features/NetworkFeature.js +35 -256
  48. package/lib/commonjs/features/NetworkFeature.js.map +1 -1
  49. package/lib/commonjs/features/TrackFeature.js +17 -38
  50. package/lib/commonjs/features/TrackFeature.js.map +1 -1
  51. package/lib/commonjs/features/ZustandLogFeature.js +21 -38
  52. package/lib/commonjs/features/ZustandLogFeature.js.map +1 -1
  53. package/lib/commonjs/hooks/useNavigationLogger.js.map +1 -1
  54. package/lib/commonjs/index.js +7 -20
  55. package/lib/commonjs/index.js.map +1 -1
  56. package/lib/commonjs/initialize.js +19 -96
  57. package/lib/commonjs/initialize.js.map +1 -1
  58. package/lib/commonjs/interceptors/networkInterceptor.js +466 -0
  59. package/lib/commonjs/interceptors/networkInterceptor.js.map +1 -0
  60. package/lib/commonjs/utils/colors.js +48 -0
  61. package/lib/commonjs/utils/colors.js.map +1 -0
  62. package/lib/commonjs/utils/createChannelFeature.js +48 -0
  63. package/lib/commonjs/utils/createChannelFeature.js.map +1 -0
  64. package/lib/commonjs/utils/layout.js +8 -0
  65. package/lib/commonjs/utils/layout.js.map +1 -0
  66. package/lib/commonjs/utils/urlRewriterRegistry.js +14 -0
  67. package/lib/commonjs/utils/urlRewriterRegistry.js.map +1 -0
  68. package/lib/module/components/ClipboardTab.js +8 -8
  69. package/lib/module/components/ClipboardTab.js.map +1 -1
  70. package/lib/module/components/ConsoleLogTab.js +66 -199
  71. package/lib/module/components/ConsoleLogTab.js.map +1 -1
  72. package/lib/module/components/DebugPanel.js +225 -0
  73. package/lib/module/components/DebugPanel.js.map +1 -0
  74. package/lib/module/components/DebugView.js +61 -0
  75. package/lib/module/components/DebugView.js.map +1 -0
  76. package/lib/module/components/EnvironmentTab.js +3 -3
  77. package/lib/module/components/EnvironmentTab.js.map +1 -1
  78. package/lib/module/components/FeatureTabBar.js +177 -0
  79. package/lib/module/components/FeatureTabBar.js.map +1 -0
  80. package/lib/module/components/FloatIcon.js +182 -0
  81. package/lib/module/components/FloatIcon.js.map +1 -0
  82. package/lib/module/components/FloatPanelView.js +141 -723
  83. package/lib/module/components/FloatPanelView.js.map +1 -1
  84. package/lib/module/components/NavigationLogTab.js +1 -1
  85. package/lib/module/components/NavigationLogTab.js.map +1 -1
  86. package/lib/module/components/NetworkLogTab.js +167 -338
  87. package/lib/module/components/NetworkLogTab.js.map +1 -1
  88. package/lib/module/components/ThirdPartyLibsTab.js +1 -1
  89. package/lib/module/components/ThirdPartyLibsTab.js.map +1 -1
  90. package/lib/module/components/TrackLogTab.js +94 -236
  91. package/lib/module/components/TrackLogTab.js.map +1 -1
  92. package/lib/module/components/ZustandLogTab.js +136 -276
  93. package/lib/module/components/ZustandLogTab.js.map +1 -1
  94. package/lib/module/components/shared/CollapsibleSection.js +1 -1
  95. package/lib/module/components/shared/CollapsibleSection.js.map +1 -1
  96. package/lib/module/components/shared/CopyButton.js +1 -1
  97. package/lib/module/components/shared/CopyButton.js.map +1 -1
  98. package/lib/module/components/shared/LogListScreen.js +169 -0
  99. package/lib/module/components/shared/LogListScreen.js.map +1 -0
  100. package/lib/module/core/DebugToolkit.js +92 -111
  101. package/lib/module/core/DebugToolkit.js.map +1 -1
  102. package/lib/module/core/DebugToolkitProvider.js +31 -29
  103. package/lib/module/core/DebugToolkitProvider.js.map +1 -1
  104. package/lib/module/features/ClipboardFeature.js +6 -2
  105. package/lib/module/features/ClipboardFeature.js.map +1 -1
  106. package/lib/module/features/ConsoleLogFeature.js +65 -49
  107. package/lib/module/features/ConsoleLogFeature.js.map +1 -1
  108. package/lib/module/features/EnvironmentFeature.js +5 -13
  109. package/lib/module/features/EnvironmentFeature.js.map +1 -1
  110. package/lib/module/features/NavigationLogFeature.js +16 -38
  111. package/lib/module/features/NavigationLogFeature.js.map +1 -1
  112. package/lib/module/features/NetworkFeature.js +34 -255
  113. package/lib/module/features/NetworkFeature.js.map +1 -1
  114. package/lib/module/features/TrackFeature.js +16 -38
  115. package/lib/module/features/TrackFeature.js.map +1 -1
  116. package/lib/module/features/ZustandLogFeature.js +22 -38
  117. package/lib/module/features/ZustandLogFeature.js.map +1 -1
  118. package/lib/module/hooks/useNavigationLogger.js.map +1 -1
  119. package/lib/module/index.js +2 -3
  120. package/lib/module/index.js.map +1 -1
  121. package/lib/module/initialize.js +19 -95
  122. package/lib/module/initialize.js.map +1 -1
  123. package/lib/module/interceptors/networkInterceptor.js +460 -0
  124. package/lib/module/interceptors/networkInterceptor.js.map +1 -0
  125. package/lib/module/utils/colors.js +43 -0
  126. package/lib/module/utils/colors.js.map +1 -0
  127. package/lib/module/utils/createChannelFeature.js +44 -0
  128. package/lib/module/utils/createChannelFeature.js.map +1 -0
  129. package/lib/module/utils/layout.js +4 -0
  130. package/lib/module/utils/layout.js.map +1 -0
  131. package/lib/module/utils/urlRewriterRegistry.js +10 -0
  132. package/lib/module/utils/urlRewriterRegistry.js.map +1 -0
  133. package/lib/typescript/src/components/ClipboardTab.d.ts.map +1 -1
  134. package/lib/typescript/src/components/ConsoleLogTab.d.ts.map +1 -1
  135. package/lib/typescript/src/components/DebugPanel.d.ts +9 -0
  136. package/lib/typescript/src/components/DebugPanel.d.ts.map +1 -0
  137. package/lib/typescript/src/components/DebugView.d.ts +19 -0
  138. package/lib/typescript/src/components/DebugView.d.ts.map +1 -0
  139. package/lib/typescript/src/components/EnvironmentTab.d.ts.map +1 -1
  140. package/lib/typescript/src/components/FeatureTabBar.d.ts +13 -0
  141. package/lib/typescript/src/components/FeatureTabBar.d.ts.map +1 -0
  142. package/lib/typescript/src/components/FloatIcon.d.ts +12 -0
  143. package/lib/typescript/src/components/FloatIcon.d.ts.map +1 -0
  144. package/lib/typescript/src/components/FloatPanelView.d.ts +4 -59
  145. package/lib/typescript/src/components/FloatPanelView.d.ts.map +1 -1
  146. package/lib/typescript/src/components/NetworkLogTab.d.ts.map +1 -1
  147. package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts.map +1 -1
  148. package/lib/typescript/src/components/TrackLogTab.d.ts.map +1 -1
  149. package/lib/typescript/src/components/ZustandLogTab.d.ts.map +1 -1
  150. package/lib/typescript/src/components/shared/LogListScreen.d.ts +21 -0
  151. package/lib/typescript/src/components/shared/LogListScreen.d.ts.map +1 -0
  152. package/lib/typescript/src/core/DebugToolkit.d.ts +11 -18
  153. package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -1
  154. package/lib/typescript/src/core/DebugToolkitProvider.d.ts +2 -5
  155. package/lib/typescript/src/core/DebugToolkitProvider.d.ts.map +1 -1
  156. package/lib/typescript/src/features/ClipboardFeature.d.ts +4 -0
  157. package/lib/typescript/src/features/ClipboardFeature.d.ts.map +1 -1
  158. package/lib/typescript/src/features/ConsoleLogFeature.d.ts +2 -0
  159. package/lib/typescript/src/features/ConsoleLogFeature.d.ts.map +1 -1
  160. package/lib/typescript/src/features/EnvironmentFeature.d.ts.map +1 -1
  161. package/lib/typescript/src/features/NavigationLogFeature.d.ts +2 -0
  162. package/lib/typescript/src/features/NavigationLogFeature.d.ts.map +1 -1
  163. package/lib/typescript/src/features/NetworkFeature.d.ts +7 -20
  164. package/lib/typescript/src/features/NetworkFeature.d.ts.map +1 -1
  165. package/lib/typescript/src/features/TrackFeature.d.ts +2 -0
  166. package/lib/typescript/src/features/TrackFeature.d.ts.map +1 -1
  167. package/lib/typescript/src/features/ZustandLogFeature.d.ts +2 -0
  168. package/lib/typescript/src/features/ZustandLogFeature.d.ts.map +1 -1
  169. package/lib/typescript/src/hooks/useNavigationLogger.d.ts +1 -8
  170. package/lib/typescript/src/hooks/useNavigationLogger.d.ts.map +1 -1
  171. package/lib/typescript/src/index.d.ts +5 -5
  172. package/lib/typescript/src/index.d.ts.map +1 -1
  173. package/lib/typescript/src/initialize.d.ts +3 -22
  174. package/lib/typescript/src/initialize.d.ts.map +1 -1
  175. package/lib/typescript/src/interceptors/networkInterceptor.d.ts +18 -0
  176. package/lib/typescript/src/interceptors/networkInterceptor.d.ts.map +1 -0
  177. package/lib/typescript/src/types/index.d.ts +26 -29
  178. package/lib/typescript/src/types/index.d.ts.map +1 -1
  179. package/lib/typescript/src/utils/colors.d.ts +21 -0
  180. package/lib/typescript/src/utils/colors.d.ts.map +1 -0
  181. package/lib/typescript/src/utils/createChannelFeature.d.ts +18 -0
  182. package/lib/typescript/src/utils/createChannelFeature.d.ts.map +1 -0
  183. package/lib/typescript/src/utils/layout.d.ts +2 -0
  184. package/lib/typescript/src/utils/layout.d.ts.map +1 -0
  185. package/lib/typescript/src/utils/urlRewriterRegistry.d.ts +7 -0
  186. package/lib/typescript/src/utils/urlRewriterRegistry.d.ts.map +1 -0
  187. package/package.json +5 -1
  188. package/src/components/ClipboardTab.tsx +8 -8
  189. package/src/components/ConsoleLogTab.tsx +49 -163
  190. package/src/components/DebugPanel.tsx +215 -0
  191. package/src/components/DebugView.tsx +80 -0
  192. package/src/components/EnvironmentTab.tsx +3 -3
  193. package/src/components/FeatureTabBar.tsx +204 -0
  194. package/src/components/FloatIcon.tsx +171 -0
  195. package/src/components/FloatPanelView.tsx +135 -647
  196. package/src/components/NavigationLogTab.tsx +1 -1
  197. package/src/components/NetworkLogTab.tsx +128 -269
  198. package/src/components/ThirdPartyLibsTab.tsx +3 -3
  199. package/src/components/TrackLogTab.tsx +53 -188
  200. package/src/components/ZustandLogTab.tsx +79 -181
  201. package/src/components/shared/CollapsibleSection.tsx +1 -1
  202. package/src/components/shared/CopyButton.tsx +1 -1
  203. package/src/components/shared/LogListScreen.tsx +164 -0
  204. package/src/core/DebugToolkit.tsx +114 -138
  205. package/src/core/DebugToolkitProvider.tsx +32 -38
  206. package/src/features/ClipboardFeature.ts +6 -2
  207. package/src/features/ConsoleLogFeature.ts +66 -68
  208. package/src/features/EnvironmentFeature.ts +5 -13
  209. package/src/features/NavigationLogFeature.ts +12 -42
  210. package/src/features/NetworkFeature.ts +43 -405
  211. package/src/features/TrackFeature.ts +14 -49
  212. package/src/features/ZustandLogFeature.ts +16 -42
  213. package/src/hooks/useNavigationLogger.ts +1 -6
  214. package/src/index.ts +5 -9
  215. package/src/initialize.ts +28 -120
  216. package/src/interceptors/networkInterceptor.ts +646 -0
  217. package/src/types/index.ts +25 -36
  218. package/src/utils/colors.ts +38 -0
  219. package/src/utils/createChannelFeature.ts +55 -0
  220. package/src/utils/layout.ts +1 -0
  221. package/src/utils/urlRewriterRegistry.ts +10 -0
  222. package/lib/commonjs/utils/constants.js +0 -135
  223. package/lib/commonjs/utils/constants.js.map +0 -1
  224. package/lib/module/utils/constants.js +0 -130
  225. package/lib/module/utils/constants.js.map +0 -1
  226. package/lib/typescript/src/utils/constants.d.ts +0 -96
  227. package/lib/typescript/src/utils/constants.d.ts.map +0 -1
  228. 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 { initializeDebugToolkit, isDebugMode } from './initialize';
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 { NetworkFeatureAPI, NetworkFeatureConfig } from './features/NetworkFeature';
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 { NativeDebugLibs } from './native/NativeDebugLibs';
16
- import type {
17
- BuiltInFeatureName,
18
- DebugFeature,
19
- DebugFeatureInput,
20
- } from './types';
14
+ import type { AnyDebugFeature, BuiltInFeatureName } from './types';
21
15
 
22
- export const isDebugMode = __DEV__;
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
- doraemonProductId?: string;
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) => DebugFeature<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 resolveFeatures(
65
- features: DebugFeatureInput[],
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
- featuresOrOptions?: DebugFeatureInput[] | {
151
- features?: FeatureConfigs;
152
- enabled?: boolean;
153
- doraemonProductId?: string;
154
- },
155
- options: InitializeOptions = {},
156
- ): DebugToolkit | null {
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
- const toolkit = DebugToolkit.getInstance(enabled);
189
- toolkit.setEnabled(enabled);
102
+ DebugToolkit.setEnabled(enabled);
190
103
 
191
104
  if (!enabled) {
192
- toolkit.reset();
193
- return toolkit;
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
- toolkit.replaceFeatures(resolvedFeatures);
109
+ DebugToolkit.replaceFeatures(resolvedFeatures);
202
110
 
203
- if (toolkit.hasFeatures()) {
204
- toolkit.showPanel();
111
+ if (DebugToolkit.hasFeatures()) {
112
+ DebugToolkit.showPanel();
205
113
  } else {
206
- toolkit.hidePanel();
114
+ DebugToolkit.hidePanel();
207
115
  }
208
116
 
209
- return toolkit;
117
+ return DebugToolkit;
210
118
  } catch (error) {
211
119
  console.error('[DebugToolkit] Initialization failed:', error);
212
- return null;
120
+ return DebugToolkit;
213
121
  }
214
122
  }