react-native-debug-toolkit 2.3.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/bin/debug-toolkit.js +114 -0
- package/lib/commonjs/core/initialize.js +5 -0
- package/lib/commonjs/core/initialize.js.map +1 -1
- package/lib/commonjs/features/network/index.js +28 -2
- package/lib/commonjs/features/network/index.js.map +1 -1
- package/lib/commonjs/features/network/networkInterceptor.js +14 -6
- package/lib/commonjs/features/network/networkInterceptor.js.map +1 -1
- package/lib/commonjs/index.js +56 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/panel/DebugPanel.js +25 -0
- package/lib/commonjs/ui/panel/DebugPanel.js.map +1 -1
- package/lib/commonjs/ui/panel/FloatPanelView.js +15 -62
- package/lib/commonjs/ui/panel/FloatPanelView.js.map +1 -1
- package/lib/commonjs/ui/panel/StreamingSettingsModal.js +495 -0
- package/lib/commonjs/ui/panel/StreamingSettingsModal.js.map +1 -0
- package/lib/commonjs/ui/panel/useTabAnimation.js +71 -0
- package/lib/commonjs/ui/panel/useTabAnimation.js.map +1 -0
- package/lib/commonjs/utils/DaemonClient.js +721 -0
- package/lib/commonjs/utils/DaemonClient.js.map +1 -0
- package/lib/commonjs/utils/createPersistedObservableStore.js +23 -3
- package/lib/commonjs/utils/createPersistedObservableStore.js.map +1 -1
- package/lib/commonjs/utils/deviceReport.js +132 -0
- 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/features/network/index.js +25 -1
- package/lib/module/features/network/index.js.map +1 -1
- package/lib/module/features/network/networkInterceptor.js +14 -6
- package/lib/module/features/network/networkInterceptor.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/panel/DebugPanel.js +26 -1
- package/lib/module/ui/panel/DebugPanel.js.map +1 -1
- package/lib/module/ui/panel/FloatPanelView.js +16 -63
- package/lib/module/ui/panel/FloatPanelView.js.map +1 -1
- package/lib/module/ui/panel/StreamingSettingsModal.js +490 -0
- package/lib/module/ui/panel/StreamingSettingsModal.js.map +1 -0
- package/lib/module/ui/panel/useTabAnimation.js +67 -0
- package/lib/module/ui/panel/useTabAnimation.js.map +1 -0
- package/lib/module/utils/DaemonClient.js +703 -0
- package/lib/module/utils/DaemonClient.js.map +1 -0
- package/lib/module/utils/createPersistedObservableStore.js +23 -3
- package/lib/module/utils/createPersistedObservableStore.js.map +1 -1
- package/lib/module/utils/deviceReport.js +128 -0
- package/lib/module/utils/deviceReport.js.map +1 -0
- package/lib/typescript/src/core/initialize.d.ts.map +1 -1
- package/lib/typescript/src/features/network/index.d.ts +2 -0
- package/lib/typescript/src/features/network/index.d.ts.map +1 -1
- package/lib/typescript/src/features/network/networkInterceptor.d.ts +1 -1
- package/lib/typescript/src/features/network/networkInterceptor.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/DebugPanel.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/FloatPanelView.d.ts.map +1 -1
- package/lib/typescript/src/ui/panel/StreamingSettingsModal.d.ts +8 -0
- package/lib/typescript/src/ui/panel/StreamingSettingsModal.d.ts.map +1 -0
- package/lib/typescript/src/ui/panel/useTabAnimation.d.ts +14 -0
- package/lib/typescript/src/ui/panel/useTabAnimation.d.ts.map +1 -0
- 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/createPersistedObservableStore.d.ts +2 -1
- package/lib/typescript/src/utils/createPersistedObservableStore.d.ts.map +1 -1
- package/lib/typescript/src/utils/deviceReport.d.ts +18 -0
- package/lib/typescript/src/utils/deviceReport.d.ts.map +1 -0
- package/node/daemon/src/cli.js +82 -0
- package/node/daemon/src/console/console.html +1662 -0
- package/node/daemon/src/console/index.js +47 -0
- package/node/daemon/src/constants.js +38 -0
- package/node/daemon/src/index.js +11 -0
- package/node/daemon/src/server.js +447 -0
- package/node/daemon/src/store.js +187 -0
- package/node/mcp/src/cli.js +31 -0
- package/node/mcp/src/constants.js +13 -0
- package/node/mcp/src/daemonClient.js +132 -0
- package/node/mcp/src/httpClient.js +49 -0
- package/node/mcp/src/index.js +15 -0
- package/node/mcp/src/logs.js +96 -0
- package/node/mcp/src/server.js +144 -0
- package/node/mcp/src/tools.js +84 -0
- package/package.json +8 -3
- package/src/core/initialize.ts +8 -0
- package/src/features/network/index.ts +30 -3
- package/src/features/network/networkInterceptor.ts +19 -6
- package/src/index.ts +22 -0
- package/src/ui/panel/DebugPanel.tsx +23 -1
- package/src/ui/panel/FloatPanelView.tsx +10 -68
- package/src/ui/panel/StreamingSettingsModal.tsx +528 -0
- package/src/ui/panel/useTabAnimation.ts +77 -0
- package/src/utils/DaemonClient.ts +887 -0
- package/src/utils/createPersistedObservableStore.ts +16 -3
- package/src/utils/deviceReport.ts +203 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
DAEMON_NAME,
|
|
5
|
+
DEFAULT_HOST,
|
|
6
|
+
DEFAULT_PORT,
|
|
7
|
+
getDefaultDeviceStorePath,
|
|
8
|
+
getLanIPs,
|
|
9
|
+
} = require('./constants');
|
|
10
|
+
const { createDaemonServer } = require('./server');
|
|
11
|
+
|
|
12
|
+
function readOption(args, name, fallback) {
|
|
13
|
+
const index = args.indexOf(name);
|
|
14
|
+
if (index < 0) {
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
return args[index + 1] || fallback;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function hasHelpFlag(args) {
|
|
21
|
+
return args.includes('--help') || args.includes('-h');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function printHelp() {
|
|
25
|
+
process.stdout.write('Usage: debug-toolkit-daemon [--host 0.0.0.0] [--port 3799] [--token dev-token] [--store ~/.react-native-debug-toolkit/daemon-devices.json]\n');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getLocalOrigin(host, port) {
|
|
29
|
+
const localHost = host === '0.0.0.0' || host === '::' ? '127.0.0.1' : host;
|
|
30
|
+
return `http://${localHost}:${port}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function startDaemonFromCli(args) {
|
|
34
|
+
if (hasHelpFlag(args)) {
|
|
35
|
+
printHelp();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const host = readOption(args, '--host', process.env.DEBUG_TOOLKIT_DAEMON_HOST || DEFAULT_HOST);
|
|
40
|
+
const port = Number(readOption(args, '--port', process.env.DEBUG_TOOLKIT_DAEMON_PORT || DEFAULT_PORT));
|
|
41
|
+
const token = readOption(args, '--token', process.env.DEBUG_TOOLKIT_DAEMON_TOKEN || '');
|
|
42
|
+
const deviceStorePath = readOption(
|
|
43
|
+
args,
|
|
44
|
+
'--store',
|
|
45
|
+
process.env.DEBUG_TOOLKIT_DAEMON_STORE || getDefaultDeviceStorePath(),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!Number.isFinite(port) || port <= 0) {
|
|
49
|
+
process.stderr.write('Invalid --port value\n');
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { server } = createDaemonServer({ token, deviceStorePath });
|
|
55
|
+
|
|
56
|
+
server.on('error', (error) => {
|
|
57
|
+
process.stderr.write(`${DAEMON_NAME} failed to start: ${error.message}\n`);
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
server.listen(port, host, () => {
|
|
62
|
+
const consolePath = token ? `/console?token=${encodeURIComponent(token)}` : '/console';
|
|
63
|
+
process.stderr.write(`${DAEMON_NAME} listening on http://${host}:${port}\n`);
|
|
64
|
+
process.stderr.write(`Web Console: ${getLocalOrigin(host, port)}${consolePath}\n`);
|
|
65
|
+
process.stderr.write(`Device store: ${deviceStorePath}\n`);
|
|
66
|
+
const lanIPs = getLanIPs();
|
|
67
|
+
if (lanIPs.length > 0) {
|
|
68
|
+
process.stderr.write(`LAN IPs: ${lanIPs.join(', ')}\n`);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const close = () => {
|
|
73
|
+
server.close(() => process.exit(0));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
process.on('SIGINT', close);
|
|
77
|
+
process.on('SIGTERM', close);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = {
|
|
81
|
+
startDaemonFromCli,
|
|
82
|
+
};
|