@xbrowser/cli 1.36.0 → 1.37.0
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 +2 -1
- package/dist/{browser-NHQDQRXB.js → browser-CWVY2C5V.js} +3 -3
- package/dist/{browser-IEZOLTHA.js → browser-DSM7YPVZ.js} +3 -3
- package/dist/{browser-XELRNYBL.js → browser-K4RWHYQ2.js} +3 -3
- package/dist/{cdp-driver-HBMCD7NU.js → cdp-driver-KVQCGEWT.js} +2 -2
- package/dist/{cdp-driver-CCG3OJUQ.js → cdp-driver-L4QGY64J.js} +2 -2
- package/dist/{cdp-driver-YJU4GRSV.js → cdp-driver-O7E64BL6.js} +28 -40
- package/dist/{cdp-driver-MJD7YIQI.js → cdp-driver-PF4QRNAV.js} +2 -2
- package/dist/{chunk-7KVH6MQG.js → chunk-3SUFLRQX.js} +35 -7
- package/dist/{chunk-ZCZELQCS.js → chunk-6DBSRCQI.js} +28 -40
- package/dist/{chunk-L6QJUB33.js → chunk-6I5BA5EC.js} +4 -3
- package/dist/{chunk-PGEZJ6V3.js → chunk-6UB2FLH2.js} +2 -2
- package/dist/{chunk-ENTENDF5.js → chunk-H433EQX5.js} +2 -2
- package/dist/{chunk-ZR4NHTUV.js → chunk-HLSBWITP.js} +1 -1
- package/dist/{chunk-SMYSNO4M.js → chunk-HMQ4EZHR.js} +1 -0
- package/dist/{chunk-GYGVHWG3.js → chunk-HWQCFH4G.js} +28 -40
- package/dist/{chunk-RL5FFY2Q.js → chunk-IAUMVNWB.js} +2 -2
- package/dist/{chunk-6DS3T6UK.js → chunk-M4FGG7A3.js} +28 -40
- package/dist/{chunk-5UXRFNXG.js → chunk-NHCVBAIA.js} +4 -3
- package/dist/{chunk-KSB4PMCY.js → chunk-P2AMADHR.js} +2 -2
- package/dist/{chunk-WGWPWNIA.js → chunk-QIESAGLP.js} +1 -1
- package/dist/{chunk-GVJ2UY65.js → chunk-SA5M52HK.js} +34 -6
- package/dist/{chunk-2IOFJ6A3.js → chunk-T33IUKF4.js} +2 -2
- package/dist/{chunk-SBMVECDS.js → chunk-ULGP5HU4.js} +1 -1
- package/dist/{chunk-YW4BIJQL.js → chunk-ZCMA5IAH.js} +168 -8
- package/dist/cli.js +107 -44
- package/dist/{convert-JNOM6H6A.js → convert-3763HY7E.js} +168 -8
- package/dist/{convert-K6TLQEPX.js → convert-5UO5IBMQ.js} +1 -1
- package/dist/{daemon-client-BBPQWLUX.js → daemon-client-AMJFDIZB.js} +1 -1
- package/dist/{daemon-client-AKQK5IIB.js → daemon-client-HGT7ZZB3.js} +1 -1
- package/dist/daemon-main.js +39 -35
- package/dist/index.d.ts +2 -0
- package/dist/index.js +108 -45
- package/dist/{run-routes-FG4LIACU.js → run-routes-EB5YPDWD.js} +6 -6
- package/dist/{run-routes-64IBBVOX.js → run-routes-FNBYGOPN.js} +6 -6
- package/dist/{server-ZHZDJJMG.js → server-HPRGIOH5.js} +4 -4
- package/dist/{server-K22LJBO2.js → server-LZ3CNGDT.js} +4 -4
- package/dist/{session-recorder-KMKSQWEP.js → session-recorder-A3AZCO57.js} +1 -1
- package/dist/{session-recorder-CNTY5KXF.js → session-recorder-LFJZDYGF.js} +1 -1
- package/dist/{session-replayer-4TCLQI76.js → session-replayer-KEQVHPWG.js} +1 -1
- package/dist/{stealth-FMPZO2OB.js → stealth-2PAR54UM.js} +1 -1
- package/dist/{stealth-MCKFKPZ6.js → stealth-67ZCVW3Z.js} +1 -1
- package/dist/{viewer-routes-CEO7HWCB.js → viewer-routes-MDYXTWVS.js} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -479,8 +479,9 @@ xbrowser create my-plugin --template static --force
|
|
|
479
479
|
|
|
480
480
|
**注意**:
|
|
481
481
|
- 命令链中如果包含特殊字符(如 `#`、`>`),需要用引号包裹整个命令链或对单个参数加引号。
|
|
482
|
-
- `,`、`+`、`->`、`&&`、`||` 两边都要有空格(`goto url -> title` ✅,`goto url->title` ❌);`;`
|
|
482
|
+
- `,`、`+`、`->`、`&&`、`||` 两边都要有空格(`goto url -> title` ✅,`goto url->title` ❌);`;` 前后的空格可有可无(`goto url; title` ✅,`goto url;title` ✅),`;` 后面跟的不是命令时它只是普通字符(`goto https://example.com/a;b=1` 整串是一个 URL)。
|
|
483
483
|
- 只在分隔符前面留空格(如 `title ,url`)不会被识别成命令链:整串按单条命令执行,后面的命令被静默忽略。
|
|
484
|
+
- 值以 `-` 开头时,用 `--` 把它和选项隔开(负数不需要):`xbrowser fill -- '#q' '- item'`。`--` 之后的一切都是字面量,`--session` 这类全局选项要写在 `--` 之前。
|
|
484
485
|
|
|
485
486
|
```bash
|
|
486
487
|
# 正确 — 整体引号
|
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
saveSessionDiskMeta,
|
|
22
22
|
setActivePage,
|
|
23
23
|
touchSession
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-P2AMADHR.js";
|
|
25
|
+
import "./chunk-HWQCFH4G.js";
|
|
26
|
+
import "./chunk-HMQ4EZHR.js";
|
|
27
27
|
import "./chunk-IYCB2KJL.js";
|
|
28
28
|
import "./chunk-GDKLH7ZY.js";
|
|
29
29
|
import "./chunk-KFQGP6VL.js";
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
saveSessionDiskMeta,
|
|
22
22
|
setActivePage,
|
|
23
23
|
touchSession
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-6UB2FLH2.js";
|
|
25
|
+
import "./chunk-6DBSRCQI.js";
|
|
26
26
|
import "./chunk-A7NEA4PA.js";
|
|
27
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-HMQ4EZHR.js";
|
|
28
28
|
import "./chunk-IYCB2KJL.js";
|
|
29
29
|
import "./chunk-GDKLH7ZY.js";
|
|
30
30
|
import "./chunk-KFQGP6VL.js";
|
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
saveSessionDiskMeta,
|
|
22
22
|
setActivePage,
|
|
23
23
|
touchSession
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-H433EQX5.js";
|
|
25
|
+
import "./chunk-M4FGG7A3.js";
|
|
26
|
+
import "./chunk-HMQ4EZHR.js";
|
|
27
27
|
import "./chunk-IYCB2KJL.js";
|
|
28
28
|
import "./chunk-GDKLH7ZY.js";
|
|
29
29
|
import "./chunk-NEE6EMYA.js";
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
scrollIntoView,
|
|
15
15
|
waitForActionable,
|
|
16
16
|
waitForNetworkIdle
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6DBSRCQI.js";
|
|
18
18
|
import "./chunk-A7NEA4PA.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-HMQ4EZHR.js";
|
|
20
20
|
import {
|
|
21
21
|
connectToCDP,
|
|
22
22
|
findChrome,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
landingOffset,
|
|
6
6
|
rand,
|
|
7
7
|
typingDelay
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HMQ4EZHR.js";
|
|
9
9
|
import {
|
|
10
10
|
connectToCDP,
|
|
11
11
|
errMsg,
|
|
@@ -85,17 +85,16 @@ var XBMouseImpl = class {
|
|
|
85
85
|
} else {
|
|
86
86
|
await this.move(tx, ty);
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
await
|
|
98
|
-
await this.up({ button });
|
|
88
|
+
const clickCount = Math.max(1, opts.clickCount ?? 1);
|
|
89
|
+
for (let n = 1; n <= clickCount; n++) {
|
|
90
|
+
await this.down({ button, clickCount: n });
|
|
91
|
+
await sleep(stealth ? rand(...DEFAULT_STEALTH_CONFIG.pressDuration) : opts.delay ?? 0);
|
|
92
|
+
if (stealth) {
|
|
93
|
+
this._x += rand(...DEFAULT_STEALTH_CONFIG.releaseDrift) * (Math.random() < 0.5 ? -1 : 1);
|
|
94
|
+
this._y += rand(...DEFAULT_STEALTH_CONFIG.releaseDrift) * (Math.random() < 0.5 ? -1 : 1);
|
|
95
|
+
}
|
|
96
|
+
await this.release(button, n);
|
|
97
|
+
if (n < clickCount) await sleep(opts.delay ?? rand(...DEFAULT_STEALTH_CONFIG.doubleClickGap));
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
async dblclick(x, y, opts = {}) {
|
|
@@ -117,18 +116,27 @@ var XBMouseImpl = class {
|
|
|
117
116
|
});
|
|
118
117
|
}
|
|
119
118
|
async up(opts = {}) {
|
|
120
|
-
|
|
119
|
+
await this.release(opts.button ?? "left", opts.clickCount ?? 1);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Release `button` and forget it. The bit is cleared BEFORE the event goes out:
|
|
123
|
+
* Chrome derives pointerup from the button-state change, so a release that still
|
|
124
|
+
* claims the button is down delivers mouseup and click but no pointerup. Measured
|
|
125
|
+
* 2026-11-24: pointer-driven sliders never finished a `mouse drag`, the recorder
|
|
126
|
+
* logged the drag as a click, and a button left in the mask made every later
|
|
127
|
+
* press of another button lose its pointerdown.
|
|
128
|
+
*/
|
|
129
|
+
async release(button, clickCount) {
|
|
130
|
+
this._buttons &= ~buttonBit(button);
|
|
121
131
|
this._button = "none";
|
|
122
132
|
await this.send("Input.dispatchMouseEvent", {
|
|
123
133
|
type: "mouseReleased",
|
|
124
134
|
x: this._x,
|
|
125
135
|
y: this._y,
|
|
126
136
|
button,
|
|
127
|
-
// release 先带位发送再清位(Puppeteer 同序——DOM mouseup 的 buttons 反映释放后状态)
|
|
128
137
|
buttons: this._buttons,
|
|
129
|
-
clickCount
|
|
138
|
+
clickCount
|
|
130
139
|
});
|
|
131
|
-
this._buttons &= ~buttonBit(button);
|
|
132
140
|
}
|
|
133
141
|
async move(x, y, opts = {}) {
|
|
134
142
|
const stealth = opts.stealth ?? process.env.XBROWSER_STEALTH !== "off";
|
|
@@ -162,16 +170,7 @@ var XBMouseImpl = class {
|
|
|
162
170
|
*/
|
|
163
171
|
async drag(x, y, opts = {}) {
|
|
164
172
|
const stealth = process.env.XBROWSER_STEALTH !== "off";
|
|
165
|
-
await this.
|
|
166
|
-
type: "mousePressed",
|
|
167
|
-
x: this._x,
|
|
168
|
-
y: this._y,
|
|
169
|
-
button: "left",
|
|
170
|
-
buttons: 1,
|
|
171
|
-
clickCount: 1
|
|
172
|
-
});
|
|
173
|
-
this._button = "left";
|
|
174
|
-
this._buttons |= 1;
|
|
173
|
+
await this.down({ button: "left" });
|
|
175
174
|
const steps = opts.steps ?? Math.max(10, Math.min(24, Math.round(Math.hypot(x - this._x, y - this._y) / 20)));
|
|
176
175
|
const fx = this._x, fy = this._y;
|
|
177
176
|
for (let i = 1; i <= steps; i++) {
|
|
@@ -190,16 +189,7 @@ var XBMouseImpl = class {
|
|
|
190
189
|
this._x = x;
|
|
191
190
|
this._y = y;
|
|
192
191
|
await sleep(rand(60, 140));
|
|
193
|
-
await this.
|
|
194
|
-
type: "mouseReleased",
|
|
195
|
-
x,
|
|
196
|
-
y,
|
|
197
|
-
button: "left",
|
|
198
|
-
buttons: this._buttons,
|
|
199
|
-
clickCount: 1
|
|
200
|
-
});
|
|
201
|
-
this._button = "none";
|
|
202
|
-
this._buttons &= ~1;
|
|
192
|
+
await this.release("left", 1);
|
|
203
193
|
}
|
|
204
194
|
async wheelAt(x, y, deltaX, deltaY) {
|
|
205
195
|
await this.move(x, y);
|
|
@@ -3392,9 +3382,7 @@ Last error: ${lastError.message}` : "";
|
|
|
3392
3382
|
await this.locator(selector).click(opts);
|
|
3393
3383
|
}
|
|
3394
3384
|
async dblclick(selector, opts = {}) {
|
|
3395
|
-
|
|
3396
|
-
await locator.click({ ...opts, clickCount: 1 });
|
|
3397
|
-
await locator.click({ ...opts, clickCount: 2 });
|
|
3385
|
+
await this.locator(selector).click({ ...opts, clickCount: 2 });
|
|
3398
3386
|
}
|
|
3399
3387
|
async fill(selector, value, opts = {}) {
|
|
3400
3388
|
await this.locator(selector).fill(value, opts);
|
|
@@ -5860,7 +5848,7 @@ async function launch(options = {}) {
|
|
|
5860
5848
|
const bv = await conn.send("Browser.getVersion");
|
|
5861
5849
|
const m = bv.product.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
|
|
5862
5850
|
if (m && !options.stealthConfig?.uaChProfile) {
|
|
5863
|
-
const { deriveUaChProfileForBinary } = await import("./stealth-
|
|
5851
|
+
const { deriveUaChProfileForBinary } = await import("./stealth-2PAR54UM.js");
|
|
5864
5852
|
stealthOpts = { stealthConfig: { uaChProfile: deriveUaChProfileForBinary(m[0], m[1]) } };
|
|
5865
5853
|
}
|
|
5866
5854
|
} catch {
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
saveSessionDiskMeta,
|
|
14
14
|
sessions,
|
|
15
15
|
setActivePage
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-P2AMADHR.js";
|
|
17
17
|
import {
|
|
18
18
|
detectAntiBot,
|
|
19
19
|
formatDetectionMessage
|
|
@@ -29,12 +29,12 @@ import {
|
|
|
29
29
|
} from "./chunk-ZTHE5RBZ.js";
|
|
30
30
|
import {
|
|
31
31
|
createRuleEngine
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-HWQCFH4G.js";
|
|
33
33
|
import {
|
|
34
34
|
rand,
|
|
35
35
|
sleep,
|
|
36
36
|
wheelDelta
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-HMQ4EZHR.js";
|
|
38
38
|
import {
|
|
39
39
|
errMsg
|
|
40
40
|
} from "./chunk-GDKLH7ZY.js";
|
|
@@ -6360,6 +6360,27 @@ function splitOutsideQuotes(input, separator) {
|
|
|
6360
6360
|
parts.push(current);
|
|
6361
6361
|
return parts;
|
|
6362
6362
|
}
|
|
6363
|
+
var CHAIN_OPERATOR_TOKENS = /* @__PURE__ */ new Set(["&&", "||", ";", ",", "+", "->"]);
|
|
6364
|
+
function quoteChainToken(word, force = false) {
|
|
6365
|
+
if (!force && !/[\s'"(),;|&]/.test(word) && !/^[+,]|[+,]$/.test(word)) return word;
|
|
6366
|
+
const absent = ['"', "'"].find((quote) => !word.includes(quote));
|
|
6367
|
+
const candidates = absent ? [absent, absent === '"' ? "'" : '"'] : ['"', "'"];
|
|
6368
|
+
for (const quote of candidates) {
|
|
6369
|
+
if (isOpaqueWhenQuoted(word, quote)) return `${quote}${word}${quote}`;
|
|
6370
|
+
}
|
|
6371
|
+
return word;
|
|
6372
|
+
}
|
|
6373
|
+
function isOpaqueWhenQuoted(word, quote) {
|
|
6374
|
+
let inside = true;
|
|
6375
|
+
for (const ch of word) {
|
|
6376
|
+
if (ch === quote) {
|
|
6377
|
+
inside = !inside;
|
|
6378
|
+
} else if (!inside && /[\s();|&]/.test(ch)) {
|
|
6379
|
+
return false;
|
|
6380
|
+
}
|
|
6381
|
+
}
|
|
6382
|
+
return inside;
|
|
6383
|
+
}
|
|
6363
6384
|
registerCommandDefinition("goto", ["url"]);
|
|
6364
6385
|
registerCommandDefinition("click", ["selector"]);
|
|
6365
6386
|
registerCommandDefinition("fill", ["selector", "value"]);
|
|
@@ -9756,7 +9777,11 @@ async function executeChain(input, options, executeCommand2) {
|
|
|
9756
9777
|
if (pluginHandled) return pluginHandled;
|
|
9757
9778
|
continue;
|
|
9758
9779
|
}
|
|
9759
|
-
const { params } = parseCommandArgs(
|
|
9780
|
+
const { params } = parseCommandArgs(
|
|
9781
|
+
cmdName,
|
|
9782
|
+
cmdArgs.map((arg) => /^-\d+(?:\.\d+)?$/.test(arg) ? `'${arg}'` : arg),
|
|
9783
|
+
unquote2
|
|
9784
|
+
);
|
|
9760
9785
|
if (options?.frame && params._frame === void 0 && params.frame === void 0) {
|
|
9761
9786
|
params._frame = options.frame;
|
|
9762
9787
|
}
|
|
@@ -9833,7 +9858,7 @@ async function executePluginChainStep(context) {
|
|
|
9833
9858
|
}
|
|
9834
9859
|
const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
|
|
9835
9860
|
if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
|
|
9836
|
-
const { forwardPluginExec } = await import("./daemon-client-
|
|
9861
|
+
const { forwardPluginExec } = await import("./daemon-client-AMJFDIZB.js");
|
|
9837
9862
|
const userTimeout = typeof pluginParams.timeout === "number" && pluginParams.timeout > 0 ? pluginParams.timeout * 1e3 + 3e4 : void 0;
|
|
9838
9863
|
const startFwd = Date.now();
|
|
9839
9864
|
const fwd = await forwardPluginExec(
|
|
@@ -10060,7 +10085,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
10060
10085
|
}
|
|
10061
10086
|
let targetPageOverride = null;
|
|
10062
10087
|
if (_target && extraOpts?.cdpEndpoint) {
|
|
10063
|
-
const { findTargetPage } = await import("./browser-
|
|
10088
|
+
const { findTargetPage } = await import("./browser-CWVY2C5V.js");
|
|
10064
10089
|
targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
|
|
10065
10090
|
if (!targetPageOverride) {
|
|
10066
10091
|
return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
|
|
@@ -10078,7 +10103,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
10078
10103
|
params = result.data;
|
|
10079
10104
|
}
|
|
10080
10105
|
if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
|
|
10081
|
-
const { forwardExec } = await import("./daemon-client-
|
|
10106
|
+
const { forwardExec } = await import("./daemon-client-AMJFDIZB.js");
|
|
10082
10107
|
const longRunning = /^(vision-task|task|crawl|scrape|record|replay)$/.test(commandName);
|
|
10083
10108
|
const result = await forwardExec(
|
|
10084
10109
|
commandName,
|
|
@@ -10366,7 +10391,10 @@ export {
|
|
|
10366
10391
|
getAllCommands,
|
|
10367
10392
|
getCommandNames,
|
|
10368
10393
|
splitOutsideQuotes,
|
|
10394
|
+
CHAIN_OPERATOR_TOKENS,
|
|
10395
|
+
quoteChainToken,
|
|
10369
10396
|
attachDetectAntiBot,
|
|
10397
|
+
bridgeHttpBase,
|
|
10370
10398
|
asZodSchema,
|
|
10371
10399
|
normalizeKebabParams,
|
|
10372
10400
|
loadHooks,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
landingOffset,
|
|
10
10
|
rand,
|
|
11
11
|
typingDelay
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HMQ4EZHR.js";
|
|
13
13
|
import {
|
|
14
14
|
connectToCDP,
|
|
15
15
|
launchChrome
|
|
@@ -88,17 +88,16 @@ var XBMouseImpl = class {
|
|
|
88
88
|
} else {
|
|
89
89
|
await this.move(tx, ty);
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
await
|
|
101
|
-
await this.up({ button });
|
|
91
|
+
const clickCount = Math.max(1, opts.clickCount ?? 1);
|
|
92
|
+
for (let n = 1; n <= clickCount; n++) {
|
|
93
|
+
await this.down({ button, clickCount: n });
|
|
94
|
+
await sleep(stealth ? rand(...DEFAULT_STEALTH_CONFIG.pressDuration) : opts.delay ?? 0);
|
|
95
|
+
if (stealth) {
|
|
96
|
+
this._x += rand(...DEFAULT_STEALTH_CONFIG.releaseDrift) * (Math.random() < 0.5 ? -1 : 1);
|
|
97
|
+
this._y += rand(...DEFAULT_STEALTH_CONFIG.releaseDrift) * (Math.random() < 0.5 ? -1 : 1);
|
|
98
|
+
}
|
|
99
|
+
await this.release(button, n);
|
|
100
|
+
if (n < clickCount) await sleep(opts.delay ?? rand(...DEFAULT_STEALTH_CONFIG.doubleClickGap));
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
async dblclick(x, y, opts = {}) {
|
|
@@ -120,18 +119,27 @@ var XBMouseImpl = class {
|
|
|
120
119
|
});
|
|
121
120
|
}
|
|
122
121
|
async up(opts = {}) {
|
|
123
|
-
|
|
122
|
+
await this.release(opts.button ?? "left", opts.clickCount ?? 1);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Release `button` and forget it. The bit is cleared BEFORE the event goes out:
|
|
126
|
+
* Chrome derives pointerup from the button-state change, so a release that still
|
|
127
|
+
* claims the button is down delivers mouseup and click but no pointerup. Measured
|
|
128
|
+
* 2026-11-24: pointer-driven sliders never finished a `mouse drag`, the recorder
|
|
129
|
+
* logged the drag as a click, and a button left in the mask made every later
|
|
130
|
+
* press of another button lose its pointerdown.
|
|
131
|
+
*/
|
|
132
|
+
async release(button, clickCount) {
|
|
133
|
+
this._buttons &= ~buttonBit(button);
|
|
124
134
|
this._button = "none";
|
|
125
135
|
await this.send("Input.dispatchMouseEvent", {
|
|
126
136
|
type: "mouseReleased",
|
|
127
137
|
x: this._x,
|
|
128
138
|
y: this._y,
|
|
129
139
|
button,
|
|
130
|
-
// release 先带位发送再清位(Puppeteer 同序——DOM mouseup 的 buttons 反映释放后状态)
|
|
131
140
|
buttons: this._buttons,
|
|
132
|
-
clickCount
|
|
141
|
+
clickCount
|
|
133
142
|
});
|
|
134
|
-
this._buttons &= ~buttonBit(button);
|
|
135
143
|
}
|
|
136
144
|
async move(x, y, opts = {}) {
|
|
137
145
|
const stealth = opts.stealth ?? process.env.XBROWSER_STEALTH !== "off";
|
|
@@ -165,16 +173,7 @@ var XBMouseImpl = class {
|
|
|
165
173
|
*/
|
|
166
174
|
async drag(x, y, opts = {}) {
|
|
167
175
|
const stealth = process.env.XBROWSER_STEALTH !== "off";
|
|
168
|
-
await this.
|
|
169
|
-
type: "mousePressed",
|
|
170
|
-
x: this._x,
|
|
171
|
-
y: this._y,
|
|
172
|
-
button: "left",
|
|
173
|
-
buttons: 1,
|
|
174
|
-
clickCount: 1
|
|
175
|
-
});
|
|
176
|
-
this._button = "left";
|
|
177
|
-
this._buttons |= 1;
|
|
176
|
+
await this.down({ button: "left" });
|
|
178
177
|
const steps = opts.steps ?? Math.max(10, Math.min(24, Math.round(Math.hypot(x - this._x, y - this._y) / 20)));
|
|
179
178
|
const fx = this._x, fy = this._y;
|
|
180
179
|
for (let i = 1; i <= steps; i++) {
|
|
@@ -193,16 +192,7 @@ var XBMouseImpl = class {
|
|
|
193
192
|
this._x = x;
|
|
194
193
|
this._y = y;
|
|
195
194
|
await sleep(rand(60, 140));
|
|
196
|
-
await this.
|
|
197
|
-
type: "mouseReleased",
|
|
198
|
-
x,
|
|
199
|
-
y,
|
|
200
|
-
button: "left",
|
|
201
|
-
buttons: this._buttons,
|
|
202
|
-
clickCount: 1
|
|
203
|
-
});
|
|
204
|
-
this._button = "none";
|
|
205
|
-
this._buttons &= ~1;
|
|
195
|
+
await this.release("left", 1);
|
|
206
196
|
}
|
|
207
197
|
async wheelAt(x, y, deltaX, deltaY) {
|
|
208
198
|
await this.move(x, y);
|
|
@@ -3293,9 +3283,7 @@ Last error: ${lastError.message}` : "";
|
|
|
3293
3283
|
await this.locator(selector).click(opts);
|
|
3294
3284
|
}
|
|
3295
3285
|
async dblclick(selector, opts = {}) {
|
|
3296
|
-
|
|
3297
|
-
await locator.click({ ...opts, clickCount: 1 });
|
|
3298
|
-
await locator.click({ ...opts, clickCount: 2 });
|
|
3286
|
+
await this.locator(selector).click({ ...opts, clickCount: 2 });
|
|
3299
3287
|
}
|
|
3300
3288
|
async fill(selector, value, opts = {}) {
|
|
3301
3289
|
await this.locator(selector).fill(value, opts);
|
|
@@ -5761,7 +5749,7 @@ async function launch(options = {}) {
|
|
|
5761
5749
|
const bv = await conn.send("Browser.getVersion");
|
|
5762
5750
|
const m = bv.product.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
|
|
5763
5751
|
if (m && !options.stealthConfig?.uaChProfile) {
|
|
5764
|
-
const { deriveUaChProfileForBinary } = await import("./stealth-
|
|
5752
|
+
const { deriveUaChProfileForBinary } = await import("./stealth-67ZCVW3Z.js");
|
|
5765
5753
|
stealthOpts = { stealthConfig: { uaChProfile: deriveUaChProfileForBinary(m[0], m[1]) } };
|
|
5766
5754
|
}
|
|
5767
5755
|
} catch {
|
|
@@ -2941,6 +2941,8 @@ var SessionRecorder = class _SessionRecorder {
|
|
|
2941
2941
|
_isRecording = false;
|
|
2942
2942
|
streamMode = "clean";
|
|
2943
2943
|
snapshotThrottle = /* @__PURE__ */ new Map();
|
|
2944
|
+
// contextmenu 不在此列:右键打开菜单是一次有目标的交互,和点击同级——当作噪音
|
|
2945
|
+
// 丢掉后,默认(clean)录制里根本没有这一步,回放时菜单永远打不开。
|
|
2944
2946
|
static AMBIENT_TYPES = /* @__PURE__ */ new Set([
|
|
2945
2947
|
"hover",
|
|
2946
2948
|
"focus",
|
|
@@ -2948,8 +2950,7 @@ var SessionRecorder = class _SessionRecorder {
|
|
|
2948
2950
|
"visibility",
|
|
2949
2951
|
"resize",
|
|
2950
2952
|
"clipboard",
|
|
2951
|
-
"touch"
|
|
2952
|
-
"contextmenu"
|
|
2953
|
+
"touch"
|
|
2953
2954
|
]);
|
|
2954
2955
|
constructor(context, page, sessionName) {
|
|
2955
2956
|
this.context = context;
|
|
@@ -3531,7 +3532,7 @@ var SessionRecorder = class _SessionRecorder {
|
|
|
3531
3532
|
} catch {
|
|
3532
3533
|
}
|
|
3533
3534
|
for (const raw of pending) {
|
|
3534
|
-
if (raw.ts
|
|
3535
|
+
if (raw.ts < this.lastActionTs) continue;
|
|
3535
3536
|
if (raw.type === "discovered_filters") {
|
|
3536
3537
|
if (Array.isArray(raw.discoveredFilters)) {
|
|
3537
3538
|
for (const f of raw.discoveredFilters) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRuleEngine,
|
|
3
3
|
launch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6DBSRCQI.js";
|
|
5
5
|
import {
|
|
6
6
|
errMsg
|
|
7
7
|
} from "./chunk-GDKLH7ZY.js";
|
|
@@ -1259,7 +1259,7 @@ async function closeSessionByName(name) {
|
|
|
1259
1259
|
} catch {
|
|
1260
1260
|
}
|
|
1261
1261
|
try {
|
|
1262
|
-
const { SessionRecorder } = await import("./session-recorder-
|
|
1262
|
+
const { SessionRecorder } = await import("./session-recorder-A3AZCO57.js");
|
|
1263
1263
|
SessionRecorder.cleanup(session.name);
|
|
1264
1264
|
} catch {
|
|
1265
1265
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
launch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-M4FGG7A3.js";
|
|
4
4
|
import {
|
|
5
5
|
errMsg
|
|
6
6
|
} from "./chunk-GDKLH7ZY.js";
|
|
@@ -817,7 +817,7 @@ async function closeSessionByName(name) {
|
|
|
817
817
|
} catch {
|
|
818
818
|
}
|
|
819
819
|
try {
|
|
820
|
-
const { SessionRecorder } = await import("./session-recorder-
|
|
820
|
+
const { SessionRecorder } = await import("./session-recorder-LFJZDYGF.js");
|
|
821
821
|
SessionRecorder.cleanup(session.name);
|
|
822
822
|
} catch {
|
|
823
823
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
landingOffset,
|
|
6
6
|
rand,
|
|
7
7
|
typingDelay
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HMQ4EZHR.js";
|
|
9
9
|
import {
|
|
10
10
|
connectToCDP,
|
|
11
11
|
launchChrome
|
|
@@ -84,17 +84,16 @@ var XBMouseImpl = class {
|
|
|
84
84
|
} else {
|
|
85
85
|
await this.move(tx, ty);
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
await
|
|
97
|
-
await this.up({ button });
|
|
87
|
+
const clickCount = Math.max(1, opts.clickCount ?? 1);
|
|
88
|
+
for (let n = 1; n <= clickCount; n++) {
|
|
89
|
+
await this.down({ button, clickCount: n });
|
|
90
|
+
await sleep(stealth ? rand(...DEFAULT_STEALTH_CONFIG.pressDuration) : opts.delay ?? 0);
|
|
91
|
+
if (stealth) {
|
|
92
|
+
this._x += rand(...DEFAULT_STEALTH_CONFIG.releaseDrift) * (Math.random() < 0.5 ? -1 : 1);
|
|
93
|
+
this._y += rand(...DEFAULT_STEALTH_CONFIG.releaseDrift) * (Math.random() < 0.5 ? -1 : 1);
|
|
94
|
+
}
|
|
95
|
+
await this.release(button, n);
|
|
96
|
+
if (n < clickCount) await sleep(opts.delay ?? rand(...DEFAULT_STEALTH_CONFIG.doubleClickGap));
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
async dblclick(x, y, opts = {}) {
|
|
@@ -116,18 +115,27 @@ var XBMouseImpl = class {
|
|
|
116
115
|
});
|
|
117
116
|
}
|
|
118
117
|
async up(opts = {}) {
|
|
119
|
-
|
|
118
|
+
await this.release(opts.button ?? "left", opts.clickCount ?? 1);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Release `button` and forget it. The bit is cleared BEFORE the event goes out:
|
|
122
|
+
* Chrome derives pointerup from the button-state change, so a release that still
|
|
123
|
+
* claims the button is down delivers mouseup and click but no pointerup. Measured
|
|
124
|
+
* 2026-11-24: pointer-driven sliders never finished a `mouse drag`, the recorder
|
|
125
|
+
* logged the drag as a click, and a button left in the mask made every later
|
|
126
|
+
* press of another button lose its pointerdown.
|
|
127
|
+
*/
|
|
128
|
+
async release(button, clickCount) {
|
|
129
|
+
this._buttons &= ~buttonBit(button);
|
|
120
130
|
this._button = "none";
|
|
121
131
|
await this.send("Input.dispatchMouseEvent", {
|
|
122
132
|
type: "mouseReleased",
|
|
123
133
|
x: this._x,
|
|
124
134
|
y: this._y,
|
|
125
135
|
button,
|
|
126
|
-
// release 先带位发送再清位(Puppeteer 同序——DOM mouseup 的 buttons 反映释放后状态)
|
|
127
136
|
buttons: this._buttons,
|
|
128
|
-
clickCount
|
|
137
|
+
clickCount
|
|
129
138
|
});
|
|
130
|
-
this._buttons &= ~buttonBit(button);
|
|
131
139
|
}
|
|
132
140
|
async move(x, y, opts = {}) {
|
|
133
141
|
const stealth = opts.stealth ?? process.env.XBROWSER_STEALTH !== "off";
|
|
@@ -161,16 +169,7 @@ var XBMouseImpl = class {
|
|
|
161
169
|
*/
|
|
162
170
|
async drag(x, y, opts = {}) {
|
|
163
171
|
const stealth = process.env.XBROWSER_STEALTH !== "off";
|
|
164
|
-
await this.
|
|
165
|
-
type: "mousePressed",
|
|
166
|
-
x: this._x,
|
|
167
|
-
y: this._y,
|
|
168
|
-
button: "left",
|
|
169
|
-
buttons: 1,
|
|
170
|
-
clickCount: 1
|
|
171
|
-
});
|
|
172
|
-
this._button = "left";
|
|
173
|
-
this._buttons |= 1;
|
|
172
|
+
await this.down({ button: "left" });
|
|
174
173
|
const steps = opts.steps ?? Math.max(10, Math.min(24, Math.round(Math.hypot(x - this._x, y - this._y) / 20)));
|
|
175
174
|
const fx = this._x, fy = this._y;
|
|
176
175
|
for (let i = 1; i <= steps; i++) {
|
|
@@ -189,16 +188,7 @@ var XBMouseImpl = class {
|
|
|
189
188
|
this._x = x;
|
|
190
189
|
this._y = y;
|
|
191
190
|
await sleep(rand(60, 140));
|
|
192
|
-
await this.
|
|
193
|
-
type: "mouseReleased",
|
|
194
|
-
x,
|
|
195
|
-
y,
|
|
196
|
-
button: "left",
|
|
197
|
-
buttons: this._buttons,
|
|
198
|
-
clickCount: 1
|
|
199
|
-
});
|
|
200
|
-
this._button = "none";
|
|
201
|
-
this._buttons &= ~1;
|
|
191
|
+
await this.release("left", 1);
|
|
202
192
|
}
|
|
203
193
|
async wheelAt(x, y, deltaX, deltaY) {
|
|
204
194
|
await this.move(x, y);
|
|
@@ -3391,9 +3381,7 @@ Last error: ${lastError.message}` : "";
|
|
|
3391
3381
|
await this.locator(selector).click(opts);
|
|
3392
3382
|
}
|
|
3393
3383
|
async dblclick(selector, opts = {}) {
|
|
3394
|
-
|
|
3395
|
-
await locator.click({ ...opts, clickCount: 1 });
|
|
3396
|
-
await locator.click({ ...opts, clickCount: 2 });
|
|
3384
|
+
await this.locator(selector).click({ ...opts, clickCount: 2 });
|
|
3397
3385
|
}
|
|
3398
3386
|
async fill(selector, value, opts = {}) {
|
|
3399
3387
|
await this.locator(selector).fill(value, opts);
|
|
@@ -5859,7 +5847,7 @@ async function launch(options = {}) {
|
|
|
5859
5847
|
const bv = await conn.send("Browser.getVersion");
|
|
5860
5848
|
const m = bv.product.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
|
|
5861
5849
|
if (m && !options.stealthConfig?.uaChProfile) {
|
|
5862
|
-
const { deriveUaChProfileForBinary } = await import("./stealth-
|
|
5850
|
+
const { deriveUaChProfileForBinary } = await import("./stealth-67ZCVW3Z.js");
|
|
5863
5851
|
stealthOpts = { stealthConfig: { uaChProfile: deriveUaChProfileForBinary(m[0], m[1]) } };
|
|
5864
5852
|
}
|
|
5865
5853
|
} catch {
|