@mobilenext/mobile-mcp 1.0.16 → 1.0.17
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/lib/coordinate-mapping.js +16 -2
- package/package.json +2 -2
|
@@ -4,6 +4,19 @@ exports.describeCoordinateMapping = void 0;
|
|
|
4
4
|
const RATIO_DECIMALS = 3;
|
|
5
5
|
const formatRatio = (ratio) => Number(ratio.toFixed(RATIO_DECIMALS)).toString();
|
|
6
6
|
const isPositive = (size) => size.width > 0 && size.height > 0;
|
|
7
|
+
const isLandscape = (size) => size.width > size.height;
|
|
8
|
+
/**
|
|
9
|
+
* The screenshot always shows the display as it is rotated right now, but the
|
|
10
|
+
* reported screen size can be the device's natural (portrait) size even while
|
|
11
|
+
* a landscape app is in front. Taps land in the current rotation's coordinates,
|
|
12
|
+
* so when the two disagree the screen size is turned to match the screenshot.
|
|
13
|
+
*/
|
|
14
|
+
const orientLike = (screen, screenshot) => {
|
|
15
|
+
if (isLandscape(screen) === isLandscape(screenshot)) {
|
|
16
|
+
return screen;
|
|
17
|
+
}
|
|
18
|
+
return { width: screen.height, height: screen.width };
|
|
19
|
+
};
|
|
7
20
|
/**
|
|
8
21
|
* Plain-words instruction for a model that reads pixel positions off a
|
|
9
22
|
* screenshot and taps in screen coordinates. The screenshot is usually
|
|
@@ -13,10 +26,11 @@ const isPositive = (size) => size.width > 0 && size.height > 0;
|
|
|
13
26
|
* Returns null when either size is unknown, in which case no instruction is
|
|
14
27
|
* better than a wrong one.
|
|
15
28
|
*/
|
|
16
|
-
const describeCoordinateMapping = (screenshot,
|
|
17
|
-
if (!isPositive(screenshot) || !isPositive(
|
|
29
|
+
const describeCoordinateMapping = (screenshot, reportedScreen) => {
|
|
30
|
+
if (!isPositive(screenshot) || !isPositive(reportedScreen)) {
|
|
18
31
|
return null;
|
|
19
32
|
}
|
|
33
|
+
const screen = orientLike(reportedScreen, screenshot);
|
|
20
34
|
if (screenshot.width === screen.width && screenshot.height === screen.height) {
|
|
21
35
|
return `Screenshot is ${screenshot.width}x${screenshot.height} and its coordinates match the screen.`;
|
|
22
36
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilenext/mobile-mcp",
|
|
3
3
|
"mcpName": "io.github.mobile-next/mobile-mcp",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.17",
|
|
5
5
|
"description": "Mobile MCP",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"commander": "14.0.0",
|
|
35
35
|
"express": "5.1.0",
|
|
36
36
|
"fast-xml-parser": "5.8.0",
|
|
37
|
-
"mobilewright": "0.0.
|
|
37
|
+
"mobilewright": "0.0.69",
|
|
38
38
|
"qs": "^6.15.0",
|
|
39
39
|
"zod": "^4.2.0",
|
|
40
40
|
"zod-to-json-schema": "3.25.0"
|