@xbrowser/cli 1.10.0 → 1.12.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/dist/{anti-bot-DR56Y63V.js → anti-bot-GTTYNEFB.js} +1 -1
- package/dist/{browser-WQZ3D6AE.js → browser-3HQKDZQ6.js} +4 -2
- package/dist/{browser-T3V3JWVH.js → browser-ILXTEWH4.js} +1 -1
- package/dist/{browser-HBL72GPZ.js → browser-XPDMY2NX.js} +3 -3
- package/dist/{cdp-driver-J3YQ4LJV.js → cdp-driver-ESH3PDE6.js} +2 -1
- package/dist/cdp-driver-N2E2ZNSC.js +4644 -0
- package/dist/cdp-driver-YIKR4BUX.js +49 -0
- package/dist/chunk-3FWLW7FS.js +106 -0
- package/dist/chunk-A6LPGFAL.js +437 -0
- package/dist/{chunk-RRBXV7KE.js → chunk-DKM2JOZL.js} +633 -63
- package/dist/{chunk-ABXMBNQ6.js → chunk-H2A5JUK5.js} +37 -466
- package/dist/{chunk-5UGR6MUK.js → chunk-HBHOKZPN.js} +51 -16
- package/dist/{chunk-BNO7OKO4.js → chunk-HBMEFSTB.js} +39 -0
- package/dist/{chunk-INTQPBYF.js → chunk-JKVUFP3G.js} +6 -2
- package/dist/chunk-KJTABK3Z.js +1255 -0
- package/dist/{chunk-DWDXEGVK.js → chunk-NKW4A74J.js} +9 -3
- package/dist/{chunk-4452SPFI.js → chunk-NODRQGOK.js} +51 -16
- package/dist/{chunk-SQHSZENE.js → chunk-OMU63E6J.js} +3 -22
- package/dist/{chunk-NITFVWWS.js → chunk-OVW2UEWN.js} +981 -407
- package/dist/{chunk-WSCP7QCJ.js → chunk-R6IJ6PIV.js} +14 -11
- package/dist/{chunk-YMUSHPU4.js → chunk-SH6OTPXN.js} +46 -16
- package/dist/{chunk-MWFHZUIY.js → chunk-TEXCXIBW.js} +1 -1
- package/dist/{cdp-driver-2T4P4ZE2.js → chunk-Z6CUR3VG.js} +1542 -134
- package/dist/{chunk-IIM5GOD7.js → chunk-ZTHE5RBZ.js} +7 -1
- package/dist/cli.js +1136 -584
- package/dist/{daemon-client-GKEPT4NY.js → daemon-client-7D6EZNOE.js} +46 -16
- package/dist/{daemon-client-O6BYVRXV.js → daemon-client-HEGAXWGK.js} +1 -1
- package/dist/daemon-main.js +1031 -522
- package/dist/{human-interaction-5AO42MBA.js → human-interaction-4YR2N6R6.js} +2 -2
- package/dist/{human-interaction-C5OEGXGO.js → human-interaction-Y5IDH6LD.js} +1 -1
- package/dist/{human-interaction-ISXZTAYY.js → human-interaction-ZUTR5AC2.js} +2 -2
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1147 -593
- package/dist/{proxy-C6CK3UH5.js → proxy-LUR4U5YF.js} +2 -1
- package/dist/{recovery-J2ISVGUL.js → recovery-FTZGV6VY.js} +2 -2
- package/dist/{recovery-ZJVVHP7N.js → recovery-L5GLDX4O.js} +1 -1
- package/dist/{recovery-EF33LKRJ.js → recovery-Z3RDZENA.js} +2 -2
- package/dist/{session-recorder-H3KEYU26.js → session-recorder-3BEVWHOK.js} +1 -1
- package/dist/{session-recorder-QRZMKFVL.js → session-recorder-SLDBENVF.js} +1 -1
- package/dist/{session-replayer-LJUC4TI7.js → session-replayer-K4A6OI4M.js} +90 -2
- package/package.json +1 -1
- package/dist/chunk-BAHSRZIX.js +0 -2191
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
launch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DKM2JOZL.js";
|
|
4
4
|
import {
|
|
5
5
|
errMsg
|
|
6
6
|
} from "./chunk-GDKLH7ZY.js";
|
|
7
7
|
import {
|
|
8
8
|
CDPInterceptorProxy
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A6LPGFAL.js";
|
|
10
10
|
|
|
11
11
|
// src/browser.ts
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
@@ -275,15 +275,18 @@ function deleteSessionDiskMeta(name) {
|
|
|
275
275
|
async function isSessionPageAlive(session) {
|
|
276
276
|
const page = session.page;
|
|
277
277
|
if (!page || typeof page.evaluate !== "function") return false;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
278
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
279
|
+
try {
|
|
280
|
+
await Promise.race([
|
|
281
|
+
page.evaluate("1"),
|
|
282
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("liveness probe timeout")), 1500))
|
|
283
|
+
]);
|
|
284
|
+
return true;
|
|
285
|
+
} catch {
|
|
286
|
+
await new Promise((r) => setTimeout(r, 400));
|
|
287
|
+
}
|
|
286
288
|
}
|
|
289
|
+
return false;
|
|
287
290
|
}
|
|
288
291
|
async function findOrRestoreSession(name, cdpEndpoint) {
|
|
289
292
|
const inMem = findSession(name);
|
|
@@ -706,7 +709,7 @@ async function closeSessionByName(name) {
|
|
|
706
709
|
} catch {
|
|
707
710
|
}
|
|
708
711
|
try {
|
|
709
|
-
const { SessionRecorder } = await import("./session-recorder-
|
|
712
|
+
const { SessionRecorder } = await import("./session-recorder-SLDBENVF.js");
|
|
710
713
|
SessionRecorder.cleanup(session.name);
|
|
711
714
|
} catch {
|
|
712
715
|
}
|
|
@@ -13,6 +13,7 @@ var pkg = require2("../package.json");
|
|
|
13
13
|
var version = pkg.version;
|
|
14
14
|
|
|
15
15
|
// src/client/daemon-client.ts
|
|
16
|
+
import { request as httpRequest } from "http";
|
|
16
17
|
var DAEMON_PORT = 9224;
|
|
17
18
|
var DAEMON_BASE = `http://localhost:${DAEMON_PORT}`;
|
|
18
19
|
var _ensurePromise = null;
|
|
@@ -67,22 +68,48 @@ async function ensureDaemonRunning() {
|
|
|
67
68
|
}
|
|
68
69
|
async function rpcCall(method, params = {}, timeoutMs = 1e4) {
|
|
69
70
|
await ensureDaemonRunning();
|
|
70
|
-
|
|
71
|
-
method
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
const body = JSON.stringify({ method, params });
|
|
73
|
+
const req = httpRequest(
|
|
74
|
+
{
|
|
75
|
+
hostname: "127.0.0.1",
|
|
76
|
+
port: DAEMON_PORT,
|
|
77
|
+
path: "/rpc",
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) }
|
|
80
|
+
},
|
|
81
|
+
(res) => {
|
|
82
|
+
const chunks = [];
|
|
83
|
+
res.on("data", (c) => chunks.push(c));
|
|
84
|
+
res.on("end", () => {
|
|
85
|
+
try {
|
|
86
|
+
const code = res.statusCode ?? 200;
|
|
87
|
+
if (code >= 400) {
|
|
88
|
+
let detail = `HTTP ${code}`;
|
|
89
|
+
try {
|
|
90
|
+
const body2 = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
91
|
+
if (body2?.error) detail = body2.error;
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
reject(new Error(`Daemon error: ${detail}`));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
98
|
+
if (parsed && typeof parsed.error === "string" && Object.keys(parsed).length === 1) {
|
|
99
|
+
reject(new Error(`Daemon error: ${parsed.error}`));
|
|
100
|
+
} else {
|
|
101
|
+
resolve(parsed);
|
|
102
|
+
}
|
|
103
|
+
} catch (e) {
|
|
104
|
+
reject(e instanceof Error ? e : new Error(String(e)));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
req.setTimeout(timeoutMs, () => req.destroy(new Error(`RPC ${method} timeout after ${timeoutMs}ms`)));
|
|
110
|
+
req.on("error", reject);
|
|
111
|
+
req.end(body);
|
|
75
112
|
});
|
|
76
|
-
if (!resp.ok) {
|
|
77
|
-
let detail = resp.statusText;
|
|
78
|
-
try {
|
|
79
|
-
const body = await resp.json();
|
|
80
|
-
if (body?.error) detail = body.error;
|
|
81
|
-
} catch {
|
|
82
|
-
}
|
|
83
|
-
throw new Error(`Daemon error: ${detail}`);
|
|
84
|
-
}
|
|
85
|
-
return resp.json();
|
|
86
113
|
}
|
|
87
114
|
async function isDaemonRunning() {
|
|
88
115
|
try {
|
|
@@ -207,7 +234,10 @@ async function forwardRecordSummary(session) {
|
|
|
207
234
|
return rpcCall("record:summary", { session }, 5e3);
|
|
208
235
|
}
|
|
209
236
|
async function forwardReplay(file, session, slowMo) {
|
|
210
|
-
return
|
|
237
|
+
return longRpcCall("replay", { file, session, slowMo }, 20 * 6e4);
|
|
238
|
+
}
|
|
239
|
+
function longRpcCall(method, params, timeoutMs) {
|
|
240
|
+
return rpcCall(method, params, timeoutMs);
|
|
211
241
|
}
|
|
212
242
|
async function forwardRecordCheckpoint(session, type, hint, selector) {
|
|
213
243
|
return rpcCall("record:checkpoint", { session, type, hint, selector }, 1e4);
|