metascraper 5.45.2 → 5.45.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.d.ts +104 -96
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "metascraper",
3
3
  "description": "A library to easily scrape metadata from an article on the web using Open Graph, JSON+LD, regular HTML metadata, and series of fallbacks.",
4
4
  "homepage": "https://metascraper.js.org",
5
- "version": "5.45.2",
5
+ "version": "5.45.3",
6
6
  "types": "src/index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "repository": {
@@ -86,5 +86,5 @@
86
86
  "tsd": {
87
87
  "directory": "test/types"
88
88
  },
89
- "gitHead": "00543a5b45cf6ed1c7a46441d292de50a9828d8a"
89
+ "gitHead": "2746fa0cbf5b3a0f7b03b72b8cea930b99249923"
90
90
  }
package/src/index.d.ts CHANGED
@@ -1,102 +1,110 @@
1
- export interface MetascraperOptions {
2
- /**
3
- * The URL associated with the HTML markup.
4
- * It is used for resolve relative links that can be present in the HTML markup.
5
- * it can be used as fallback field for different rules as well.
6
- *
7
- */
8
- url: string;
9
- /**
10
- * The HTML markup for extracting the content.
11
- */
12
- html?: string;
13
- /**
14
- * You can pass additional rules to add on execution time.
15
- * These rules will be merged with your loaded rules at the beginning.
16
- */
17
- rules?: Rules[];
18
- /**
19
- * Ensure the URL provided is validated as a WHATWG URL API compliant.
20
- */
21
- validateUrl?: boolean;
22
- }
1
+ /**
2
+ * It creates a [metascraper](https://metascraper.js.org/) instance, declaring the rules bundle to be used explicitly.
3
+ * @param rules - The [rules bundles](https://metascraper.js.org/#/?id=rules-bundles) to be applied for metadata extraction.
4
+ */
5
+ declare function createMetascraper(
6
+ rules: createMetascraper.Rules[]
7
+ ): createMetascraper.Metascraper;
23
8
 
24
- export interface Metadata {
25
- /**
26
- * Get audio property from HTML markup
27
- * The package [metascraper-audio](https://example.com/metascraper-audio) needs to be loaded.
28
- */
29
- audio?: string;
30
- /**
31
- * Get author property from HTML markup.
32
- * The package [metascraper-author](https://example.com/metascraper-author) needs to be loaded.
33
- */
34
- author?: string;
35
- /**
36
- * Get date property from HTML markup.
37
- * The package [metascraper-date](https://example.com/metascraper-date) needs to be loaded.
38
- */
39
- date?: string;
40
- /**
41
- * Get description property from HTML markup.
42
- * The package [metascraper-description](https://example.com/metascraper-description) needs to be loaded.
43
- */
44
- description?: string;
45
- /**
46
- * Get image property from HTML markup.
47
- * The package [metascraper-image](https://example.com/metascraper-image) needs to be loaded.
48
- */
49
- image?: string;
50
- /**
51
- * Get lang property from HTML markup
52
- * The package [metascraper-lang](https://example.com/metascraper-lang) needs to be loaded.
53
- */
54
- lang?: string;
55
- /**
56
- * Get logo property from HTML markup
57
- * The package [metascraper-logo](https://example.com/metascraper-logo) needs to be loaded.
58
- */
59
- logo?: string;
60
- /**
61
- * Get publisher property from HTML markup
62
- * The package [metascraper-publisher](https://example.com/metascraper-publisher) needs to be loaded.
63
- */
64
- publisher?: string;
65
- /**
66
- * Get title property from HTML markup
67
- * The package [metascraper-title](https://example.com/metascraper-title) needs to be loaded.
68
- */
69
- title?: string;
70
- /**
71
- * Get url property from HTML markup
72
- * The package [metascraper-url](https://example.com/metascraper-url) needs to be loaded.
73
- */
74
- url?: string;
75
- /**
76
- * Get video property from HTML markup
77
- * The package [metascraper-video](https://example.com/metascraper-video) needs to be loaded.
78
- */
79
- video?: string;
80
- [key: string]: string | undefined;
81
- }
9
+ export = createMetascraper;
82
10
 
83
- export type Rules = {
84
- [C in keyof Metadata]?: Array<RulesOptions> | RulesOptions;
85
- } & {
86
- test?: (options: RulesTestOptions) => boolean;
87
- };
11
+ declare namespace createMetascraper {
12
+ export interface MetascraperOptions {
13
+ /**
14
+ * The URL associated with the HTML markup.
15
+ * It is used for resolve relative links that can be present in the HTML markup.
16
+ * it can be used as fallback field for different rules as well.
17
+ *
18
+ */
19
+ url: string;
20
+ /**
21
+ * The HTML markup for extracting the content.
22
+ */
23
+ html?: string;
24
+ /**
25
+ * You can pass additional rules to add on execution time.
26
+ * These rules will be merged with your loaded rules at the beginning.
27
+ */
28
+ rules?: Rules[];
29
+ /**
30
+ * Ensure the URL provided is validated as a WHATWG URL API compliant.
31
+ */
32
+ validateUrl?: boolean;
33
+ }
88
34
 
89
- export type RulesOptions = (options: RulesTestOptions) => string | null | undefined;
35
+ export interface Metadata {
36
+ /**
37
+ * Get audio property from HTML markup
38
+ * The package [metascraper-audio](https://example.com/metascraper-audio) needs to be loaded.
39
+ */
40
+ audio?: string;
41
+ /**
42
+ * Get author property from HTML markup.
43
+ * The package [metascraper-author](https://example.com/metascraper-author) needs to be loaded.
44
+ */
45
+ author?: string;
46
+ /**
47
+ * Get date property from HTML markup.
48
+ * The package [metascraper-date](https://example.com/metascraper-date) needs to be loaded.
49
+ */
50
+ date?: string;
51
+ /**
52
+ * Get description property from HTML markup.
53
+ * The package [metascraper-description](https://example.com/metascraper-description) needs to be loaded.
54
+ */
55
+ description?: string;
56
+ /**
57
+ * Get image property from HTML markup.
58
+ * The package [metascraper-image](https://example.com/metascraper-image) needs to be loaded.
59
+ */
60
+ image?: string;
61
+ /**
62
+ * Get lang property from HTML markup
63
+ * The package [metascraper-lang](https://example.com/metascraper-lang) needs to be loaded.
64
+ */
65
+ lang?: string;
66
+ /**
67
+ * Get logo property from HTML markup
68
+ * The package [metascraper-logo](https://example.com/metascraper-logo) needs to be loaded.
69
+ */
70
+ logo?: string;
71
+ /**
72
+ * Get publisher property from HTML markup
73
+ * The package [metascraper-publisher](https://example.com/metascraper-publisher) needs to be loaded.
74
+ */
75
+ publisher?: string;
76
+ /**
77
+ * Get title property from HTML markup
78
+ * The package [metascraper-title](https://example.com/metascraper-title) needs to be loaded.
79
+ */
80
+ title?: string;
81
+ /**
82
+ * Get url property from HTML markup
83
+ * The package [metascraper-url](https://example.com/metascraper-url) needs to be loaded.
84
+ */
85
+ url?: string;
86
+ /**
87
+ * Get video property from HTML markup
88
+ * The package [metascraper-video](https://example.com/metascraper-video) needs to be loaded.
89
+ */
90
+ video?: string;
91
+ [key: string]: string | undefined;
92
+ }
90
93
 
91
- export interface RulesTestOptions {
92
- htmlDom: import('cheerio').CheerioAPI;
93
- url: string;
94
- }
94
+ export type Rules = {
95
+ [C in keyof Metadata]?: Array<RulesOptions> | RulesOptions;
96
+ } & {
97
+ test?: (options: RulesTestOptions) => boolean;
98
+ };
95
99
 
96
- export type Metascraper = (options: MetascraperOptions) => Promise<Metadata>;
100
+ export type RulesOptions = (
101
+ options: RulesTestOptions
102
+ ) => string | null | undefined;
97
103
 
98
- /**
99
- * It creates a [metascraper](https://metascraper.js.org/) instance, declaring the rules bundle to be used explicitly.
100
- * @param rules - The [rules bundles](https://metascraper.js.org/#/?id=rules-bundles) to be applied for metadata extraction.
101
- */
102
- export default function createMetascraper(rules: Rules[]): Metascraper;
104
+ export interface RulesTestOptions {
105
+ htmlDom: import("cheerio").CheerioAPI;
106
+ url: string;
107
+ }
108
+
109
+ export type Metascraper = (options: MetascraperOptions) => Promise<Metadata>;
110
+ }