polite-crawler 0.2.2 → 0.2.4

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.
Files changed (36) hide show
  1. package/README.md +20 -2
  2. package/build/{cli-daemon-DkqyVxAI.mjs → cli-daemon-DreOSWKI.mjs} +2 -2
  3. package/build/{cli-daemon-DkqyVxAI.mjs.map → cli-daemon-DreOSWKI.mjs.map} +1 -1
  4. package/build/{cli-recipes-D96ppgSX.mjs → cli-recipes-DyacSWtg.mjs} +2 -2
  5. package/build/{cli-recipes-D96ppgSX.mjs.map → cli-recipes-DyacSWtg.mjs.map} +1 -1
  6. package/build/cli.mjs +7 -7
  7. package/build/{daemon-Bu1wpAwl.mjs → daemon-DI3WPTzq.mjs} +3 -3
  8. package/build/{daemon-Bu1wpAwl.mjs.map → daemon-DI3WPTzq.mjs.map} +1 -1
  9. package/build/{diff-Dyzr2-Oi.mjs → diff-BxjQT4r9.mjs} +2 -2
  10. package/build/{diff-Dyzr2-Oi.mjs.map → diff-BxjQT4r9.mjs.map} +1 -1
  11. package/build/{extract-DCClsy1y.mjs → extract-DfF_0IuS.mjs} +3 -3
  12. package/build/{extract-DCClsy1y.mjs.map → extract-DfF_0IuS.mjs.map} +1 -1
  13. package/build/{html-DkQUAE_d.mjs → html-DzobO0fy.mjs} +17 -2
  14. package/build/html-DzobO0fy.mjs.map +1 -0
  15. package/build/html.mjs +1 -1
  16. package/build/index.d.mts +42 -4
  17. package/build/index.mjs +11 -11
  18. package/build/{open-DXTLJWhU.mjs → open-CRRsEIrJ.mjs} +36 -11
  19. package/build/{open-DXTLJWhU.mjs.map → open-CRRsEIrJ.mjs.map} +1 -1
  20. package/build/{recipe-WTgRhbwY.mjs → recipe-Bh3_labG.mjs} +4 -4
  21. package/build/{recipe-WTgRhbwY.mjs.map → recipe-Bh3_labG.mjs.map} +1 -1
  22. package/build/{recipe-product-CuUlNx4_.mjs → recipe-product-CCjNbW8K.mjs} +5 -5
  23. package/build/{recipe-product-CuUlNx4_.mjs.map → recipe-product-CCjNbW8K.mjs.map} +1 -1
  24. package/build/robots.mjs +11 -6
  25. package/build/robots.mjs.map +1 -1
  26. package/build/{runtime-BwOZJ71n.mjs → runtime-C0gNyPHi.mjs} +10 -4
  27. package/build/runtime-C0gNyPHi.mjs.map +1 -0
  28. package/build/{version-CHqkjAh1.mjs → version-B_Mpbx8R.mjs} +2 -2
  29. package/build/{version-CHqkjAh1.mjs.map → version-B_Mpbx8R.mjs.map} +1 -1
  30. package/build/{wacz-CBMk0bzI.mjs → wacz-C1EJ8t57.mjs} +3 -3
  31. package/build/{wacz-CBMk0bzI.mjs.map → wacz-C1EJ8t57.mjs.map} +1 -1
  32. package/build/{warc-D632nC5y.mjs → warc-CLeYeJNf.mjs} +2 -2
  33. package/build/{warc-D632nC5y.mjs.map → warc-CLeYeJNf.mjs.map} +1 -1
  34. package/package.json +2 -2
  35. package/build/html-DkQUAE_d.mjs.map +0 -1
  36. package/build/runtime-BwOZJ71n.mjs.map +0 -1
@@ -35,6 +35,21 @@ const charsetOf = (contentType) => {
35
35
  const match = /;\s*charset\s*=\s*(?:"([^"]*)"|([^\s;"]+))/i.exec(contentType.slice(0, 512));
36
36
  return match?.[1] ?? match?.[2] ?? void 0;
37
37
  };
38
+ /**
39
+ * This function removes each comment (`<!--` to the next `-->`) of a text, in one pass from the
40
+ * start. It uses no regular expression, so its time is linear.
41
+ */
42
+ const withoutComments = (text) => {
43
+ let out = "";
44
+ let at = 0;
45
+ for (let open = text.indexOf("<!--"); open !== -1; open = text.indexOf("<!--", at)) {
46
+ const close = text.indexOf("-->", open + 4);
47
+ if (close === -1) break;
48
+ out += text.slice(at, open);
49
+ at = close + 3;
50
+ }
51
+ return out + text.slice(at);
52
+ };
38
53
  /** This function reads the encoding that the start of an HTML or XML document declares. */
39
54
  const declaredCharset = (bytes) => {
40
55
  let head = "";
@@ -42,7 +57,7 @@ const declaredCharset = (bytes) => {
42
57
  for (let index = 0; index < end; index += 1) head += String.fromCharCode(bytes[index]);
43
58
  const xml = /^\s*<\?xml[^>]*?\bencoding\s*=\s*["']([^"']+)["']/i.exec(head);
44
59
  if (xml !== null) return xml[1];
45
- const markup = head.replace(/<!--[\s\S]*?-->/g, "");
60
+ const markup = withoutComments(head);
46
61
  return /<meta\b[^>]*?\bcharset\s*=\s*["']?\s*([A-Za-z0-9_:.+-]+)/i.exec(markup)?.[1];
47
62
  };
48
63
  /**
@@ -1014,4 +1029,4 @@ const extractPage = (html, pageUrl) => {
1014
1029
  //#endregion
1015
1030
  export { bodyEncoding as a, visibleText as i, readJsonLd as n, decodeBody as o, typesOf as r, extractPage as t };
1016
1031
 
1017
- //# sourceMappingURL=html-DkQUAE_d.mjs.map
1032
+ //# sourceMappingURL=html-DzobO0fy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-DzobO0fy.mjs","names":[],"sources":["../src/text.ts","../src/html.ts"],"sourcesContent":["/**\n * The body decoder changes the bytes of a response into text. It finds the encoding in this order,\n * as the WHATWG encoding rules and the browsers do:\n *\n * 1. A byte order mark.\n * 2. The `charset` of the `Content-Type` header.\n * 3. A `<meta charset>` or `http-equiv` declaration in the first 2,048 bytes of an HTML page, or the\n * encoding of an XML declaration.\n * 4. UTF-8 when the bytes are UTF-8, and windows-1252 when they are not.\n *\n * It uses only `TextDecoder`, so it operates in a browser too. A byte that the encoding does not\n * know becomes U+FFFD. The decoder does not throw.\n */\n\nconst PRESCAN_BYTES = 2048;\n\n/** This function gives the WHATWG name of an encoding label, or undefined when the runtime does not know the label. */\nconst encodingOf = (label: string): string | undefined => {\n try {\n return new TextDecoder(label.trim().toLowerCase()).encoding;\n } catch {\n return undefined;\n }\n};\n\nconst bomOf = (bytes: Uint8Array): string | undefined => {\n if (bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf) return \"utf-8\";\n if (bytes[0] === 0xfe && bytes[1] === 0xff) return \"utf-16be\";\n if (bytes[0] === 0xff && bytes[1] === 0xfe) return \"utf-16le\";\n return undefined;\n};\n\n/** This function gives the `charset` parameter of a media type, or undefined. */\nconst charsetOf = (contentType: string | null): string | undefined => {\n if (contentType === null) return undefined;\n const match = /;\\s*charset\\s*=\\s*(?:\"([^\"]*)\"|([^\\s;\"]+))/i.exec(contentType.slice(0, 512));\n return match?.[1] ?? match?.[2] ?? undefined;\n};\n\n/**\n * This function removes each comment (`<!--` to the next `-->`) of a text, in one pass from the\n * start. It uses no regular expression, so its time is linear.\n */\nconst withoutComments = (text: string): string => {\n let out = \"\";\n let at = 0;\n for (let open = text.indexOf(\"<!--\"); open !== -1; open = text.indexOf(\"<!--\", at)) {\n const close = text.indexOf(\"-->\", open + 4);\n // a comment that does not close stays, and no later comment can close\n if (close === -1) break;\n out += text.slice(at, open);\n at = close + 3;\n }\n return out + text.slice(at);\n};\n\n/** This function reads the encoding that the start of an HTML or XML document declares. */\nconst declaredCharset = (bytes: Uint8Array): string | undefined => {\n let head = \"\";\n const end = Math.min(bytes.length, PRESCAN_BYTES);\n for (let index = 0; index < end; index += 1) head += String.fromCharCode(bytes[index]!);\n const xml = /^\\s*<\\?xml[^>]*?\\bencoding\\s*=\\s*[\"']([^\"']+)[\"']/i.exec(head);\n if (xml !== null) return xml[1];\n // a declaration inside a comment declares nothing\n const markup = withoutComments(head);\n // `<meta charset=x>`, and `<meta http-equiv=\"Content-Type\" content=\"text/html; charset=x\">`\n const meta = /<meta\\b[^>]*?\\bcharset\\s*=\\s*[\"']?\\s*([A-Za-z0-9_:.+-]+)/i.exec(markup);\n return meta?.[1];\n};\n\n/**\n * This function counts the UTF-8 sequences of more than one byte, and the bytes that no UTF-8\n * sequence explains. An incomplete sequence at the end is no error: a body cut at its size limit\n * ends so.\n */\nconst utf8Evidence = (\n bytes: Uint8Array,\n): { readonly multibyte: number; readonly invalid: number } => {\n let multibyte = 0;\n let invalid = 0;\n let index = 0;\n while (index < bytes.length) {\n const lead = bytes[index]!;\n if (lead < 0x80) {\n index += 1;\n continue;\n }\n const need =\n lead >= 0xc2 && lead <= 0xdf\n ? 1\n : lead >= 0xe0 && lead <= 0xef\n ? 2\n : lead >= 0xf0 && lead <= 0xf4\n ? 3\n : 0;\n if (need === 0) {\n invalid += 1;\n index += 1;\n continue;\n }\n // the second byte has a narrower range after E0, ED, F0 and F4\n const low = lead === 0xe0 ? 0xa0 : lead === 0xf0 ? 0x90 : 0x80;\n const high = lead === 0xed ? 0x9f : lead === 0xf4 ? 0x8f : 0xbf;\n let ok = true;\n let at = 1;\n while (at <= need && index + at < bytes.length) {\n const next = bytes[index + at]!;\n if (at === 1 ? next < low || next > high : next < 0x80 || next > 0xbf) {\n ok = false;\n break;\n }\n at += 1;\n }\n // the body ends inside the sequence\n if (ok && at <= need) break;\n if (ok) {\n multibyte += 1;\n index += need + 1;\n } else {\n invalid += 1;\n index += 1;\n }\n }\n return { multibyte, invalid };\n};\n\n/**\n * This function gives the WHATWG name of the encoding of a body, for example `utf-8` or\n * `windows-1252`. The function `decodeBody` uses it.\n */\nexport const bodyEncoding = (bytes: Uint8Array, contentType: string | null): string => {\n const bom = bomOf(bytes);\n if (bom !== undefined) return bom;\n const header = charsetOf(contentType);\n const fromHeader = header === undefined ? undefined : encodingOf(header);\n if (fromHeader !== undefined) return fromHeader;\n if (contentType === null || /html|xml/i.test(contentType)) {\n const label = declaredCharset(bytes);\n let declared = label === undefined ? undefined : encodingOf(label);\n // the HTML standard reads a UTF-16 declaration in ASCII-compatible bytes as UTF-8\n if (declared?.startsWith(\"utf-16\") === true) declared = \"utf-8\";\n if (declared === \"x-user-defined\") declared = \"windows-1252\";\n if (declared === \"utf-8\") return declared;\n if (declared !== undefined) {\n // A browser serialises the page it rendered as UTF-8, and the old declaration stays. UTF-8\n // with no error is almost never a legacy encoding by chance.\n const evidence = utf8Evidence(bytes);\n return evidence.invalid === 0 && evidence.multibyte > 0 ? \"utf-8\" : declared;\n }\n }\n if (/json/i.test(contentType ?? \"\")) return \"utf-8\";\n const evidence = utf8Evidence(bytes);\n return evidence.invalid > 0 && evidence.invalid >= evidence.multibyte ? \"windows-1252\" : \"utf-8\";\n};\n\n/**\n * These are the characters of the bytes 0x80 to 0x9F in windows-1252, from the WHATWG index.\n * Node.js 22 decodes windows-1252 as ISO-8859-1, which gives a control character for each of\n * these bytes. A later runtime gives the correct characters, and then the map changes nothing.\n */\nconst WINDOWS_1252_HIGH = [\n 0x20ac, 0x81, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152,\n 0x8d, 0x17d, 0x8f, 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, 0x2122,\n 0x161, 0x203a, 0x153, 0x9d, 0x17e, 0x178,\n];\nconst C1_CONTROLS = new RegExp(`[${String.fromCharCode(0x80)}-${String.fromCharCode(0x9f)}]`, \"g\");\nconst repairWindows1252 = (text: string): string =>\n text.replace(C1_CONTROLS, (char) =>\n String.fromCharCode(WINDOWS_1252_HIGH[char.charCodeAt(0) - 0x80]!),\n );\n\n/**\n * This function decodes the body of a response. It reads the encoding from the byte order mark,\n * the `Content-Type` header and the document, with `bodyEncoding`. It does not throw.\n */\nexport const decodeBody = (bytes: Uint8Array, contentType: string | null): string => {\n const encoding = bodyEncoding(bytes, contentType);\n try {\n const text = new TextDecoder(encoding, { fatal: false }).decode(bytes);\n return encoding === \"windows-1252\" ? repairWindows1252(text) : text;\n } catch {\n // a runtime with a small ICU knows only a few encodings\n return new TextDecoder(\"utf-8\", { fatal: false }).decode(bytes);\n }\n};\n","import { Readability } from \"@mozilla/readability\";\nimport { parseHTML } from \"linkedom\";\nimport { canonicalUrl } from \"./urls.ts\";\n\nexport { bodyEncoding, decodeBody } from \"./text.ts\";\n\n/**\n * The page reader reads a web page with no browser first. It gives:\n *\n * 1. The JSON-LD, the structured data that 41% of pages have. For a venue, it gives the name, the\n * address, the phone number and sometimes the hours.\n * 2. The visible text of the page.\n * 3. A decision: does the page need JavaScript to show its content?\n *\n * On a short page, the text is all of the visible text. Readability is for articles, and it\n * removes footers, sidebars and tables, where a venue keeps its hours. Thus on a long page, the\n * main text of Readability comes first. A blank line follows it, and then each other line of the\n * page.\n *\n * The cost of the reader grows in proportion to the size of the page. It walks the document with\n * no recursion, so deep markup cannot overflow the stack. It does not use Readability on a page\n * that is too large or too deep for it.\n */\n\nexport interface PageLink {\n readonly href: string;\n readonly text: string;\n}\n\nexport interface PageExtract {\n readonly title: string;\n readonly description: string | null;\n readonly text: string;\n /**\n * When the reader cut `text` to its maximum, this text is the whole visible text in the order of\n * the page. A quote past the cut is still in it. Otherwise this value is undefined.\n */\n readonly fullText?: string | undefined;\n /** These are the JSON-LD objects of the page, with each `@graph` made flat. */\n readonly jsonld: readonly Record<string, unknown>[];\n readonly links: readonly PageLink[];\n readonly lang: string | null;\n readonly visibleChars: number;\n /** These are the names of the application states that the HTML holds (Next.js, Nuxt, Apollo). */\n readonly embedded: readonly string[];\n /** This value is true when the page shows almost nothing without its scripts. */\n readonly needsRender: boolean;\n readonly renderReason: string | null;\n /** This URL is the `<link rel=\"canonical\">` of the page when it is on the same site, or null. */\n readonly canonical: string | null;\n /**\n * These URLs are the RSS and Atom feeds that the page links with `<link rel=\"alternate\">`, 10 or\n * fewer. They can be on a different site. `extractPage` always gives them. The field is optional,\n * so a `PageExtract` of version 0.1.1 stays correct.\n */\n readonly feeds?: readonly string[] | undefined;\n /** This URL is the target of a `<meta http-equiv=\"refresh\">` that sends the reader on in 5 seconds or less. */\n readonly redirect: string | null;\n /**\n * This value names the bot check or the firewall that sent its page in place of the content, for\n * example \"Cloudflare\". A crawler must not open a browser to get past it.\n */\n readonly blocked: string | null;\n /** These notes tell what the reader left out, for example a JSON-LD block that it cannot read. */\n readonly notes: readonly string[];\n}\n\nconst SKIP = new Set([\n \"script\",\n \"style\",\n \"noscript\",\n // a template is inert; a declarative shadow root is read (see `isShadowRoot`)\n \"template\",\n \"svg\",\n \"math\",\n // never shown, and a page without a <head> leaves it among the content\n \"title\",\n \"meta\",\n \"link\",\n \"base\",\n \"iframe\",\n \"frame\",\n \"object\",\n \"embed\",\n \"canvas\",\n \"audio\",\n \"video\",\n \"datalist\",\n \"param\",\n \"source\",\n \"track\",\n]);\n/** These elements show as blocks: each starts a line. The list follows the default style sheet of HTML. */\nconst BLOCK = new Set([\n \"address\",\n \"article\",\n \"aside\",\n \"blockquote\",\n \"body\",\n \"br\",\n \"caption\",\n \"center\",\n \"dd\",\n \"details\",\n \"dialog\",\n \"dir\",\n \"div\",\n \"dl\",\n \"dt\",\n \"fieldset\",\n \"figcaption\",\n \"figure\",\n \"footer\",\n \"form\",\n \"frameset\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n // linkedom leaves the content of a page that never closes its <head> inside it\n \"head\",\n \"header\",\n \"hgroup\",\n \"hr\",\n \"html\",\n \"legend\",\n \"li\",\n \"listing\",\n \"main\",\n \"marquee\",\n \"menu\",\n \"nav\",\n \"noframes\",\n \"ol\",\n // a dropdown's choices, one to a line\n \"optgroup\",\n \"option\",\n \"p\",\n \"plaintext\",\n \"pre\",\n \"search\",\n \"section\",\n \"summary\",\n \"table\",\n \"tbody\",\n \"tfoot\",\n \"thead\",\n \"tr\",\n \"ul\",\n \"xmp\",\n]);\n/**\n * These elements run inline with the text around them. Any other element, a custom element too,\n * ends a word, so its text stays apart from the next word.\n */\nconst INLINE = new Set([\n \"a\",\n \"abbr\",\n \"acronym\",\n \"b\",\n \"bdi\",\n \"bdo\",\n \"big\",\n \"blink\",\n \"cite\",\n \"code\",\n \"data\",\n \"del\",\n \"dfn\",\n \"em\",\n \"font\",\n \"i\",\n \"img\",\n \"ins\",\n \"kbd\",\n \"label\",\n \"mark\",\n \"nobr\",\n \"picture\",\n \"q\",\n \"rb\",\n \"rp\",\n \"rt\",\n \"rtc\",\n \"ruby\",\n \"s\",\n \"samp\",\n \"slot\",\n \"small\",\n \"span\",\n \"strike\",\n \"strong\",\n \"sub\",\n \"sup\",\n \"time\",\n \"tt\",\n \"u\",\n \"var\",\n \"wbr\",\n]);\n/** A table row becomes one line (\"Sunday 10 am–5 pm\"), with a space between its cells. */\nconst CELL = new Set([\"td\", \"th\"]);\nconst WORD_END = new Set([\"a\", \"button\"]);\n\n/** A page shorter than this keeps all its text. On a longer page, the text of Readability comes first. */\nconst SHORT_PAGE_CHARS = 6000;\nconst MAX_TEXT_CHARS = 50_000;\n/** On a long page, this part of the text is kept for the lines after the article: a footer keeps its hours. */\nconst REST_RESERVE_CHARS = 12_000;\nconst MAX_LINKS = 300;\n/** The reader keeps this number of feed links of a page at most. */\nconst MAX_FEEDS = 10;\n/** These media types name an RSS or an Atom feed in a `<link rel=\"alternate\">`. */\nconst FEED_TYPES: ReadonlySet<string> = new Set([\"application/rss+xml\", \"application/atom+xml\"]);\n/** Readability takes seconds on a page with more elements or links than this, and more time again on deep markup. */\nconst READABILITY_MAX_ELEMENTS = 10_000;\nconst READABILITY_MAX_LINKS = 1500;\nconst READABILITY_MAX_DEPTH = 150;\n/**\n * The parser of linkedom takes time in proportion to the square of the depth of the markup: 200,000\n * levels take 30 seconds. The reader reads the tags below this depth as text.\n */\nconst MAX_DEPTH = 1000;\n\n/** This is the small part of the DOM that this file uses. Node has no DOM types, and linkedom supplies the DOM. */\nexport interface DomNode {\n readonly nodeType: number;\n readonly nodeName: string;\n readonly textContent: string | null;\n readonly childNodes: ArrayLike<DomNode>;\n readonly firstChild?: DomNode | null | undefined;\n readonly nextSibling?: DomNode | null | undefined;\n readonly parentNode?: DomNode | null | undefined;\n /** This method takes the node out of its parent. */\n readonly remove?: (() => void) | undefined;\n}\n\ninterface DomElement extends DomNode {\n getAttribute(name: string): string | null;\n querySelector(selector: string): DomElement | null;\n /** This is the content of a `<template>`. */\n readonly content?: DomNode | null | undefined;\n}\n\n/**\n * This type has no `body` or `head`, on purpose. When an element comes before `<head>`, linkedom\n * makes a new, empty pair. Then `document.body` reads nothing, but a browser shows the full page.\n */\ninterface DomDocument extends DomNode {\n querySelector(selector: string): DomElement | null;\n querySelectorAll(selector: string): ArrayLike<DomElement> & Iterable<DomElement>;\n readonly documentElement: DomElement | null;\n}\n\nconst parse = (html: string): DomDocument =>\n (parseHTML(html) as unknown as { document: DomDocument }).document;\n\n/** These elements have no end tag. */\nconst VOID = new Set([\n \"area\",\n \"base\",\n \"basefont\",\n \"bgsound\",\n \"br\",\n \"col\",\n \"embed\",\n \"frame\",\n \"hr\",\n \"img\",\n \"input\",\n \"keygen\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n/** The content of these elements is text up to their end tag, not markup. */\nconst RAW_TEXT = new Set([\n \"iframe\",\n \"noembed\",\n \"noframes\",\n \"noscript\",\n \"plaintext\",\n \"script\",\n \"style\",\n \"textarea\",\n \"title\",\n \"xmp\",\n]);\n/** A new element of one of these kinds closes the open one (\"<li>one<li>two\"). */\nconst IMPLIED_END = new Set([\n \"dd\",\n \"dt\",\n \"li\",\n \"optgroup\",\n \"option\",\n \"p\",\n \"rb\",\n \"rp\",\n \"rt\",\n \"rtc\",\n \"tbody\",\n \"td\",\n \"tfoot\",\n \"th\",\n \"thead\",\n \"tr\",\n]);\n\nconst isLetter = (code: number): boolean =>\n (code >= 0x61 && code <= 0x7a) || (code >= 0x41 && code <= 0x5a);\nconst isNameChar = (code: number): boolean =>\n isLetter(code) ||\n (code >= 0x30 && code <= 0x39) ||\n code === 0x2d ||\n code === 0x3a ||\n code === 0x5f ||\n code === 0x2e;\n\n/** This function gives the index after the `>` of a tag. A `>` inside a quoted attribute value does not end it. */\nconst endOfTag = (html: string, from: number): number => {\n let quote = 0;\n let afterEquals = false;\n for (let at = from; at < html.length; at += 1) {\n const code = html.charCodeAt(at);\n if (quote !== 0) {\n if (code === quote) quote = 0;\n } else if ((code === 0x22 || code === 0x27) && afterEquals) {\n quote = code;\n } else if (code === 0x3e) {\n return at + 1;\n }\n if (code === 0x3d) afterEquals = true;\n else if (code !== 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) afterEquals = false;\n }\n return html.length;\n};\n\n/**\n * This function reads the tags below `MAX_DEPTH` levels as text: a block tag becomes a line break\n * and another tag becomes nothing. It counts the open elements roughly, in one pass. When it\n * removes nothing, it gives the same string.\n */\nconst flattenDeepMarkup = (html: string): { readonly html: string; readonly dropped: number } => {\n const stack: string[] = [];\n const open = new Map<string, number>();\n const extra = new Map<string, number>();\n const out: string[] = [];\n let copied = 0;\n let dropped = 0;\n const popTo = (name: string): void => {\n if ((open.get(name) ?? 0) === 0) return;\n for (;;) {\n const top = stack.pop()!;\n open.set(top, (open.get(top) ?? 1) - 1);\n if (top === name) return;\n }\n };\n const replace = (start: number, end: number, name: string): void => {\n out.push(html.slice(copied, start), BLOCK.has(name) ? \"\\n\" : INLINE.has(name) ? \"\" : \" \");\n copied = end;\n };\n let index = 0;\n while (index < html.length) {\n const lt = html.indexOf(\"<\", index);\n if (lt === -1) break;\n if (html.startsWith(\"<!--\", lt)) {\n const end = html.indexOf(\"-->\", lt + 4);\n index = end === -1 ? html.length : end + 3;\n continue;\n }\n const next = html.charCodeAt(lt + 1);\n if (next === 0x21 || next === 0x3f) {\n const end = html.indexOf(\">\", lt);\n index = end === -1 ? html.length : end + 1;\n continue;\n }\n const closing = next === 0x2f;\n const nameStart = lt + (closing ? 2 : 1);\n if (!isLetter(html.charCodeAt(nameStart))) {\n index = lt + 1;\n continue;\n }\n let nameEnd = nameStart + 1;\n while (nameEnd < html.length && isNameChar(html.charCodeAt(nameEnd))) nameEnd += 1;\n const name = html.slice(nameStart, nameEnd).toLowerCase();\n const tagEnd = endOfTag(html, nameEnd);\n index = tagEnd;\n if (closing) {\n // the deepest elements close first, and those are the ones that were removed\n const removed = extra.get(name) ?? 0;\n if (removed > 0) {\n extra.set(name, removed - 1);\n replace(lt, tagEnd, name);\n } else {\n popTo(name);\n }\n continue;\n }\n if (RAW_TEXT.has(name)) {\n const end = new RegExp(`</${name}[\\\\s/>]`, \"gi\");\n end.lastIndex = tagEnd;\n index = end.exec(html)?.index ?? html.length;\n continue;\n }\n if (VOID.has(name) || html.charCodeAt(tagEnd - 2) === 0x2f) continue;\n if (IMPLIED_END.has(name)) popTo(name);\n if (stack.length >= MAX_DEPTH) {\n extra.set(name, (extra.get(name) ?? 0) + 1);\n dropped += 1;\n replace(lt, tagEnd, name);\n continue;\n }\n stack.push(name);\n open.set(name, (open.get(name) ?? 0) + 1);\n }\n if (dropped === 0) return { html, dropped };\n out.push(html.slice(copied));\n return { html: out.join(\"\"), dropped };\n};\n\nconst attribute = (node: DomNode, name: string): string | null =>\n typeof (node as Partial<DomElement>).getAttribute === \"function\"\n ? (node as DomElement).getAttribute(name)\n : null;\n\n/** A `<template shadowrootmode>` holds a declarative shadow root: the browser shows its content. */\nconst isShadowRoot = (node: DomNode): boolean =>\n attribute(node, \"shadowrootmode\") !== null || attribute(node, \"shadowroot\") !== null;\n\n/** The reader reads only these properties of an inline style. */\nconst STYLE_PROPERTIES = new Set([\"display\", \"font-size\"]);\n\n/**\n * This function reads `display` and `font-size` from the `style` attribute of an element. The last\n * declaration wins, and an `!important` declaration wins over a declaration that is not important.\n * It reads no style sheet. Its time grows in proportion to the length of the attribute.\n */\nconst inlineStyle = (node: DomNode): ReadonlyMap<string, string> => {\n const found = new Map<string, string>();\n const style = attribute(node, \"style\");\n if (style === null || style.length === 0) return found;\n const important = new Set<string>();\n for (const declaration of style.split(\";\")) {\n const colon = declaration.indexOf(\":\");\n if (colon === -1) continue;\n const property = declaration.slice(0, colon).trim().toLowerCase();\n if (!STYLE_PROPERTIES.has(property)) continue;\n let value = declaration\n .slice(colon + 1)\n .trim()\n .toLowerCase();\n const bang = value.lastIndexOf(\"!\");\n const strong = bang !== -1 && value.slice(bang + 1).trim() === \"important\";\n if (strong) value = value.slice(0, bang).trim();\n if (important.has(property) && !strong) continue;\n if (strong) important.add(property);\n found.set(property, value);\n }\n return found;\n};\n\n/**\n * This function tells if a reader of the page does not get an element and its content. A browser\n * does not show an element with `display: none` or with the attribute `hidden` (unless its inline\n * style sets a different display). A screen reader skips an element with `aria-hidden=\"true\"`, and\n * a model reads a page as a screen reader does.\n */\nconst notRendered = (node: DomNode, style: ReadonlyMap<string, string>): boolean => {\n const display = style.get(\"display\");\n if (display === \"none\") return true;\n if (display === undefined && attribute(node, \"hidden\") !== null) return true;\n return attribute(node, \"aria-hidden\")?.trim().toLowerCase() === \"true\";\n};\n\n/** A font size of zero: `0`, `0px`, `0em` or `0%`. */\nconst ZERO_SIZE = /^\\+?(?:0+(?:\\.0*)?|\\.0+)(?:[a-z]{1,4}|%)?$/;\n/** These sizes are a part of the size of the parent, so a part of zero stays zero. */\nconst RELATIVE_SIZE =\n /^(?:\\+?[\\d.]+(?:em|ex|ch|cap|ic|lh|%)|larger|smaller|inherit|unset|revert|revert-layer)$/;\n\n/** This function tells if the text of an element has a zero size. A child that sets a size of its own shows its text again. */\nconst zeroSize = (fontSize: string | undefined, parentZero: boolean): boolean => {\n if (fontSize === undefined) return parentZero;\n if (ZERO_SIZE.test(fontSize)) return true;\n return parentZero && RELATIVE_SIZE.test(fontSize);\n};\n\ninterface Walked {\n readonly text: string;\n readonly elements: number;\n readonly links: number;\n readonly depth: number;\n /** These nodes are not text for a reader: the elements that `notRendered` refuses, and the text of a zero size. */\n readonly unseen: readonly DomNode[];\n}\n\ninterface Frame {\n readonly name: string;\n /** The children of an element are read with `nextSibling`, which costs nothing in linkedom. */\n next: DomNode | null | undefined;\n /** linkedom gives a document type no `nextSibling`, so the few children of a document are read as a list. */\n readonly list: ArrayLike<DomNode> | undefined;\n index: number;\n /** This value is true when the text of the element has a zero size. */\n readonly zero: boolean;\n}\n\n/**\n * This function walks a tree with a stack of its own. Thus the depth of the markup cannot overflow\n * the stack. It reads only the text that a reader gets (refer to `notRendered` and `zeroSize`), and it\n * gives the nodes that it did not read.\n */\nconst walkText = (root: DomNode): Walked => {\n const parts: string[] = [];\n const unseen: DomNode[] = [];\n // a link or a button ends a word even where the markup runs it into the\n // next (\"Offers from AmexGlobal Dining Access\"), though not before a stop\n let seam = false;\n let elements = 0;\n let links = 0;\n let depth = 0;\n const stack: Frame[] = [];\n const enter = (node: DomNode): void => {\n if (node.nodeType === 3) {\n if (stack[stack.length - 1]?.zero === true) {\n unseen.push(node);\n return;\n }\n const text = node.textContent ?? \"\";\n if (seam && /^[^\\s.,;:!?)\\]–—-]/.test(text)) parts.push(\" \");\n if (text.length > 0) seam = false;\n parts.push(text);\n return;\n }\n if (node.nodeType !== 1 && node.nodeType !== 9 && node.nodeType !== 11) return;\n const name = node.nodeName.toLowerCase();\n let container = node;\n if (name === \"template\") {\n if (!isShadowRoot(node)) return;\n container = (node as DomElement).content ?? node;\n } else if (SKIP.has(name)) {\n return;\n }\n let zero = stack[stack.length - 1]?.zero ?? false;\n if (node.nodeType === 1) {\n const style = inlineStyle(node);\n if (notRendered(node, style)) {\n unseen.push(node);\n return;\n }\n zero = zeroSize(style.get(\"font-size\"), zero);\n elements += 1;\n if (name === \"a\") links += 1;\n if (BLOCK.has(name)) parts.push(\"\\n\");\n else if (!INLINE.has(name) && !CELL.has(name)) seam = true;\n }\n stack.push(\n container.nodeType === 1\n ? { name, next: container.firstChild, list: undefined, index: 0, zero }\n : { name, next: undefined, list: container.childNodes, index: 0, zero },\n );\n if (stack.length > depth) depth = stack.length;\n };\n const leave = (name: string): void => {\n const block = BLOCK.has(name);\n if (block) parts.push(\"\\n\");\n else if (CELL.has(name)) parts.push(\" \");\n if (block) seam = false;\n else if (WORD_END.has(name) || !INLINE.has(name)) seam = true;\n };\n enter(root);\n while (stack.length > 0) {\n const frame = stack[stack.length - 1]!;\n let child: DomNode | null | undefined;\n if (frame.list !== undefined) {\n child = frame.index < frame.list.length ? frame.list[frame.index] : undefined;\n frame.index += 1;\n } else {\n child = frame.next;\n if (child !== null && child !== undefined) frame.next = child.nextSibling;\n }\n if (child === null || child === undefined) {\n stack.pop();\n leave(frame.name);\n } else {\n enter(child);\n }\n }\n const text = parts\n .join(\"\")\n .split(\"\\n\")\n .map((line) =>\n line\n .replace(/[​-‍⁠­]/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim(),\n )\n .filter((line) => line.length > 0)\n .join(\"\\n\");\n return { text, elements, links, depth, unseen };\n};\n\n/** This function gives the text that a reader sees, with one line for each block. */\nexport const visibleText = (root: DomNode): string => walkText(root).text;\n\n// ── JSON-LD ─────────────────────────────────────────────────────────────────\n\nconst WRAPPERS: ReadonlyArray<readonly [RegExp, RegExp]> = [\n [/^<!--/, /-->$/],\n [/^\\/\\/\\s{0,8}<!\\[CDATA\\[/, /\\/\\/\\s{0,8}\\]\\]>$/],\n [/^\\/\\*\\s{0,8}<!\\[CDATA\\[\\s{0,8}\\*\\//, /\\/\\*\\s{0,8}\\]\\]>\\s{0,8}\\*\\/$/],\n [/^<!\\[CDATA\\[/, /\\]\\]>$/],\n];\n\nconst unwrap = (source: string): string => {\n let text = source.replace(/^/, \"\").trim();\n for (const [open, close] of WRAPPERS) {\n text = text.replace(open, \"\").trim();\n text = text.replace(close, \"\").trim();\n }\n return text;\n};\n\n/**\n * This function cuts a script into its top-level JSON values. It also repairs two common faults: a\n * comma before a closing bracket, and a raw control character inside a string.\n */\nconst jsonValues = (source: string): string[] => {\n const values: string[] = [];\n let out: string[] = [];\n let depth = 0;\n let inString = false;\n let escaped = false;\n let pendingComma = false;\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]!;\n const code = source.charCodeAt(index);\n if (inString) {\n if (escaped) escaped = false;\n else if (char === \"\\\\\") escaped = true;\n else if (char === '\"') inString = false;\n // a string between two values is skipped with them\n if (depth === 0) continue;\n out.push(\n code >= 0x20\n ? char\n : char === \"\\n\"\n ? \"\\\\n\"\n : char === \"\\r\"\n ? \"\\\\r\"\n : char === \"\\t\"\n ? \"\\\\t\"\n : `\\\\u${code.toString(16).padStart(4, \"0\")}`,\n );\n continue;\n }\n if (depth === 0) {\n // between values only an object or an array starts a value\n if (char === \"{\" || char === \"[\") {\n depth = 1;\n out = [char];\n pendingComma = false;\n } else if (char === '\"') {\n inString = true;\n }\n continue;\n }\n if (code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d) {\n out.push(char);\n continue;\n }\n if (char === \",\") {\n if (pendingComma) out.push(\",\");\n pendingComma = true;\n continue;\n }\n if (pendingComma) {\n // a comma before a closing bracket is dropped\n if (char !== \"}\" && char !== \"]\") out.push(\",\");\n pendingComma = false;\n }\n out.push(char);\n if (char === '\"') inString = true;\n else if (char === \"{\" || char === \"[\") depth += 1;\n else if (char === \"}\" || char === \"]\") {\n depth -= 1;\n if (depth === 0) {\n values.push(out.join(\"\"));\n out = [];\n }\n }\n }\n // a value that never closes is given whole, and its parse fails\n if (depth > 0) values.push(out.join(\"\"));\n return values;\n};\n\nconst parseJsonLd = (\n sources: readonly string[],\n): { readonly records: Record<string, unknown>[]; readonly unreadable: number } => {\n const records: Record<string, unknown>[] = [];\n let unreadable = 0;\n // an explicit stack: JSON nested deeply in arrays cannot overflow the call stack\n const push = (first: unknown): void => {\n const stack: unknown[] = [first];\n const found: Record<string, unknown>[] = [];\n while (stack.length > 0) {\n const value = stack.pop();\n if (Array.isArray(value)) {\n for (let index = value.length - 1; index >= 0; index -= 1) stack.push(value[index]);\n continue;\n }\n if (value === null || typeof value !== \"object\") continue;\n const record = value as Record<string, unknown>;\n const graph = record[\"@graph\"];\n if (graph !== undefined && graph !== null && typeof graph === \"object\") {\n const { \"@graph\": _graph, ...rest } = record;\n // the record itself first, then its graph, in the order of the page\n stack.push(graph);\n if (Object.keys(rest).some((key) => key !== \"@context\")) found.push(rest);\n continue;\n }\n found.push(record);\n }\n records.push(...found);\n };\n for (const source of sources) {\n const text = unwrap(source);\n if (text.length === 0) continue;\n try {\n push(JSON.parse(text));\n continue;\n } catch {\n // repaired below\n }\n let failed = false;\n let any = false;\n for (const value of jsonValues(text)) {\n try {\n push(JSON.parse(value));\n any = true;\n } catch {\n failed = true;\n }\n }\n if (failed || !any) unreadable += 1;\n }\n return { records, unreadable };\n};\n\n/**\n * This function reads the JSON-LD blocks and makes arrays and `@graph` flat. It repairs a comma\n * before a closing bracket, a raw line break in a string and two values in one block. It ignores\n * a block that it cannot repair.\n */\nexport const readJsonLd = (sources: readonly string[]): Record<string, unknown>[] =>\n parseJsonLd(sources).records;\n\n/** This function gives the types that a JSON-LD object declares, without the schema.org prefix. */\nexport const typesOf = (record: Record<string, unknown>): string[] => {\n const raw = record[\"@type\"];\n const list = Array.isArray(raw) ? raw : raw === undefined ? [] : [raw];\n return list\n .filter((value): value is string => typeof value === \"string\")\n .map((value) => value.replace(/^.*[/#]/, \"\").replace(/^[A-Za-z][\\w.+-]*:/, \"\"));\n};\n\n// ── URLs ────────────────────────────────────────────────────────────────────\n\nexport { canonicalUrl };\n\nconst isWeb = (url: URL): boolean => url.protocol === \"http:\" || url.protocol === \"https:\";\nconst siteOf = (host: string): string => host.toLowerCase().replace(/^www\\./, \"\");\n\n// ── what the page needs ─────────────────────────────────────────────────────\n\n/** The marks of the pages that a bot check or a firewall sends in place of the content. */\nconst CHALLENGES: ReadonlyArray<readonly [string, RegExp]> = [\n [\"Incapsula\", /_Incapsula_Resource|Incapsula incident ID/i],\n [\"Cloudflare\", /\\/cdn-cgi\\/challenge-platform\\/|cf-chl-|cf_chl_opt|cf-browser-verification/i],\n [\"Sucuri\", /sucuri_cloudproxy|Sucuri WebSite Firewall/i],\n [\"DataDome\", /captcha-delivery\\.com/i],\n [\"PerimeterX\", /_pxCaptcha|px-captcha|captcha\\.px-cdn\\.net/i],\n [\"AWS WAF\", /AwsWafIntegration|token\\.awswaf\\.com|\\/challenge\\.js.{0,80}awswaf/i],\n [\"DDoS-Guard\", /ddos-guard\\.net\\/|__ddg1_/i],\n];\nconst CHALLENGE_TITLE =\n /^(?:just a moment\\.*|attention required!? \\| cloudflare|access to this page has been denied\\.?|please verify you are a human|are you a robot\\??|ddos-guard|checking your browser.{0,40})$/i;\n\nconst ASKS_FOR_SCRIPT =\n /(?:enable|turn on|activate|switch on|allow)\\s+(?:your\\s+)?javascript|javascript\\s+(?:is\\s+)?(?:required|disabled|turned off|not enabled|must be enabled|needs to be enabled)|(?:requires?|needs?)\\s+javascript|javascript\\s+aktivieren|activ(?:er|ez)\\s+(?:le\\s+)?javascript|habilit(?:ar|e)\\s+(?:el\\s+)?javascript/i;\n/** The noscript of a comment widget (Disqus) asks for JavaScript for the comments, not for the page. */\nconst COMMENTS = /comments|disqus/i;\n\n/** These elements hold the whole page of an application that its scripts draw. */\nconst APP_ROOTS = \"#root, #app, #__next, #__nuxt, #___gatsby, app-root, my-app, [data-reactroot]\";\n\nconst EMBEDDED: ReadonlyArray<readonly [string, (html: string, doc: DomDocument) => boolean]> = [\n [\"next\", (_html, doc) => doc.querySelector('script[id=\"__NEXT_DATA__\"]') !== null],\n [\"next-app\", (html) => html.includes(\"self.__next_f.push\")],\n [\"nuxt\", (html) => html.includes(\"__NUXT_DATA__\") || html.includes(\"window.__NUXT__\")],\n [\"apollo\", (html) => html.includes(\"__APOLLO_STATE__\")],\n];\n\n/** This function reads `content=\"0; url=/home\"`. A refresh with no URL reloads the page, and is no redirect. */\nconst refreshTarget = (\n content: string,\n): { readonly delay: number; readonly url: string } | undefined => {\n const text = content.slice(0, 2000).trim();\n const delay = /^\\d+(?:\\.\\d*)?/.exec(text)?.[0] ?? \"\";\n const url = text\n .slice(delay.length)\n .replace(/^[\\s;,]+/, \"\")\n .replace(/^url\\s*=\\s*/i, \"\")\n .replace(/^([\"'])(.*)\\1$/s, \"$2\")\n .trim();\n return url.length === 0 ? undefined : { delay: Number(delay || 0), url };\n};\n\n// ── composing the text ──────────────────────────────────────────────────────\n\n/** This function cuts text to a length at the end of a line where it can. It does not cut a surrogate pair. */\nconst cutHead = (text: string, length: number): string => {\n if (text.length <= length) return text;\n if (length <= 0) return \"\";\n const line = text.lastIndexOf(\"\\n\", length);\n let end = line > length - 2000 && line > 0 ? line : length;\n const code = text.charCodeAt(end - 1);\n if (code >= 0xd800 && code <= 0xdbff) end -= 1;\n return text.slice(0, end);\n};\n\n/** This function keeps the end of the text, from the start of a line where it can. */\nconst cutTail = (text: string, length: number): string => {\n if (text.length <= length) return text;\n if (length <= 0) return \"\";\n let start = text.length - length;\n const line = text.indexOf(\"\\n\", start);\n if (line !== -1 && line < start + 2000) start = line + 1;\n const code = text.charCodeAt(start);\n if (code >= 0xdc00 && code <= 0xdfff) start += 1;\n return text.slice(start);\n};\n\n/** This function keeps the start and the end of a text that is too long: a footer keeps its hours. */\nconst capText = (text: string): string =>\n text.length <= MAX_TEXT_CHARS\n ? text\n : `${cutHead(text, MAX_TEXT_CHARS - REST_RESERVE_CHARS - 2)}\\n\\n${cutTail(text, REST_RESERVE_CHARS)}`;\n\n/** A line that can label the lines below it: short, with no number, and not a sentence (\"Opening hours\"). */\nconst isHeading = (line: string): boolean =>\n line.length <= 40 && !/[.!?]$/.test(line) && !/[0-9]/.test(line);\n\n/**\n * This function finds the lines of the article in the lines of the page, one for one and in order.\n * Thus a line that the article and a sidebar share stays in the sidebar (\"10 am – 5 pm\").\n */\nconst articleLines = (all: readonly string[], main: readonly string[]): Uint8Array => {\n const taken = new Uint8Array(all.length);\n const positions = new Map<string, number[]>();\n all.forEach((line, index) => {\n const list = positions.get(line);\n if (list === undefined) positions.set(line, [index]);\n else list.push(index);\n });\n const cursors = new Map<string, number>();\n let at = 0;\n let matched = 0;\n for (const line of main) {\n const list = positions.get(line);\n if (list === undefined) continue;\n let cursor = cursors.get(line) ?? 0;\n while (cursor < list.length && list[cursor]! < at) cursor += 1;\n cursors.set(line, cursor);\n const position = list[cursor];\n if (position === undefined) continue;\n // a line far ahead is the same line only when the page has it once\n if (matched > 0 && position - at > 400 && list.length > 1) continue;\n taken[position] = 1;\n cursors.set(line, cursor + 1);\n at = position + 1;\n matched += 1;\n }\n return taken;\n};\n\n/** This function gives the lines of the page that are not in the article. Each run keeps the heading above it. */\nconst restOf = (all: readonly string[], taken: Uint8Array): string[] => {\n const rest: string[] = [];\n for (let index = 0; index < all.length; index += 1) {\n if (taken[index] === 1) continue;\n const above = all[index - 1];\n if (index > 0 && taken[index - 1] === 1 && above !== undefined && isHeading(above))\n rest.push(above);\n rest.push(all[index]!);\n }\n return rest;\n};\n\nexport const extractPage = (html: string, pageUrl: string): PageExtract => {\n const notes: string[] = [];\n const flat = flattenDeepMarkup(html);\n if (flat.dropped > 0) {\n notes.push(\n `the markup nests deeper than ${String(MAX_DEPTH)} elements, so the reader read the deeper tags as text`,\n );\n }\n const doc = parse(flat.html);\n const meta = (selector: string): string | null =>\n doc.querySelector(selector)?.getAttribute(\"content\")?.trim() || null;\n\n const scripts = [...doc.querySelectorAll(\"script\")];\n const parsed = parseJsonLd(\n scripts\n .filter((node) =>\n /^\\s*application\\/ld\\+json\\s*(?:;|$)/i.test(node.getAttribute(\"type\") ?? \"\"),\n )\n .map((node) => node.textContent ?? \"\"),\n );\n const jsonld = parsed.records;\n if (parsed.unreadable > 0) {\n notes.push(\n `${String(parsed.unreadable)} JSON-LD ${parsed.unreadable === 1 ? \"block\" : \"blocks\"} could not be read`,\n );\n }\n\n const page = (() => {\n try {\n return new URL(pageUrl);\n } catch {\n return undefined;\n }\n })();\n const baseHref = doc.querySelector(\"base[href]\")?.getAttribute(\"href\");\n const base = (() => {\n try {\n const resolved = new URL(baseHref ?? pageUrl, pageUrl);\n // a <base href=\"javascript:...\"> would take every relative link with it\n return isWeb(resolved) ? resolved.href : pageUrl;\n } catch {\n return pageUrl;\n }\n })();\n const resolve = (raw: string): URL | undefined => {\n try {\n const url = new URL(raw.trim(), base);\n if (!isWeb(url)) return undefined;\n url.username = \"\";\n url.password = \"\";\n return url;\n } catch {\n return undefined;\n }\n };\n const self = page === undefined ? undefined : canonicalUrl(page.href);\n\n const refresh = [...doc.querySelectorAll(\"meta[http-equiv]\")]\n .filter((node) => /^\\s*refresh\\s*$/i.test(node.getAttribute(\"http-equiv\") ?? \"\"))\n .map((node) => refreshTarget(node.getAttribute(\"content\") ?? \"\"))\n .find((target) => target !== undefined);\n const refreshUrl = refresh === undefined ? undefined : resolve(refresh.url);\n const redirect =\n refresh !== undefined &&\n refresh.delay <= 5 &&\n refreshUrl !== undefined &&\n canonicalUrl(refreshUrl.href) !== self\n ? canonicalUrl(refreshUrl.href)\n : null;\n\n const canonical = (() => {\n const node = [...doc.querySelectorAll(\"link[rel][href]\")].find((link) =>\n (link.getAttribute(\"rel\") ?? \"\").toLowerCase().split(/\\s+/).includes(\"canonical\"),\n );\n const url = node === undefined ? undefined : resolve(node.getAttribute(\"href\") ?? \"\");\n // a canonical on another site could take the page's identity: it is not trusted\n if (url === undefined || page === undefined || siteOf(url.hostname) !== siteOf(page.hostname)) {\n return null;\n }\n return canonicalUrl(url.href);\n })();\n\n const feeds: string[] = [];\n for (const link of doc.querySelectorAll(\"link[rel][href]\")) {\n if (feeds.length >= MAX_FEEDS) break;\n if (!(link.getAttribute(\"rel\") ?? \"\").toLowerCase().split(/\\s+/).includes(\"alternate\"))\n continue;\n const type = (link.getAttribute(\"type\") ?? \"\").split(\";\")[0]!.trim().toLowerCase();\n if (!FEED_TYPES.has(type)) continue;\n const url = resolve(link.getAttribute(\"href\") ?? \"\");\n const href = url === undefined ? undefined : canonicalUrl(url.href);\n if (href !== undefined && !feeds.includes(href)) feeds.push(href);\n }\n\n const clean = (value: string | null | undefined): string =>\n (value ?? \"\").replace(/\\s+/g, \" \").trim();\n const titles = [...doc.querySelectorAll(\"title\")];\n // an <svg> keeps a <title> of its own (\"Icon\"), which names no page\n const inSvg = (node: DomNode): boolean => {\n for (let parent = node.parentNode; parent; parent = parent.parentNode) {\n if (parent.nodeName.toLowerCase() === \"svg\") return true;\n }\n return false;\n };\n const title =\n meta('meta[property=\"og:title\"]') ||\n clean(titles.find((node) => !inSvg(node))?.textContent) ||\n clean(doc.querySelector(\"h1\")?.textContent) ||\n pageUrl;\n const description = meta('meta[name=\"description\"]') ?? meta('meta[property=\"og:description\"]');\n const lang = doc.documentElement?.getAttribute(\"lang\")?.trim() || null;\n const noscript = [...doc.querySelectorAll(\"noscript\")]\n .map((node) => node.textContent ?? \"\")\n .filter((text) => !COMMENTS.test(text))\n .join(\" \");\n const embedded = EMBEDDED.filter(([, found]) => found(html, doc)).map(([name]) => name);\n const appShell = [...doc.querySelectorAll(APP_ROOTS)].some(\n (node) => (node.textContent ?? \"\").trim().length === 0,\n );\n\n // the whole document: a page that omits <html> is not under\n // documentElement at all, and document.body can be a decoy (see DomDocument;\n // a homepage read as 0 characters and went to the browser for nothing)\n const walked = walkText(doc);\n // the links and Readability read only what a reader gets: text that the page hides goes now\n for (const node of walked.unseen) node.remove?.();\n\n const seen = new Set<string>(self === undefined ? [] : [self]);\n const links: PageLink[] = [];\n if (redirect !== null) {\n seen.add(redirect);\n links.push({ href: redirect, text: \"\" });\n }\n for (const anchor of doc.querySelectorAll(\"a[href]\")) {\n if (links.length >= MAX_LINKS) break;\n const url = resolve(anchor.getAttribute(\"href\") ?? \"\");\n if (url === undefined) continue;\n const href = canonicalUrl(url.href);\n const text =\n (anchor.textContent ?? \"\").replace(/\\s+/g, \" \").trim() ||\n anchor.getAttribute(\"aria-label\")?.trim() ||\n anchor.getAttribute(\"title\")?.trim() ||\n anchor.querySelector(\"img[alt]\")?.getAttribute(\"alt\")?.trim() ||\n \"\";\n // the link to the target of a meta refresh gets the text of the first anchor that names it\n if (href === redirect && links[0]?.href === redirect && links[0].text === \"\") {\n links[0] = { href, text: text.slice(0, 120) };\n continue;\n }\n // a link to the page itself (\"#menu\") is no link\n if (seen.has(href)) continue;\n seen.add(href);\n links.push({ href, text: text.slice(0, 120) });\n }\n\n const all = walked.text;\n let text = capText(all);\n let cut = text.length < all.length;\n if (all.length > SHORT_PAGE_CHARS) {\n const main = (() => {\n if (\n walked.elements > READABILITY_MAX_ELEMENTS ||\n walked.links > READABILITY_MAX_LINKS ||\n walked.depth > READABILITY_MAX_DEPTH\n ) {\n notes.push(\"the page is too large for Readability, so its text is in page order\");\n return \"\";\n }\n try {\n // Readability rewrites the document, and the reader has no more use for it. It gives its\n // article as an element, read here so that blocks stay lines\n const article = new Readability<DomNode>(\n doc as unknown as ConstructorParameters<typeof Readability>[0],\n {\n charThreshold: 500,\n disableJSONLD: true,\n serializer: (node) => node as unknown as DomNode,\n },\n ).parse();\n return article?.content === null || article?.content === undefined\n ? \"\"\n : visibleText(article.content);\n } catch {\n notes.push(\"Readability could not read the page, so its text is in page order\");\n return \"\";\n }\n })();\n if (main.length > 500) {\n // the article first, then every other line the page shows: a venue's\n // hours sit in a table or a sidebar Readability drops (a museum's visit\n // page), not only in its footer\n const lines = all.split(\"\\n\");\n const rest = restOf(lines, articleLines(lines, main.split(\"\\n\"))).join(\"\\n\");\n const head = cutHead(main, MAX_TEXT_CHARS - Math.min(rest.length, REST_RESERVE_CHARS) - 2);\n const tail = cutHead(rest, MAX_TEXT_CHARS - head.length - 2);\n text = rest.length > 0 ? `${head}\\n\\n${tail}` : head;\n cut = head.length < main.length || tail.length < rest.length;\n }\n }\n if (cut) notes.push(`the text is cut to ${String(MAX_TEXT_CHARS)} characters`);\n\n const visibleChars = all.length;\n const pageTitle = clean(titles[0]?.textContent);\n const blocked =\n visibleChars < 2000\n ? CHALLENGE_TITLE.test(pageTitle)\n ? (CHALLENGES.find(([, pattern]) => pattern.test(html))?.[0] ?? \"a bot check\")\n : (CHALLENGES.find(([, pattern]) => pattern.test(html))?.[0] ?? null)\n : null;\n const reason =\n // a browser would only go past a bot check or follow the redirect\n blocked !== null || redirect !== null\n ? null\n : // an app shell shows next to nothing; a small venue page can still say\n // its hours and address in a hundred characters, and needs no browser\n visibleChars < 80\n ? `only ${String(visibleChars)} characters of visible text`\n : visibleChars < 1200 && ASKS_FOR_SCRIPT.test(noscript)\n ? \"the page asks for JavaScript\"\n : visibleChars < 1200 && appShell\n ? \"an empty application root\"\n : null;\n\n return {\n title: title.replace(/\\s+/g, \" \").slice(0, 300),\n description,\n text,\n ...(cut ? { fullText: all } : {}),\n jsonld,\n links,\n lang,\n visibleChars,\n embedded,\n needsRender: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M,CAAC,CAAC,CAAC,OAAO,KAAK;CAChE;AACF;;;ACrHA,MAAM,uBAAO,IAAI,IAAI;CACnB;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAED,MAAM,wBAAQ,IAAI,IAAI;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAKD,MAAM,yBAAS,IAAI,IAAI;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAED,MAAM,uBAAO,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;AACjC,MAAM,2BAAW,IAAI,IAAI,CAAC,KAAK,QAAQ,CAAC;;AAGxC,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;AAEvB,MAAM,qBAAqB;AAC3B,MAAM,YAAY;;AAElB,MAAM,YAAY;;AAElB,MAAM,6BAAkC,IAAI,IAAI,CAAC,uBAAuB,sBAAsB,CAAC;;AAE/F,MAAM,2BAA2B;AACjC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;;;;;AAK9B,MAAM,YAAY;AAgClB,MAAM,SAAS,SACZ,UAAU,IAAI,CAAC,CAA0C;;AAG5D,MAAM,uBAAO,IAAI,IAAI;CACnB;CACA;CACA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EACd;EACA;EACA;EACA;EACA;CACF;AACF"}
package/build/html.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { n as canonicalUrl } from "./urls-BHFeSyEK.mjs";
2
- import { a as bodyEncoding, i as visibleText, n as readJsonLd, o as decodeBody, r as typesOf, t as extractPage } from "./html-DkQUAE_d.mjs";
2
+ import { a as bodyEncoding, i as visibleText, n as readJsonLd, o as decodeBody, r as typesOf, t as extractPage } from "./html-DzobO0fy.mjs";
3
3
  export { bodyEncoding, canonicalUrl, decodeBody, extractPage, readJsonLd, typesOf, visibleText };
package/build/index.d.mts CHANGED
@@ -3302,6 +3302,26 @@ interface WatchOptions {
3302
3302
  readonly onBehalfOf?: readonly string[] | undefined;
3303
3303
  /** This value is the number of checks that must see a change before it is confirmed. The default is 2. */
3304
3304
  readonly confirm?: 1 | 2 | undefined;
3305
+ /**
3306
+ * The value `true` keeps the time of the next check of a page that the list has. The default
3307
+ * `false` sets that time one `every` after the last check. A new entry is due at once in the two cases.
3308
+ *
3309
+ * @beta
3310
+ */
3311
+ readonly keepSchedule?: boolean | undefined;
3312
+ }
3313
+ /**
3314
+ * These options change the time of the next check of an entry (`reschedule`).
3315
+ *
3316
+ * @beta
3317
+ */
3318
+ interface WatchRescheduleOptions {
3319
+ /**
3320
+ * This time is the next check of the entry: an ISO 8601 text or a `Date`. A run checks the due
3321
+ * entries in the sequence of these times, so an earlier time also gives an earlier check. The
3322
+ * time is not before one floor (`watchFloor`) after the last check, so a watch cannot hammer a site.
3323
+ */
3324
+ readonly at: string | Date;
3305
3325
  }
3306
3326
  /** A change that one check saw, and that the next check can confirm. */
3307
3327
  interface WatchPending {
@@ -3370,6 +3390,8 @@ interface WatchRunOptions {
3370
3390
  interface WatchRunnerOptions extends WatchRunOptions {
3371
3391
  /** These agents get their robots.txt rules applied to each check, before the agents of the entry. */
3372
3392
  readonly onBehalfOf?: readonly string[] | undefined;
3393
+ /** This name connects the captures of each check to the job that asked for them, as `PageOptions.job` does. */
3394
+ readonly job?: string | undefined;
3373
3395
  /** This function operates before the first check. `openCrawler` waits there for the open of the store. */
3374
3396
  readonly ready?: (() => Promise<void>) | undefined;
3375
3397
  }
@@ -3439,6 +3461,13 @@ interface WatchList {
3439
3461
  list(): Promise<WatchEntry[]>;
3440
3462
  /** This method checks the entries that are due, to a budget. A `for await` loop gets each event. */
3441
3463
  run(options?: WatchRunOptions): WatchRun;
3464
+ /**
3465
+ * This optional method changes the time of the next check of a page (`WatchStore.reschedule`). It
3466
+ * gives the changed entry, or undefined when the list does not have the page. `openCrawler` gives it.
3467
+ *
3468
+ * @beta
3469
+ */
3470
+ reschedule?(url: string, options: WatchRescheduleOptions): Promise<WatchEntry | undefined>;
3442
3471
  }
3443
3472
  /**
3444
3473
  * These options open a watch store.
@@ -3540,10 +3569,17 @@ export declare class WatchStore {
3540
3569
  private row;
3541
3570
  /**
3542
3571
  * This method adds a page, or changes the options of its watch and keeps its state. A new entry
3543
- * is due at once. A changed entry is due one `every` after its last check. A bad option throws
3544
- * a `RangeError`.
3572
+ * is due at once. A changed entry is due one `every` after its last check. With `keepSchedule`,
3573
+ * it keeps the time of its next check. A bad option throws a `RangeError`.
3545
3574
  */
3546
3575
  add(url: string, options: WatchOptions, now: number): WatchEntry;
3576
+ /**
3577
+ * This method changes the time of the next check of a page, and nothing else. It gives the
3578
+ * changed entry, or undefined when the list does not have the page. A bad time, or a time before
3579
+ * one floor after the last check, throws a `RangeError`. A check in progress sets the time again
3580
+ * when it ends.
3581
+ */
3582
+ reschedule(url: string, options: WatchRescheduleOptions, now: number): WatchEntry | undefined;
3547
3583
  /** This method removes a page. It gives false when the list does not have the page. */
3548
3584
  remove(url: string): boolean;
3549
3585
  /** This method gives the entry of a page, or undefined. */
@@ -3579,7 +3615,7 @@ export declare const runWatch: (runtime: CrawlRuntime, source: WatchStore | (()
3579
3615
  //#endregion
3580
3616
  //#region src/version.d.ts
3581
3617
  /** This is the version of the package. A test makes sure that it agrees with `package.json`. */
3582
- export declare const VERSION = "0.2.2";
3618
+ export declare const VERSION = "0.2.4";
3583
3619
  /** This is the product token that robots.txt rules match when an application gives no token. */
3584
3620
  export declare const DEFAULT_TOKEN = "PoliteCrawler";
3585
3621
  /** This page tells a site owner what the crawler is and how to control it. */
@@ -3858,6 +3894,8 @@ interface OpenedCrawler extends PoliteCrawler {
3858
3894
  interface HybridCrawler extends OpenedCrawler {
3859
3895
  /** This method searches the stored documents. It also takes `rank: "hybrid"`, when the crawler has an embedder. */
3860
3896
  find(q: string, options?: SearchOptions): Promise<Found[]>;
3897
+ /** This list is the watch list of `OpenedCrawler`, with each optional method, for example `reschedule`. */
3898
+ readonly watch: Required<WatchList>;
3861
3899
  /** This search ranks with the vectors of the embedder, or it is undefined when the crawler has no embedder. */
3862
3900
  readonly hybrid: HybridSearch | undefined;
3863
3901
  /** This method gives vectors to the stored documents that have none, within a budget. It rejects when the crawler has no embedder. */
@@ -4920,5 +4958,5 @@ interface WaczResult extends ArchiveCounts {
4920
4958
  */
4921
4959
  export declare const exportWacz: (source: ArchiveSource, options: ArchiveOptions) => Promise<WaczResult>;
4922
4960
  //#endregion
4923
- export { ALLOW_ALL, type AiInput, type ArchiveCounts, type ArchiveFilter, type ArchiveOptions, type ArchiveSource, type Archived, type BlobStore, type CacheEntry, type CacheIndex, type CaptureFilter, type CaptureLogOptions, type CapturePayload, type CaptureReader, type CaptureRecord, type CaptureWriter, type CatchUpResult, type ChangeCommandOptions, type Changefreq, type ChunkOptions, type Clock, type CrawlEvent, type CrawlOptions, type CrawlPage, type CrawlRun, type CrawlRunOptions, type CrawlRuntime, type CrawlStop, type CrawlSummary, type CrawlerOptions, DAYS, DEFAULT_POLICY, type Daemon, type DaemonDue, type DaemonMcpHooks, type DaemonMcpHost, type DaemonMcpOptions, type DaemonMcpService, type DaemonOptions, type DaemonState, type DaemonStatus, type DaemonTask, type DaemonTick, type DamagedLine, type Day, type DiffHunk, type DiffInput, type DiffLimits, type DiffLine, type DiffOptions, type DiffResult, type DiffSide, type DiffSummary, type DigestOptions, type DirectoryKey, type DiscoverOptions, type DiscoverResult, type DiscoverRunOptions, type DiscoverSource, type DiscoverStop, type DiscoveredUrl, type Doc, type DocDigest, type DocIndexOptions, type DocInput, type DocVersion, type Duration, type EgressOptions, type EgressResolve, type EmbedCallOptions, type EmbedOptions, type EmbedResult, type EmbedStop, type Embedder, type EmbeddingModel, type ExtractOptions, type ExtractResult, type ExtractSource, type ExtractSummary, type ExtractedDoc, type Extractor, type FeatureExtractor, type FetchOptions, type FetchOutcome, type FetchRequest, type Fetched, type FieldCandidate, type FieldCheck, type FieldClaim, type FieldKind, type FieldResult, type FieldSpan, type FieldStatus, type FieldsChecked, type FileBlobStoreOptions, type FindIndexOptions, type FindOptions, type Found, type FusedRank, type HostCounts, type HostResult, type HostStateStore, type HostStop, type Hours, type HoursComparison, type HybridCrawler, type HybridFindOptions, type HybridOptions, type HybridSearch, type HybridSearchOptions, type IndexBuild, type IndexCounts, type Indexed, type Interval, type JsonRecord, type JwkInput, type KeyDirectory, type KeyInput, type Latest, MemoryHostStateStore, type MetaChange, type Money, type OllamaEmbedderOptions, type OpenOptions, type OpenedCrawler, type Outcome, type PageExtract, type PageLink, type PageOptions, type PageResult, type Passage, type PdfOptions, type PdfText, type PlaywrightRenderer, type PolicyOptions, type PoliteCrawler, type PolitenessPolicy, type Pooling, type ProductOptions, type ProductRead, type ProductResult, type ProductVariant, type RankMode, type RankOptions, type Ranked, type ReadOptions, type ReadResult, type ReadingIndex, type Recipe, type RecipeCapture, type RecipeDefinition, type RecipeDoc, type RecipeExtract, type RecipeRequest, type RecipeRequestOptions, type RecipeResult, type RecipeRunOptions, type RecipeTarget, type RecordInput, type RefusedReason, type ReindexResult, type RenderOptions, type RenderRequest, type Rendered, type Renderer, type RequestSigner, type Robots, type RobotsDecision, type RobotsGroup, type RobotsRule, type RobotsSignal, type RuntimeOptions, type ScanOptions, type ScheduleOptions, type ScheduleResult, type ScopeOptions, type SearchOptions, type SearchRank, type Signals, type SignatureAgentType, type SignatureCheck, type SignedRequest, type SitemapEntry, type SitemapKind, type SitemapLimits, type SitemapRead, type SqliteHostStateOptions, type StoreRuntime, type StoredChunk, type TextChunk, type TextDiff, type TransformersEmbedderOptions, type TransformersModule, type UrlPattern, VALIDATOR_MEMO, type ValidatorAnswer, type ValidatorLimits, type ValidatorMemo, type ValidatorReport, type ValidatorVerdict, type Variant, type VectorCounts, type VectorHit, type VectorStoreOptions, type VectorWrite, type VenueLink, type VenueLocation, type VenueOptions, type VenueOsm, type VenuePage, type VenueRead, type VenueReading, type VenueResult, type VenueSource, type Verified, type VerifyOptions, type VerifyResult, type VersionAt, type VersionChoice, type VersionText, type WaczResult, type WarcResult, type WatchEntry, type WatchEvent, type WatchKind, type WatchList, type WatchOptions, type WatchPending, type WatchRow, type WatchRun, type WatchRunOptions, type WatchRunnerOptions, type WatchSchedule, type WatchState, type WatchStop, type WatchStoreOptions, type WatchSummary, type WatchUpdate, type WebArchive, type WebBotAuthOptions, type WebBotAuthSigner, type Week, type WordPart, bodyEncoding, compareHours, decide, decodeBody, describeWeek, disagreements, extractPage, fromCompact, fromSchemaOrg, fromText, nextValidatorMemo, parseRobots, realClock, toHoursWeek, typesOf };
4961
+ export { ALLOW_ALL, type AiInput, type ArchiveCounts, type ArchiveFilter, type ArchiveOptions, type ArchiveSource, type Archived, type BlobStore, type CacheEntry, type CacheIndex, type CaptureFilter, type CaptureLogOptions, type CapturePayload, type CaptureReader, type CaptureRecord, type CaptureWriter, type CatchUpResult, type ChangeCommandOptions, type Changefreq, type ChunkOptions, type Clock, type CrawlEvent, type CrawlOptions, type CrawlPage, type CrawlRun, type CrawlRunOptions, type CrawlRuntime, type CrawlStop, type CrawlSummary, type CrawlerOptions, DAYS, DEFAULT_POLICY, type Daemon, type DaemonDue, type DaemonMcpHooks, type DaemonMcpHost, type DaemonMcpOptions, type DaemonMcpService, type DaemonOptions, type DaemonState, type DaemonStatus, type DaemonTask, type DaemonTick, type DamagedLine, type Day, type DiffHunk, type DiffInput, type DiffLimits, type DiffLine, type DiffOptions, type DiffResult, type DiffSide, type DiffSummary, type DigestOptions, type DirectoryKey, type DiscoverOptions, type DiscoverResult, type DiscoverRunOptions, type DiscoverSource, type DiscoverStop, type DiscoveredUrl, type Doc, type DocDigest, type DocIndexOptions, type DocInput, type DocVersion, type Duration, type EgressOptions, type EgressResolve, type EmbedCallOptions, type EmbedOptions, type EmbedResult, type EmbedStop, type Embedder, type EmbeddingModel, type ExtractOptions, type ExtractResult, type ExtractSource, type ExtractSummary, type ExtractedDoc, type Extractor, type FeatureExtractor, type FetchOptions, type FetchOutcome, type FetchRequest, type Fetched, type FieldCandidate, type FieldCheck, type FieldClaim, type FieldKind, type FieldResult, type FieldSpan, type FieldStatus, type FieldsChecked, type FileBlobStoreOptions, type FindIndexOptions, type FindOptions, type Found, type FusedRank, type HostCounts, type HostResult, type HostStateStore, type HostStop, type Hours, type HoursComparison, type HybridCrawler, type HybridFindOptions, type HybridOptions, type HybridSearch, type HybridSearchOptions, type IndexBuild, type IndexCounts, type Indexed, type Interval, type JsonRecord, type JwkInput, type KeyDirectory, type KeyInput, type Latest, MemoryHostStateStore, type MetaChange, type Money, type OllamaEmbedderOptions, type OpenOptions, type OpenedCrawler, type Outcome, type PageExtract, type PageLink, type PageOptions, type PageResult, type Passage, type PdfOptions, type PdfText, type PlaywrightRenderer, type PolicyOptions, type PoliteCrawler, type PolitenessPolicy, type Pooling, type ProductOptions, type ProductRead, type ProductResult, type ProductVariant, type RankMode, type RankOptions, type Ranked, type ReadOptions, type ReadResult, type ReadingIndex, type Recipe, type RecipeCapture, type RecipeDefinition, type RecipeDoc, type RecipeExtract, type RecipeRequest, type RecipeRequestOptions, type RecipeResult, type RecipeRunOptions, type RecipeTarget, type RecordInput, type RefusedReason, type ReindexResult, type RenderOptions, type RenderRequest, type Rendered, type Renderer, type RequestSigner, type Robots, type RobotsDecision, type RobotsGroup, type RobotsRule, type RobotsSignal, type RuntimeOptions, type ScanOptions, type ScheduleOptions, type ScheduleResult, type ScopeOptions, type SearchOptions, type SearchRank, type Signals, type SignatureAgentType, type SignatureCheck, type SignedRequest, type SitemapEntry, type SitemapKind, type SitemapLimits, type SitemapRead, type SqliteHostStateOptions, type StoreRuntime, type StoredChunk, type TextChunk, type TextDiff, type TransformersEmbedderOptions, type TransformersModule, type UrlPattern, VALIDATOR_MEMO, type ValidatorAnswer, type ValidatorLimits, type ValidatorMemo, type ValidatorReport, type ValidatorVerdict, type Variant, type VectorCounts, type VectorHit, type VectorStoreOptions, type VectorWrite, type VenueLink, type VenueLocation, type VenueOptions, type VenueOsm, type VenuePage, type VenueRead, type VenueReading, type VenueResult, type VenueSource, type Verified, type VerifyOptions, type VerifyResult, type VersionAt, type VersionChoice, type VersionText, type WaczResult, type WarcResult, type WatchEntry, type WatchEvent, type WatchKind, type WatchList, type WatchOptions, type WatchPending, type WatchRescheduleOptions, type WatchRow, type WatchRun, type WatchRunOptions, type WatchRunnerOptions, type WatchSchedule, type WatchState, type WatchStop, type WatchStoreOptions, type WatchSummary, type WatchUpdate, type WebArchive, type WebBotAuthOptions, type WebBotAuthSigner, type Week, type WordPart, bodyEncoding, compareHours, decide, decodeBody, describeWeek, disagreements, extractPage, fromCompact, fromSchemaOrg, fromText, nextValidatorMemo, parseRobots, realClock, toHoursWeek, typesOf };
4924
4962
  //# sourceMappingURL=index.d.mts.map
package/build/index.mjs CHANGED
@@ -1,21 +1,21 @@
1
1
  import { n as FileBlobStore, t as CaptureLog } from "./log-CmBWcyQm.mjs";
2
2
  import { n as RenderRefused, r as playwrightRenderer, t as NO_PLAYWRIGHT } from "./render-CKE2LILH.mjs";
3
3
  import { t as browserMissing } from "./browser-56dBBLec.mjs";
4
- import { i as durationMs, n as DEFAULT_TOKEN, r as VERSION, t as BOT_PAGE } from "./version-CHqkjAh1.mjs";
5
- import { A as DEADLINE_NOTE, F as EgressRefused, I as egressLookup, M as makeRecord, O as CAPTURE_SCHEMA, S as readPdf, T as locate, _ as archivedDocId, a as fetchPage, c as isHeldBack, d as recordOverride, f as reindex, h as archiveExtractor, i as fetchAndIndex, j as DEFAULT_SECRET_PARAMS, k as Crawler, l as isoTime, m as versionAtTime, n as HELD_BACK, o as findDocuments, p as verifyQuote, r as catchUpIndex, s as heldBackMeta, t as Extractors, u as readDocument, x as isPdf } from "./runtime-BwOZJ71n.mjs";
4
+ import { i as durationMs, n as DEFAULT_TOKEN, r as VERSION, t as BOT_PAGE } from "./version-B_Mpbx8R.mjs";
5
+ import { A as DEADLINE_NOTE, F as EgressRefused, I as egressLookup, M as makeRecord, O as CAPTURE_SCHEMA, S as readPdf, T as locate, _ as archivedDocId, a as fetchPage, c as isHeldBack, d as recordOverride, f as reindex, h as archiveExtractor, i as fetchAndIndex, j as DEFAULT_SECRET_PARAMS, k as Crawler, l as isoTime, m as versionAtTime, n as HELD_BACK, o as findDocuments, p as verifyQuote, r as catchUpIndex, s as heldBackMeta, t as Extractors, u as readDocument, x as isPdf } from "./runtime-C0gNyPHi.mjs";
6
6
  import { DEFAULT_POLICY, MemoryHostStateStore, VALIDATOR_MEMO, nextValidatorMemo, realClock } from "./politeness.mjs";
7
7
  import { ALLOW_ALL, decide, parseRobots } from "./robots.mjs";
8
8
  import { i as keyDirectory, n as KEY_DIRECTORY_TYPE, o as verifySignature, r as createWebBotAuthSigner, t as KEY_DIRECTORY_PATH } from "./webbotauth-Dq_dA_u3.mjs";
9
- import { A as NO_EMBEDDER, C as DISCOVER_LIMITS, D as readSitemap, E as feedDate, O as DocIndex, S as crawlSite, T as SITEMAP_LIMITS, _ as estimateTokens, b as SqliteHostStateStore, c as WatchStore, d as VectorStore, f as createHybridSearch, g as chunkTokensOf, h as chunkText, i as openCrawler, k as FAST_RANK_SHARE, l as runWatch, m as HYBRID_DEFAULTS, n as defaultUserAgent, o as WATCH_LIMITS, p as CHUNK_LIMITS, r as isMailbox, s as WATCH_SCHEMA, t as createRuntime, u as VECTORS_SCHEMA, v as fuseRanks, w as discoverSite, x as CRAWL_LIMITS, y as unitVector } from "./open-DXTLJWhU.mjs";
10
- import { a as bodyEncoding, o as decodeBody, r as typesOf, t as extractPage } from "./html-DkQUAE_d.mjs";
11
- import { a as formatDiff, n as diffDocument, r as diffTexts, t as DIFF_LIMITS } from "./diff-Dyzr2-Oi.mjs";
12
- import { n as checkFields, r as extractDocument, t as FIELD_KINDS } from "./extract-DCClsy1y.mjs";
13
- import { a as readJson, i as defineRecipe, n as RESERVED_RECIPES, o as registerRecipe, s as runRecipe, t as RECIPE_LIMITS } from "./recipe-WTgRhbwY.mjs";
14
- import { c as startDaemon, i as daemonStateFile, n as DAEMON_STATE_SCHEMA, o as readDaemonState, r as changeCommand, s as scheduleWatches, t as DAEMON_DEFAULTS } from "./daemon-Bu1wpAwl.mjs";
9
+ import { A as NO_EMBEDDER, C as DISCOVER_LIMITS, D as readSitemap, E as feedDate, O as DocIndex, S as crawlSite, T as SITEMAP_LIMITS, _ as estimateTokens, b as SqliteHostStateStore, c as WatchStore, d as VectorStore, f as createHybridSearch, g as chunkTokensOf, h as chunkText, i as openCrawler, k as FAST_RANK_SHARE, l as runWatch, m as HYBRID_DEFAULTS, n as defaultUserAgent, o as WATCH_LIMITS, p as CHUNK_LIMITS, r as isMailbox, s as WATCH_SCHEMA, t as createRuntime, u as VECTORS_SCHEMA, v as fuseRanks, w as discoverSite, x as CRAWL_LIMITS, y as unitVector } from "./open-CRRsEIrJ.mjs";
10
+ import { a as bodyEncoding, o as decodeBody, r as typesOf, t as extractPage } from "./html-DzobO0fy.mjs";
11
+ import { a as formatDiff, n as diffDocument, r as diffTexts, t as DIFF_LIMITS } from "./diff-BxjQT4r9.mjs";
12
+ import { n as checkFields, r as extractDocument, t as FIELD_KINDS } from "./extract-DfF_0IuS.mjs";
13
+ import { a as readJson, i as defineRecipe, n as RESERVED_RECIPES, o as registerRecipe, s as runRecipe, t as RECIPE_LIMITS } from "./recipe-Bh3_labG.mjs";
14
+ import { c as startDaemon, i as daemonStateFile, n as DAEMON_STATE_SCHEMA, o as readDaemonState, r as changeCommand, s as scheduleWatches, t as DAEMON_DEFAULTS } from "./daemon-DI3WPTzq.mjs";
15
15
  import { i as ollamaEmbedder, n as OLLAMA_MODELS, r as isLoopback, t as NO_OLLAMA } from "./ollama-D1xRh3hY.mjs";
16
16
  import { n as TRANSFORMERS_MODELS, r as transformersEmbedder, t as NO_TRANSFORMERS } from "./transformers-BNiuiLxT.mjs";
17
17
  import { DAYS, compareHours, describeWeek, disagreements, fromCompact, fromSchemaOrg, fromText, toHoursWeek } from "./hours.mjs";
18
- import { a as readAmount, c as locationMatches, d as readVenue, f as venueReadingsOf, i as productOf, l as namesVenue, n as pickProduct, o as readProduct, r as pickVariant, s as VENUE_LIMITS, t as PRODUCT_LIMITS, u as rankHoursLinks } from "./recipe-product-CuUlNx4_.mjs";
19
- import { t as exportWacz } from "./wacz-CBMk0bzI.mjs";
20
- import { n as exportWarc } from "./warc-D632nC5y.mjs";
18
+ import { a as readAmount, c as locationMatches, d as readVenue, f as venueReadingsOf, i as productOf, l as namesVenue, n as pickProduct, o as readProduct, r as pickVariant, s as VENUE_LIMITS, t as PRODUCT_LIMITS, u as rankHoursLinks } from "./recipe-product-CCjNbW8K.mjs";
19
+ import { t as exportWacz } from "./wacz-C1EJ8t57.mjs";
20
+ import { n as exportWarc } from "./warc-CLeYeJNf.mjs";
21
21
  export { ALLOW_ALL, BOT_PAGE, CAPTURE_SCHEMA, CHUNK_LIMITS, CRAWL_LIMITS, CaptureLog, Crawler, DAEMON_DEFAULTS, DAEMON_STATE_SCHEMA, DAYS, DEADLINE_NOTE, DEFAULT_POLICY, DEFAULT_SECRET_PARAMS, DEFAULT_TOKEN, DIFF_LIMITS, DISCOVER_LIMITS, DocIndex, EgressRefused, Extractors, FAST_RANK_SHARE, FIELD_KINDS, FileBlobStore, HELD_BACK, HYBRID_DEFAULTS, KEY_DIRECTORY_PATH, KEY_DIRECTORY_TYPE, MemoryHostStateStore, NO_EMBEDDER, NO_OLLAMA, NO_PLAYWRIGHT, NO_TRANSFORMERS, OLLAMA_MODELS, PRODUCT_LIMITS, RECIPE_LIMITS, RESERVED_RECIPES, RenderRefused, SITEMAP_LIMITS, SqliteHostStateStore, TRANSFORMERS_MODELS, VALIDATOR_MEMO, VECTORS_SCHEMA, VENUE_LIMITS, VERSION, VectorStore, WATCH_LIMITS, WATCH_SCHEMA, WatchStore, archiveExtractor, archivedDocId, bodyEncoding, browserMissing, catchUpIndex, changeCommand, checkFields, chunkText, chunkTokensOf, compareHours, crawlSite, createHybridSearch, createRuntime, createWebBotAuthSigner, daemonStateFile, decide, decodeBody, defaultUserAgent, defineRecipe, describeWeek, diffDocument, diffTexts, disagreements, discoverSite, durationMs, egressLookup, estimateTokens, exportWacz, exportWarc, extractDocument, extractPage, feedDate, fetchAndIndex, fetchPage, findDocuments, formatDiff, fromCompact, fromSchemaOrg, fromText, fuseRanks, heldBackMeta, isHeldBack, isLoopback, isMailbox, isPdf, isoTime, keyDirectory, locate, locationMatches, makeRecord, namesVenue, nextValidatorMemo, ollamaEmbedder, openCrawler, parseRobots, pickProduct, pickVariant, playwrightRenderer, productOf, rankHoursLinks, readAmount, readDaemonState, readDocument, readJson, readPdf, readProduct, readSitemap, readVenue, realClock, recordOverride, registerRecipe, reindex, runRecipe, runWatch, scheduleWatches, startDaemon, toHoursWeek, transformersEmbedder, typesOf, unitVector, venueReadingsOf, verifyQuote, verifySignature, versionAtTime };
@@ -2,15 +2,15 @@ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { n as FileBlobStore, t as CaptureLog } from "./log-CmBWcyQm.mjs";
3
3
  import { r as playwrightRenderer } from "./render-CKE2LILH.mjs";
4
4
  import { r as checkedRenderer } from "./browser-56dBBLec.mjs";
5
- import { i as durationMs, n as DEFAULT_TOKEN, r as VERSION, t as BOT_PAGE } from "./version-CHqkjAh1.mjs";
6
- import { A as DEADLINE_NOTE, C as fold, D as snippetOf, E as parseQuery, N as sha256$1, P as stableStringify, a as fetchPage, c as isHeldBack, f as reindex, i as fetchAndIndex, k as Crawler, o as findDocuments, p as verifyQuote, r as catchUpIndex, t as Extractors, u as readDocument, y as archivedOf } from "./runtime-BwOZJ71n.mjs";
5
+ import { i as durationMs, n as DEFAULT_TOKEN, r as VERSION, t as BOT_PAGE } from "./version-B_Mpbx8R.mjs";
6
+ import { A as DEADLINE_NOTE, C as fold, D as snippetOf, E as parseQuery, N as sha256$1, P as stableStringify, a as fetchPage, c as isHeldBack, f as reindex, i as fetchAndIndex, k as Crawler, l as isoTime, o as findDocuments, p as verifyQuote, r as catchUpIndex, t as Extractors, u as readDocument, y as archivedOf } from "./runtime-C0gNyPHi.mjs";
7
7
  import { MemoryHostStateStore, nextValidatorMemo, realClock } from "./politeness.mjs";
8
8
  import { matchesPattern } from "./robots.mjs";
9
9
  import { n as canonicalUrl, r as scopeTest, t as cacheKeyOf } from "./urls-BHFeSyEK.mjs";
10
- import { o as decodeBody, t as extractPage } from "./html-DkQUAE_d.mjs";
11
- import { n as diffDocument, r as diffTexts } from "./diff-Dyzr2-Oi.mjs";
12
- import { r as extractDocument } from "./extract-DCClsy1y.mjs";
13
- import { o as registerRecipe } from "./recipe-WTgRhbwY.mjs";
10
+ import { o as decodeBody, t as extractPage } from "./html-DzobO0fy.mjs";
11
+ import { n as diffDocument, r as diffTexts } from "./diff-BxjQT4r9.mjs";
12
+ import { r as extractDocument } from "./extract-DfF_0IuS.mjs";
13
+ import { o as registerRecipe } from "./recipe-Bh3_labG.mjs";
14
14
  import { createHash, randomUUID } from "node:crypto";
15
15
  import { dirname, join } from "node:path";
16
16
  import { existsSync, lstatSync, mkdirSync, realpathSync, statSync } from "node:fs";
@@ -3636,8 +3636,8 @@ var WatchStore = class {
3636
3636
  }
3637
3637
  /**
3638
3638
  * This method adds a page, or changes the options of its watch and keeps its state. A new entry
3639
- * is due at once. A changed entry is due one `every` after its last check. A bad option throws
3640
- * a `RangeError`.
3639
+ * is due at once. A changed entry is due one `every` after its last check. With `keepSchedule`,
3640
+ * it keeps the time of its next check. A bad option throws a `RangeError`.
3641
3641
  */
3642
3642
  add(url, options, now) {
3643
3643
  const { key, target, host } = targetOf(url);
@@ -3655,11 +3655,32 @@ var WatchStore = class {
3655
3655
  ON CONFLICT(url) DO UPDATE SET target = excluded.target, host = excluded.host,
3656
3656
  every_ms = excluded.every_ms, render = excluded.render, confirm = excluded.confirm,
3657
3657
  scope = excluded.scope, labels = excluded.labels, on_behalf_of = excluded.on_behalf_of,
3658
- next_at = CASE WHEN watches.last_at IS NULL THEN watches.next_at
3659
- ELSE watches.last_at + excluded.every_ms END`).run(key, target, host, every, render, confirm, options.scope ?? null, labels, agents, now, now);
3658
+ next_at = CASE WHEN ? = 1 OR watches.last_at IS NULL THEN watches.next_at
3659
+ ELSE watches.last_at + excluded.every_ms END`).run(key, target, host, every, render, confirm, options.scope ?? null, labels, agents, now, now, options.keepSchedule === true ? 1 : 0);
3660
3660
  return entryOf(this.row(key), now);
3661
3661
  });
3662
3662
  }
3663
+ /**
3664
+ * This method changes the time of the next check of a page, and nothing else. It gives the
3665
+ * changed entry, or undefined when the list does not have the page. A bad time, or a time before
3666
+ * one floor after the last check, throws a `RangeError`. A check in progress sets the time again
3667
+ * when it ends.
3668
+ */
3669
+ reschedule(url, options, now) {
3670
+ const { key } = targetOf(url);
3671
+ const at = Date.parse(isoTime("at", options.at));
3672
+ return this.step(() => {
3673
+ const row = this.row(key);
3674
+ if (row === void 0) return void 0;
3675
+ const earliest = row.last_at === null ? -Infinity : row.last_at + this.floorMs;
3676
+ if (at < earliest) throw new RangeError(`the next check must be at ${iso(earliest)} or later, ${String(this.floorMs / 6e4)} minutes after the last check, so a watch cannot hammer a site, not ${iso(at)}`);
3677
+ this.stmt("UPDATE watches SET next_at = ? WHERE url = ?").run(at, key);
3678
+ return entryOf({
3679
+ ...row,
3680
+ next_at: at
3681
+ }, now);
3682
+ });
3683
+ }
3663
3684
  /** This method removes a page. It gives false when the list does not have the page. */
3664
3685
  remove(url) {
3665
3686
  const { key } = targetOf(url);
@@ -3799,6 +3820,7 @@ const runWatch = (runtime, source, options = {}) => {
3799
3820
  render: row.render,
3800
3821
  maxAgeMs: 0,
3801
3822
  onBehalfOf: agents,
3823
+ job: options.job,
3802
3824
  signal: abort.signal,
3803
3825
  scope: row.scope ?? void 0,
3804
3826
  labels,
@@ -4304,6 +4326,9 @@ const openCrawler = (options) => {
4304
4326
  async list() {
4305
4327
  return (await watchStore()).list(clockNow());
4306
4328
  },
4329
+ async reschedule(url, rescheduleOptions) {
4330
+ return (await watchStore()).reschedule(url, rescheduleOptions, clockNow());
4331
+ },
4307
4332
  run(runOptions = {}) {
4308
4333
  return runWatch(runtime, watchStore, {
4309
4334
  ...runOptions,
@@ -4331,4 +4356,4 @@ const openCrawler = (options) => {
4331
4356
  //#endregion
4332
4357
  export { NO_EMBEDDER as A, DISCOVER_LIMITS as C, readSitemap as D, feedDate as E, DocIndex as O, crawlSite as S, SITEMAP_LIMITS as T, estimateTokens as _, open_exports as a, SqliteHostStateStore as b, WatchStore as c, VectorStore as d, createHybridSearch as f, chunkTokensOf as g, chunkText as h, openCrawler as i, FAST_RANK_SHARE as k, runWatch as l, HYBRID_DEFAULTS as m, defaultUserAgent as n, WATCH_LIMITS as o, CHUNK_LIMITS as p, isMailbox as r, WATCH_SCHEMA as s, createRuntime as t, VECTORS_SCHEMA as u, fuseRanks as v, discoverSite as w, CRAWL_LIMITS as x, unitVector as y };
4333
4358
 
4334
- //# sourceMappingURL=open-DXTLJWhU.mjs.map
4359
+ //# sourceMappingURL=open-CRRsEIrJ.mjs.map