@vercel/next-browser 0.1.6 → 0.1.7
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 +6 -5
- package/dist/mcp.js +8 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -18,6 +18,7 @@ if (cmd === "open") {
|
|
|
18
18
|
console.error("usage: next-browser open <url> [--cookies-json <file>]");
|
|
19
19
|
process.exit(1);
|
|
20
20
|
}
|
|
21
|
+
const url = /^https?:\/\//.test(arg) ? arg : `http://${arg}`;
|
|
21
22
|
const cookieIdx = args.indexOf("--cookies-json");
|
|
22
23
|
const cookieFile = cookieIdx >= 0 ? args[cookieIdx + 1] : undefined;
|
|
23
24
|
if (cookieFile) {
|
|
@@ -26,15 +27,15 @@ if (cmd === "open") {
|
|
|
26
27
|
exit(res, "");
|
|
27
28
|
const raw = readFileSync(cookieFile, "utf-8");
|
|
28
29
|
const cookies = JSON.parse(raw);
|
|
29
|
-
const domain = new URL(
|
|
30
|
+
const domain = new URL(url).hostname;
|
|
30
31
|
const cRes = await send("cookies", { cookies, domain });
|
|
31
32
|
if (!cRes.ok)
|
|
32
33
|
exit(cRes, "");
|
|
33
|
-
await send("goto", { url
|
|
34
|
-
exit(res, `opened → ${
|
|
34
|
+
await send("goto", { url });
|
|
35
|
+
exit(res, `opened → ${url} (${cookies.length} cookies for ${domain})`);
|
|
35
36
|
}
|
|
36
|
-
const res = await send("open", { url
|
|
37
|
-
exit(res, `opened → ${
|
|
37
|
+
const res = await send("open", { url });
|
|
38
|
+
exit(res, `opened → ${url}`);
|
|
38
39
|
}
|
|
39
40
|
if (cmd === "ppr" && arg === "lock") {
|
|
40
41
|
const res = await send("lock");
|
package/dist/mcp.js
CHANGED
|
@@ -27,5 +27,12 @@ export async function call(origin, tool, args = {}) {
|
|
|
27
27
|
if (parsed.error)
|
|
28
28
|
throw new Error(parsed.error.message);
|
|
29
29
|
const text = parsed.result?.content?.[0]?.text;
|
|
30
|
-
|
|
30
|
+
if (!text)
|
|
31
|
+
return parsed.result;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(text);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return text;
|
|
37
|
+
}
|
|
31
38
|
}
|