@xbrowser/cli 1.0.4 → 1.0.5
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/cli.js +19 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9760,7 +9760,16 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
|
|
|
9760
9760
|
} else if (!result.success) {
|
|
9761
9761
|
outputError(result.message || "Command failed");
|
|
9762
9762
|
} else {
|
|
9763
|
-
|
|
9763
|
+
const data = result.data;
|
|
9764
|
+
const isEmptyResult = data && typeof data === "object" && Object.values(data).every((v) => v === "" || v === null || v === void 0);
|
|
9765
|
+
if (isEmptyResult) {
|
|
9766
|
+
const hint = cdpEndpoint ? `\u53EF\u80FD\u672A\u8FDE\u63A5\u5230\u6D4F\u89C8\u5668\u3002\u8BF7\u786E\u8BA4 ${cdpEndpoint} \u4E0A\u6709 Chrome \u8FD0\u884C\uFF08--remote-debugging-port\uFF09\u3002` : "\u53EF\u80FD\u672A\u8FDE\u63A5\u5230\u6D4F\u89C8\u5668\u3002\u8BF7\u4F7F\u7528 --cdp <endpoint> \u8FDE\u63A5\uFF0C\u6216\u5B89\u88C5 cdp-tunnel \u590D\u7528\u5DF2\u6709 Chrome\u3002";
|
|
9767
|
+
outputResult(result.data, mode);
|
|
9768
|
+
console.error(`
|
|
9769
|
+
\u26A0\uFE0F ${hint}`);
|
|
9770
|
+
} else {
|
|
9771
|
+
outputResult(result.data, mode);
|
|
9772
|
+
}
|
|
9764
9773
|
}
|
|
9765
9774
|
}
|
|
9766
9775
|
|
|
@@ -12046,7 +12055,8 @@ async function handleChainInput(input, argv) {
|
|
|
12046
12055
|
}
|
|
12047
12056
|
if (!chainResult.success) throw new Error("Command failed");
|
|
12048
12057
|
}
|
|
12049
|
-
async function routeCommand(
|
|
12058
|
+
async function routeCommand(argvIn, stdinCommands) {
|
|
12059
|
+
let argv = argvIn;
|
|
12050
12060
|
try {
|
|
12051
12061
|
if (stdinCommands && stdinCommands.length > 0) {
|
|
12052
12062
|
await handleStdinMode(stdinCommands, argv);
|
|
@@ -12060,6 +12070,13 @@ async function routeCommand(argv, stdinCommands) {
|
|
|
12060
12070
|
await handleChainInput(argv[0], argv);
|
|
12061
12071
|
return;
|
|
12062
12072
|
}
|
|
12073
|
+
if (argv[0] && argv[0].includes(" ")) {
|
|
12074
|
+
const spaceIdx = argv[0].indexOf(" ");
|
|
12075
|
+
const possibleCmd = argv[0].substring(0, spaceIdx);
|
|
12076
|
+
if (/^[a-zA-Z][\w-]*$/.test(possibleCmd)) {
|
|
12077
|
+
argv = [possibleCmd, argv[0].substring(spaceIdx + 1), ...argv.slice(1)];
|
|
12078
|
+
}
|
|
12079
|
+
}
|
|
12063
12080
|
} catch (e) {
|
|
12064
12081
|
outputError(e instanceof Error ? e.message : String(e));
|
|
12065
12082
|
return;
|
package/dist/index.d.ts
CHANGED
|
@@ -1267,7 +1267,7 @@ interface AISearchResult {
|
|
|
1267
1267
|
* @param argv - Raw CLI argument array (typically `process.argv.slice(2)`).
|
|
1268
1268
|
* @param stdinCommands - Optional array of commands read from stdin.
|
|
1269
1269
|
*/
|
|
1270
|
-
declare function routeCommand(
|
|
1270
|
+
declare function routeCommand(argvIn: string[], stdinCommands?: string[]): Promise<void>;
|
|
1271
1271
|
|
|
1272
1272
|
/**
|
|
1273
1273
|
* Open a new browser session, navigate to the given URL, and persist session metadata.
|
package/dist/index.js
CHANGED
|
@@ -10100,7 +10100,16 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
|
|
|
10100
10100
|
} else if (!result.success) {
|
|
10101
10101
|
outputError(result.message || "Command failed");
|
|
10102
10102
|
} else {
|
|
10103
|
-
|
|
10103
|
+
const data = result.data;
|
|
10104
|
+
const isEmptyResult = data && typeof data === "object" && Object.values(data).every((v) => v === "" || v === null || v === void 0);
|
|
10105
|
+
if (isEmptyResult) {
|
|
10106
|
+
const hint = cdpEndpoint ? `\u53EF\u80FD\u672A\u8FDE\u63A5\u5230\u6D4F\u89C8\u5668\u3002\u8BF7\u786E\u8BA4 ${cdpEndpoint} \u4E0A\u6709 Chrome \u8FD0\u884C\uFF08--remote-debugging-port\uFF09\u3002` : "\u53EF\u80FD\u672A\u8FDE\u63A5\u5230\u6D4F\u89C8\u5668\u3002\u8BF7\u4F7F\u7528 --cdp <endpoint> \u8FDE\u63A5\uFF0C\u6216\u5B89\u88C5 cdp-tunnel \u590D\u7528\u5DF2\u6709 Chrome\u3002";
|
|
10107
|
+
outputResult(result.data, mode);
|
|
10108
|
+
console.error(`
|
|
10109
|
+
\u26A0\uFE0F ${hint}`);
|
|
10110
|
+
} else {
|
|
10111
|
+
outputResult(result.data, mode);
|
|
10112
|
+
}
|
|
10104
10113
|
}
|
|
10105
10114
|
}
|
|
10106
10115
|
|
|
@@ -12386,7 +12395,8 @@ async function handleChainInput(input, argv) {
|
|
|
12386
12395
|
}
|
|
12387
12396
|
if (!chainResult.success) throw new Error("Command failed");
|
|
12388
12397
|
}
|
|
12389
|
-
async function routeCommand(
|
|
12398
|
+
async function routeCommand(argvIn, stdinCommands) {
|
|
12399
|
+
let argv = argvIn;
|
|
12390
12400
|
try {
|
|
12391
12401
|
if (stdinCommands && stdinCommands.length > 0) {
|
|
12392
12402
|
await handleStdinMode(stdinCommands, argv);
|
|
@@ -12400,6 +12410,13 @@ async function routeCommand(argv, stdinCommands) {
|
|
|
12400
12410
|
await handleChainInput(argv[0], argv);
|
|
12401
12411
|
return;
|
|
12402
12412
|
}
|
|
12413
|
+
if (argv[0] && argv[0].includes(" ")) {
|
|
12414
|
+
const spaceIdx = argv[0].indexOf(" ");
|
|
12415
|
+
const possibleCmd = argv[0].substring(0, spaceIdx);
|
|
12416
|
+
if (/^[a-zA-Z][\w-]*$/.test(possibleCmd)) {
|
|
12417
|
+
argv = [possibleCmd, argv[0].substring(spaceIdx + 1), ...argv.slice(1)];
|
|
12418
|
+
}
|
|
12419
|
+
}
|
|
12403
12420
|
} catch (e) {
|
|
12404
12421
|
outputError(e instanceof Error ? e.message : String(e));
|
|
12405
12422
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbrowser/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|