@xbrowser/cli 1.9.8 → 1.10.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-MCVM6IFB.js → anti-bot-DR56Y63V.js} +1 -1
- package/dist/{browser-SJWPJFN7.js → browser-HBL72GPZ.js} +2 -2
- package/dist/{browser-GT4BMX6X.js → browser-T3V3JWVH.js} +1 -1
- package/dist/{browser-43YXUIML.js → browser-WQZ3D6AE.js} +2 -2
- package/dist/{cdp-driver-WAFYSIIW.js → cdp-driver-2T4P4ZE2.js} +87 -1
- package/dist/{cdp-driver-PUZLDSQU.js → cdp-driver-J3YQ4LJV.js} +1 -1
- package/dist/chunk-3OD76SUE.js +20 -0
- package/dist/chunk-43TEMG4U.js +9 -0
- package/dist/{chunk-C3LIGO4V.js → chunk-4452SPFI.js} +906 -16
- package/dist/{chunk-VEWTHYDG.js → chunk-5UGR6MUK.js} +906 -16
- package/dist/{chunk-ENCEMM7Z.js → chunk-BAHSRZIX.js} +82 -29
- package/dist/{chunk-7ZDWM6T2.js → chunk-BNO7OKO4.js} +5 -6
- package/dist/{chunk-24SY6PE5.js → chunk-CG3D3CHY.js} +1 -8
- package/dist/{chunk-ZJHQPMCY.js → chunk-DWDXEGVK.js} +5 -6
- package/dist/{chunk-DPJNCMLC.js → chunk-INTQPBYF.js} +7 -0
- package/dist/{human-interaction-OU7LZ6OZ.js → chunk-MWFHZUIY.js} +6 -7
- package/dist/{chunk-A4YHJW3Z.js → chunk-NITFVWWS.js} +168 -29
- package/dist/chunk-Q2DFJQGS.js +128 -0
- package/dist/{chunk-GM3HWQ5U.js → chunk-RRBXV7KE.js} +87 -1
- package/dist/{human-interaction-HJTXFVQS.js → chunk-SQHSZENE.js} +2 -2
- package/dist/chunk-TZPKFUBT.js +20 -0
- package/dist/{chunk-PBDID7SE.js → chunk-WSCP7QCJ.js} +82 -29
- package/dist/{chunk-YAUG3NSI.js → chunk-YMUSHPU4.js} +16 -128
- package/dist/cli.js +48 -31
- package/dist/{daemon-client-4HJENICO.js → daemon-client-GKEPT4NY.js} +15 -3
- package/dist/{daemon-client-CMRAWXTN.js → daemon-client-O6BYVRXV.js} +4 -1
- package/dist/daemon-main.js +649 -58
- package/dist/human-interaction-5AO42MBA.js +8 -0
- package/dist/{human-interaction-2DZK4MW7.js → human-interaction-C5OEGXGO.js} +1 -1
- package/dist/human-interaction-ISXZTAYY.js +8 -0
- package/dist/index.d.ts +167 -2
- package/dist/index.js +194 -67
- package/dist/recovery-EF33LKRJ.js +77 -0
- package/dist/recovery-J2ISVGUL.js +77 -0
- package/dist/recovery-ZJVVHP7N.js +76 -0
- package/dist/{session-recorder-K3K63Q33.js → session-recorder-H3KEYU26.js} +1 -1
- package/dist/{session-recorder-AG6CH6EI.js → session-recorder-QRZMKFVL.js} +1 -1
- package/dist/{session-replayer-V4MP6M6I.js → session-replayer-LJUC4TI7.js} +24 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -21,16 +21,21 @@ import {
|
|
|
21
21
|
forwardSessionClose,
|
|
22
22
|
forwardSessionList,
|
|
23
23
|
forwardViewerCheckSelector,
|
|
24
|
+
version
|
|
25
|
+
} from "./chunk-YMUSHPU4.js";
|
|
26
|
+
import {
|
|
27
|
+
buildViewerUrl
|
|
28
|
+
} from "./chunk-3OD76SUE.js";
|
|
29
|
+
import {
|
|
24
30
|
getDaemonConfig,
|
|
25
31
|
getDaemonProcessStatus,
|
|
26
32
|
killAllDaemonProcesses,
|
|
27
33
|
startDaemonProcess,
|
|
28
|
-
stopDaemonProcess
|
|
29
|
-
|
|
30
|
-
} from "./chunk-YAUG3NSI.js";
|
|
34
|
+
stopDaemonProcess
|
|
35
|
+
} from "./chunk-Q2DFJQGS.js";
|
|
31
36
|
import {
|
|
32
37
|
SessionRecorder
|
|
33
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-4452SPFI.js";
|
|
34
39
|
import {
|
|
35
40
|
addKnownIssue,
|
|
36
41
|
getKnowledgePath,
|
|
@@ -54,7 +59,7 @@ import {
|
|
|
54
59
|
resolveLaunchOpts,
|
|
55
60
|
saveSessionDiskMeta,
|
|
56
61
|
setActivePage
|
|
57
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-NITFVWWS.js";
|
|
58
63
|
import "./chunk-TNEN6VQ2.js";
|
|
59
64
|
import {
|
|
60
65
|
errMsg
|
|
@@ -62,7 +67,7 @@ import {
|
|
|
62
67
|
import {
|
|
63
68
|
detectAntiBot,
|
|
64
69
|
formatDetectionMessage
|
|
65
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-INTQPBYF.js";
|
|
66
71
|
import {
|
|
67
72
|
NPM_REGISTRY_URL,
|
|
68
73
|
NPM_SCOPE,
|
|
@@ -5866,7 +5871,7 @@ function describeSelector(strategy, value, name) {
|
|
|
5866
5871
|
// src/context.ts
|
|
5867
5872
|
function attachDetectAntiBot(ctx) {
|
|
5868
5873
|
ctx.detectAntiBot = async (page, config) => {
|
|
5869
|
-
const { detectAntiBot: detectAntiBot2 } = await import("./anti-bot-
|
|
5874
|
+
const { detectAntiBot: detectAntiBot2 } = await import("./anti-bot-DR56Y63V.js");
|
|
5870
5875
|
return detectAntiBot2(page, config);
|
|
5871
5876
|
};
|
|
5872
5877
|
}
|
|
@@ -6313,18 +6318,6 @@ async function getPluginLoader() {
|
|
|
6313
6318
|
return pluginLoader;
|
|
6314
6319
|
}
|
|
6315
6320
|
|
|
6316
|
-
// src/utils/viewer-url.ts
|
|
6317
|
-
function buildViewerUrl(sessionName = "default") {
|
|
6318
|
-
try {
|
|
6319
|
-
const status = getDaemonProcessStatus();
|
|
6320
|
-
if (!status.running) return void 0;
|
|
6321
|
-
const port = status.port || getDaemonConfig().basePort;
|
|
6322
|
-
return `http://localhost:${port}/preview/${encodeURIComponent(sessionName)}`;
|
|
6323
|
-
} catch {
|
|
6324
|
-
return void 0;
|
|
6325
|
-
}
|
|
6326
|
-
}
|
|
6327
|
-
|
|
6328
6321
|
// src/plugin/login-guard.ts
|
|
6329
6322
|
async function checkPluginLoginRequired(options) {
|
|
6330
6323
|
const { site, command, commandName, ctx, page, sessionName } = options;
|
|
@@ -7058,7 +7051,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
7058
7051
|
}
|
|
7059
7052
|
let targetPageOverride = null;
|
|
7060
7053
|
if (_target && extraOpts?.cdpEndpoint) {
|
|
7061
|
-
const { findTargetPage } = await import("./browser-
|
|
7054
|
+
const { findTargetPage } = await import("./browser-T3V3JWVH.js");
|
|
7062
7055
|
targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
|
|
7063
7056
|
if (!targetPageOverride) {
|
|
7064
7057
|
return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
|
|
@@ -7075,7 +7068,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
7075
7068
|
params = result.data;
|
|
7076
7069
|
}
|
|
7077
7070
|
if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
|
|
7078
|
-
const { forwardExec } = await import("./daemon-client-
|
|
7071
|
+
const { forwardExec } = await import("./daemon-client-O6BYVRXV.js");
|
|
7079
7072
|
const result = await forwardExec(commandName, params, sessionName, extraOpts?.cdpEndpoint);
|
|
7080
7073
|
if (result) return result;
|
|
7081
7074
|
}
|
|
@@ -7263,6 +7256,26 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
7263
7256
|
const end = Date.now();
|
|
7264
7257
|
const duration = end - start;
|
|
7265
7258
|
const errorMessage = errMsg(err);
|
|
7259
|
+
if (session?.page && process.env.XBROWSER_RECOVERY && !extraOpts?._recoveryAttempted) {
|
|
7260
|
+
try {
|
|
7261
|
+
const { attemptRecovery } = await import("./recovery-J2ISVGUL.js");
|
|
7262
|
+
const recovery = await attemptRecovery(
|
|
7263
|
+
session.page,
|
|
7264
|
+
sessionName,
|
|
7265
|
+
commandName,
|
|
7266
|
+
errorMessage
|
|
7267
|
+
);
|
|
7268
|
+
if (recovery.recovered) {
|
|
7269
|
+
const retry = await executeCommand(commandName, params, sessionName, {
|
|
7270
|
+
...extraOpts,
|
|
7271
|
+
skipCleanup: true,
|
|
7272
|
+
_recoveryAttempted: true
|
|
7273
|
+
});
|
|
7274
|
+
return retry;
|
|
7275
|
+
}
|
|
7276
|
+
} catch {
|
|
7277
|
+
}
|
|
7278
|
+
}
|
|
7266
7279
|
if (session) {
|
|
7267
7280
|
streamCommandEvent(session.id, {
|
|
7268
7281
|
sessionId: session.id,
|
|
@@ -10551,7 +10564,7 @@ async function handlePlugin(args, options, mode) {
|
|
|
10551
10564
|
} catch {
|
|
10552
10565
|
}
|
|
10553
10566
|
try {
|
|
10554
|
-
const { daemonPing } = await import("./daemon-client-
|
|
10567
|
+
const { daemonPing } = await import("./daemon-client-O6BYVRXV.js");
|
|
10555
10568
|
if (await daemonPing()) {
|
|
10556
10569
|
await fetch("http://localhost:9224/rpc", {
|
|
10557
10570
|
method: "POST",
|
|
@@ -11117,7 +11130,7 @@ async function handleFilter(args, _mode, options) {
|
|
|
11117
11130
|
}
|
|
11118
11131
|
}
|
|
11119
11132
|
async function handleGeneratePlugin(sessionName, pluginName, outputDir) {
|
|
11120
|
-
const { SessionRecorder: SessionRecorder2 } = await import("./session-recorder-
|
|
11133
|
+
const { SessionRecorder: SessionRecorder2 } = await import("./session-recorder-QRZMKFVL.js");
|
|
11121
11134
|
const { readSiteKnowledge: readSiteKnowledge2, toMarkdown } = await import("./site-knowledge-SYC6VCDB.js");
|
|
11122
11135
|
const { mkdirSync: mkdirSync10, writeFileSync: writeFileSync12 } = await import("fs");
|
|
11123
11136
|
const { join: join13 } = await import("path");
|
|
@@ -11354,7 +11367,7 @@ async function handleRun(filePath, options) {
|
|
|
11354
11367
|
|
|
11355
11368
|
// src/cli/viewer-routes.ts
|
|
11356
11369
|
async function handleViewer(_args, options, mode, _cdpEndpoint) {
|
|
11357
|
-
const name = options.
|
|
11370
|
+
const name = options.session || process.env.XBROWSER_SESSION || "default";
|
|
11358
11371
|
const selector = options.selector;
|
|
11359
11372
|
const userPort = options.port ? Number(options.port) : void 0;
|
|
11360
11373
|
let status = getDaemonProcessStatus();
|
|
@@ -12685,12 +12698,16 @@ async function routeCommand(argvIn, stdinCommands) {
|
|
|
12685
12698
|
}
|
|
12686
12699
|
const globalFlags = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--output", "--timeout", "--help", "-h", "--version"]);
|
|
12687
12700
|
let chainArgIdx = -1;
|
|
12701
|
+
let seenCommandWord = false;
|
|
12688
12702
|
for (let i = 0; i < argv.length; i++) {
|
|
12689
12703
|
if (globalFlags.has(argv[i])) continue;
|
|
12690
12704
|
if (globalFlags.has(argv[i]) || i > 0 && globalFlags.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
|
|
12691
|
-
if (
|
|
12692
|
-
|
|
12693
|
-
|
|
12705
|
+
if (!seenCommandWord) {
|
|
12706
|
+
if (argv[i].includes(" ") && /^[a-zA-Z]/.test(argv[i])) {
|
|
12707
|
+
chainArgIdx = i;
|
|
12708
|
+
break;
|
|
12709
|
+
}
|
|
12710
|
+
seenCommandWord = true;
|
|
12694
12711
|
}
|
|
12695
12712
|
}
|
|
12696
12713
|
if (chainArgIdx >= 0) {
|
|
@@ -13054,9 +13071,9 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
|
|
|
13054
13071
|
}
|
|
13055
13072
|
const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
|
|
13056
13073
|
if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
|
|
13057
|
-
const {
|
|
13074
|
+
const { forwardPluginExec } = await import("./daemon-client-O6BYVRXV.js");
|
|
13058
13075
|
const userTimeout = typeof params.timeout === "number" && params.timeout > 0 ? params.timeout * 1e3 + 3e4 : void 0;
|
|
13059
|
-
const result = await
|
|
13076
|
+
const result = await forwardPluginExec(`${command}.${subCommand}`, params, sessionName, cdpEndpoint, userTimeout);
|
|
13060
13077
|
const resultData = result && typeof result === "object" && "data" in result ? result.data : void 0;
|
|
13061
13078
|
if (result && result.success === false && resultData?.code === "LOGIN_REQUIRED") {
|
|
13062
13079
|
process.exitCode = 1;
|
|
@@ -13094,7 +13111,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
|
|
|
13094
13111
|
const targetPage = pages[cmdTabIndex];
|
|
13095
13112
|
await targetPage.bringToFront().catch(() => {
|
|
13096
13113
|
});
|
|
13097
|
-
const { setActivePage: setActivePage2 } = await import("./browser-
|
|
13114
|
+
const { setActivePage: setActivePage2 } = await import("./browser-T3V3JWVH.js");
|
|
13098
13115
|
setActivePage2(session, targetPage);
|
|
13099
13116
|
}
|
|
13100
13117
|
}
|
|
@@ -13370,7 +13387,7 @@ async function main() {
|
|
|
13370
13387
|
const command = process.argv[2];
|
|
13371
13388
|
const isLongRunning = command === "preview" || command === "serve";
|
|
13372
13389
|
if (!isLongRunning) {
|
|
13373
|
-
const { ensureProcessCanExit } = await import("./browser-
|
|
13390
|
+
const { ensureProcessCanExit } = await import("./browser-T3V3JWVH.js");
|
|
13374
13391
|
await ensureProcessCanExit().catch(() => {
|
|
13375
13392
|
});
|
|
13376
13393
|
process.exit(process.exitCode || exitCode);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
startDaemonProcess,
|
|
3
|
-
stopDaemonProcess,
|
|
4
2
|
version
|
|
5
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-43TEMG4U.js";
|
|
4
|
+
import {
|
|
5
|
+
startDaemonProcess,
|
|
6
|
+
stopDaemonProcess
|
|
7
|
+
} from "./chunk-CG3D3CHY.js";
|
|
6
8
|
import {
|
|
7
9
|
errMsg
|
|
8
10
|
} from "./chunk-GDKLH7ZY.js";
|
|
@@ -117,6 +119,15 @@ async function forwardExec(command, params, session = "default", cdpEndpoint, ti
|
|
|
117
119
|
return { success: false, data: null, message: errMsg(e), duration: 0 };
|
|
118
120
|
}
|
|
119
121
|
}
|
|
122
|
+
async function forwardPluginExec(command, params, session = "default", cdpEndpoint, timeoutMs = 12e4) {
|
|
123
|
+
const rpcParams = { command, params, session };
|
|
124
|
+
if (cdpEndpoint) rpcParams.cdpEndpoint = cdpEndpoint;
|
|
125
|
+
try {
|
|
126
|
+
return await rpcCall("plugin:exec", rpcParams, timeoutMs);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
return { success: false, data: null, message: errMsg(e), duration: 0 };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
120
131
|
async function forwardChain(input, session = "default", cdpEndpoint) {
|
|
121
132
|
const params = { chain: input, session };
|
|
122
133
|
if (cdpEndpoint) params.cdpEndpoint = cdpEndpoint;
|
|
@@ -224,6 +235,7 @@ export {
|
|
|
224
235
|
forwardNetworkList,
|
|
225
236
|
forwardNetworkReplay,
|
|
226
237
|
forwardNetworkTop,
|
|
238
|
+
forwardPluginExec,
|
|
227
239
|
forwardRecordCheckpoint,
|
|
228
240
|
forwardRecordStart,
|
|
229
241
|
forwardRecordStatus,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
forwardNetworkList,
|
|
18
18
|
forwardNetworkReplay,
|
|
19
19
|
forwardNetworkTop,
|
|
20
|
+
forwardPluginExec,
|
|
20
21
|
forwardRecordCheckpoint,
|
|
21
22
|
forwardRecordStart,
|
|
22
23
|
forwardRecordStatus,
|
|
@@ -29,7 +30,8 @@ import {
|
|
|
29
30
|
forwardSessionList,
|
|
30
31
|
forwardViewerCheckSelector,
|
|
31
32
|
isDaemonRunning
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-YMUSHPU4.js";
|
|
34
|
+
import "./chunk-Q2DFJQGS.js";
|
|
33
35
|
import "./chunk-GDKLH7ZY.js";
|
|
34
36
|
import "./chunk-KFQGP6VL.js";
|
|
35
37
|
export {
|
|
@@ -51,6 +53,7 @@ export {
|
|
|
51
53
|
forwardNetworkList,
|
|
52
54
|
forwardNetworkReplay,
|
|
53
55
|
forwardNetworkTop,
|
|
56
|
+
forwardPluginExec,
|
|
54
57
|
forwardRecordCheckpoint,
|
|
55
58
|
forwardRecordStart,
|
|
56
59
|
forwardRecordStatus,
|