@ohah/react-native-mcp-server 0.1.0-rc.1 → 0.1.0-rc.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/LICENSE +21 -0
- package/README.md +25 -1
- package/babel-plugin-app-registry.cjs +5 -0
- package/babel-preset.cjs +30 -2
- package/dist/adb-utils-BKpV6qdg.js +3 -0
- package/dist/{adb-utils-DreOsWp-.js → adb-utils-Bb_T_gBq.js} +25 -22
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +3 -0
- package/dist/client-Boy8p1w3.js +701 -0
- package/dist/index-CEnLTOvE.d.ts +261 -0
- package/dist/index.d.ts +2 -7
- package/dist/index.js +1394 -342
- package/dist/{init-202kCwU5.js → init-B9XAArR1.js} +1 -1
- package/dist/reporters-RkDvqoty.js +1204 -0
- package/dist/symbolicate.d.ts +21 -0
- package/dist/symbolicate.js +133 -0
- package/dist/test/cli.d.ts +1 -0
- package/dist/test/cli.js +232 -0
- package/dist/test/index.d.ts +261 -0
- package/dist/test/index.js +4 -0
- package/package.json +24 -5
- package/runtime.js +1091 -452
- package/scripts/doctor.mjs +126 -0
- package/dist/adb-utils-R7jCnMjU.js +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ohah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -85,6 +85,28 @@ module.exports = {
|
|
|
85
85
|
};
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
### Babel preset options
|
|
89
|
+
|
|
90
|
+
Pass options as the second element of the preset array:
|
|
91
|
+
|
|
92
|
+
| Option | Type | Default | Description |
|
|
93
|
+
| ----------------- | ----------------------------------------------------- | ------- | ----------------------------------------------------------------------- |
|
|
94
|
+
| `renderHighlight` | `boolean` or `{ style: 'react-scan' \| 'react-mcp' }` | `false` | Start render highlight on load. `true` = style `'react-mcp'` (default). |
|
|
95
|
+
|
|
96
|
+
- **`true`** — enable with style `'react-mcp'` (cyan #61dafb, default, matches DevTools icon).
|
|
97
|
+
- **`{ style: 'react-mcp' }`** — same as `true`.
|
|
98
|
+
- **`{ style: 'react-scan' }`** — purple, react-scan style.
|
|
99
|
+
|
|
100
|
+
Example:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
presets: [
|
|
104
|
+
'module:@react-native/babel-preset',
|
|
105
|
+
['@ohah/react-native-mcp-server/babel-preset', { renderHighlight: true }],
|
|
106
|
+
// or: { renderHighlight: { style: 'react-scan' } } for purple
|
|
107
|
+
],
|
|
108
|
+
```
|
|
109
|
+
|
|
88
110
|
Then add the MCP server entry to your client config (e.g. `.cursor/mcp.json` or Claude config) as in the Quick Start step 3.
|
|
89
111
|
|
|
90
112
|
## Native tools (idb / adb)
|
|
@@ -100,7 +122,9 @@ Without these, other MCP tools (state, network, console, eval) still work.
|
|
|
100
122
|
|
|
101
123
|
## Documentation
|
|
102
124
|
|
|
103
|
-
- **Full docs:** [https://
|
|
125
|
+
- **Full docs:** [react-native-mcp.dev](https://react-native-mcp.dev) ([en](https://react-native-mcp.dev/en/mcp/getting-started) / [ko](https://react-native-mcp.dev/ko/mcp/getting-started))
|
|
126
|
+
- **VS Code Extension:** Install from [Marketplace](https://marketplace.visualstudio.com/items?itemName=ohah.react-native-mcp-devtools) or `Ctrl+Shift+X` → search **React Native MCP DevTools**. [Doc](https://react-native-mcp.dev/en/mcp/vscode-extension) ([ko](https://react-native-mcp.dev/ko/mcp/vscode-extension))
|
|
127
|
+
- **Tool Reference:** [All MCP tools](https://react-native-mcp.dev/en/mcp/tools/) · **E2E Testing:** [YAML scenarios](https://react-native-mcp.dev/en/test/)
|
|
104
128
|
- **Repository:** [github.com/ohah/react-native-mcp](https://github.com/ohah/react-native-mcp)
|
|
105
129
|
|
|
106
130
|
## License
|
|
@@ -21,7 +21,12 @@ function babel_plugin_app_registry_default(babel) {
|
|
|
21
21
|
if (!state.runtimeInjected) {
|
|
22
22
|
const programPath = path.findParent((p) => p.isProgram?.());
|
|
23
23
|
if (programPath?.node?.body) {
|
|
24
|
+
const rh = state.opts?.renderHighlight;
|
|
25
|
+
const renderHighlightEnabled = rh === true || typeof rh === "object" && rh !== null && rh.enabled === true;
|
|
26
|
+
const renderHighlightStyle = rh === true ? "react-mcp" : typeof rh === "object" && rh !== null && (rh.style === "react-scan" || rh.style === "react-mcp") ? rh.style : "react-mcp";
|
|
24
27
|
programPath.node.body.unshift(t.expressionStatement(t.callExpression(t.identifier("require"), [t.stringLiteral(RUNTIME_MODULE_ID)])));
|
|
28
|
+
programPath.node.body.unshift(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("global"), t.identifier("__REACT_NATIVE_MCP_RENDER_HIGHLIGHT_STYLE__")), t.stringLiteral(renderHighlightStyle))));
|
|
29
|
+
programPath.node.body.unshift(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("global"), t.identifier("__REACT_NATIVE_MCP_RENDER_HIGHLIGHT__")), t.booleanLiteral(renderHighlightEnabled))));
|
|
25
30
|
programPath.node.body.unshift(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("global"), t.identifier("__REACT_NATIVE_MCP_ENABLED__")), t.booleanLiteral(true))));
|
|
26
31
|
state.runtimeInjected = true;
|
|
27
32
|
}
|
package/babel-preset.cjs
CHANGED
|
@@ -5,6 +5,18 @@
|
|
|
5
5
|
* babel.config.js에서 presets에 한 번만 넣으면 됨.
|
|
6
6
|
* - __DEV__ 빌드: 자동 활성화 (환경변수 불필요)
|
|
7
7
|
* - Release 빌드: REACT_NATIVE_MCP_ENABLED=true|1 일 때만 활성화
|
|
8
|
+
*
|
|
9
|
+
* 옵션 (두 번째 인자로 객체 전달):
|
|
10
|
+
* - renderHighlight (boolean | { style: 'react-scan' | 'react-mcp' }, default: false)
|
|
11
|
+
* - true: 앱 로드 시 렌더 하이라이트 켬, 스타일 'react-mcp'(기본)
|
|
12
|
+
* - { style: 'react-mcp' }: React Native MCP DevTools 아이콘 톤(시안 #61dafb)
|
|
13
|
+
* - { style: 'react-scan' }: react-scan 스타일(보라)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* presets: [
|
|
17
|
+
* ['@ohah/react-native-mcp-server/babel-preset', { renderHighlight: true }],
|
|
18
|
+
* ['@ohah/react-native-mcp-server/babel-preset', { renderHighlight: { style: 'react-scan' } }],
|
|
19
|
+
* ]
|
|
8
20
|
*/
|
|
9
21
|
function isMcpEnabled() {
|
|
10
22
|
// Metro는 DEV 빌드 시 NODE_ENV를 'development'로 설정한다
|
|
@@ -13,13 +25,29 @@ function isMcpEnabled() {
|
|
|
13
25
|
return v === 'true' || v === '1';
|
|
14
26
|
}
|
|
15
27
|
|
|
16
|
-
|
|
28
|
+
function normalizeRenderHighlight(value) {
|
|
29
|
+
if (value === true) {
|
|
30
|
+
return { enabled: true, style: 'react-mcp' };
|
|
31
|
+
}
|
|
32
|
+
if (
|
|
33
|
+
value &&
|
|
34
|
+
typeof value === 'object' &&
|
|
35
|
+
(value.style === 'react-scan' || value.style === 'react-mcp')
|
|
36
|
+
) {
|
|
37
|
+
return { enabled: true, style: value.style };
|
|
38
|
+
}
|
|
39
|
+
return { enabled: false, style: 'react-mcp' };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = function (api, options) {
|
|
17
43
|
if (!isMcpEnabled()) {
|
|
18
44
|
return { plugins: [] };
|
|
19
45
|
}
|
|
46
|
+
const opts = options || {};
|
|
47
|
+
const renderHighlight = normalizeRenderHighlight(opts.renderHighlight);
|
|
20
48
|
return {
|
|
21
49
|
plugins: [
|
|
22
|
-
require('./babel-plugin-app-registry.cjs'),
|
|
50
|
+
[require('./babel-plugin-app-registry.cjs'), { renderHighlight }],
|
|
23
51
|
require('./babel-plugin-inject-testid.cjs'),
|
|
24
52
|
],
|
|
25
53
|
};
|
|
@@ -149,16 +149,11 @@ async function getAndroidScale(serial) {
|
|
|
149
149
|
return 2.75;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
const _topInsetBySerial = /* @__PURE__ */ new Map();
|
|
153
152
|
/**
|
|
154
|
-
* Android 디바이스의
|
|
155
|
-
*
|
|
156
|
-
* 파싱 실패 시 0 반환 (호출자가 fallback 처리).
|
|
153
|
+
* Android 디바이스의 statusBar/navBar/captionBar 높이(px)를 dumpsys에서 파싱.
|
|
154
|
+
* getAndroidTopInset 보다 상세한 정보가 필요할 때 사용.
|
|
157
155
|
*/
|
|
158
|
-
async function
|
|
159
|
-
const key = serial ?? "_default";
|
|
160
|
-
const cached = _topInsetBySerial.get(key);
|
|
161
|
-
if (cached != null) return cached;
|
|
156
|
+
async function getAndroidInsets(serial) {
|
|
162
157
|
try {
|
|
163
158
|
const text = await runAdbCommand([
|
|
164
159
|
"shell",
|
|
@@ -166,22 +161,30 @@ async function getAndroidTopInset(serial) {
|
|
|
166
161
|
"window",
|
|
167
162
|
"displays"
|
|
168
163
|
], serial, { timeoutMs: 5e3 });
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
_topInsetBySerial.set(key, px);
|
|
173
|
-
return px;
|
|
174
|
-
}
|
|
164
|
+
let statusBarPx = 0;
|
|
165
|
+
let navBarPx = 0;
|
|
166
|
+
let captionBarPx = 0;
|
|
175
167
|
const statusMatch = text.match(/InsetsSource[^\n]*type=statusBars[^\n]*frame=\[\d+,\d+\]\[\d+,(\d+)\]/);
|
|
176
|
-
if (statusMatch)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
168
|
+
if (statusMatch) statusBarPx = parseInt(statusMatch[1], 10);
|
|
169
|
+
const navMatch = text.match(/InsetsSource[^\n]*type=navigationBars[^\n]*frame=\[\d+,(\d+)\]\[\d+,\d+\]/);
|
|
170
|
+
if (navMatch) {
|
|
171
|
+
const top = parseInt(navMatch[1], 10);
|
|
172
|
+
const bottomMatch = text.match(/InsetsSource[^\n]*type=navigationBars[^\n]*frame=\[\d+,\d+\]\[\d+,(\d+)\]/);
|
|
173
|
+
if (bottomMatch) navBarPx = parseInt(bottomMatch[1], 10) - top;
|
|
180
174
|
}
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
const captionMatch = text.match(/InsetsSource[^\n]*type=captionBar[^\n]*frame=\[\d+,\d+\]\[\d+,(\d+)\]/);
|
|
176
|
+
if (captionMatch) captionBarPx = parseInt(captionMatch[1], 10);
|
|
177
|
+
return {
|
|
178
|
+
statusBarPx,
|
|
179
|
+
navBarPx,
|
|
180
|
+
captionBarPx
|
|
181
|
+
};
|
|
183
182
|
} catch {
|
|
184
|
-
return
|
|
183
|
+
return {
|
|
184
|
+
statusBarPx: 0,
|
|
185
|
+
navBarPx: 0,
|
|
186
|
+
captionBarPx: 0
|
|
187
|
+
};
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
190
|
function adbNotInstalledError() {
|
|
@@ -203,4 +206,4 @@ function adbNotInstalledError() {
|
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
//#endregion
|
|
206
|
-
export { isAndroidEmulator as a, runAdbCommand as c,
|
|
209
|
+
export { isAndroidEmulator as a, runAdbCommand as c, getAndroidScale as i, runCommand as l, checkAdbAvailable as n, listAdbDevices as o, getAndroidInsets as r, resolveSerial as s, adbNotInstalledError as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as WaitOpts, a as AssertCountResult, c as CreateAppOptions, d as ElementInfo, f as ElementMeasure, g as VisualCompareResult, h as VisualCompareOpts, i as createApp, l as DebuggerStatus, m as ScrollUntilVisibleResult, n as McpToolError, o as AssertOpts, p as Platform, r as AppClient, s as AssertResult, t as ConnectionError, u as DeviceOpts } from "../index-CEnLTOvE.js";
|
|
2
|
+
export { AppClient, AssertCountResult, AssertOpts, AssertResult, ConnectionError, CreateAppOptions, DebuggerStatus, DeviceOpts, ElementInfo, ElementMeasure, McpToolError, Platform, ScrollUntilVisibleResult, VisualCompareOpts, VisualCompareResult, WaitOpts, createApp };
|