polite-crawler 0.6.3 → 0.7.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.
Files changed (46) hide show
  1. package/README.md +17 -4
  2. package/build/api.d.mts +76 -11
  3. package/build/api.mjs +161 -28
  4. package/build/api.mjs.map +1 -1
  5. package/build/{cli-daemon-Dh7_akeK.mjs → cli-daemon-CZ-vmYE1.mjs} +2 -2
  6. package/build/{cli-daemon-Dh7_akeK.mjs.map → cli-daemon-CZ-vmYE1.mjs.map} +1 -1
  7. package/build/{cli-recipes-DnmjTnyY.mjs → cli-recipes-CkbbzByr.mjs} +2 -2
  8. package/build/{cli-recipes-DnmjTnyY.mjs.map → cli-recipes-CkbbzByr.mjs.map} +1 -1
  9. package/build/cli.mjs +7 -7
  10. package/build/{daemon-Skkq_MW8.mjs → daemon-IZ91wnyJ.mjs} +3 -3
  11. package/build/{daemon-Skkq_MW8.mjs.map → daemon-IZ91wnyJ.mjs.map} +1 -1
  12. package/build/{diff-BUGMvIqe.mjs → diff-BYzp68Pl.mjs} +2 -2
  13. package/build/{diff-BUGMvIqe.mjs.map → diff-BYzp68Pl.mjs.map} +1 -1
  14. package/build/{extract-Cm_bF25a.mjs → extract-D2VKh3He.mjs} +3 -3
  15. package/build/{extract-Cm_bF25a.mjs.map → extract-D2VKh3He.mjs.map} +1 -1
  16. package/build/html.d.mts +83 -2
  17. package/build/html.mjs +844 -1
  18. package/build/html.mjs.map +1 -0
  19. package/build/index.d.mts +9 -4
  20. package/build/index.mjs +12 -11
  21. package/build/{open-Cw4NVDBE.mjs → open-ChtVn0WK.mjs} +88 -901
  22. package/build/open-ChtVn0WK.mjs.map +1 -0
  23. package/build/politeness.d.mts +6 -0
  24. package/build/politeness.mjs.map +1 -1
  25. package/build/{recipe-CRT_I64C.mjs → recipe-BweJp7jV.mjs} +4 -4
  26. package/build/{recipe-CRT_I64C.mjs.map → recipe-BweJp7jV.mjs.map} +1 -1
  27. package/build/{recipe-product-n0fZKTxE.mjs → recipe-product-Dj-SHWXm.mjs} +37 -9
  28. package/build/recipe-product-Dj-SHWXm.mjs.map +1 -0
  29. package/build/{runtime-BYb320jE.mjs → runtime-CM4YRvnW.mjs} +804 -16
  30. package/build/runtime-CM4YRvnW.mjs.map +1 -0
  31. package/build/text.d.mts +10 -0
  32. package/build/text.mjs +188 -0
  33. package/build/text.mjs.map +1 -0
  34. package/build/{version-bKln1r5i.mjs → version-GyHkLzZY.mjs} +2 -2
  35. package/build/{version-bKln1r5i.mjs.map → version-GyHkLzZY.mjs.map} +1 -1
  36. package/build/{wacz-fsby_Qur.mjs → wacz-Cwfn0sH4.mjs} +3 -3
  37. package/build/{wacz-fsby_Qur.mjs.map → wacz-Cwfn0sH4.mjs.map} +1 -1
  38. package/build/{warc-C9VpeTjp.mjs → warc-6-zIJFSL.mjs} +2 -2
  39. package/build/{warc-C9VpeTjp.mjs.map → warc-6-zIJFSL.mjs.map} +1 -1
  40. package/package.json +6 -2
  41. package/build/html-CawWTgMQ.mjs +0 -1030
  42. package/build/html-CawWTgMQ.mjs.map +0 -1
  43. package/build/html-oS_ueu9U.d.mts +0 -92
  44. package/build/open-Cw4NVDBE.mjs.map +0 -1
  45. package/build/recipe-product-n0fZKTxE.mjs.map +0 -1
  46. package/build/runtime-BYb320jE.mjs.map +0 -1
package/build/html.d.mts CHANGED
@@ -1,3 +1,84 @@
1
1
  import { canonicalUrl } from "./urls.mjs";
2
- import { a as readJsonLd, c as bodyEncoding, i as extractPage, l as decodeBody, n as PageExtract, o as typesOf, r as PageLink, s as visibleText, t as DomNode } from "./html-oS_ueu9U.mjs";
3
- export { DomNode, PageExtract, PageLink, bodyEncoding, canonicalUrl, decodeBody, extractPage, readJsonLd, typesOf, visibleText };
2
+ import { bodyEncoding, decodeBody } from "./text.mjs";
3
+ /**
4
+ * The page reader reads a web page with no browser first. It gives:
5
+ *
6
+ * 1. The JSON-LD, the structured data that 41% of pages have. For a venue, it gives the name, the
7
+ * address, the phone number and sometimes the hours.
8
+ * 2. The visible text of the page.
9
+ * 3. A decision: does the page need JavaScript to show its content?
10
+ *
11
+ * On a short page, the text is all of the visible text. Readability is for articles, and it
12
+ * removes footers, sidebars and tables, where a venue keeps its hours. Thus on a long page, the
13
+ * main text of Readability comes first. A blank line follows it, and then each other line of the
14
+ * page.
15
+ *
16
+ * The cost of the reader grows in proportion to the size of the page. It walks the document with
17
+ * no recursion, so deep markup cannot overflow the stack. It does not use Readability on a page
18
+ * that is too large or too deep for it.
19
+ */
20
+ export interface PageLink {
21
+ readonly href: string;
22
+ readonly text: string;
23
+ }
24
+ export interface PageExtract {
25
+ readonly title: string;
26
+ readonly description: string | null;
27
+ readonly text: string;
28
+ /**
29
+ * When the reader cut `text` to its maximum, this text is the whole visible text in the order of
30
+ * the page. A quote past the cut is still in it. Otherwise this value is undefined.
31
+ */
32
+ readonly fullText?: string | undefined;
33
+ /** These are the JSON-LD objects of the page, with each `@graph` made flat. */
34
+ readonly jsonld: readonly Record<string, unknown>[];
35
+ readonly links: readonly PageLink[];
36
+ readonly lang: string | null;
37
+ readonly visibleChars: number;
38
+ /** These are the names of the application states that the HTML holds (Next.js, Nuxt, Apollo). */
39
+ readonly embedded: readonly string[];
40
+ /** This value is true when the page shows almost nothing without its scripts. */
41
+ readonly needsRender: boolean;
42
+ readonly renderReason: string | null;
43
+ /** This URL is the `<link rel="canonical">` of the page when it is on the same site, or null. */
44
+ readonly canonical: string | null;
45
+ /**
46
+ * These URLs are the RSS and Atom feeds that the page links with `<link rel="alternate">`, 10 or
47
+ * fewer. They can be on a different site. `extractPage` always gives them. The field is optional,
48
+ * so a `PageExtract` of version 0.1.1 stays correct.
49
+ */
50
+ readonly feeds?: readonly string[] | undefined;
51
+ /** This URL is the target of a `<meta http-equiv="refresh">` that sends the reader on in 5 seconds or less. */
52
+ readonly redirect: string | null;
53
+ /**
54
+ * This value names the bot check or the firewall that sent its page in place of the content, for
55
+ * example "Cloudflare". A crawler must not open a browser to get past it.
56
+ */
57
+ readonly blocked: string | null;
58
+ /** These notes tell what the reader left out, for example a JSON-LD block that it cannot read. */
59
+ readonly notes: readonly string[];
60
+ }
61
+ /** This is the small part of the DOM that this file uses. Node has no DOM types, and linkedom supplies the DOM. */
62
+ export interface DomNode {
63
+ readonly nodeType: number;
64
+ readonly nodeName: string;
65
+ readonly textContent: string | null;
66
+ readonly childNodes: ArrayLike<DomNode>;
67
+ readonly firstChild?: DomNode | null | undefined;
68
+ readonly nextSibling?: DomNode | null | undefined;
69
+ readonly parentNode?: DomNode | null | undefined;
70
+ /** This method takes the node out of its parent. */
71
+ readonly remove?: (() => void) | undefined;
72
+ }
73
+ /** This function gives the text that a reader sees, with one line for each block. */
74
+ export declare const visibleText: (root: DomNode) => string;
75
+ /**
76
+ * This function reads the JSON-LD blocks and makes arrays and `@graph` flat. It repairs a comma
77
+ * before a closing bracket, a raw line break in a string and two values in one block. It ignores
78
+ * a block that it cannot repair.
79
+ */
80
+ export declare const readJsonLd: (sources: readonly string[]) => Record<string, unknown>[];
81
+ /** This function gives the types that a JSON-LD object declares, without the schema.org prefix. */
82
+ export declare const typesOf: (record: Record<string, unknown>) => string[];
83
+ export declare const extractPage: (html: string, pageUrl: string) => PageExtract;
84
+ export { bodyEncoding, canonicalUrl, decodeBody };