@mearl/client 3.4.0 → 3.4.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/dist/cli.js +13 -2
- package/dist/commands.d.ts +2 -2
- package/dist/commands.js +2 -1
- package/dist/guides/api-page-debugging.md +2 -0
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -738,8 +738,19 @@ export async function runMearlCli(args, options = {}) {
|
|
|
738
738
|
if (/connection timeout/i.test(message)) {
|
|
739
739
|
console.error('连接未就绪,请运行 mearl check 定位控制链路故障。');
|
|
740
740
|
}
|
|
741
|
-
else if (/请求超时|(?:request|command) timeout|timed out/i.test(message)
|
|
742
|
-
|
|
741
|
+
else if (/请求超时|(?:request|command) timeout|timed out/i.test(message) ||
|
|
742
|
+
(parsed.action === 'page_screenshot' && /due to timeout/i.test(message))) {
|
|
743
|
+
if (parsed.action === 'page_screenshot') {
|
|
744
|
+
if (parsed.payload.captureMode !== 'visible' &&
|
|
745
|
+
!message.includes('captureMode') &&
|
|
746
|
+
(!message.startsWith('CDP command timeout: ') ||
|
|
747
|
+
message.startsWith('CDP command timeout: Page.captureScreenshot'))) {
|
|
748
|
+
console.error('如果目标页在后台且使用纯 CDP 连接,可以传入 "captureMode":"visible" 重试。此选项可能激活目标标签页。');
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
console.error('超时不代表动作未执行。点击、提交或写入后先读取当前状态确认结果;只读查询可缩小范围或增加 --timeout(秒)后重试。');
|
|
753
|
+
}
|
|
743
754
|
}
|
|
744
755
|
return 1;
|
|
745
756
|
}
|
package/dist/commands.d.ts
CHANGED
|
@@ -1041,7 +1041,7 @@ export declare const COMMANDS: readonly [{
|
|
|
1041
1041
|
}, {
|
|
1042
1042
|
readonly name: "captureMode";
|
|
1043
1043
|
readonly type: "\"cdp\" | \"visible\"";
|
|
1044
|
-
readonly description: "默认 cdp
|
|
1044
|
+
readonly description: "默认 cdp。纯 CDP 连接下,visible 会在必要时激活目标标签页,确认可见后截图。扩展连接下,visible 截取已活动的标签页,普通网页无需 debugger,且不支持 selector。设备模拟复用模拟会话并截取业务视口。";
|
|
1045
1045
|
}, {
|
|
1046
1046
|
readonly name: "tabId";
|
|
1047
1047
|
readonly type: "number";
|
|
@@ -1050,7 +1050,7 @@ export declare const COMMANDS: readonly [{
|
|
|
1050
1050
|
}];
|
|
1051
1051
|
readonly notes: readonly ["使用 --output <path> 保存图片;省略时 stdout 返回含 base64 data 的 JSON,避免直接将其加载为文本。"];
|
|
1052
1052
|
readonly result: readonly ["meta 包含 format、width、height、size、url、title;宽高为实际截图的物理像素。"];
|
|
1053
|
-
readonly examples: ["page_screenshot --payload '{\"tabId\":12345}' --output ./screenshot.png", "page_screenshot --payload '{\"tabId\":12345,\"selector\":\".product-card\"}' --output ./card.png"];
|
|
1053
|
+
readonly examples: ["page_screenshot --payload '{\"tabId\":12345}' --output ./screenshot.png", "page_screenshot --payload '{\"tabId\":12345,\"captureMode\":\"visible\"}' --output ./screenshot.png", "page_screenshot --payload '{\"tabId\":12345,\"selector\":\".product-card\"}' --output ./card.png"];
|
|
1054
1054
|
}, {
|
|
1055
1055
|
readonly name: "set_device_emulation";
|
|
1056
1056
|
readonly description: "把目标 tab 切换为移动端模拟(视口/DPR/UA/触摸/视觉比例),等价 DevTools 设备工具栏,作用域 per-tab;需保持调试控制才持续生效";
|
package/dist/commands.js
CHANGED
|
@@ -1176,7 +1176,7 @@ export const COMMANDS = [
|
|
|
1176
1176
|
{
|
|
1177
1177
|
name: 'captureMode',
|
|
1178
1178
|
type: '"cdp" | "visible"',
|
|
1179
|
-
description: '默认 cdp
|
|
1179
|
+
description: '默认 cdp。纯 CDP 连接下,visible 会在必要时激活目标标签页,确认可见后截图。扩展连接下,visible 截取已活动的标签页,普通网页无需 debugger,且不支持 selector。设备模拟复用模拟会话并截取业务视口。',
|
|
1180
1180
|
},
|
|
1181
1181
|
{ name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
|
|
1182
1182
|
],
|
|
@@ -1186,6 +1186,7 @@ export const COMMANDS = [
|
|
|
1186
1186
|
result: ['meta 包含 format、width、height、size、url、title;宽高为实际截图的物理像素。'],
|
|
1187
1187
|
examples: [
|
|
1188
1188
|
`page_screenshot --payload '{"tabId":12345}' --output ./screenshot.png`,
|
|
1189
|
+
`page_screenshot --payload '{"tabId":12345,"captureMode":"visible"}' --output ./screenshot.png`,
|
|
1189
1190
|
`page_screenshot --payload '{"tabId":12345,"selector":".product-card"}' --output ./card.png`,
|
|
1190
1191
|
],
|
|
1191
1192
|
},
|
|
@@ -36,4 +36,6 @@
|
|
|
36
36
|
|
|
37
37
|
用 `page_screenshot --output <绝对路径>` 保存后交给图像查看能力;避免将 base64 stdout 放进文本上下文。支持当前视口和指定元素截图,元素截图可能滚动目标到可见区。
|
|
38
38
|
|
|
39
|
+
纯 CDP 后台截图超时时,可用 `captureMode: "visible"` 重试。此模式会在必要时激活目标标签页,确认页面可见后截图,适用于允许切换标签页的窗口。
|
|
40
|
+
|
|
39
41
|
Canvas、纯视觉变化、跨域 iframe 或用户明确要求的 UI 核验才需要截图,不作为每个动作后的固定步骤。图片宽高是物理像素,按 CSS 尺寸 × DPR 解释。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearl/client",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "Unified Mearl SDK & CLI for local and remote browsers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"commander": "^14.0.3",
|
|
70
70
|
"fastest-levenshtein": "^1.0.16",
|
|
71
71
|
"ws": "^8.18.0",
|
|
72
|
-
"@mearl/
|
|
73
|
-
"@mearl/
|
|
74
|
-
"@mearl/
|
|
75
|
-
"@mearl/browser-core": "3.4.
|
|
76
|
-
"@mearl/
|
|
72
|
+
"@mearl/provider": "3.4.2",
|
|
73
|
+
"@mearl/cloud-types": "3.4.2",
|
|
74
|
+
"@mearl/agent-runtime": "3.4.2",
|
|
75
|
+
"@mearl/browser-core": "3.4.2",
|
|
76
|
+
"@mearl/daemon-core": "3.4.2"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@types/node": "^24.9.1",
|