@xbrowser/cli 1.11.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/{browser-V3JIWSTR.js → browser-3HQKDZQ6.js} +4 -3
- package/dist/{browser-Q5APBNF6.js → browser-ILXTEWH4.js} +1 -1
- package/dist/{browser-XNU7JQYC.js → browser-XPDMY2NX.js} +2 -2
- package/dist/{cdp-driver-VEK6BNN6.js → cdp-driver-ESH3PDE6.js} +1 -1
- package/dist/{cdp-driver-XFTTZI5O.js → cdp-driver-N2E2ZNSC.js} +1142 -12
- package/dist/{cdp-driver-GD6YBBGE.js → cdp-driver-YIKR4BUX.js} +2 -1
- package/dist/chunk-A6LPGFAL.js +437 -0
- package/dist/{chunk-7OFM755Z.js → chunk-DKM2JOZL.js} +202 -12
- package/dist/{chunk-ABXMBNQ6.js → chunk-H2A5JUK5.js} +37 -466
- package/dist/{chunk-BNO7OKO4.js → chunk-HBMEFSTB.js} +39 -0
- package/dist/chunk-KJTABK3Z.js +1255 -0
- package/dist/{chunk-DWDXEGVK.js → chunk-NKW4A74J.js} +9 -3
- package/dist/{chunk-SQHSZENE.js → chunk-OMU63E6J.js} +3 -22
- package/dist/{chunk-JEDP4PJW.js → chunk-OVW2UEWN.js} +878 -687
- package/dist/{chunk-XKQVUFUS.js → chunk-R6IJ6PIV.js} +2 -2
- package/dist/{chunk-WHPBNUKB.js → chunk-SH6OTPXN.js} +42 -46
- package/dist/{chunk-MWFHZUIY.js → chunk-TEXCXIBW.js} +1 -1
- package/dist/{chunk-XQ4HRPDJ.js → chunk-Z6CUR3VG.js} +1143 -12
- package/dist/{chunk-IIM5GOD7.js → chunk-ZTHE5RBZ.js} +7 -1
- package/dist/cli.js +1075 -569
- package/dist/{daemon-client-MMDRYCF5.js → daemon-client-7D6EZNOE.js} +42 -46
- package/dist/{daemon-client-Y2YSZCGK.js → daemon-client-HEGAXWGK.js} +1 -1
- package/dist/daemon-main.js +950 -499
- 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 +2 -0
- package/dist/index.js +1086 -578
- 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-replayer-WIUYVN5J.js → session-replayer-K4A6OI4M.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-HVPUVVSA.js +0 -2194
|
@@ -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";
|
|
@@ -68,22 +68,48 @@ async function ensureDaemonRunning() {
|
|
|
68
68
|
}
|
|
69
69
|
async function rpcCall(method, params = {}, timeoutMs = 1e4) {
|
|
70
70
|
await ensureDaemonRunning();
|
|
71
|
-
|
|
72
|
-
method
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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);
|
|
76
112
|
});
|
|
77
|
-
if (!resp.ok) {
|
|
78
|
-
let detail = resp.statusText;
|
|
79
|
-
try {
|
|
80
|
-
const body = await resp.json();
|
|
81
|
-
if (body?.error) detail = body.error;
|
|
82
|
-
} catch {
|
|
83
|
-
}
|
|
84
|
-
throw new Error(`Daemon error: ${detail}`);
|
|
85
|
-
}
|
|
86
|
-
return resp.json();
|
|
87
113
|
}
|
|
88
114
|
async function isDaemonRunning() {
|
|
89
115
|
try {
|
|
@@ -211,37 +237,7 @@ async function forwardReplay(file, session, slowMo) {
|
|
|
211
237
|
return longRpcCall("replay", { file, session, slowMo }, 20 * 6e4);
|
|
212
238
|
}
|
|
213
239
|
function longRpcCall(method, params, timeoutMs) {
|
|
214
|
-
return
|
|
215
|
-
const body = JSON.stringify({ method, params });
|
|
216
|
-
const req = httpRequest(
|
|
217
|
-
{
|
|
218
|
-
hostname: "127.0.0.1",
|
|
219
|
-
port: DAEMON_PORT,
|
|
220
|
-
path: "/rpc",
|
|
221
|
-
method: "POST",
|
|
222
|
-
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) }
|
|
223
|
-
},
|
|
224
|
-
(res) => {
|
|
225
|
-
const chunks = [];
|
|
226
|
-
res.on("data", (c) => chunks.push(c));
|
|
227
|
-
res.on("end", () => {
|
|
228
|
-
try {
|
|
229
|
-
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
230
|
-
if (parsed && typeof parsed.error === "string" && Object.keys(parsed).length === 1) {
|
|
231
|
-
reject(new Error(`Daemon error: ${parsed.error}`));
|
|
232
|
-
} else {
|
|
233
|
-
resolve(parsed);
|
|
234
|
-
}
|
|
235
|
-
} catch (e) {
|
|
236
|
-
reject(e instanceof Error ? e : new Error(String(e)));
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
);
|
|
241
|
-
req.setTimeout(timeoutMs, () => req.destroy(new Error(`replay RPC timeout after ${timeoutMs}ms`)));
|
|
242
|
-
req.on("error", reject);
|
|
243
|
-
req.end(body);
|
|
244
|
-
});
|
|
240
|
+
return rpcCall(method, params, timeoutMs);
|
|
245
241
|
}
|
|
246
242
|
async function forwardRecordCheckpoint(session, type, hint, selector) {
|
|
247
243
|
return rpcCall("record:checkpoint", { session, type, hint, selector }, 1e4);
|