polite-crawler 0.5.0 → 0.5.1
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/README.md +1 -0
- package/build/{browser-56dBBLec.mjs → browser-Cp5W-dmj.mjs} +5 -10
- package/build/{browser-56dBBLec.mjs.map → browser-Cp5W-dmj.mjs.map} +1 -1
- package/build/classify.d.mts +0 -2
- package/build/classify.mjs +1 -2
- package/build/{cli-daemon-kNj07eYU.mjs → cli-daemon-oSJWogkA.mjs} +3 -4
- package/build/{cli-daemon-kNj07eYU.mjs.map → cli-daemon-oSJWogkA.mjs.map} +1 -1
- package/build/{cli-recipes-DB3PgVig.mjs → cli-recipes-DVTMTQLx.mjs} +4 -5
- package/build/{cli-recipes-DB3PgVig.mjs.map → cli-recipes-DVTMTQLx.mjs.map} +1 -1
- package/build/cli.mjs +16 -19
- package/build/cli.mjs.map +1 -1
- package/build/{daemon-DePmNqn9.mjs → daemon-DNGSr4hR.mjs} +7 -13
- package/build/{daemon-DePmNqn9.mjs.map → daemon-DNGSr4hR.mjs.map} +1 -1
- package/build/{diff-Db1AmXuk.mjs → diff-ChsL3yux.mjs} +5 -12
- package/build/{diff-Db1AmXuk.mjs.map → diff-ChsL3yux.mjs.map} +1 -1
- package/build/{extract-D4J0D0IZ.mjs → extract-DO-NFOmF.mjs} +7 -12
- package/build/{extract-D4J0D0IZ.mjs.map → extract-DO-NFOmF.mjs.map} +1 -1
- package/build/hours.d.mts +0 -2
- package/build/hours.mjs +1 -2
- package/build/{html-Dir5QEi0.mjs → html-CawWTgMQ.mjs} +4 -6
- package/build/{html-Dir5QEi0.mjs.map → html-CawWTgMQ.mjs.map} +1 -1
- package/build/{html-o5bDHjNi.d.mts → html-oS_ueu9U.d.mts} +2 -20
- package/build/html.d.mts +2 -1
- package/build/html.mjs +2 -2
- package/build/index.d.mts +5 -72
- package/build/index.mjs +20 -19
- package/build/{log-CmBWcyQm.mjs → log-CB5bADmd.mjs} +3 -5
- package/build/{log-CmBWcyQm.mjs.map → log-CB5bADmd.mjs.map} +1 -1
- package/build/{mcp-package-Y0bREnOS.mjs → mcp-package-D9ACY0Ux.mjs} +2 -3
- package/build/{mcp-package-Y0bREnOS.mjs.map → mcp-package-D9ACY0Ux.mjs.map} +1 -1
- package/build/{ollama-D1xRh3hY.mjs → ollama-BDZjLDOK.mjs} +4 -10
- package/build/{ollama-D1xRh3hY.mjs.map → ollama-BDZjLDOK.mjs.map} +1 -1
- package/build/{open-EuCYPZVC.mjs → open-DOgE033K.mjs} +23 -40
- package/build/{open-EuCYPZVC.mjs.map → open-DOgE033K.mjs.map} +1 -1
- package/build/politeness.d.mts +0 -2
- package/build/politeness.mjs +1 -2
- package/build/{recipe-uLu2GLkr.mjs → recipe-BsGOZJyi.mjs} +5 -6
- package/build/{recipe-uLu2GLkr.mjs.map → recipe-BsGOZJyi.mjs.map} +1 -1
- package/build/{recipe-product-C_zv5j3z.mjs → recipe-product-DEDPKMY5.mjs} +7 -9
- package/build/{recipe-product-C_zv5j3z.mjs.map → recipe-product-DEDPKMY5.mjs.map} +1 -1
- package/build/{render-CKE2LILH.mjs → render-CZaqvjQh.mjs} +2 -3
- package/build/{render-CKE2LILH.mjs.map → render-CZaqvjQh.mjs.map} +1 -1
- package/build/robots.d.mts +0 -2
- package/build/robots.mjs +1 -2
- package/build/{rolldown-runtime-8H4AJuhK.mjs → rolldown-runtime-BJohB4LM.mjs} +1 -2
- package/build/{runtime-ByOn76mm.mjs → runtime-NyweI69B.mjs} +13 -20
- package/build/{runtime-ByOn76mm.mjs.map → runtime-NyweI69B.mjs.map} +1 -1
- package/build/signals.d.mts +0 -2
- package/build/signals.mjs +1 -2
- package/build/{transformers-BNiuiLxT.mjs → transformers-C_ziG8yf.mjs} +4 -9
- package/build/{transformers-BNiuiLxT.mjs.map → transformers-C_ziG8yf.mjs.map} +1 -1
- package/build/urls.d.mts +28 -0
- package/build/{urls-BHFeSyEK.mjs → urls.mjs} +3 -4
- package/build/urls.mjs.map +1 -0
- package/build/{version-D4u8ScwH.mjs → version-hVv3n9O6.mjs} +4 -6
- package/build/{version-D4u8ScwH.mjs.map → version-hVv3n9O6.mjs.map} +1 -1
- package/build/{wacz-DlGT0YXp.mjs → wacz-Blvh5qwS.mjs} +7 -9
- package/build/{wacz-DlGT0YXp.mjs.map → wacz-Blvh5qwS.mjs.map} +1 -1
- package/build/{warc-Cq3gO3NK.mjs → warc-DiE1M5le.mjs} +7 -17
- package/build/{warc-Cq3gO3NK.mjs.map → warc-DiE1M5le.mjs.map} +1 -1
- package/build/{webbotauth-Dq_dA_u3.mjs → webbotauth-W3GXY3dy.mjs} +4 -11
- package/build/{webbotauth-Dq_dA_u3.mjs.map → webbotauth-W3GXY3dy.mjs.map} +1 -1
- package/package.json +5 -1
- package/build/urls-BHFeSyEK.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ The package is ESM only, and it includes its TypeScript declarations. It has the
|
|
|
48
48
|
| `polite-crawler/classify` | The outcome of a response | Yes |
|
|
49
49
|
| `polite-crawler/politeness` | The queue that keeps one request in progress for each host | Yes |
|
|
50
50
|
| `polite-crawler/signals` | The reader of usage signals (`Content-Signal`) | Yes |
|
|
51
|
+
| `polite-crawler/urls` | The canonical form of a URL, its cache key and its site. It imports no module. | Yes |
|
|
51
52
|
|
|
52
53
|
The entry points that work in a browser import no Node.js module. The package loads no MCP SDK and no `zod`: the MCP server is the package `polite-crawler-mcp`.
|
|
53
54
|
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import { n as RenderRefused, t as NO_PLAYWRIGHT } from "./render-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
|
+
import { n as RenderRefused, t as NO_PLAYWRIGHT } from "./render-CZaqvjQh.mjs";
|
|
3
3
|
import { basename, dirname, join } from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
|
-
|
|
6
|
-
var browser_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
-
NO_BROWSER: () => NO_BROWSER,
|
|
8
|
-
browserMissing: () => browserMissing,
|
|
9
|
-
checkedRenderer: () => checkedRenderer
|
|
10
|
-
});
|
|
5
|
+
// src/browser.ts
|
|
6
|
+
var browser_exports = /* @__PURE__ */ __exportAll({ browserMissing: () => browserMissing });
|
|
11
7
|
/** The text of the note when `playwright-core` is installed, but its browser is not. */
|
|
12
8
|
const NO_BROWSER = "rendering needs a browser: npx playwright-core install chromium-headless-shell";
|
|
13
9
|
/**
|
|
@@ -60,7 +56,6 @@ const checkedRenderer = (renderer, check = () => browserMissing()) => {
|
|
|
60
56
|
close: () => renderer.close()
|
|
61
57
|
};
|
|
62
58
|
};
|
|
63
|
-
//#endregion
|
|
64
59
|
export { browser_exports as n, checkedRenderer as r, browserMissing as t };
|
|
65
60
|
|
|
66
|
-
//# sourceMappingURL=browser-
|
|
61
|
+
//# sourceMappingURL=browser-Cp5W-dmj.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-
|
|
1
|
+
{"version":3,"file":"browser-Cp5W-dmj.mjs","names":[],"sources":["../src/browser.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\nimport type { Renderer } from \"./render.ts\";\nimport { NO_PLAYWRIGHT, RenderRefused } from \"./render.ts\";\n\n/** The text of the note when `playwright-core` is installed, but its browser is not. */\nexport const NO_BROWSER =\n \"rendering needs a browser: npx playwright-core install chromium-headless-shell\";\n\n/** This is the part of `playwright-core` that the check uses. */\ninterface Chromium {\n executablePath(): string;\n}\n\n/**\n * This function tells if the default renderer can start a browser. It gives no value when it can,\n * and the reason when it cannot. The command line and the MCP server use it one time at start.\n * Then a missing browser costs no wait and no error capture for each page that needs JavaScript.\n *\n * The check does not start the browser. It finds the full Chromium build or the headless shell of\n * the same revision on the disk. When the check cannot find the answer, it gives no value, and the\n * renderer then tries.\n *\n * @beta\n */\nexport const browserMissing = async (\n load: () => Promise<{ readonly chromium: { executablePath(): string } }> = () =>\n import(\"playwright-core\"),\n): Promise<string | undefined> => {\n let chromium: Chromium;\n try {\n ({ chromium } = await load());\n } catch {\n return NO_PLAYWRIGHT;\n }\n try {\n const executable = chromium.executablePath();\n if (existsSync(executable)) return undefined;\n // the headless shell is in a folder next to the folder of the full build, with the same revision\n let folder = dirname(executable);\n while (dirname(folder) !== folder && !/^chromium-\\d+$/.test(basename(folder)))\n folder = dirname(folder);\n const revision = /^chromium-(\\d+)$/.exec(basename(folder))?.[1];\n if (revision === undefined) return undefined;\n return existsSync(join(dirname(folder), `chromium_headless_shell-${revision}`))\n ? undefined\n : NO_BROWSER;\n } catch {\n return undefined;\n }\n};\n\n/**\n * This function gives a renderer that checks one time, before its first page, that the browser is\n * on the disk (`browserMissing`). With no browser, each page gets a `RenderRefused` with the reason\n * `browser` at once, and the renderer opens nothing. `createRuntime` puts its default renderer in\n * it, so a library with no browser costs no wait and no error capture.\n *\n * This export is internal: the root entry point does not have it since 0.2.0.\n */\nexport const checkedRenderer = (\n renderer: Renderer,\n check: () => Promise<string | undefined> = () => browserMissing(),\n): Renderer => {\n let missing: Promise<string | undefined> | undefined;\n return {\n async render(url, options) {\n missing ??= check().catch(() => undefined);\n const reason = await missing;\n if (reason !== undefined) throw new RenderRefused(\"browser\", reason);\n return renderer.render(url, options);\n },\n close: () => renderer.close(),\n };\n};\n"],"mappings":";;;;;;;AAMA,MAAa,aACX;;;;;;;;;;;;AAkBF,MAAa,iBAAiB,OAC5B,aACE,OAAO,uBACuB;CAChC,IAAI;CACJ,IAAI;EACF,CAAC,CAAE,YAAa,MAAM,KAAK;CAC7B,QAAQ;EACN,OAAO;CACT;CACA,IAAI;EACF,MAAM,aAAa,SAAS,eAAe;EAC3C,IAAI,WAAW,UAAU,GAAG,OAAO,KAAA;EAEnC,IAAI,SAAS,QAAQ,UAAU;EAC/B,OAAO,QAAQ,MAAM,MAAM,UAAU,CAAC,iBAAiB,KAAK,SAAS,MAAM,CAAC,GAC1E,SAAS,QAAQ,MAAM;EACzB,MAAM,WAAW,mBAAmB,KAAK,SAAS,MAAM,CAAC,CAAC,GAAG;EAC7D,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;EACnC,OAAO,WAAW,KAAK,QAAQ,MAAM,GAAG,2BAA2B,UAAU,CAAC,IAC1E,KAAA,IACA;CACN,QAAQ;EACN;CACF;AACF;;;;;;;;;AAUA,MAAa,mBACX,UACA,cAAiD,eAAe,MACnD;CACb,IAAI;CACJ,OAAO;EACL,MAAM,OAAO,KAAK,SAAS;GACzB,YAAY,MAAM,CAAC,CAAC,YAAY,KAAA,CAAS;GACzC,MAAM,SAAS,MAAM;GACrB,IAAI,WAAW,KAAA,GAAW,MAAM,IAAI,cAAc,WAAW,MAAM;GACnE,OAAO,SAAS,OAAO,KAAK,OAAO;EACrC;EACA,aAAa,SAAS,MAAM;CAC9B;AACF"}
|
package/build/classify.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/classify.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The outcome tells what a response means for the crawl. The crawler decides it before it keeps
|
|
4
3
|
* the body as content. The crawler sees a refusal and stops. It does not try again with a
|
|
@@ -46,5 +45,4 @@ export declare const STOPS_HOST: ReadonlySet<Outcome>;
|
|
|
46
45
|
*/
|
|
47
46
|
export declare const isClientError: (status: number) => boolean;
|
|
48
47
|
export declare const classify: (status: number, header: (name: string) => string | undefined, now: number) => Classified;
|
|
49
|
-
//#endregion
|
|
50
48
|
//# sourceMappingURL=classify.d.mts.map
|
package/build/classify.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/classify.ts
|
|
2
2
|
const MONTHS = [
|
|
3
3
|
"Jan",
|
|
4
4
|
"Feb",
|
|
@@ -110,7 +110,6 @@ const classify = (status, header, now) => {
|
|
|
110
110
|
if (status === 502 || status === 503 || status === 504) return result("unavailable");
|
|
111
111
|
return result("error", status === 0 ? "no response" : `status ${String(status)}`);
|
|
112
112
|
};
|
|
113
|
-
//#endregion
|
|
114
113
|
export { STOPS_HOST, classify, isClientError, parseHttpDate, parseRetryAfter };
|
|
115
114
|
|
|
116
115
|
//# sourceMappingURL=classify.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as describeDaemonStatus } from "./cli.mjs";
|
|
2
|
-
|
|
2
|
+
// src/cli-daemon.ts
|
|
3
3
|
/**
|
|
4
4
|
* This function does the command `daemon`, and gives the exit code. `daemon status` gives 0 when a
|
|
5
5
|
* daemon operates on the store, and 1 when none operates. `daemon` gives 0 after a clean stop. An
|
|
6
6
|
* error at start rejects, so the command exits with 1.
|
|
7
7
|
*/
|
|
8
8
|
const daemonCommand = async (line, options, io) => {
|
|
9
|
-
const { changeCommand, readDaemonState, startDaemon } = await import("./daemon-
|
|
9
|
+
const { changeCommand, readDaemonState, startDaemon } = await import("./daemon-DNGSr4hR.mjs").then((n) => n.a);
|
|
10
10
|
if (line.action === "status") {
|
|
11
11
|
const state = readDaemonState(options.dir);
|
|
12
12
|
io.out(io.json ? JSON.stringify(state ?? null, null, 2) : describeDaemonStatus(state, options.dir));
|
|
@@ -32,7 +32,6 @@ const daemonCommand = async (line, options, io) => {
|
|
|
32
32
|
})).done;
|
|
33
33
|
return 0;
|
|
34
34
|
};
|
|
35
|
-
//#endregion
|
|
36
35
|
export { daemonCommand };
|
|
37
36
|
|
|
38
|
-
//# sourceMappingURL=cli-daemon-
|
|
37
|
+
//# sourceMappingURL=cli-daemon-oSJWogkA.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-daemon-
|
|
1
|
+
{"version":3,"file":"cli-daemon-oSJWogkA.mjs","names":[],"sources":["../src/cli-daemon.ts"],"sourcesContent":["/*\n * The command `daemon` of the command line: `daemon` runs the daemon until `SIGINT` or `SIGTERM`, and\n * `daemon status` prints the state file. `cli.ts` loads this file only for the command `daemon`.\n */\nimport type { DaemonLine } from \"./cli-line.ts\";\nimport { describeDaemonStatus } from \"./cli-line.ts\";\nimport type { OpenOptions } from \"./open.ts\";\n\n/** These are the parts of the command line that the command `daemon` uses. */\nexport interface DaemonIo {\n /** The value true lets `user_provided` work when the MCP client cannot ask the user. */\n readonly allowUserProvided: boolean;\n /** The value true prints the status as JSON. */\n readonly json: boolean;\n /** This function prints a line on the standard output. */\n readonly out: (text: string) => void;\n}\n\n/**\n * This function does the command `daemon`, and gives the exit code. `daemon status` gives 0 when a\n * daemon operates on the store, and 1 when none operates. `daemon` gives 0 after a clean stop. An\n * error at start rejects, so the command exits with 1.\n */\nexport const daemonCommand = async (\n line: DaemonLine,\n options: OpenOptions,\n io: DaemonIo,\n): Promise<number> => {\n const { changeCommand, readDaemonState, startDaemon } = await import(\"./daemon.ts\");\n if (line.action === \"status\") {\n const state = readDaemonState(options.dir);\n io.out(\n io.json ? JSON.stringify(state ?? null, null, 2) : describeDaemonStatus(state, options.dir),\n );\n return state?.alive === true ? 0 : 1;\n }\n const daemon = await startDaemon({\n ...options,\n tick: line.tickMs,\n jitter: line.jitterMs,\n budget: line.budgetMs,\n maxPages: line.maxPages,\n grace: line.graceMs,\n events: line.events,\n onChange: line.onChange === undefined ? undefined : changeCommand(line.onChange),\n mcp:\n line.mcp === undefined\n ? undefined\n : {\n port: line.mcp.port,\n host: line.mcp.host,\n allowRemote: line.mcp.allowRemote,\n tokenFile: line.mcp.tokenFile,\n allowUserProvided: io.allowUserProvided,\n },\n signals: true,\n });\n await daemon.done;\n return 0;\n};\n"],"mappings":";;;;;;;AAuBA,MAAa,gBAAgB,OAC3B,MACA,SACA,OACoB;CACpB,MAAM,EAAE,eAAe,iBAAiB,gBAAgB,MAAM,OAAO,wBAAc,CAAA,MAAA,MAAA,EAAA,CAAA;CACnF,IAAI,KAAK,WAAW,UAAU;EAC5B,MAAM,QAAQ,gBAAgB,QAAQ,GAAG;EACzC,GAAG,IACD,GAAG,OAAO,KAAK,UAAU,SAAS,MAAM,MAAM,CAAC,IAAI,qBAAqB,OAAO,QAAQ,GAAG,CAC5F;EACA,OAAO,OAAO,UAAU,OAAO,IAAI;CACrC;CAsBA,OAAM,MArBe,YAAY;EAC/B,GAAG;EACH,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,QAAQ,KAAK;EACb,UAAU,KAAK;EACf,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,UAAU,KAAK,aAAa,KAAA,IAAY,KAAA,IAAY,cAAc,KAAK,QAAQ;EAC/E,KACE,KAAK,QAAQ,KAAA,IACT,KAAA,IACA;GACE,MAAM,KAAK,IAAI;GACf,MAAM,KAAK,IAAI;GACf,aAAa,KAAK,IAAI;GACtB,WAAW,KAAK,IAAI;GACpB,mBAAmB,GAAG;EACxB;EACN,SAAS;CACX,CAAC,EAAA,CACY;CACb,OAAO;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { compareHours, fromCompact } from "./hours.mjs";
|
|
2
|
-
import { d as readVenue, o as readProduct } from "./recipe-product-C_zv5j3z.mjs";
|
|
3
1
|
import { a as keptWeekOf, i as describeVenue, o as productCode, r as describeProduct, s as venueCode, t as UsageError } from "./cli.mjs";
|
|
4
|
-
|
|
2
|
+
import { compareHours, fromCompact } from "./hours.mjs";
|
|
3
|
+
import { d as readVenue, o as readProduct } from "./recipe-product-DEDPKMY5.mjs";
|
|
4
|
+
// src/cli-recipes.ts
|
|
5
5
|
/**
|
|
6
6
|
* This function checks the parts of `venue` that need a file or a reader, before the store opens.
|
|
7
7
|
* They are the kept week of `--compare` and the value of `--osm`. An error is a usage error.
|
|
@@ -53,7 +53,6 @@ const productCommand = async (target, line, io) => {
|
|
|
53
53
|
io.out(io.json ? JSON.stringify(result, null, 2) : describeProduct(result, io.renderOff).join("\n"));
|
|
54
54
|
return productCode(result);
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { prepareRecipe, productCommand, venueCommand };
|
|
58
57
|
|
|
59
|
-
//# sourceMappingURL=cli-recipes-
|
|
58
|
+
//# sourceMappingURL=cli-recipes-DVTMTQLx.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-recipes-
|
|
1
|
+
{"version":3,"file":"cli-recipes-DVTMTQLx.mjs","names":[],"sources":["../src/cli-recipes.ts"],"sourcesContent":["/*\n * The commands `venue` and `product` of the command line. They read a venue or a product page with\n * the recipes of the package (`readVenue` and `readProduct`). `cli.ts` loads this file only for these\n * two commands, so the other commands do not load the recipes.\n */\nimport type { KeptWeek, RecipeLine, VenueCompare } from \"./cli-line.ts\";\nimport {\n UsageError,\n describeProduct,\n describeVenue,\n keptWeekOf,\n productCode,\n venueCode,\n} from \"./cli-line.ts\";\nimport { compareHours, fromCompact } from \"./hours.ts\";\nimport type { RecipeTarget } from \"./recipe.ts\";\nimport type { ProductOptions } from \"./recipe-product.ts\";\nimport { readProduct } from \"./recipe-product.ts\";\nimport type { VenueOptions } from \"./recipe-venue.ts\";\nimport { readVenue } from \"./recipe-venue.ts\";\n\n/** These are the parts of the command line that `venue` and `product` use. */\nexport interface RecipeIo {\n /** The value true prints the result as JSON. */\n readonly json: boolean;\n /** This function prints a line on the standard output. */\n readonly out: (text: string) => void;\n /** This text tells why rendering is off, when the computer has no browser. */\n readonly renderOff?: string | undefined;\n}\n\n/** These are the inputs of `venue` that the command reads before the store opens. */\nexport interface RecipeInput {\n /** This value is the kept week of `--compare`, or undefined with no `--compare`. */\n readonly kept: KeptWeek | undefined;\n}\n\n/**\n * This function checks the parts of `venue` that need a file or a reader, before the store opens.\n * They are the kept week of `--compare` and the value of `--osm`. An error is a usage error.\n */\nexport const prepareRecipe = (line: RecipeLine): RecipeInput => {\n if (line.osm !== undefined && fromCompact(line.osm, \"osm\") === undefined) {\n throw new UsageError(\n `--osm: the hours reader cannot read \"${line.osm}\". Write an opening_hours value, such as \"Mo-Fr 08:00-18:00; Sa 09:00-13:00\"`,\n );\n }\n return { kept: line.compare === undefined ? undefined : keptWeekOf(line.compare) };\n};\n\n/** This function gives the options of the recipe that `venue` and `product` share. */\nconst sharedOptions = (line: RecipeLine): ProductOptions => ({\n render: line.render,\n maxAge: line.maxAge,\n budget: line.budget,\n onBehalfOf: line.onBehalfOf,\n userProvided: line.userProvided,\n fallback: line.fallback,\n archiveDespiteRobots: line.archiveDespiteRobots,\n});\n\n/**\n * This function does the command `venue`, and gives the exit code. It reads the hours of the venue\n * with `readVenue`. With `--compare`, it compares the week of the site (`from_site`) with the kept\n * week through `compareHours`.\n */\nexport const venueCommand = async (\n target: RecipeTarget,\n line: RecipeLine,\n input: RecipeInput,\n io: RecipeIo,\n): Promise<number> => {\n const options: VenueOptions = {\n ...sharedOptions(line),\n name: line.name,\n requireName: line.requireName,\n location: line.location,\n osm: line.osm,\n pages: line.pages,\n };\n const result = await readVenue(target, line.url, options);\n const site = result.from_site;\n const compare: VenueCompare | undefined =\n input.kept === undefined\n ? undefined\n : {\n file: input.kept.file,\n kept: input.kept.week,\n comparison: site === null ? null : compareHours(input.kept.week, site.week),\n };\n io.out(\n io.json\n ? JSON.stringify(compare === undefined ? result : { ...result, compare }, null, 2)\n : describeVenue(result, compare, io.renderOff).join(\"\\n\"),\n );\n return venueCode(result);\n};\n\n/** This function does the command `product`, and gives the exit code. It reads the page with `readProduct`. */\nexport const productCommand = async (\n target: RecipeTarget,\n line: RecipeLine,\n io: RecipeIo,\n): Promise<number> => {\n const result = await readProduct(target, line.url, sharedOptions(line));\n io.out(\n io.json ? JSON.stringify(result, null, 2) : describeProduct(result, io.renderOff).join(\"\\n\"),\n );\n return productCode(result);\n};\n"],"mappings":";;;;;;;;AAyCA,MAAa,iBAAiB,SAAkC;CAC9D,IAAI,KAAK,QAAQ,KAAA,KAAa,YAAY,KAAK,KAAK,KAAK,MAAM,KAAA,GAC7D,MAAM,IAAI,WACR,wCAAwC,KAAK,IAAI,6EACnD;CAEF,OAAO,EAAE,MAAM,KAAK,YAAY,KAAA,IAAY,KAAA,IAAY,WAAW,KAAK,OAAO,EAAE;AACnF;;AAGA,MAAM,iBAAiB,UAAsC;CAC3D,QAAQ,KAAK;CACb,QAAQ,KAAK;CACb,QAAQ,KAAK;CACb,YAAY,KAAK;CACjB,cAAc,KAAK;CACnB,UAAU,KAAK;CACf,sBAAsB,KAAK;AAC7B;;;;;;AAOA,MAAa,eAAe,OAC1B,QACA,MACA,OACA,OACoB;CACpB,MAAM,UAAwB;EAC5B,GAAG,cAAc,IAAI;EACrB,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,UAAU,KAAK;EACf,KAAK,KAAK;EACV,OAAO,KAAK;CACd;CACA,MAAM,SAAS,MAAM,UAAU,QAAQ,KAAK,KAAK,OAAO;CACxD,MAAM,OAAO,OAAO;CACpB,MAAM,UACJ,MAAM,SAAS,KAAA,IACX,KAAA,IACA;EACE,MAAM,MAAM,KAAK;EACjB,MAAM,MAAM,KAAK;EACjB,YAAY,SAAS,OAAO,OAAO,aAAa,MAAM,KAAK,MAAM,KAAK,IAAI;CAC5E;CACN,GAAG,IACD,GAAG,OACC,KAAK,UAAU,YAAY,KAAA,IAAY,SAAS;EAAE,GAAG;EAAQ;CAAQ,GAAG,MAAM,CAAC,IAC/E,cAAc,QAAQ,SAAS,GAAG,SAAS,CAAC,CAAC,KAAK,IAAI,CAC5D;CACA,OAAO,UAAU,MAAM;AACzB;;AAGA,MAAa,iBAAiB,OAC5B,QACA,MACA,OACoB;CACpB,MAAM,SAAS,MAAM,YAAY,QAAQ,KAAK,KAAK,cAAc,IAAI,CAAC;CACtE,GAAG,IACD,GAAG,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI,gBAAgB,QAAQ,GAAG,SAAS,CAAC,CAAC,KAAK,IAAI,CAC7F;CACA,OAAO,YAAY,MAAM;AAC3B"}
|
package/build/cli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as durationMs, r as VERSION } from "./version-
|
|
2
|
+
import { i as durationMs, r as VERSION } from "./version-hVv3n9O6.mjs";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { isIP } from "node:net";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
|
-
|
|
8
|
+
// src/loopback.ts
|
|
9
9
|
/**
|
|
10
10
|
* This function tells if a host name or an address is a loopback host: `localhost`, an address in
|
|
11
11
|
* `127.0.0.0/8`, or `::1`. The MCP server over HTTP binds to a loopback host unless the operator
|
|
@@ -20,8 +20,7 @@ const isLoopbackHost = (host) => {
|
|
|
20
20
|
if (isIP(name) === 6) return /^(?:0{0,4}:){7}0{0,3}1$|^::1$/.test(name);
|
|
21
21
|
return false;
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
//#region src/cli-line.ts
|
|
23
|
+
// src/cli-line.ts
|
|
25
24
|
/** A usage error is a wrong command line. It exits with code 2. */
|
|
26
25
|
var UsageError = class extends Error {};
|
|
27
26
|
/** These options belong to the command `export`. */
|
|
@@ -1171,8 +1170,7 @@ const readLine = (args, env) => {
|
|
|
1171
1170
|
recipeLine
|
|
1172
1171
|
};
|
|
1173
1172
|
};
|
|
1174
|
-
|
|
1175
|
-
//#region src/cli.ts
|
|
1173
|
+
// src/cli.ts
|
|
1176
1174
|
const emitWarning = process.emitWarning.bind(process);
|
|
1177
1175
|
process.emitWarning = ((warning, ...rest) => {
|
|
1178
1176
|
const first = rest[0];
|
|
@@ -1335,13 +1333,13 @@ Exit codes:
|
|
|
1335
1333
|
* command line first. The export only reads the store: it makes no store, and it sends no request.
|
|
1336
1334
|
*/
|
|
1337
1335
|
const exportCommand = async (plan, dir, json) => {
|
|
1338
|
-
const result = plan.format === "wacz" ? await (await import("./wacz-
|
|
1336
|
+
const result = plan.format === "wacz" ? await (await import("./wacz-Blvh5qwS.mjs").then((n) => n.n)).exportWacz(dir, plan.options) : await (await import("./warc-DiE1M5le.mjs").then((n) => n.a)).exportWarc(dir, plan.options);
|
|
1339
1337
|
process.stdout.write(`${json ? JSON.stringify(result, null, 2) : describeExport(result, plan.options.includeRefusals)}\n`);
|
|
1340
1338
|
return 0;
|
|
1341
1339
|
};
|
|
1342
1340
|
/** This function prints the key directory of a key file, and tells where to host it. */
|
|
1343
1341
|
const keyDirectoryCommand = async (key, agent) => {
|
|
1344
|
-
const { KEY_DIRECTORY_PATH, KEY_DIRECTORY_TYPE, keyDirectory } = await import("./webbotauth-
|
|
1342
|
+
const { KEY_DIRECTORY_PATH, KEY_DIRECTORY_TYPE, keyDirectory } = await import("./webbotauth-W3GXY3dy.mjs").then((n) => n.s);
|
|
1345
1343
|
let directory;
|
|
1346
1344
|
try {
|
|
1347
1345
|
directory = keyDirectory([key]);
|
|
@@ -1457,7 +1455,7 @@ const runWatchCommand = async (crawler, line, values, limits, json, out) => {
|
|
|
1457
1455
|
};
|
|
1458
1456
|
/** This function gives the text of a diff for a person: the two captures, then the text of `formatDiff`. */
|
|
1459
1457
|
const describeDiff = async (diff) => {
|
|
1460
|
-
const { formatDiff } = await import("./diff-
|
|
1458
|
+
const { formatDiff } = await import("./diff-ChsL3yux.mjs").then((n) => n.i);
|
|
1461
1459
|
return [
|
|
1462
1460
|
`${diff.doc} ${diff.from.capture} (${diff.from.fetched_at}) -> ${diff.to.capture} (${diff.to.fetched_at})`,
|
|
1463
1461
|
formatDiff(diff),
|
|
@@ -1467,7 +1465,7 @@ const describeDiff = async (diff) => {
|
|
|
1467
1465
|
};
|
|
1468
1466
|
/** This function checks the fields against a stored document, and prints a line for each field. The exit code is 0 when each field is verified or normalized. */
|
|
1469
1467
|
const runExtract = async (crawler, doc, fields, options, json, out) => {
|
|
1470
|
-
const { extractDocument } = await import("./extract-
|
|
1468
|
+
const { extractDocument } = await import("./extract-DO-NFOmF.mjs").then((n) => n.i);
|
|
1471
1469
|
const claims = fields;
|
|
1472
1470
|
const result = crawler.extract === void 0 ? await extractDocument(crawler.runtime, doc, claims, options) : await crawler.extract(doc, claims, options);
|
|
1473
1471
|
if (json) out(JSON.stringify(result, null, 2));
|
|
@@ -1481,14 +1479,14 @@ const runExtract = async (crawler, doc, fields, options, json, out) => {
|
|
|
1481
1479
|
const embedderFor = async (choice, dir) => {
|
|
1482
1480
|
try {
|
|
1483
1481
|
if (choice.kind === "ollama") {
|
|
1484
|
-
const { ollamaEmbedder } = await import("./ollama-
|
|
1482
|
+
const { ollamaEmbedder } = await import("./ollama-BDZjLDOK.mjs").then((n) => n.a);
|
|
1485
1483
|
return ollamaEmbedder({
|
|
1486
1484
|
...choice.model === void 0 ? {} : { model: choice.model },
|
|
1487
1485
|
...choice.url === void 0 ? {} : { baseUrl: choice.url },
|
|
1488
1486
|
allowRemote: choice.allowRemote
|
|
1489
1487
|
});
|
|
1490
1488
|
}
|
|
1491
|
-
const { transformersEmbedder } = await import("./transformers-
|
|
1489
|
+
const { transformersEmbedder } = await import("./transformers-C_ziG8yf.mjs").then((n) => n.i);
|
|
1492
1490
|
return transformersEmbedder({
|
|
1493
1491
|
...choice.model === void 0 ? {} : { model: choice.model },
|
|
1494
1492
|
cacheDir: join(dir, "models")
|
|
@@ -1532,7 +1530,7 @@ const main = async (args) => {
|
|
|
1532
1530
|
if (command === "key-directory") return keyDirectoryCommand(keyFile(signKey), signatureAgent);
|
|
1533
1531
|
let signer;
|
|
1534
1532
|
if (signKey !== void 0 && signatureAgent !== void 0) {
|
|
1535
|
-
const { createWebBotAuthSigner } = await import("./webbotauth-
|
|
1533
|
+
const { createWebBotAuthSigner } = await import("./webbotauth-W3GXY3dy.mjs").then((n) => n.s);
|
|
1536
1534
|
const privateKey = keyFile(signKey);
|
|
1537
1535
|
try {
|
|
1538
1536
|
signer = createWebBotAuthSigner({
|
|
@@ -1553,7 +1551,7 @@ const main = async (args) => {
|
|
|
1553
1551
|
...embedder === void 0 ? {} : { embedder }
|
|
1554
1552
|
};
|
|
1555
1553
|
if (command === "mcp") {
|
|
1556
|
-
const { McpPackageMissing, loadMcpPackage } = await import("./mcp-package-
|
|
1554
|
+
const { McpPackageMissing, loadMcpPackage } = await import("./mcp-package-D9ACY0Ux.mjs");
|
|
1557
1555
|
let mcp;
|
|
1558
1556
|
try {
|
|
1559
1557
|
mcp = await loadMcpPackage();
|
|
@@ -1570,7 +1568,7 @@ const main = async (args) => {
|
|
|
1570
1568
|
return 0;
|
|
1571
1569
|
}
|
|
1572
1570
|
if (command === "daemon") {
|
|
1573
|
-
const { daemonCommand } = await import("./cli-daemon-
|
|
1571
|
+
const { daemonCommand } = await import("./cli-daemon-oSJWogkA.mjs");
|
|
1574
1572
|
return daemonCommand(line.daemonLine, options, {
|
|
1575
1573
|
allowUserProvided: line.allowUserProvided,
|
|
1576
1574
|
json: values.json === true,
|
|
@@ -1579,14 +1577,14 @@ const main = async (args) => {
|
|
|
1579
1577
|
}
|
|
1580
1578
|
if (line.exportPlan !== void 0) return exportCommand(line.exportPlan, dir, values.json === true);
|
|
1581
1579
|
const recipeLine = line.recipeLine;
|
|
1582
|
-
const recipes = recipeLine === void 0 ? void 0 : await import("./cli-recipes-
|
|
1580
|
+
const recipes = recipeLine === void 0 ? void 0 : await import("./cli-recipes-DVTMTQLx.mjs");
|
|
1583
1581
|
const recipeInput = recipes === void 0 || recipeLine === void 0 ? void 0 : recipes.prepareRecipe(recipeLine);
|
|
1584
|
-
const { openCrawler } = await import("./open-
|
|
1582
|
+
const { openCrawler } = await import("./open-DOgE033K.mjs").then((n) => n.a);
|
|
1585
1583
|
let renderOff;
|
|
1586
1584
|
let renderer = options.renderer;
|
|
1587
1585
|
if (!(command === "fetch" || command === "crawl" || recipeLine !== void 0 || watchLine?.action === "run") || render === "never") renderer = false;
|
|
1588
1586
|
else if (renderer === void 0) {
|
|
1589
|
-
const { browserMissing } = await import("./browser-
|
|
1587
|
+
const { browserMissing } = await import("./browser-Cp5W-dmj.mjs").then((n) => n.n);
|
|
1590
1588
|
renderOff = await browserMissing();
|
|
1591
1589
|
if (renderOff !== void 0) renderer = false;
|
|
1592
1590
|
}
|
|
@@ -1695,7 +1693,6 @@ main(process.argv.slice(2)).then((code) => {
|
|
|
1695
1693
|
process.stderr.write(`polite-crawler: ${message}${usage ? " (polite-crawler --help lists the commands)" : ""}\n`);
|
|
1696
1694
|
process.exitCode = usage ? 2 : 1;
|
|
1697
1695
|
});
|
|
1698
|
-
//#endregion
|
|
1699
1696
|
export { keptWeekOf as a, describeVenue as i, describeDaemonStatus as n, productCode as o, describeProduct as r, venueCode as s, UsageError as t };
|
|
1700
1697
|
|
|
1701
1698
|
//# sourceMappingURL=cli.mjs.map
|