@xbrowser/cli 1.6.1 → 1.6.3
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 +37 -5
- package/dist/daemon-main.js +37 -5
- package/dist/index.js +37 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -950,10 +950,7 @@ var evaluateCommand = registerCommand({
|
|
|
950
950
|
const result = await ctx.page.evaluate(p.expression);
|
|
951
951
|
const response = ok7({ result });
|
|
952
952
|
if (decision && decision.severity === "danger") {
|
|
953
|
-
response.tips = normalizeTips2([
|
|
954
|
-
`\u26A0\uFE0F CDP Firewall: ${decision.reason}`,
|
|
955
|
-
`\u{1F4A1} Fix: ${decision.suggestion}`
|
|
956
|
-
]);
|
|
953
|
+
response.tips = normalizeTips2([`${decision.suggestion}`]);
|
|
957
954
|
}
|
|
958
955
|
return response;
|
|
959
956
|
}
|
|
@@ -2178,10 +2175,45 @@ function createTurndown() {
|
|
|
2178
2175
|
},
|
|
2179
2176
|
replacement: () => ""
|
|
2180
2177
|
});
|
|
2178
|
+
turndown.addRule("complexTables", {
|
|
2179
|
+
filter: (node) => {
|
|
2180
|
+
if (typeof node !== "object" || node === null) return false;
|
|
2181
|
+
const n = node;
|
|
2182
|
+
return n.nodeName?.toLowerCase() === "table";
|
|
2183
|
+
},
|
|
2184
|
+
replacement: (_content, node) => {
|
|
2185
|
+
const html = node.outerHTML || "";
|
|
2186
|
+
if (!html) return "";
|
|
2187
|
+
const rows = [];
|
|
2188
|
+
const rowRegex = /<tr[^>]*>([\s\S]*?)<\/tr>/gi;
|
|
2189
|
+
let rowMatch;
|
|
2190
|
+
while ((rowMatch = rowRegex.exec(html)) !== null) {
|
|
2191
|
+
const cells = [];
|
|
2192
|
+
const cellRegex = /<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi;
|
|
2193
|
+
let cellMatch;
|
|
2194
|
+
while ((cellMatch = cellRegex.exec(rowMatch[1])) !== null) {
|
|
2195
|
+
cells.push(cellMatch[1].replace(/<[^>]+>/g, "").trim().replace(/\n/g, " "));
|
|
2196
|
+
}
|
|
2197
|
+
if (cells.length > 0) rows.push(cells);
|
|
2198
|
+
}
|
|
2199
|
+
if (rows.length === 0) return "";
|
|
2200
|
+
const mdRows = rows.map((cells) => {
|
|
2201
|
+
const escaped = cells.map((c) => c.replace(/\|/g, "\\|") || "");
|
|
2202
|
+
return `| ${escaped.join(" | ")} |`;
|
|
2203
|
+
});
|
|
2204
|
+
const hasHeader = /<th/i.test(html);
|
|
2205
|
+
if (hasHeader && mdRows.length > 0) {
|
|
2206
|
+
const colCount = rows[0].length;
|
|
2207
|
+
const sep = `| ${Array(colCount).fill("---").join(" | ")} |`;
|
|
2208
|
+
mdRows.splice(1, 0, sep);
|
|
2209
|
+
}
|
|
2210
|
+
return "\n\n" + mdRows.join("\n") + "\n\n";
|
|
2211
|
+
}
|
|
2212
|
+
});
|
|
2181
2213
|
return turndown;
|
|
2182
2214
|
}
|
|
2183
2215
|
function postClean(md) {
|
|
2184
|
-
md = md.replace(/<
|
|
2216
|
+
md = md.replace(/<[^>]+>/g, "");
|
|
2185
2217
|
md = md.replace(/\n{3,}/g, "\n\n");
|
|
2186
2218
|
md = md.replace(/!\[[^\]]*\]\(\s*\)/g, "");
|
|
2187
2219
|
md = md.replace(/\[([^\]]*)\]\(\s*\)/g, "$1");
|
package/dist/daemon-main.js
CHANGED
|
@@ -911,10 +911,7 @@ var evaluateCommand = registerCommand({
|
|
|
911
911
|
const result = await ctx.page.evaluate(p.expression);
|
|
912
912
|
const response = ok7({ result });
|
|
913
913
|
if (decision && decision.severity === "danger") {
|
|
914
|
-
response.tips = normalizeTips2([
|
|
915
|
-
`\u26A0\uFE0F CDP Firewall: ${decision.reason}`,
|
|
916
|
-
`\u{1F4A1} Fix: ${decision.suggestion}`
|
|
917
|
-
]);
|
|
914
|
+
response.tips = normalizeTips2([`${decision.suggestion}`]);
|
|
918
915
|
}
|
|
919
916
|
return response;
|
|
920
917
|
}
|
|
@@ -2139,10 +2136,45 @@ function createTurndown() {
|
|
|
2139
2136
|
},
|
|
2140
2137
|
replacement: () => ""
|
|
2141
2138
|
});
|
|
2139
|
+
turndown.addRule("complexTables", {
|
|
2140
|
+
filter: (node) => {
|
|
2141
|
+
if (typeof node !== "object" || node === null) return false;
|
|
2142
|
+
const n = node;
|
|
2143
|
+
return n.nodeName?.toLowerCase() === "table";
|
|
2144
|
+
},
|
|
2145
|
+
replacement: (_content, node) => {
|
|
2146
|
+
const html = node.outerHTML || "";
|
|
2147
|
+
if (!html) return "";
|
|
2148
|
+
const rows = [];
|
|
2149
|
+
const rowRegex = /<tr[^>]*>([\s\S]*?)<\/tr>/gi;
|
|
2150
|
+
let rowMatch;
|
|
2151
|
+
while ((rowMatch = rowRegex.exec(html)) !== null) {
|
|
2152
|
+
const cells = [];
|
|
2153
|
+
const cellRegex = /<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi;
|
|
2154
|
+
let cellMatch;
|
|
2155
|
+
while ((cellMatch = cellRegex.exec(rowMatch[1])) !== null) {
|
|
2156
|
+
cells.push(cellMatch[1].replace(/<[^>]+>/g, "").trim().replace(/\n/g, " "));
|
|
2157
|
+
}
|
|
2158
|
+
if (cells.length > 0) rows.push(cells);
|
|
2159
|
+
}
|
|
2160
|
+
if (rows.length === 0) return "";
|
|
2161
|
+
const mdRows = rows.map((cells) => {
|
|
2162
|
+
const escaped = cells.map((c) => c.replace(/\|/g, "\\|") || "");
|
|
2163
|
+
return `| ${escaped.join(" | ")} |`;
|
|
2164
|
+
});
|
|
2165
|
+
const hasHeader = /<th/i.test(html);
|
|
2166
|
+
if (hasHeader && mdRows.length > 0) {
|
|
2167
|
+
const colCount = rows[0].length;
|
|
2168
|
+
const sep = `| ${Array(colCount).fill("---").join(" | ")} |`;
|
|
2169
|
+
mdRows.splice(1, 0, sep);
|
|
2170
|
+
}
|
|
2171
|
+
return "\n\n" + mdRows.join("\n") + "\n\n";
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2142
2174
|
return turndown;
|
|
2143
2175
|
}
|
|
2144
2176
|
function postClean(md) {
|
|
2145
|
-
md = md.replace(/<
|
|
2177
|
+
md = md.replace(/<[^>]+>/g, "");
|
|
2146
2178
|
md = md.replace(/\n{3,}/g, "\n\n");
|
|
2147
2179
|
md = md.replace(/!\[[^\]]*\]\(\s*\)/g, "");
|
|
2148
2180
|
md = md.replace(/\[([^\]]*)\]\(\s*\)/g, "$1");
|
package/dist/index.js
CHANGED
|
@@ -990,10 +990,7 @@ var evaluateCommand = registerCommand({
|
|
|
990
990
|
const result = await ctx.page.evaluate(p.expression);
|
|
991
991
|
const response = ok7({ result });
|
|
992
992
|
if (decision && decision.severity === "danger") {
|
|
993
|
-
response.tips = normalizeTips2([
|
|
994
|
-
`\u26A0\uFE0F CDP Firewall: ${decision.reason}`,
|
|
995
|
-
`\u{1F4A1} Fix: ${decision.suggestion}`
|
|
996
|
-
]);
|
|
993
|
+
response.tips = normalizeTips2([`${decision.suggestion}`]);
|
|
997
994
|
}
|
|
998
995
|
return response;
|
|
999
996
|
}
|
|
@@ -2218,10 +2215,45 @@ function createTurndown() {
|
|
|
2218
2215
|
},
|
|
2219
2216
|
replacement: () => ""
|
|
2220
2217
|
});
|
|
2218
|
+
turndown.addRule("complexTables", {
|
|
2219
|
+
filter: (node) => {
|
|
2220
|
+
if (typeof node !== "object" || node === null) return false;
|
|
2221
|
+
const n = node;
|
|
2222
|
+
return n.nodeName?.toLowerCase() === "table";
|
|
2223
|
+
},
|
|
2224
|
+
replacement: (_content, node) => {
|
|
2225
|
+
const html = node.outerHTML || "";
|
|
2226
|
+
if (!html) return "";
|
|
2227
|
+
const rows = [];
|
|
2228
|
+
const rowRegex = /<tr[^>]*>([\s\S]*?)<\/tr>/gi;
|
|
2229
|
+
let rowMatch;
|
|
2230
|
+
while ((rowMatch = rowRegex.exec(html)) !== null) {
|
|
2231
|
+
const cells = [];
|
|
2232
|
+
const cellRegex = /<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi;
|
|
2233
|
+
let cellMatch;
|
|
2234
|
+
while ((cellMatch = cellRegex.exec(rowMatch[1])) !== null) {
|
|
2235
|
+
cells.push(cellMatch[1].replace(/<[^>]+>/g, "").trim().replace(/\n/g, " "));
|
|
2236
|
+
}
|
|
2237
|
+
if (cells.length > 0) rows.push(cells);
|
|
2238
|
+
}
|
|
2239
|
+
if (rows.length === 0) return "";
|
|
2240
|
+
const mdRows = rows.map((cells) => {
|
|
2241
|
+
const escaped = cells.map((c) => c.replace(/\|/g, "\\|") || "");
|
|
2242
|
+
return `| ${escaped.join(" | ")} |`;
|
|
2243
|
+
});
|
|
2244
|
+
const hasHeader = /<th/i.test(html);
|
|
2245
|
+
if (hasHeader && mdRows.length > 0) {
|
|
2246
|
+
const colCount = rows[0].length;
|
|
2247
|
+
const sep = `| ${Array(colCount).fill("---").join(" | ")} |`;
|
|
2248
|
+
mdRows.splice(1, 0, sep);
|
|
2249
|
+
}
|
|
2250
|
+
return "\n\n" + mdRows.join("\n") + "\n\n";
|
|
2251
|
+
}
|
|
2252
|
+
});
|
|
2221
2253
|
return turndown;
|
|
2222
2254
|
}
|
|
2223
2255
|
function postClean(md) {
|
|
2224
|
-
md = md.replace(/<
|
|
2256
|
+
md = md.replace(/<[^>]+>/g, "");
|
|
2225
2257
|
md = md.replace(/\n{3,}/g, "\n\n");
|
|
2226
2258
|
md = md.replace(/!\[[^\]]*\]\(\s*\)/g, "");
|
|
2227
2259
|
md = md.replace(/\[([^\]]*)\]\(\s*\)/g, "$1");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbrowser/cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
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": {
|