@xbrowser/cli 1.5.0 → 1.5.2
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 +36 -10
- package/dist/daemon-main.js +5 -2
- package/dist/index.js +36 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5221,6 +5221,9 @@ var tabCommand = registerCommand({
|
|
|
5221
5221
|
data: z23.unknown()
|
|
5222
5222
|
}),
|
|
5223
5223
|
handler: async (p, ctx) => {
|
|
5224
|
+
if (!ctx.browserContext) {
|
|
5225
|
+
return fail6("No browser context available. Use --cdp to connect to a browser first.");
|
|
5226
|
+
}
|
|
5224
5227
|
const pages = ctx.browserContext.pages();
|
|
5225
5228
|
switch (p.subcommand) {
|
|
5226
5229
|
case "list":
|
|
@@ -5404,8 +5407,8 @@ function parseCommandChain(input, options) {
|
|
|
5404
5407
|
continue;
|
|
5405
5408
|
}
|
|
5406
5409
|
if (char === "," && isSpaceAdjacent(input, i)) {
|
|
5407
|
-
|
|
5408
|
-
|
|
5410
|
+
lastOperator = "sequence";
|
|
5411
|
+
flushPipeline();
|
|
5409
5412
|
continue;
|
|
5410
5413
|
}
|
|
5411
5414
|
if (char === "+" && isSpaceAdjacent(input, i)) {
|
|
@@ -8917,7 +8920,7 @@ var pluginSearchBuiltin = {
|
|
|
8917
8920
|
const query = args[0] || "";
|
|
8918
8921
|
try {
|
|
8919
8922
|
const searchOptions = {
|
|
8920
|
-
query,
|
|
8923
|
+
query: query || (options["tag"] || ""),
|
|
8921
8924
|
tag: options["tag"],
|
|
8922
8925
|
site: options["site"],
|
|
8923
8926
|
limit: options["limit"] ? Number.parseInt(String(options["limit"])) : 20
|
|
@@ -10522,7 +10525,11 @@ Total: ${enrichedPlugins.length} plugins`);
|
|
|
10522
10525
|
case "reload": {
|
|
10523
10526
|
const name = subArgs[0];
|
|
10524
10527
|
if (!name) outputError("Usage: xbrowser plugin reload <name>");
|
|
10525
|
-
|
|
10528
|
+
try {
|
|
10529
|
+
await (await getPluginLoader()).reloadPlugin(name);
|
|
10530
|
+
} catch {
|
|
10531
|
+
outputError(`Plugin "${name}" not found. Use 'xbrowser plugin list' to see installed plugins.`);
|
|
10532
|
+
}
|
|
10526
10533
|
outputResult({ ok: true, name }, mode);
|
|
10527
10534
|
break;
|
|
10528
10535
|
}
|
|
@@ -12482,13 +12489,24 @@ async function routeCommand(argvIn, stdinCommands) {
|
|
|
12482
12489
|
await handleChainInput(argv[0], argv);
|
|
12483
12490
|
return;
|
|
12484
12491
|
}
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12492
|
+
const globalFlags = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--output", "--timeout", "--help", "-h", "--version"]);
|
|
12493
|
+
let chainArgIdx = -1;
|
|
12494
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12495
|
+
if (globalFlags.has(argv[i])) continue;
|
|
12496
|
+
if (globalFlags.has(argv[i]) || i > 0 && globalFlags.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
|
|
12497
|
+
if (argv[i].includes(" ") && /^[a-zA-Z]/.test(argv[i])) {
|
|
12498
|
+
chainArgIdx = i;
|
|
12499
|
+
break;
|
|
12500
|
+
}
|
|
12501
|
+
}
|
|
12502
|
+
if (chainArgIdx >= 0) {
|
|
12503
|
+
const chainArg = argv[chainArgIdx];
|
|
12504
|
+
const spaceIdx = chainArg.indexOf(" ");
|
|
12505
|
+
const possibleCmd = chainArg.substring(0, spaceIdx);
|
|
12488
12506
|
if (/^[a-zA-Z][\w-]*$/.test(possibleCmd)) {
|
|
12489
|
-
const remainder =
|
|
12507
|
+
const remainder = chainArg.substring(spaceIdx + 1);
|
|
12490
12508
|
const remainderParts = remainder.split(/\s+/).filter(Boolean);
|
|
12491
|
-
argv = [possibleCmd, ...remainderParts, ...argv.slice(1)];
|
|
12509
|
+
argv = [...argv.slice(0, chainArgIdx), possibleCmd, ...remainderParts, ...argv.slice(chainArgIdx + 1)];
|
|
12492
12510
|
}
|
|
12493
12511
|
}
|
|
12494
12512
|
} catch (e) {
|
|
@@ -12682,7 +12700,15 @@ async function routeCommand(argvIn, stdinCommands) {
|
|
|
12682
12700
|
const internalLoader = loader.getCore().loader;
|
|
12683
12701
|
const site = internalLoader.getSite(command);
|
|
12684
12702
|
if (!site) {
|
|
12685
|
-
const
|
|
12703
|
+
const globalFlagSet = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--help", "-h", "--version", "--output", "-o"]);
|
|
12704
|
+
const cleanParts = [];
|
|
12705
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12706
|
+
if (globalFlagSet.has(argv[i])) continue;
|
|
12707
|
+
if (i > 0 && globalFlagSet.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
|
|
12708
|
+
if (argv[i].startsWith("--session=") || argv[i].startsWith("--cdp=")) continue;
|
|
12709
|
+
cleanParts.push(argv[i]);
|
|
12710
|
+
}
|
|
12711
|
+
const fullInput = cleanParts.join(" ");
|
|
12686
12712
|
if (isChainInput(fullInput)) {
|
|
12687
12713
|
const chainResult = await executeChain(fullInput, { cdpEndpoint, sessionName });
|
|
12688
12714
|
for (const step of chainResult.steps) {
|
package/dist/daemon-main.js
CHANGED
|
@@ -5182,6 +5182,9 @@ var tabCommand = registerCommand({
|
|
|
5182
5182
|
data: z23.unknown()
|
|
5183
5183
|
}),
|
|
5184
5184
|
handler: async (p, ctx) => {
|
|
5185
|
+
if (!ctx.browserContext) {
|
|
5186
|
+
return fail6("No browser context available. Use --cdp to connect to a browser first.");
|
|
5187
|
+
}
|
|
5185
5188
|
const pages = ctx.browserContext.pages();
|
|
5186
5189
|
switch (p.subcommand) {
|
|
5187
5190
|
case "list":
|
|
@@ -5365,8 +5368,8 @@ function parseCommandChain(input, options) {
|
|
|
5365
5368
|
continue;
|
|
5366
5369
|
}
|
|
5367
5370
|
if (char === "," && isSpaceAdjacent(input, i)) {
|
|
5368
|
-
|
|
5369
|
-
|
|
5371
|
+
lastOperator = "sequence";
|
|
5372
|
+
flushPipeline();
|
|
5370
5373
|
continue;
|
|
5371
5374
|
}
|
|
5372
5375
|
if (char === "+" && isSpaceAdjacent(input, i)) {
|
package/dist/index.js
CHANGED
|
@@ -5538,6 +5538,9 @@ var tabCommand = registerCommand({
|
|
|
5538
5538
|
data: z23.unknown()
|
|
5539
5539
|
}),
|
|
5540
5540
|
handler: async (p, ctx) => {
|
|
5541
|
+
if (!ctx.browserContext) {
|
|
5542
|
+
return fail6("No browser context available. Use --cdp to connect to a browser first.");
|
|
5543
|
+
}
|
|
5541
5544
|
const pages = ctx.browserContext.pages();
|
|
5542
5545
|
switch (p.subcommand) {
|
|
5543
5546
|
case "list":
|
|
@@ -5721,8 +5724,8 @@ function parseCommandChain(input, options) {
|
|
|
5721
5724
|
continue;
|
|
5722
5725
|
}
|
|
5723
5726
|
if (char === "," && isSpaceAdjacent(input, i)) {
|
|
5724
|
-
|
|
5725
|
-
|
|
5727
|
+
lastOperator = "sequence";
|
|
5728
|
+
flushPipeline();
|
|
5726
5729
|
continue;
|
|
5727
5730
|
}
|
|
5728
5731
|
if (char === "+" && isSpaceAdjacent(input, i)) {
|
|
@@ -9252,7 +9255,7 @@ var pluginSearchBuiltin = {
|
|
|
9252
9255
|
const query = args[0] || "";
|
|
9253
9256
|
try {
|
|
9254
9257
|
const searchOptions = {
|
|
9255
|
-
query,
|
|
9258
|
+
query: query || (options["tag"] || ""),
|
|
9256
9259
|
tag: options["tag"],
|
|
9257
9260
|
site: options["site"],
|
|
9258
9261
|
limit: options["limit"] ? Number.parseInt(String(options["limit"])) : 20
|
|
@@ -10862,7 +10865,11 @@ Total: ${enrichedPlugins.length} plugins`);
|
|
|
10862
10865
|
case "reload": {
|
|
10863
10866
|
const name = subArgs[0];
|
|
10864
10867
|
if (!name) outputError("Usage: xbrowser plugin reload <name>");
|
|
10865
|
-
|
|
10868
|
+
try {
|
|
10869
|
+
await (await getPluginLoader()).reloadPlugin(name);
|
|
10870
|
+
} catch {
|
|
10871
|
+
outputError(`Plugin "${name}" not found. Use 'xbrowser plugin list' to see installed plugins.`);
|
|
10872
|
+
}
|
|
10866
10873
|
outputResult({ ok: true, name }, mode);
|
|
10867
10874
|
break;
|
|
10868
10875
|
}
|
|
@@ -12822,13 +12829,24 @@ async function routeCommand(argvIn, stdinCommands) {
|
|
|
12822
12829
|
await handleChainInput(argv[0], argv);
|
|
12823
12830
|
return;
|
|
12824
12831
|
}
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12832
|
+
const globalFlags = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--output", "--timeout", "--help", "-h", "--version"]);
|
|
12833
|
+
let chainArgIdx = -1;
|
|
12834
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12835
|
+
if (globalFlags.has(argv[i])) continue;
|
|
12836
|
+
if (globalFlags.has(argv[i]) || i > 0 && globalFlags.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
|
|
12837
|
+
if (argv[i].includes(" ") && /^[a-zA-Z]/.test(argv[i])) {
|
|
12838
|
+
chainArgIdx = i;
|
|
12839
|
+
break;
|
|
12840
|
+
}
|
|
12841
|
+
}
|
|
12842
|
+
if (chainArgIdx >= 0) {
|
|
12843
|
+
const chainArg = argv[chainArgIdx];
|
|
12844
|
+
const spaceIdx = chainArg.indexOf(" ");
|
|
12845
|
+
const possibleCmd = chainArg.substring(0, spaceIdx);
|
|
12828
12846
|
if (/^[a-zA-Z][\w-]*$/.test(possibleCmd)) {
|
|
12829
|
-
const remainder =
|
|
12847
|
+
const remainder = chainArg.substring(spaceIdx + 1);
|
|
12830
12848
|
const remainderParts = remainder.split(/\s+/).filter(Boolean);
|
|
12831
|
-
argv = [possibleCmd, ...remainderParts, ...argv.slice(1)];
|
|
12849
|
+
argv = [...argv.slice(0, chainArgIdx), possibleCmd, ...remainderParts, ...argv.slice(chainArgIdx + 1)];
|
|
12832
12850
|
}
|
|
12833
12851
|
}
|
|
12834
12852
|
} catch (e) {
|
|
@@ -13022,7 +13040,15 @@ async function routeCommand(argvIn, stdinCommands) {
|
|
|
13022
13040
|
const internalLoader = loader.getCore().loader;
|
|
13023
13041
|
const site = internalLoader.getSite(command);
|
|
13024
13042
|
if (!site) {
|
|
13025
|
-
const
|
|
13043
|
+
const globalFlagSet = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--help", "-h", "--version", "--output", "-o"]);
|
|
13044
|
+
const cleanParts = [];
|
|
13045
|
+
for (let i = 0; i < argv.length; i++) {
|
|
13046
|
+
if (globalFlagSet.has(argv[i])) continue;
|
|
13047
|
+
if (i > 0 && globalFlagSet.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
|
|
13048
|
+
if (argv[i].startsWith("--session=") || argv[i].startsWith("--cdp=")) continue;
|
|
13049
|
+
cleanParts.push(argv[i]);
|
|
13050
|
+
}
|
|
13051
|
+
const fullInput = cleanParts.join(" ");
|
|
13026
13052
|
if (isChainInput(fullInput)) {
|
|
13027
13053
|
const chainResult = await executeChain(fullInput, { cdpEndpoint, sessionName });
|
|
13028
13054
|
for (const step of chainResult.steps) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbrowser/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
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": {
|