react-native-debug-toolkit 3.3.0 → 3.3.2

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.
@@ -2,6 +2,13 @@ import { NativeModules } from 'react-native';
2
2
 
3
3
  import { buildMetroTarget } from './devConnectUtils';
4
4
 
5
+ export interface NativeDiagnostics {
6
+ log: string[];
7
+ swizzleInstalled: boolean;
8
+ swizzleInvoked: boolean;
9
+ persistedMetroHost: string | null;
10
+ }
11
+
5
12
  interface DebugToolkitDevConnectNativeModule {
6
13
  applyMetroHost: (hostPort: string) => Promise<{ hostPort?: string } | void>;
7
14
  resetMetroHost: () => Promise<void>;
@@ -9,6 +16,8 @@ interface DebugToolkitDevConnectNativeModule {
9
16
  getLocalIp?: () => Promise<string | null>;
10
17
  isDebugBuild?: () => Promise<boolean>;
11
18
  getPreference?: (key: string) => Promise<string | null>;
19
+ getDiagnostics?: () => Promise<NativeDiagnostics>;
20
+ clearDiagnostics?: () => Promise<void>;
12
21
  }
13
22
 
14
23
  type MetroBundleFailureReason =
@@ -154,17 +163,26 @@ export async function nativeIsDebugBuild(): Promise<boolean | null> {
154
163
  }
155
164
  }
156
165
 
157
- export async function flushNativeDiagnostic(key: string, label: string): Promise<void> {
166
+ export async function getNativeDiagnostics(): Promise<NativeDiagnostics | null> {
167
+ const nativeModule = getNativeModule();
168
+ if (!nativeModule?.getDiagnostics) {
169
+ return null;
170
+ }
171
+ try {
172
+ return await nativeModule.getDiagnostics();
173
+ } catch {
174
+ return null;
175
+ }
176
+ }
177
+
178
+ export async function clearNativeDiagnostics(): Promise<void> {
158
179
  const nativeModule = getNativeModule();
159
- if (!nativeModule?.getPreference) {
180
+ if (!nativeModule?.clearDiagnostics) {
160
181
  return;
161
182
  }
162
183
  try {
163
- const raw = await nativeModule.getPreference(key);
164
- if (raw && typeof raw === 'string') {
165
- console.info(`[${label}] Last native diagnostic:`, raw);
166
- }
184
+ await nativeModule.clearDiagnostics();
167
185
  } catch {
168
- // Silent - diagnostic is best-effort
186
+ // best-effort
169
187
  }
170
188
  }