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
|
@@ -1,67 +1,76 @@
|
|
|
1
1
|
import { ConsoleLogTab } from '../components/ConsoleLogTab';
|
|
2
2
|
import type { ConsoleLogEntry, DebugFeature } from '../types';
|
|
3
|
-
import { createEventChannel } from '../utils/createEventChannel';
|
|
4
3
|
import { createObservableStore } from '../utils/createObservableStore';
|
|
5
4
|
|
|
6
|
-
type ConsoleLogPayload = Omit<ConsoleLogEntry, 'id'>;
|
|
7
|
-
|
|
8
|
-
const DEFAULT_MAX_LOGS = 200;
|
|
9
|
-
const consoleChannel = createEventChannel<ConsoleLogPayload>();
|
|
10
|
-
const originalConsole: Partial<Record<ConsoleLogEntry['level'], (...args: unknown[]) => void>> =
|
|
11
|
-
{};
|
|
12
5
|
const LEVELS: ConsoleLogEntry['level'][] = ['log', 'info', 'warn', 'error'];
|
|
13
6
|
|
|
14
|
-
|
|
7
|
+
// ─── Console capture manager (encapsulated mutable state) ──
|
|
8
|
+
|
|
9
|
+
const consoleCapture = (() => {
|
|
10
|
+
const originalMethods: Partial<Record<ConsoleLogEntry['level'], (...args: unknown[]) => void>> = {};
|
|
11
|
+
let refCount = 0;
|
|
15
12
|
|
|
16
|
-
function
|
|
17
|
-
|
|
13
|
+
function stop(): void {
|
|
14
|
+
refCount = Math.max(0, refCount - 1);
|
|
15
|
+
if (refCount > 0) return;
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
LEVELS.forEach((level) => {
|
|
18
|
+
const original = originalMethods[level];
|
|
19
|
+
if (original) {
|
|
20
|
+
console[level] = original;
|
|
21
|
+
delete originalMethods[level];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
function isIntercepted(): boolean {
|
|
27
|
+
return LEVELS.some((level) => originalMethods[level] !== undefined);
|
|
28
|
+
}
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
function start(emit: (entry: ConsoleLogEntry) => void): () => void {
|
|
31
|
+
refCount += 1;
|
|
32
|
+
if (isIntercepted()) {
|
|
33
|
+
return () => { stop(); };
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
LEVELS.forEach((level) => {
|
|
37
|
+
originalMethods[level] = console[level];
|
|
38
|
+
|
|
39
|
+
console[level] = (...args: unknown[]) => {
|
|
40
|
+
originalMethods[level]?.apply(console, args);
|
|
41
|
+
if (level === 'log' && typeof args[0] === 'string' && args[0].startsWith('[DebugToolkit:Copy]')) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
emit({
|
|
45
|
+
id: '',
|
|
46
|
+
timestamp: Date.now(),
|
|
47
|
+
level,
|
|
48
|
+
data: args,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return () => { stop(); };
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
consoleChannel.emit({
|
|
54
|
-
timestamp: Date.now(),
|
|
55
|
-
level,
|
|
56
|
-
data: args,
|
|
56
|
+
return {
|
|
57
|
+
start,
|
|
58
|
+
reset() {
|
|
59
|
+
LEVELS.forEach((level) => {
|
|
60
|
+
const original = originalMethods[level];
|
|
61
|
+
if (original) {
|
|
62
|
+
console[level] = original;
|
|
63
|
+
delete originalMethods[level];
|
|
64
|
+
}
|
|
57
65
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return () => {
|
|
62
|
-
stopConsoleCapture();
|
|
66
|
+
refCount = 0;
|
|
67
|
+
},
|
|
63
68
|
};
|
|
64
|
-
}
|
|
69
|
+
})();
|
|
70
|
+
|
|
71
|
+
// ─── Feature factory ──────────────────────────────────
|
|
72
|
+
|
|
73
|
+
const DEFAULT_MAX_LOGS = 200;
|
|
65
74
|
|
|
66
75
|
export interface ConsoleFeatureConfig {
|
|
67
76
|
/** Maximum number of console logs to keep (default: 200) */
|
|
@@ -73,7 +82,6 @@ export const createConsoleLogFeature = (config?: ConsoleFeatureConfig): DebugFea
|
|
|
73
82
|
const logStore = createObservableStore<ConsoleLogEntry>();
|
|
74
83
|
let nextId = 0;
|
|
75
84
|
let initialized = false;
|
|
76
|
-
let unsubscribeLogs: (() => void) | null = null;
|
|
77
85
|
let stopCapture: (() => void) | null = null;
|
|
78
86
|
|
|
79
87
|
return {
|
|
@@ -81,33 +89,18 @@ export const createConsoleLogFeature = (config?: ConsoleFeatureConfig): DebugFea
|
|
|
81
89
|
label: 'Console',
|
|
82
90
|
renderContent: ConsoleLogTab,
|
|
83
91
|
setup: () => {
|
|
84
|
-
if (initialized)
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
92
|
+
if (initialized) return;
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
logStore.push(
|
|
90
|
-
{
|
|
91
|
-
...entry,
|
|
92
|
-
id: String(nextId++),
|
|
93
|
-
},
|
|
94
|
-
maxLogs,
|
|
95
|
-
);
|
|
94
|
+
stopCapture = consoleCapture.start((entry) => {
|
|
95
|
+
logStore.push({ ...entry, id: String(nextId++) }, maxLogs);
|
|
96
96
|
});
|
|
97
|
-
stopCapture = startConsoleCapture();
|
|
98
97
|
initialized = true;
|
|
99
98
|
},
|
|
100
99
|
getData: () => logStore.getData(),
|
|
101
|
-
clear: () => {
|
|
102
|
-
logStore.clear();
|
|
103
|
-
},
|
|
100
|
+
clear: () => { logStore.clear(); },
|
|
104
101
|
cleanup: () => {
|
|
105
|
-
if (!initialized)
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
102
|
+
if (!initialized) return;
|
|
108
103
|
|
|
109
|
-
unsubscribeLogs?.();
|
|
110
|
-
unsubscribeLogs = null;
|
|
111
104
|
stopCapture?.();
|
|
112
105
|
stopCapture = null;
|
|
113
106
|
logStore.clear();
|
|
@@ -116,3 +109,8 @@ export const createConsoleLogFeature = (config?: ConsoleFeatureConfig): DebugFea
|
|
|
116
109
|
subscribe: (listener) => logStore.subscribe(listener),
|
|
117
110
|
};
|
|
118
111
|
};
|
|
112
|
+
|
|
113
|
+
/** Reset module-level state for testing */
|
|
114
|
+
export function _resetConsoleForTesting(): void {
|
|
115
|
+
consoleCapture.reset();
|
|
116
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnvironmentTab } from '../components/EnvironmentTab';
|
|
2
2
|
import type { DebugFeature, EnvironmentConfig, EnvironmentState } from '../types';
|
|
3
3
|
import { createObservableStore } from '../utils/createObservableStore';
|
|
4
|
-
import {
|
|
4
|
+
import { urlRewriter } from '../utils/urlRewriterRegistry';
|
|
5
5
|
|
|
6
6
|
// Lazy AsyncStorage loader
|
|
7
7
|
type AsyncStorageModule = {
|
|
@@ -97,9 +97,9 @@ export const createEnvironmentFeature = (
|
|
|
97
97
|
if (initialized) {
|
|
98
98
|
try {
|
|
99
99
|
if (envId && environments.length > 0) {
|
|
100
|
-
|
|
100
|
+
urlRewriter.set(createUrlRewriter());
|
|
101
101
|
} else {
|
|
102
|
-
|
|
102
|
+
urlRewriter.set(null);
|
|
103
103
|
}
|
|
104
104
|
} catch (err) {
|
|
105
105
|
if (__DEV__) console.warn('[DebugToolkit] Failed to set URL rewriter:', err);
|
|
@@ -144,11 +144,7 @@ export const createEnvironmentFeature = (
|
|
|
144
144
|
|
|
145
145
|
// Install rewriter if an environment is already selected
|
|
146
146
|
if (activeEnvironmentId && environments.length > 0) {
|
|
147
|
-
|
|
148
|
-
setUrlRewriter(createUrlRewriter());
|
|
149
|
-
} catch {
|
|
150
|
-
// NetworkFeature may not be available
|
|
151
|
-
}
|
|
147
|
+
urlRewriter.set(createUrlRewriter());
|
|
152
148
|
}
|
|
153
149
|
|
|
154
150
|
// Async persistence load (will override if a preference exists)
|
|
@@ -161,11 +157,7 @@ export const createEnvironmentFeature = (
|
|
|
161
157
|
},
|
|
162
158
|
cleanup: () => {
|
|
163
159
|
if (!initialized) return;
|
|
164
|
-
|
|
165
|
-
setUrlRewriter(null);
|
|
166
|
-
} catch (err) {
|
|
167
|
-
if (__DEV__) console.warn('[DebugToolkit] Failed to set URL rewriter:', err);
|
|
168
|
-
}
|
|
160
|
+
urlRewriter.set(null);
|
|
169
161
|
activeEnvironmentId = null;
|
|
170
162
|
currentHostsMap = null;
|
|
171
163
|
stateStore.clear();
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { NavigationLogTab } from '../components/NavigationLogTab';
|
|
2
2
|
import type { DebugFeature, NavigationLogEntry } from '../types';
|
|
3
3
|
import { createEventChannel } from '../utils/createEventChannel';
|
|
4
|
-
import {
|
|
4
|
+
import { createChannelFeature } from '../utils/createChannelFeature';
|
|
5
5
|
|
|
6
6
|
type NavigationLogPayload = Omit<NavigationLogEntry, 'id'>;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const navigationChannel = createEventChannel<NavigationLogPayload>();
|
|
8
|
+
let navigationChannel = createEventChannel<NavigationLogPayload>();
|
|
10
9
|
|
|
11
10
|
export const addNavigationLog = (
|
|
12
11
|
action: string,
|
|
@@ -32,43 +31,14 @@ export interface NavigationFeatureConfig {
|
|
|
32
31
|
maxLogs?: number;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
export const createNavigationLogFeature = (config?: NavigationFeatureConfig): DebugFeature<NavigationLogEntry> =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
export const createNavigationLogFeature = (config?: NavigationFeatureConfig): DebugFeature<NavigationLogEntry> =>
|
|
35
|
+
createChannelFeature(
|
|
36
|
+
() => navigationChannel,
|
|
37
|
+
(payload, id) => ({ ...payload, id }),
|
|
38
|
+
{ name: 'navigation', label: 'Navigation', renderContent: NavigationLogTab, maxLogs: config?.maxLogs },
|
|
39
|
+
);
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
setup: () => {
|
|
47
|
-
if (initialized) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
unsubscribeLogs = navigationChannel.subscribe((entry) => {
|
|
52
|
-
logStore.push(
|
|
53
|
-
{
|
|
54
|
-
...entry,
|
|
55
|
-
id: String(nextId++),
|
|
56
|
-
},
|
|
57
|
-
maxLogs,
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
initialized = true;
|
|
61
|
-
},
|
|
62
|
-
getData: () => logStore.getData(),
|
|
63
|
-
clear: () => {
|
|
64
|
-
logStore.clear();
|
|
65
|
-
},
|
|
66
|
-
cleanup: () => {
|
|
67
|
-
unsubscribeLogs?.();
|
|
68
|
-
unsubscribeLogs = null;
|
|
69
|
-
logStore.clear();
|
|
70
|
-
initialized = false;
|
|
71
|
-
},
|
|
72
|
-
subscribe: (listener) => logStore.subscribe(listener),
|
|
73
|
-
};
|
|
74
|
-
};
|
|
41
|
+
/** Reset module-level state for testing */
|
|
42
|
+
export function _resetNavigationForTesting(): void {
|
|
43
|
+
navigationChannel = createEventChannel<NavigationLogPayload>();
|
|
44
|
+
}
|