@xbrowser/cli 1.11.0 → 1.13.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-XNU7JQYC.js → browser-AQ2AT2YZ.js} +2 -2
- package/dist/{browser-Q5APBNF6.js → browser-OMGJMSBB.js} +1 -1
- package/dist/{browser-V3JIWSTR.js → browser-T7OVLAEC.js} +4 -3
- package/dist/{cdp-driver-XFTTZI5O.js → cdp-driver-ALDNOZYD.js} +1176 -13
- package/dist/{cdp-driver-GD6YBBGE.js → cdp-driver-HYCLE4YP.js} +2 -1
- package/dist/{cdp-driver-VEK6BNN6.js → cdp-driver-VS7Z7W7Y.js} +1 -1
- package/dist/chunk-A6LPGFAL.js +437 -0
- package/dist/{chunk-JEDP4PJW.js → chunk-BY5TT6WZ.js} +912 -688
- package/dist/{chunk-XKQVUFUS.js → chunk-CW7L53JE.js} +2 -2
- package/dist/{chunk-ABXMBNQ6.js → chunk-H2A5JUK5.js} +37 -466
- package/dist/{chunk-BNO7OKO4.js → chunk-HBMEFSTB.js} +39 -0
- package/dist/chunk-HD4FX2N5.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-7OFM755Z.js → chunk-R2POF2GP.js} +236 -13
- package/dist/{chunk-WHPBNUKB.js → chunk-SH6OTPXN.js} +42 -46
- package/dist/{chunk-XQ4HRPDJ.js → chunk-T2CNKWPV.js} +1177 -13
- package/dist/{chunk-MWFHZUIY.js → chunk-TEXCXIBW.js} +1 -1
- 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-UVH5FGY2.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-HVPUVVSA.js +0 -2194
|
@@ -66,22 +66,48 @@ async function ensureDaemonRunning() {
|
|
|
66
66
|
}
|
|
67
67
|
async function rpcCall(method, params = {}, timeoutMs = 1e4) {
|
|
68
68
|
await ensureDaemonRunning();
|
|
69
|
-
|
|
70
|
-
method
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const body = JSON.stringify({ method, params });
|
|
71
|
+
const req = httpRequest(
|
|
72
|
+
{
|
|
73
|
+
hostname: "127.0.0.1",
|
|
74
|
+
port: DAEMON_PORT,
|
|
75
|
+
path: "/rpc",
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) }
|
|
78
|
+
},
|
|
79
|
+
(res) => {
|
|
80
|
+
const chunks = [];
|
|
81
|
+
res.on("data", (c) => chunks.push(c));
|
|
82
|
+
res.on("end", () => {
|
|
83
|
+
try {
|
|
84
|
+
const code = res.statusCode ?? 200;
|
|
85
|
+
if (code >= 400) {
|
|
86
|
+
let detail = `HTTP ${code}`;
|
|
87
|
+
try {
|
|
88
|
+
const body2 = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
89
|
+
if (body2?.error) detail = body2.error;
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
reject(new Error(`Daemon error: ${detail}`));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
96
|
+
if (parsed && typeof parsed.error === "string" && Object.keys(parsed).length === 1) {
|
|
97
|
+
reject(new Error(`Daemon error: ${parsed.error}`));
|
|
98
|
+
} else {
|
|
99
|
+
resolve(parsed);
|
|
100
|
+
}
|
|
101
|
+
} catch (e) {
|
|
102
|
+
reject(e instanceof Error ? e : new Error(String(e)));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
req.setTimeout(timeoutMs, () => req.destroy(new Error(`RPC ${method} timeout after ${timeoutMs}ms`)));
|
|
108
|
+
req.on("error", reject);
|
|
109
|
+
req.end(body);
|
|
74
110
|
});
|
|
75
|
-
if (!resp.ok) {
|
|
76
|
-
let detail = resp.statusText;
|
|
77
|
-
try {
|
|
78
|
-
const body = await resp.json();
|
|
79
|
-
if (body?.error) detail = body.error;
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
throw new Error(`Daemon error: ${detail}`);
|
|
83
|
-
}
|
|
84
|
-
return resp.json();
|
|
85
111
|
}
|
|
86
112
|
async function isDaemonRunning() {
|
|
87
113
|
try {
|
|
@@ -209,37 +235,7 @@ async function forwardReplay(file, session, slowMo) {
|
|
|
209
235
|
return longRpcCall("replay", { file, session, slowMo }, 20 * 6e4);
|
|
210
236
|
}
|
|
211
237
|
function longRpcCall(method, params, timeoutMs) {
|
|
212
|
-
return
|
|
213
|
-
const body = JSON.stringify({ method, params });
|
|
214
|
-
const req = httpRequest(
|
|
215
|
-
{
|
|
216
|
-
hostname: "127.0.0.1",
|
|
217
|
-
port: DAEMON_PORT,
|
|
218
|
-
path: "/rpc",
|
|
219
|
-
method: "POST",
|
|
220
|
-
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) }
|
|
221
|
-
},
|
|
222
|
-
(res) => {
|
|
223
|
-
const chunks = [];
|
|
224
|
-
res.on("data", (c) => chunks.push(c));
|
|
225
|
-
res.on("end", () => {
|
|
226
|
-
try {
|
|
227
|
-
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
228
|
-
if (parsed && typeof parsed.error === "string" && Object.keys(parsed).length === 1) {
|
|
229
|
-
reject(new Error(`Daemon error: ${parsed.error}`));
|
|
230
|
-
} else {
|
|
231
|
-
resolve(parsed);
|
|
232
|
-
}
|
|
233
|
-
} catch (e) {
|
|
234
|
-
reject(e instanceof Error ? e : new Error(String(e)));
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
);
|
|
239
|
-
req.setTimeout(timeoutMs, () => req.destroy(new Error(`replay RPC timeout after ${timeoutMs}ms`)));
|
|
240
|
-
req.on("error", reject);
|
|
241
|
-
req.end(body);
|
|
242
|
-
});
|
|
238
|
+
return rpcCall(method, params, timeoutMs);
|
|
243
239
|
}
|
|
244
240
|
async function forwardRecordCheckpoint(session, type, hint, selector) {
|
|
245
241
|
return rpcCall("record:checkpoint", { session, type, hint, selector }, 1e4);
|