react-native-debug-toolkit 3.0.0 → 3.1.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.
- package/README.md +115 -97
- package/README.zh-CN.md +113 -95
- package/lib/commonjs/core/initialize.js +5 -0
- package/lib/commonjs/core/initialize.js.map +1 -1
- package/lib/commonjs/index.js +23 -26
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/panel/StreamingSettingsModal.js +24 -58
- package/lib/commonjs/ui/panel/StreamingSettingsModal.js.map +1 -1
- package/lib/commonjs/utils/DaemonClient.js +721 -0
- package/lib/commonjs/utils/DaemonClient.js.map +1 -0
- package/lib/commonjs/utils/{sessionReport.js → deviceReport.js} +3 -3
- package/lib/commonjs/utils/deviceReport.js.map +1 -0
- package/lib/module/core/initialize.js +6 -0
- package/lib/module/core/initialize.js.map +1 -1
- package/lib/module/index.js +3 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/panel/StreamingSettingsModal.js +21 -55
- package/lib/module/ui/panel/StreamingSettingsModal.js.map +1 -1
- package/lib/module/utils/DaemonClient.js +703 -0
- package/lib/module/utils/DaemonClient.js.map +1 -0
- package/lib/module/utils/{sessionReport.js → deviceReport.js} +2 -2
- package/lib/module/utils/deviceReport.js.map +1 -0
- package/lib/typescript/src/core/initialize.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -10
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/StreamingSettingsModal.d.ts.map +1 -1
- package/lib/typescript/src/utils/DaemonClient.d.ts +141 -0
- package/lib/typescript/src/utils/DaemonClient.d.ts.map +1 -0
- package/lib/typescript/src/utils/{sessionReport.d.ts → deviceReport.d.ts} +4 -4
- package/lib/typescript/src/utils/deviceReport.d.ts.map +1 -0
- package/node/daemon/src/cli.js +9 -2
- package/node/daemon/src/console/console.html +914 -188
- package/node/daemon/src/constants.js +6 -0
- package/node/daemon/src/server.js +205 -123
- package/node/daemon/src/store.js +122 -45
- package/node/mcp/src/daemonClient.js +6 -6
- package/node/mcp/src/index.js +2 -2
- package/node/mcp/src/logs.js +5 -4
- package/node/mcp/src/tools.js +16 -16
- package/package.json +2 -2
- package/src/core/initialize.ts +8 -0
- package/src/index.ts +18 -10
- package/src/ui/panel/StreamingSettingsModal.tsx +25 -63
- package/src/utils/DaemonClient.ts +887 -0
- package/src/utils/{sessionReport.ts → deviceReport.ts} +6 -6
- package/lib/commonjs/utils/autoDetectDaemon.js +0 -141
- package/lib/commonjs/utils/autoDetectDaemon.js.map +0 -1
- package/lib/commonjs/utils/daemonConnection.js +0 -81
- package/lib/commonjs/utils/daemonConnection.js.map +0 -1
- package/lib/commonjs/utils/daemonSettings.js +0 -110
- package/lib/commonjs/utils/daemonSettings.js.map +0 -1
- package/lib/commonjs/utils/reportToDaemon.js +0 -112
- package/lib/commonjs/utils/reportToDaemon.js.map +0 -1
- package/lib/commonjs/utils/sessionReport.js.map +0 -1
- package/lib/commonjs/utils/streamToDaemon.js +0 -334
- package/lib/commonjs/utils/streamToDaemon.js.map +0 -1
- package/lib/module/utils/autoDetectDaemon.js +0 -136
- package/lib/module/utils/autoDetectDaemon.js.map +0 -1
- package/lib/module/utils/daemonConnection.js +0 -77
- package/lib/module/utils/daemonConnection.js.map +0 -1
- package/lib/module/utils/daemonSettings.js +0 -102
- package/lib/module/utils/daemonSettings.js.map +0 -1
- package/lib/module/utils/reportToDaemon.js +0 -105
- package/lib/module/utils/reportToDaemon.js.map +0 -1
- package/lib/module/utils/sessionReport.js.map +0 -1
- package/lib/module/utils/streamToDaemon.js +0 -328
- package/lib/module/utils/streamToDaemon.js.map +0 -1
- package/lib/typescript/src/utils/autoDetectDaemon.d.ts +0 -15
- package/lib/typescript/src/utils/autoDetectDaemon.d.ts.map +0 -1
- package/lib/typescript/src/utils/daemonConnection.d.ts +0 -18
- package/lib/typescript/src/utils/daemonConnection.d.ts.map +0 -1
- package/lib/typescript/src/utils/daemonSettings.d.ts +0 -19
- package/lib/typescript/src/utils/daemonSettings.d.ts.map +0 -1
- package/lib/typescript/src/utils/reportToDaemon.d.ts +0 -34
- package/lib/typescript/src/utils/reportToDaemon.d.ts.map +0 -1
- package/lib/typescript/src/utils/sessionReport.d.ts.map +0 -1
- package/lib/typescript/src/utils/streamToDaemon.d.ts +0 -23
- package/lib/typescript/src/utils/streamToDaemon.d.ts.map +0 -1
- package/src/utils/autoDetectDaemon.ts +0 -175
- package/src/utils/daemonConnection.ts +0 -133
- package/src/utils/daemonSettings.ts +0 -134
- package/src/utils/reportToDaemon.ts +0 -172
- package/src/utils/streamToDaemon.ts +0 -419
package/README.md
CHANGED
|
@@ -1,51 +1,47 @@
|
|
|
1
1
|
# React Native Debug Toolkit
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
[中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Dev-only React Native inspector with a local log bridge.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
It shows app logs on device, then can send the same device log stream to a local daemon for browser, curl, scripts, or MCP.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Model
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
```text
|
|
12
|
+
RN App logs -> Debug Panel -> local daemon -> Web Console / HTTP / MCP
|
|
13
|
+
```
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
- **Console** — Capture `console.log / info / warn / error`
|
|
16
|
-
- **Zustand** — Log state transitions via middleware
|
|
17
|
-
- **Navigation** — Track route changes
|
|
18
|
-
- **Track** — Record custom analytics events
|
|
19
|
-
- **Environment** — Switch API hosts on the fly
|
|
20
|
-
- **Clipboard** — Paste text and copy to computer
|
|
21
|
-
- **Log Persistence** — Network, Console, Track logs survive app restarts (requires AsyncStorage)
|
|
15
|
+
Captured logs:
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
- Network
|
|
18
|
+
- Console
|
|
19
|
+
- Navigation
|
|
20
|
+
- Track
|
|
21
|
+
- Zustand
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
23
|
+
The CLI daemon persists device logs to `~/.react-native-debug-toolkit/daemon-devices.json`.
|
|
24
|
+
Use `DELETE /devices` to clear stored logs.
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
## Install
|
|
30
27
|
|
|
31
28
|
```bash
|
|
32
|
-
npm install
|
|
29
|
+
npm install react-native-debug-toolkit
|
|
33
30
|
```
|
|
34
31
|
|
|
35
|
-
Optional
|
|
32
|
+
Optional:
|
|
36
33
|
|
|
37
34
|
```bash
|
|
35
|
+
npm install @react-native-clipboard/clipboard
|
|
38
36
|
npm install @react-native-async-storage/async-storage
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## Quick Start
|
|
39
|
+
## App Usage
|
|
44
40
|
|
|
45
41
|
```tsx
|
|
46
42
|
import { DebugView } from 'react-native-debug-toolkit';
|
|
47
43
|
|
|
48
|
-
function App() {
|
|
44
|
+
export function App() {
|
|
49
45
|
return (
|
|
50
46
|
<DebugView>
|
|
51
47
|
<AppContent />
|
|
@@ -54,11 +50,9 @@ function App() {
|
|
|
54
50
|
}
|
|
55
51
|
```
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Network, console, navigation, zustand, track, and clipboard are enabled by default. Network capture hooks React Native's XHR transport, so fetch and axios requests using the default adapter are captured automatically.
|
|
53
|
+
Open app in dev mode. Tap `DBG`.
|
|
60
54
|
|
|
61
|
-
Disable
|
|
55
|
+
Disable features:
|
|
62
56
|
|
|
63
57
|
```tsx
|
|
64
58
|
<DebugView features={{ clipboard: false, zustand: false }}>
|
|
@@ -66,102 +60,126 @@ Disable specific features:
|
|
|
66
60
|
</DebugView>
|
|
67
61
|
```
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### Navigation Tracking
|
|
63
|
+
Navigation tracking:
|
|
72
64
|
|
|
73
65
|
```tsx
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const navRef = useRef(null);
|
|
80
|
-
return (
|
|
81
|
-
<DebugView navigationRef={navRef}>
|
|
82
|
-
<NavigationContainer ref={navRef}>
|
|
83
|
-
<AppContent />
|
|
84
|
-
</NavigationContainer>
|
|
85
|
-
</DebugView>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
66
|
+
<DebugView navigationRef={navigationRef}>
|
|
67
|
+
<NavigationContainer ref={navigationRef}>
|
|
68
|
+
<AppContent />
|
|
69
|
+
</NavigationContainer>
|
|
70
|
+
</DebugView>
|
|
88
71
|
```
|
|
89
72
|
|
|
90
|
-
|
|
73
|
+
Zustand:
|
|
91
74
|
|
|
92
75
|
```tsx
|
|
93
|
-
|
|
94
|
-
environments={[
|
|
95
|
-
{ id: 'dev', label: 'Dev', host: 'dev-api.example.com', color: '#34C759' },
|
|
96
|
-
{ id: 'prod', label: 'Prod', host: 'api.example.com', color: '#FF3B30' },
|
|
97
|
-
]}
|
|
98
|
-
>
|
|
99
|
-
<AppContent />
|
|
100
|
-
</DebugView>
|
|
76
|
+
import { zustandLogMiddleware } from 'react-native-debug-toolkit';
|
|
101
77
|
```
|
|
102
78
|
|
|
103
|
-
|
|
79
|
+
Track:
|
|
104
80
|
|
|
105
81
|
```tsx
|
|
106
|
-
import {
|
|
82
|
+
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
107
83
|
|
|
108
|
-
|
|
109
|
-
zustandLogMiddleware((set) => ({
|
|
110
|
-
count: 0,
|
|
111
|
-
increment: () => set((s) => ({ count: s.count + 1 }), false, 'increment'),
|
|
112
|
-
// ↑ merge ↑ action name (shown in debug panel)
|
|
113
|
-
}))
|
|
114
|
-
);
|
|
84
|
+
addTrackLog({ eventName: 'button_click' });
|
|
115
85
|
```
|
|
116
86
|
|
|
117
|
-
|
|
87
|
+
## Desktop Logs
|
|
118
88
|
|
|
119
|
-
|
|
120
|
-
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
89
|
+
Start daemon:
|
|
121
90
|
|
|
122
|
-
|
|
91
|
+
```bash
|
|
92
|
+
npx debug-toolkit --daemon-only
|
|
123
93
|
```
|
|
124
94
|
|
|
125
|
-
|
|
95
|
+
The default device log store is `~/.react-native-debug-toolkit/daemon-devices.json`.
|
|
96
|
+
Override it with `--store /path/to/devices.json` or `DEBUG_TOOLKIT_DAEMON_STORE`.
|
|
126
97
|
|
|
127
|
-
|
|
98
|
+
Open:
|
|
128
99
|
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
features={{
|
|
132
|
-
network: {
|
|
133
|
-
maxLogs: 100,
|
|
134
|
-
blacklist: ['/analytics', /\/healthcheck$/],
|
|
135
|
-
},
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
<AppContent />
|
|
139
|
-
</DebugView>
|
|
100
|
+
```text
|
|
101
|
+
http://127.0.0.1:3799/console
|
|
140
102
|
```
|
|
141
103
|
|
|
142
|
-
|
|
104
|
+
In app: Debug Panel -> gear -> `Send Once` or `Start Live Sync`.
|
|
143
105
|
|
|
144
|
-
|
|
106
|
+
Endpoints:
|
|
145
107
|
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
| Runtime | Endpoint |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| iOS simulator | `http://localhost:3799` |
|
|
111
|
+
| Android emulator | `http://10.0.2.2:3799` |
|
|
112
|
+
| Real device | `http://<mac-ip>:3799` |
|
|
113
|
+
|
|
114
|
+
Real device rule: phone browser must open `http://<mac-ip>:3799/health`. If not, check firewall, Wi-Fi isolation, VPN, and cleartext HTTP.
|
|
115
|
+
|
|
116
|
+
## HTTP
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
BASE=http://127.0.0.1:3799
|
|
120
|
+
|
|
121
|
+
curl "$BASE/health"
|
|
122
|
+
curl "$BASE/devices"
|
|
123
|
+
curl "$BASE/devices/latest"
|
|
148
124
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
125
|
+
DEVICE_ID=$(curl -s "$BASE/devices" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log((JSON.parse(s).devices||[])[0]?.deviceId||''))")
|
|
126
|
+
|
|
127
|
+
curl "$BASE/devices/$DEVICE_ID"
|
|
128
|
+
curl "$BASE/devices/$DEVICE_ID/logs?limit=100"
|
|
129
|
+
curl "$BASE/devices/$DEVICE_ID/logs?type=network&failedOnly=true&limit=50"
|
|
130
|
+
curl "$BASE/devices/$DEVICE_ID/logs?type=console&limit=100"
|
|
131
|
+
curl -X DELETE "$BASE/devices"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Main endpoints:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
GET /health
|
|
138
|
+
POST /report
|
|
139
|
+
POST /ingest
|
|
140
|
+
GET /devices
|
|
141
|
+
GET /devices/latest
|
|
142
|
+
GET /devices/:deviceId
|
|
143
|
+
GET /devices/:deviceId/logs
|
|
144
|
+
DELETE /devices
|
|
145
|
+
GET /events
|
|
146
|
+
GET /console
|
|
153
147
|
```
|
|
154
148
|
|
|
155
|
-
|
|
149
|
+
## MCP
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
claude mcp add debug-toolkit -- npx debug-toolkit
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Tools:
|
|
156
|
+
|
|
157
|
+
- `list_app_devices`
|
|
158
|
+
- `get_app_logs`
|
|
159
|
+
|
|
160
|
+
Use curl when shell is available.
|
|
161
|
+
|
|
162
|
+
## Exports
|
|
163
|
+
|
|
164
|
+
- `DebugView`
|
|
165
|
+
- `DebugToolkit`
|
|
166
|
+
- `initializeDebugToolkit`
|
|
167
|
+
- `createDebugDeviceReport`
|
|
168
|
+
- `checkDaemonConnection`
|
|
169
|
+
- `reportDebugDeviceToDaemon`
|
|
170
|
+
- `startStreaming`
|
|
171
|
+
- `stopStreaming`
|
|
172
|
+
- `isStreaming`
|
|
173
|
+
- `autoDetectDaemonIp`
|
|
174
|
+
- feature factories and types
|
|
156
175
|
|
|
157
|
-
##
|
|
176
|
+
## Boundaries
|
|
158
177
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
| @react-native-async-storage/async-storage | >= 1.0.0 | No |
|
|
178
|
+
- Dev tool, not production monitoring.
|
|
179
|
+
- Local daemon, not cloud replay.
|
|
180
|
+
- Network logs are observed traffic, not auth/token analysis.
|
|
181
|
+
- No default redaction.
|
|
182
|
+
- Not a React Native DevTools replacement.
|
|
165
183
|
|
|
166
184
|
## License
|
|
167
185
|
|
package/README.zh-CN.md
CHANGED
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
React Native 开发期调试面板 + 本地日志桥。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
它能在 App 内看日志,也能把同一台设备的日志流发到本机 daemon,供浏览器、curl、脚本、MCP 读取。
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 模型
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
```text
|
|
12
|
+
RN App logs -> Debug Panel -> local daemon -> Web Console / HTTP / MCP
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
采集:
|
|
16
|
+
|
|
17
|
+
- Network
|
|
18
|
+
- Console
|
|
19
|
+
- Navigation
|
|
20
|
+
- Track
|
|
21
|
+
- Zustand
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- **Zustand** — 通过中间件记录状态变化
|
|
17
|
-
- **Navigation** — 追踪路由切换
|
|
18
|
-
- **Track** — 记录自定义埋点事件
|
|
19
|
-
- **Environment** — 运行时切换 API 环境
|
|
20
|
-
- **Clipboard** — 粘贴文本并复制到电脑
|
|
21
|
-
- **日志持久化** — Network、Console、Track 日志在应用重启后保留(需要 AsyncStorage)
|
|
23
|
+
CLI daemon 默认把设备日志持久化到 `~/.react-native-debug-toolkit/daemon-devices.json`。
|
|
24
|
+
用 `DELETE /devices` 清空已存日志。
|
|
22
25
|
|
|
23
26
|
## 安装
|
|
24
27
|
|
|
@@ -26,26 +29,19 @@
|
|
|
26
29
|
npm install react-native-debug-toolkit
|
|
27
30
|
```
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
可选:
|
|
30
33
|
|
|
31
34
|
```bash
|
|
32
35
|
npm install @react-native-clipboard/clipboard
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
可选 — FAB 位置与上次 Tab 持久化:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
36
|
npm install @react-native-async-storage/async-storage
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## 快速开始
|
|
39
|
+
## App 接入
|
|
44
40
|
|
|
45
41
|
```tsx
|
|
46
42
|
import { DebugView } from 'react-native-debug-toolkit';
|
|
47
43
|
|
|
48
|
-
function App() {
|
|
44
|
+
export function App() {
|
|
49
45
|
return (
|
|
50
46
|
<DebugView>
|
|
51
47
|
<AppContent />
|
|
@@ -54,11 +50,9 @@ function App() {
|
|
|
54
50
|
}
|
|
55
51
|
```
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
网络、控制台、导航、Zustand、埋点和剪贴板默认启用。Network 会拦截 React Native 的 XHR 传输层,因此使用默认 adapter 的 fetch 和 axios 请求会自动被捕获。
|
|
53
|
+
开发模式打开 App。点击 `DBG`。
|
|
60
54
|
|
|
61
|
-
|
|
55
|
+
禁用功能:
|
|
62
56
|
|
|
63
57
|
```tsx
|
|
64
58
|
<DebugView features={{ clipboard: false, zustand: false }}>
|
|
@@ -66,102 +60,126 @@ function App() {
|
|
|
66
60
|
</DebugView>
|
|
67
61
|
```
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### 导航追踪
|
|
63
|
+
导航追踪:
|
|
72
64
|
|
|
73
65
|
```tsx
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const navRef = useRef(null);
|
|
80
|
-
return (
|
|
81
|
-
<DebugView navigationRef={navRef}>
|
|
82
|
-
<NavigationContainer ref={navRef}>
|
|
83
|
-
<AppContent />
|
|
84
|
-
</NavigationContainer>
|
|
85
|
-
</DebugView>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
66
|
+
<DebugView navigationRef={navigationRef}>
|
|
67
|
+
<NavigationContainer ref={navigationRef}>
|
|
68
|
+
<AppContent />
|
|
69
|
+
</NavigationContainer>
|
|
70
|
+
</DebugView>
|
|
88
71
|
```
|
|
89
72
|
|
|
90
|
-
|
|
73
|
+
Zustand:
|
|
91
74
|
|
|
92
75
|
```tsx
|
|
93
|
-
|
|
94
|
-
environments={[
|
|
95
|
-
{ id: 'dev', label: 'Dev', host: 'dev-api.example.com', color: '#34C759' },
|
|
96
|
-
{ id: 'prod', label: 'Prod', host: 'api.example.com', color: '#FF3B30' },
|
|
97
|
-
]}
|
|
98
|
-
>
|
|
99
|
-
<AppContent />
|
|
100
|
-
</DebugView>
|
|
76
|
+
import { zustandLogMiddleware } from 'react-native-debug-toolkit';
|
|
101
77
|
```
|
|
102
78
|
|
|
103
|
-
|
|
79
|
+
Track:
|
|
104
80
|
|
|
105
81
|
```tsx
|
|
106
|
-
import {
|
|
82
|
+
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
107
83
|
|
|
108
|
-
|
|
109
|
-
zustandLogMiddleware((set) => ({
|
|
110
|
-
count: 0,
|
|
111
|
-
increment: () => set((s) => ({ count: s.count + 1 }), false, 'increment'),
|
|
112
|
-
// ↑ merge ↑ action 名称(显示在调试面板)
|
|
113
|
-
}))
|
|
114
|
-
);
|
|
84
|
+
addTrackLog({ eventName: 'button_click' });
|
|
115
85
|
```
|
|
116
86
|
|
|
117
|
-
|
|
87
|
+
## Desktop Logs
|
|
118
88
|
|
|
119
|
-
|
|
120
|
-
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
89
|
+
启动 daemon:
|
|
121
90
|
|
|
122
|
-
|
|
91
|
+
```bash
|
|
92
|
+
npx debug-toolkit --daemon-only
|
|
123
93
|
```
|
|
124
94
|
|
|
125
|
-
|
|
95
|
+
默认设备日志存储文件:`~/.react-native-debug-toolkit/daemon-devices.json`。
|
|
96
|
+
可用 `--store /path/to/devices.json` 或 `DEBUG_TOOLKIT_DAEMON_STORE` 覆盖。
|
|
126
97
|
|
|
127
|
-
|
|
98
|
+
打开:
|
|
128
99
|
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
features={{
|
|
132
|
-
network: {
|
|
133
|
-
maxLogs: 100,
|
|
134
|
-
blacklist: ['/analytics', /\/healthcheck$/],
|
|
135
|
-
},
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
<AppContent />
|
|
139
|
-
</DebugView>
|
|
100
|
+
```text
|
|
101
|
+
http://127.0.0.1:3799/console
|
|
140
102
|
```
|
|
141
103
|
|
|
142
|
-
|
|
104
|
+
App 内:Debug Panel -> 齿轮 -> `Send Once` 或 `Start Live Sync`。
|
|
143
105
|
|
|
144
|
-
|
|
106
|
+
Endpoint:
|
|
145
107
|
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
| 运行时 | Endpoint |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| iOS simulator | `http://localhost:3799` |
|
|
111
|
+
| Android emulator | `http://10.0.2.2:3799` |
|
|
112
|
+
| 真机 | `http://<mac-ip>:3799` |
|
|
113
|
+
|
|
114
|
+
真机规则:手机浏览器必须能打开 `http://<mac-ip>:3799/health`。打不开就查防火墙、Wi-Fi 隔离、VPN、明文 HTTP。
|
|
115
|
+
|
|
116
|
+
## HTTP
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
BASE=http://127.0.0.1:3799
|
|
120
|
+
|
|
121
|
+
curl "$BASE/health"
|
|
122
|
+
curl "$BASE/devices"
|
|
123
|
+
curl "$BASE/devices/latest"
|
|
148
124
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
125
|
+
DEVICE_ID=$(curl -s "$BASE/devices" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log((JSON.parse(s).devices||[])[0]?.deviceId||''))")
|
|
126
|
+
|
|
127
|
+
curl "$BASE/devices/$DEVICE_ID"
|
|
128
|
+
curl "$BASE/devices/$DEVICE_ID/logs?limit=100"
|
|
129
|
+
curl "$BASE/devices/$DEVICE_ID/logs?type=network&failedOnly=true&limit=50"
|
|
130
|
+
curl "$BASE/devices/$DEVICE_ID/logs?type=console&limit=100"
|
|
131
|
+
curl -X DELETE "$BASE/devices"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
主要端点:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
GET /health
|
|
138
|
+
POST /report
|
|
139
|
+
POST /ingest
|
|
140
|
+
GET /devices
|
|
141
|
+
GET /devices/latest
|
|
142
|
+
GET /devices/:deviceId
|
|
143
|
+
GET /devices/:deviceId/logs
|
|
144
|
+
DELETE /devices
|
|
145
|
+
GET /events
|
|
146
|
+
GET /console
|
|
153
147
|
```
|
|
154
148
|
|
|
155
|
-
|
|
149
|
+
## MCP
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
claude mcp add debug-toolkit -- npx debug-toolkit
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
工具:
|
|
156
|
+
|
|
157
|
+
- `list_app_devices`
|
|
158
|
+
- `get_app_logs`
|
|
159
|
+
|
|
160
|
+
有 shell 时优先 curl。
|
|
161
|
+
|
|
162
|
+
## 导出
|
|
163
|
+
|
|
164
|
+
- `DebugView`
|
|
165
|
+
- `DebugToolkit`
|
|
166
|
+
- `initializeDebugToolkit`
|
|
167
|
+
- `createDebugDeviceReport`
|
|
168
|
+
- `checkDaemonConnection`
|
|
169
|
+
- `reportDebugDeviceToDaemon`
|
|
170
|
+
- `startStreaming`
|
|
171
|
+
- `stopStreaming`
|
|
172
|
+
- `isStreaming`
|
|
173
|
+
- `autoDetectDaemonIp`
|
|
174
|
+
- feature factories and types
|
|
156
175
|
|
|
157
|
-
##
|
|
176
|
+
## 边界
|
|
158
177
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
| @react-native-async-storage/async-storage | >= 1.0.0 | 否 |
|
|
178
|
+
- 开发工具,不是生产监控。
|
|
179
|
+
- 本地 daemon,不是云 replay。
|
|
180
|
+
- Network 日志只是监测流量,不做 auth/token 分析。
|
|
181
|
+
- 不默认脱敏。
|
|
182
|
+
- 不替代 React Native DevTools。
|
|
165
183
|
|
|
166
184
|
## 许可证
|
|
167
185
|
|
|
@@ -12,7 +12,11 @@ var _navigation = require("../features/navigation");
|
|
|
12
12
|
var _track = require("../features/track");
|
|
13
13
|
var _environment = require("../features/environment");
|
|
14
14
|
var _clipboard = require("../features/clipboard");
|
|
15
|
+
var _DaemonClient = require("../utils/DaemonClient");
|
|
15
16
|
const isDebugMode = __DEV__;
|
|
17
|
+
_DaemonClient.daemonClient.setEndpointDetector(url => {
|
|
18
|
+
(0, _network._addDaemonEndpointToNetworkBlacklist)(url);
|
|
19
|
+
});
|
|
16
20
|
|
|
17
21
|
/** Feature-specific configuration map */
|
|
18
22
|
|
|
@@ -75,6 +79,7 @@ function initializeDebugToolkit(options) {
|
|
|
75
79
|
} else {
|
|
76
80
|
_DebugToolkit.DebugToolkit.hideLauncher();
|
|
77
81
|
}
|
|
82
|
+
(0, _DaemonClient.restoreDaemonStreaming)().catch(() => {});
|
|
78
83
|
return _DebugToolkit.DebugToolkit;
|
|
79
84
|
} catch (error) {
|
|
80
85
|
console.error('[DebugToolkit] Initialization failed:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_DebugToolkit","require","_network","_console","_zustand","_navigation","_track","_environment","_clipboard","isDebugMode","__DEV__","featureRegistry","network","createNetworkFeature","console","createConsoleLogFeature","zustand","createZustandLogFeature","navigation","createNavigationLogFeature","track","createTrackFeature","environment","createEnvironmentFeature","clipboard","createClipboardFeature","DEFAULT_FEATURES","resolveFeatureConfigs","configs","features","entries","Object","name","config","creator","warn","undefined","push","resolveDefaultFeatures","map","initializeDebugToolkit","options","enabled","resolvedFeatures","DebugToolkit","setEnabled","reset","replaceFeatures","hasFeatures","showLauncher","hideLauncher","error"],"sourceRoot":"../../../src","sources":["core/initialize.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;
|
|
1
|
+
{"version":3,"names":["_DebugToolkit","require","_network","_console","_zustand","_navigation","_track","_environment","_clipboard","_DaemonClient","isDebugMode","__DEV__","daemonClient","setEndpointDetector","url","_addDaemonEndpointToNetworkBlacklist","featureRegistry","network","createNetworkFeature","console","createConsoleLogFeature","zustand","createZustandLogFeature","navigation","createNavigationLogFeature","track","createTrackFeature","environment","createEnvironmentFeature","clipboard","createClipboardFeature","DEFAULT_FEATURES","resolveFeatureConfigs","configs","features","entries","Object","name","config","creator","warn","undefined","push","resolveDefaultFeatures","map","initializeDebugToolkit","options","enabled","resolvedFeatures","DebugToolkit","setEnabled","reset","replaceFeatures","hasFeatures","showLauncher","hideLauncher","restoreDaemonStreaming","catch","error"],"sourceRoot":"../../../src","sources":["core/initialize.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AAEA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