@depup/cheerio 1.2.0-depup.2

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 (230) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/Readme.md +229 -0
  4. package/changes.json +30 -0
  5. package/dist/browser/api/attributes.d.ts +385 -0
  6. package/dist/browser/api/attributes.d.ts.map +1 -0
  7. package/dist/browser/api/attributes.js +636 -0
  8. package/dist/browser/api/attributes.js.map +1 -0
  9. package/dist/browser/api/css.d.ts +42 -0
  10. package/dist/browser/api/css.d.ts.map +1 -0
  11. package/dist/browser/api/css.js +116 -0
  12. package/dist/browser/api/css.js.map +1 -0
  13. package/dist/browser/api/extract.d.ts +27 -0
  14. package/dist/browser/api/extract.d.ts.map +1 -0
  15. package/dist/browser/api/extract.js +42 -0
  16. package/dist/browser/api/extract.js.map +1 -0
  17. package/dist/browser/api/forms.d.ts +36 -0
  18. package/dist/browser/api/forms.d.ts.map +1 -0
  19. package/dist/browser/api/forms.js +81 -0
  20. package/dist/browser/api/forms.js.map +1 -0
  21. package/dist/browser/api/manipulation.d.ts +528 -0
  22. package/dist/browser/api/manipulation.d.ts.map +1 -0
  23. package/dist/browser/api/manipulation.js +831 -0
  24. package/dist/browser/api/manipulation.js.map +1 -0
  25. package/dist/browser/api/traversing.d.ts +657 -0
  26. package/dist/browser/api/traversing.d.ts.map +1 -0
  27. package/dist/browser/api/traversing.js +857 -0
  28. package/dist/browser/api/traversing.js.map +1 -0
  29. package/dist/browser/cheerio.d.ts +85 -0
  30. package/dist/browser/cheerio.d.ts.map +1 -0
  31. package/dist/browser/cheerio.js +58 -0
  32. package/dist/browser/cheerio.js.map +1 -0
  33. package/dist/browser/index-browser.d.mts.map +1 -0
  34. package/dist/browser/index-browser.mjs.map +1 -0
  35. package/dist/browser/index.d.ts +5 -0
  36. package/dist/browser/index.js +3 -0
  37. package/dist/browser/load-parse.d.ts +20 -0
  38. package/dist/browser/load-parse.d.ts.map +1 -0
  39. package/dist/browser/load-parse.js +28 -0
  40. package/dist/browser/load-parse.js.map +1 -0
  41. package/dist/browser/load.d.ts +91 -0
  42. package/dist/browser/load.d.ts.map +1 -0
  43. package/dist/browser/load.js +129 -0
  44. package/dist/browser/load.js.map +1 -0
  45. package/dist/browser/options.d.ts +98 -0
  46. package/dist/browser/options.d.ts.map +1 -0
  47. package/dist/browser/options.js +34 -0
  48. package/dist/browser/options.js.map +1 -0
  49. package/dist/browser/package.json +3 -0
  50. package/dist/browser/parse.d.ts +18 -0
  51. package/dist/browser/parse.d.ts.map +1 -0
  52. package/dist/browser/parse.js +73 -0
  53. package/dist/browser/parse.js.map +1 -0
  54. package/dist/browser/parsers/parse5-adapter.d.ts +20 -0
  55. package/dist/browser/parsers/parse5-adapter.d.ts.map +1 -0
  56. package/dist/browser/parsers/parse5-adapter.js +50 -0
  57. package/dist/browser/parsers/parse5-adapter.js.map +1 -0
  58. package/dist/browser/slim.d.ts +25 -0
  59. package/dist/browser/slim.d.ts.map +1 -0
  60. package/dist/browser/slim.js +22 -0
  61. package/dist/browser/slim.js.map +1 -0
  62. package/dist/browser/static.d.ts +112 -0
  63. package/dist/browser/static.d.ts.map +1 -0
  64. package/dist/browser/static.js +204 -0
  65. package/dist/browser/static.js.map +1 -0
  66. package/dist/browser/types.d.ts +21 -0
  67. package/dist/browser/types.d.ts.map +1 -0
  68. package/dist/browser/types.js +3 -0
  69. package/dist/browser/types.js.map +1 -0
  70. package/dist/browser/utils.d.ts +55 -0
  71. package/dist/browser/utils.d.ts.map +1 -0
  72. package/dist/browser/utils.js +84 -0
  73. package/dist/browser/utils.js.map +1 -0
  74. package/dist/commonjs/api/attributes.d.ts +385 -0
  75. package/dist/commonjs/api/attributes.d.ts.map +1 -0
  76. package/dist/commonjs/api/attributes.js +647 -0
  77. package/dist/commonjs/api/attributes.js.map +1 -0
  78. package/dist/commonjs/api/css.d.ts +42 -0
  79. package/dist/commonjs/api/css.d.ts.map +1 -0
  80. package/dist/commonjs/api/css.js +119 -0
  81. package/dist/commonjs/api/css.js.map +1 -0
  82. package/dist/commonjs/api/extract.d.ts +27 -0
  83. package/dist/commonjs/api/extract.d.ts.map +1 -0
  84. package/dist/commonjs/api/extract.js +45 -0
  85. package/dist/commonjs/api/extract.js.map +1 -0
  86. package/dist/commonjs/api/forms.d.ts +36 -0
  87. package/dist/commonjs/api/forms.d.ts.map +1 -0
  88. package/dist/commonjs/api/forms.js +85 -0
  89. package/dist/commonjs/api/forms.js.map +1 -0
  90. package/dist/commonjs/api/manipulation.d.ts +528 -0
  91. package/dist/commonjs/api/manipulation.d.ts.map +1 -0
  92. package/dist/commonjs/api/manipulation.js +850 -0
  93. package/dist/commonjs/api/manipulation.js.map +1 -0
  94. package/dist/commonjs/api/traversing.d.ts +657 -0
  95. package/dist/commonjs/api/traversing.d.ts.map +1 -0
  96. package/dist/commonjs/api/traversing.js +914 -0
  97. package/dist/commonjs/api/traversing.js.map +1 -0
  98. package/dist/commonjs/cheerio.d.ts +85 -0
  99. package/dist/commonjs/cheerio.d.ts.map +1 -0
  100. package/dist/commonjs/cheerio.js +95 -0
  101. package/dist/commonjs/cheerio.js.map +1 -0
  102. package/dist/commonjs/index.d.ts +104 -0
  103. package/dist/commonjs/index.d.ts.map +1 -0
  104. package/dist/commonjs/index.js +250 -0
  105. package/dist/commonjs/index.js.map +1 -0
  106. package/dist/commonjs/load-parse.d.ts +20 -0
  107. package/dist/commonjs/load-parse.d.ts.map +1 -0
  108. package/dist/commonjs/load-parse.js +34 -0
  109. package/dist/commonjs/load-parse.js.map +1 -0
  110. package/dist/commonjs/load.d.ts +91 -0
  111. package/dist/commonjs/load.d.ts.map +1 -0
  112. package/dist/commonjs/load.js +165 -0
  113. package/dist/commonjs/load.js.map +1 -0
  114. package/dist/commonjs/options.d.ts +98 -0
  115. package/dist/commonjs/options.d.ts.map +1 -0
  116. package/dist/commonjs/options.js +37 -0
  117. package/dist/commonjs/options.js.map +1 -0
  118. package/dist/commonjs/package.json +3 -0
  119. package/dist/commonjs/parse.d.ts +18 -0
  120. package/dist/commonjs/parse.d.ts.map +1 -0
  121. package/dist/commonjs/parse.js +77 -0
  122. package/dist/commonjs/parse.js.map +1 -0
  123. package/dist/commonjs/parsers/parse5-adapter.d.ts +20 -0
  124. package/dist/commonjs/parsers/parse5-adapter.d.ts.map +1 -0
  125. package/dist/commonjs/parsers/parse5-adapter.js +54 -0
  126. package/dist/commonjs/parsers/parse5-adapter.js.map +1 -0
  127. package/dist/commonjs/slim.d.ts +25 -0
  128. package/dist/commonjs/slim.d.ts.map +1 -0
  129. package/dist/commonjs/slim.js +30 -0
  130. package/dist/commonjs/slim.js.map +1 -0
  131. package/dist/commonjs/static.d.ts +112 -0
  132. package/dist/commonjs/static.d.ts.map +1 -0
  133. package/dist/commonjs/static.js +214 -0
  134. package/dist/commonjs/static.js.map +1 -0
  135. package/dist/commonjs/types.d.ts +21 -0
  136. package/dist/commonjs/types.d.ts.map +1 -0
  137. package/dist/commonjs/types.js +4 -0
  138. package/dist/commonjs/types.js.map +1 -0
  139. package/dist/commonjs/utils.d.ts +55 -0
  140. package/dist/commonjs/utils.d.ts.map +1 -0
  141. package/dist/commonjs/utils.js +91 -0
  142. package/dist/commonjs/utils.js.map +1 -0
  143. package/dist/esm/api/attributes.d.ts +385 -0
  144. package/dist/esm/api/attributes.d.ts.map +1 -0
  145. package/dist/esm/api/attributes.js +636 -0
  146. package/dist/esm/api/attributes.js.map +1 -0
  147. package/dist/esm/api/css.d.ts +42 -0
  148. package/dist/esm/api/css.d.ts.map +1 -0
  149. package/dist/esm/api/css.js +116 -0
  150. package/dist/esm/api/css.js.map +1 -0
  151. package/dist/esm/api/extract.d.ts +27 -0
  152. package/dist/esm/api/extract.d.ts.map +1 -0
  153. package/dist/esm/api/extract.js +42 -0
  154. package/dist/esm/api/extract.js.map +1 -0
  155. package/dist/esm/api/forms.d.ts +36 -0
  156. package/dist/esm/api/forms.d.ts.map +1 -0
  157. package/dist/esm/api/forms.js +81 -0
  158. package/dist/esm/api/forms.js.map +1 -0
  159. package/dist/esm/api/manipulation.d.ts +528 -0
  160. package/dist/esm/api/manipulation.d.ts.map +1 -0
  161. package/dist/esm/api/manipulation.js +831 -0
  162. package/dist/esm/api/manipulation.js.map +1 -0
  163. package/dist/esm/api/traversing.d.ts +657 -0
  164. package/dist/esm/api/traversing.d.ts.map +1 -0
  165. package/dist/esm/api/traversing.js +857 -0
  166. package/dist/esm/api/traversing.js.map +1 -0
  167. package/dist/esm/cheerio.d.ts +85 -0
  168. package/dist/esm/cheerio.d.ts.map +1 -0
  169. package/dist/esm/cheerio.js +58 -0
  170. package/dist/esm/cheerio.js.map +1 -0
  171. package/dist/esm/index.d.ts +104 -0
  172. package/dist/esm/index.d.ts.map +1 -0
  173. package/dist/esm/index.js +202 -0
  174. package/dist/esm/index.js.map +1 -0
  175. package/dist/esm/load-parse.d.ts +20 -0
  176. package/dist/esm/load-parse.d.ts.map +1 -0
  177. package/dist/esm/load-parse.js +28 -0
  178. package/dist/esm/load-parse.js.map +1 -0
  179. package/dist/esm/load.d.ts +91 -0
  180. package/dist/esm/load.d.ts.map +1 -0
  181. package/dist/esm/load.js +129 -0
  182. package/dist/esm/load.js.map +1 -0
  183. package/dist/esm/options.d.ts +98 -0
  184. package/dist/esm/options.d.ts.map +1 -0
  185. package/dist/esm/options.js +34 -0
  186. package/dist/esm/options.js.map +1 -0
  187. package/dist/esm/package.json +3 -0
  188. package/dist/esm/parse.d.ts +18 -0
  189. package/dist/esm/parse.d.ts.map +1 -0
  190. package/dist/esm/parse.js +73 -0
  191. package/dist/esm/parse.js.map +1 -0
  192. package/dist/esm/parsers/parse5-adapter.d.ts +20 -0
  193. package/dist/esm/parsers/parse5-adapter.d.ts.map +1 -0
  194. package/dist/esm/parsers/parse5-adapter.js +50 -0
  195. package/dist/esm/parsers/parse5-adapter.js.map +1 -0
  196. package/dist/esm/slim.d.ts +25 -0
  197. package/dist/esm/slim.d.ts.map +1 -0
  198. package/dist/esm/slim.js +22 -0
  199. package/dist/esm/slim.js.map +1 -0
  200. package/dist/esm/static.d.ts +112 -0
  201. package/dist/esm/static.d.ts.map +1 -0
  202. package/dist/esm/static.js +204 -0
  203. package/dist/esm/static.js.map +1 -0
  204. package/dist/esm/types.d.ts +21 -0
  205. package/dist/esm/types.d.ts.map +1 -0
  206. package/dist/esm/types.js +3 -0
  207. package/dist/esm/types.js.map +1 -0
  208. package/dist/esm/utils.d.ts +55 -0
  209. package/dist/esm/utils.d.ts.map +1 -0
  210. package/dist/esm/utils.js +84 -0
  211. package/dist/esm/utils.js.map +1 -0
  212. package/package.json +219 -0
  213. package/src/api/attributes.ts +1145 -0
  214. package/src/api/css.ts +224 -0
  215. package/src/api/extract.ts +92 -0
  216. package/src/api/forms.ts +103 -0
  217. package/src/api/manipulation.ts +1115 -0
  218. package/src/api/traversing.ts +1175 -0
  219. package/src/cheerio.ts +143 -0
  220. package/src/index-browser.mts +10 -0
  221. package/src/index.ts +294 -0
  222. package/src/load-parse.ts +39 -0
  223. package/src/load.ts +282 -0
  224. package/src/options.ts +136 -0
  225. package/src/parse.ts +105 -0
  226. package/src/parsers/parse5-adapter.ts +66 -0
  227. package/src/slim.ts +33 -0
  228. package/src/static.ts +312 -0
  229. package/src/types.ts +58 -0
  230. package/src/utils.ts +99 -0
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.load = exports.merge = exports.contains = void 0;
7
+ /**
8
+ * @file Alternative entry point for Cheerio that always uses htmlparser2. This
9
+ * way, parse5 won't be loaded, saving some memory.
10
+ */
11
+ const load_js_1 = require("./load.js");
12
+ const parse_js_1 = require("./parse.js");
13
+ const dom_serializer_1 = __importDefault(require("dom-serializer"));
14
+ const htmlparser2_1 = require("htmlparser2");
15
+ var static_js_1 = require("./static.js");
16
+ Object.defineProperty(exports, "contains", { enumerable: true, get: function () { return static_js_1.contains; } });
17
+ Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return static_js_1.merge; } });
18
+ /**
19
+ * Create a querying function, bound to a document created from the provided
20
+ * markup.
21
+ *
22
+ * @param content - Markup to be loaded.
23
+ * @param options - Options for the created instance.
24
+ * @param isDocument - Always `false` here, as we are always using
25
+ * `htmlparser2`.
26
+ * @returns The loaded document.
27
+ * @see {@link https://cheerio.js.org#loading} for additional usage information.
28
+ */
29
+ exports.load = (0, load_js_1.getLoad)((0, parse_js_1.getParse)(htmlparser2_1.parseDocument), dom_serializer_1.default);
30
+ //# sourceMappingURL=slim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slim.js","sourceRoot":"","sources":["../../src/slim.ts"],"names":[],"mappings":";;;;;;AAAA;;;GAGG;AACH,uCAAqD;AAErD,yCAAsC;AAEtC,oEAAoC;AACpC,6CAA4C;AAE5C,yCAA8C;AAArC,qGAAA,QAAQ,OAAA;AAAE,kGAAA,KAAK,OAAA;AAMxB;;;;;;;;;;GAUG;AACU,QAAA,IAAI,GAIC,IAAA,iBAAO,EAAC,IAAA,mBAAQ,EAAC,2BAAa,CAAC,EAAE,wBAAM,CAAC,CAAC"}
@@ -0,0 +1,112 @@
1
+ import type { BasicAcceptedElems } from './types.js';
2
+ import type { CheerioAPI } from './load.js';
3
+ import type { Cheerio } from './cheerio.js';
4
+ import type { AnyNode, Document } from 'domhandler';
5
+ import { type CheerioOptions } from './options.js';
6
+ import type { ExtractedMap, ExtractMap } from './api/extract.js';
7
+ /**
8
+ * Renders the document.
9
+ *
10
+ * @category Static
11
+ * @param options - Options for the renderer.
12
+ * @returns The rendered document.
13
+ */
14
+ export declare function html(this: CheerioAPI, options?: CheerioOptions): string;
15
+ /**
16
+ * Renders the document.
17
+ *
18
+ * @category Static
19
+ * @param dom - Element to render.
20
+ * @param options - Options for the renderer.
21
+ * @returns The rendered document.
22
+ */
23
+ export declare function html(this: CheerioAPI, dom?: BasicAcceptedElems<AnyNode>, options?: CheerioOptions): string;
24
+ /**
25
+ * Render the document as XML.
26
+ *
27
+ * @category Static
28
+ * @param dom - Element to render.
29
+ * @returns THe rendered document.
30
+ */
31
+ export declare function xml(this: CheerioAPI, dom?: BasicAcceptedElems<AnyNode>): string;
32
+ /**
33
+ * Render the document as text.
34
+ *
35
+ * This returns the `textContent` of the passed elements. The result will
36
+ * include the contents of `<script>` and `<style>` elements. To avoid this, use
37
+ * `.prop('innerText')` instead.
38
+ *
39
+ * @category Static
40
+ * @param elements - Elements to render.
41
+ * @returns The rendered document.
42
+ */
43
+ export declare function text(this: CheerioAPI | void, elements?: ArrayLike<AnyNode>): string;
44
+ /**
45
+ * Parses a string into an array of DOM nodes. The `context` argument has no
46
+ * meaning for Cheerio, but it is maintained for API compatibility with jQuery.
47
+ *
48
+ * @category Static
49
+ * @param data - Markup that will be parsed.
50
+ * @param context - Will be ignored. If it is a boolean it will be used as the
51
+ * value of `keepScripts`.
52
+ * @param keepScripts - If false all scripts will be removed.
53
+ * @returns The parsed DOM.
54
+ * @alias Cheerio.parseHTML
55
+ * @see {@link https://api.jquery.com/jQuery.parseHTML/}
56
+ */
57
+ export declare function parseHTML(this: CheerioAPI, data: string, context?: unknown, keepScripts?: boolean): AnyNode[];
58
+ export declare function parseHTML(this: CheerioAPI, data?: '' | null): null;
59
+ /**
60
+ * Sometimes you need to work with the top-level root element. To query it, you
61
+ * can use `$.root()`.
62
+ *
63
+ * @category Static
64
+ * @example
65
+ *
66
+ * ```js
67
+ * $.root().append('<ul id="vegetables"></ul>').html();
68
+ * //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
69
+ * ```
70
+ *
71
+ * @returns Cheerio instance wrapping the root node.
72
+ * @alias Cheerio.root
73
+ */
74
+ export declare function root(this: CheerioAPI): Cheerio<Document>;
75
+ /**
76
+ * Checks to see if the `contained` DOM element is a descendant of the
77
+ * `container` DOM element.
78
+ *
79
+ * @category Static
80
+ * @param container - Potential parent node.
81
+ * @param contained - Potential child node.
82
+ * @returns Indicates if the nodes contain one another.
83
+ * @alias Cheerio.contains
84
+ * @see {@link https://api.jquery.com/jQuery.contains/}
85
+ */
86
+ export declare function contains(container: AnyNode, contained: AnyNode): boolean;
87
+ /**
88
+ * Extract multiple values from a document, and store them in an object.
89
+ *
90
+ * @category Static
91
+ * @param map - An object containing key-value pairs. The keys are the names of
92
+ * the properties to be created on the object, and the values are the
93
+ * selectors to be used to extract the values.
94
+ * @returns An object containing the extracted values.
95
+ */
96
+ export declare function extract<M extends ExtractMap>(this: CheerioAPI, map: M): ExtractedMap<M>;
97
+ type Writable<T> = {
98
+ -readonly [P in keyof T]: T[P];
99
+ };
100
+ /**
101
+ * $.merge().
102
+ *
103
+ * @category Static
104
+ * @param arr1 - First array.
105
+ * @param arr2 - Second array.
106
+ * @returns `arr1`, with elements of `arr2` inserted.
107
+ * @alias Cheerio.merge
108
+ * @see {@link https://api.jquery.com/jQuery.merge/}
109
+ */
110
+ export declare function merge<T>(arr1: Writable<ArrayLike<T>>, arr2: ArrayLike<T>): ArrayLike<T> | undefined;
111
+ export {};
112
+ //# sourceMappingURL=static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAwCjE;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,E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AC,CAAC;CAAE,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC5B,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GACjB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAY1B"}
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.html = html;
4
+ exports.xml = xml;
5
+ exports.text = text;
6
+ exports.parseHTML = parseHTML;
7
+ exports.root = root;
8
+ exports.contains = contains;
9
+ exports.extract = extract;
10
+ exports.merge = merge;
11
+ const domutils_1 = require("domutils");
12
+ const options_js_1 = require("./options.js");
13
+ /**
14
+ * Helper function to render a DOM.
15
+ *
16
+ * @param that - Cheerio instance to render.
17
+ * @param dom - The DOM to render. Defaults to `that`'s root.
18
+ * @param options - Options for rendering.
19
+ * @returns The rendered document.
20
+ */
21
+ function render(that, dom, options) {
22
+ if (!that)
23
+ return '';
24
+ return that(dom !== null && dom !== void 0 ? dom : that._root.children, null, undefined, options).toString();
25
+ }
26
+ /**
27
+ * Checks if a passed object is an options object.
28
+ *
29
+ * @param dom - Object to check if it is an options object.
30
+ * @param options - Options object.
31
+ * @returns Whether the object is an options object.
32
+ */
33
+ function isOptions(dom, options) {
34
+ return (!options &&
35
+ typeof dom === 'object' &&
36
+ dom != null &&
37
+ !('length' in dom) &&
38
+ !('type' in dom));
39
+ }
40
+ function html(dom, options) {
41
+ /*
42
+ * Be flexible about parameters, sometimes we call html(),
43
+ * with options as only parameter
44
+ * check dom argument for dom element specific properties
45
+ * assume there is no 'length' or 'type' properties in the options object
46
+ */
47
+ const toRender = isOptions(dom) ? ((options = dom), undefined) : dom;
48
+ /*
49
+ * Sometimes `$.html()` is used without preloading html,
50
+ * so fallback non-existing options to the default ones.
51
+ */
52
+ const opts = {
53
+ ...this === null || this === void 0 ? void 0 : this._options,
54
+ ...(0, options_js_1.flattenOptions)(options),
55
+ };
56
+ return render(this, toRender, opts);
57
+ }
58
+ /**
59
+ * Render the document as XML.
60
+ *
61
+ * @category Static
62
+ * @param dom - Element to render.
63
+ * @returns THe rendered document.
64
+ */
65
+ function xml(dom) {
66
+ const options = { ...this._options, xmlMode: true };
67
+ return render(this, dom, options);
68
+ }
69
+ /**
70
+ * Render the document as text.
71
+ *
72
+ * This returns the `textContent` of the passed elements. The result will
73
+ * include the contents of `<script>` and `<style>` elements. To avoid this, use
74
+ * `.prop('innerText')` instead.
75
+ *
76
+ * @category Static
77
+ * @param elements - Elements to render.
78
+ * @returns The rendered document.
79
+ */
80
+ function text(elements) {
81
+ const elems = elements !== null && elements !== void 0 ? elements : (this ? this.root() : []);
82
+ let ret = '';
83
+ for (let i = 0; i < elems.length; i++) {
84
+ ret += (0, domutils_1.textContent)(elems[i]);
85
+ }
86
+ return ret;
87
+ }
88
+ function parseHTML(data, context, keepScripts = typeof context === 'boolean' ? context : false) {
89
+ if (!data || typeof data !== 'string') {
90
+ return null;
91
+ }
92
+ if (typeof context === 'boolean') {
93
+ keepScripts = context;
94
+ }
95
+ const parsed = this.load(data, this._options, false);
96
+ if (!keepScripts) {
97
+ parsed('script').remove();
98
+ }
99
+ /*
100
+ * The `children` array is used by Cheerio internally to group elements that
101
+ * share the same parents. When nodes created through `parseHTML` are
102
+ * inserted into previously-existing DOM structures, they will be removed
103
+ * from the `children` array. The results of `parseHTML` should remain
104
+ * constant across these operations, so a shallow copy should be returned.
105
+ */
106
+ return [...parsed.root()[0].children];
107
+ }
108
+ /**
109
+ * Sometimes you need to work with the top-level root element. To query it, you
110
+ * can use `$.root()`.
111
+ *
112
+ * @category Static
113
+ * @example
114
+ *
115
+ * ```js
116
+ * $.root().append('<ul id="vegetables"></ul>').html();
117
+ * //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
118
+ * ```
119
+ *
120
+ * @returns Cheerio instance wrapping the root node.
121
+ * @alias Cheerio.root
122
+ */
123
+ function root() {
124
+ return this(this._root);
125
+ }
126
+ /**
127
+ * Checks to see if the `contained` DOM element is a descendant of the
128
+ * `container` DOM element.
129
+ *
130
+ * @category Static
131
+ * @param container - Potential parent node.
132
+ * @param contained - Potential child node.
133
+ * @returns Indicates if the nodes contain one another.
134
+ * @alias Cheerio.contains
135
+ * @see {@link https://api.jquery.com/jQuery.contains/}
136
+ */
137
+ function contains(container, contained) {
138
+ // According to the jQuery API, an element does not "contain" itself
139
+ if (contained === container) {
140
+ return false;
141
+ }
142
+ /*
143
+ * Step up the descendants, stopping when the root element is reached
144
+ * (signaled by `.parent` returning a reference to the same object)
145
+ */
146
+ let next = contained;
147
+ while (next && next !== next.parent) {
148
+ next = next.parent;
149
+ if (next === container) {
150
+ return true;
151
+ }
152
+ }
153
+ return false;
154
+ }
155
+ /**
156
+ * Extract multiple values from a document, and store them in an object.
157
+ *
158
+ * @category Static
159
+ * @param map - An object containing key-value pairs. The keys are the names of
160
+ * the properties to be created on the object, and the values are the
161
+ * selectors to be used to extract the values.
162
+ * @returns An object containing the extracted values.
163
+ */
164
+ function extract(map) {
165
+ return this.root().extract(map);
166
+ }
167
+ /**
168
+ * $.merge().
169
+ *
170
+ * @category Static
171
+ * @param arr1 - First array.
172
+ * @param arr2 - Second array.
173
+ * @returns `arr1`, with elements of `arr2` inserted.
174
+ * @alias Cheerio.merge
175
+ * @see {@link https://api.jquery.com/jQuery.merge/}
176
+ */
177
+ function merge(arr1, arr2) {
178
+ if (!isArrayLike(arr1) || !isArrayLike(arr2)) {
179
+ return;
180
+ }
181
+ let newLength = arr1.length;
182
+ const len = +arr2.length;
183
+ for (let i = 0; i < len; i++) {
184
+ arr1[newLength++] = arr2[i];
185
+ }
186
+ arr1.length = newLength;
187
+ return arr1;
188
+ }
189
+ /**
190
+ * Checks if an object is array-like.
191
+ *
192
+ * @category Static
193
+ * @param item - Item to check.
194
+ * @returns Indicates if the item is array-like.
195
+ */
196
+ function isArrayLike(item) {
197
+ if (Array.isArray(item)) {
198
+ return true;
199
+ }
200
+ if (typeof item !== 'object' ||
201
+ item === null ||
202
+ !('length' in item) ||
203
+ typeof item.length !== 'number' ||
204
+ item.length < 0) {
205
+ return false;
206
+ }
207
+ for (let i = 0; i < item.length; i++) {
208
+ if (!(i in item)) {
209
+ return false;
210
+ }
211
+ }
212
+ return true;
213
+ }
214
+ //# sourceMappingURL=static.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.js","sourceRoot":"","sources":["../../src/static.ts"],"names":[],"mappings":";;AAuEA,oBAuBC;AASD,kBAOC;AAaD,oBAaC;AAsBD,8BA2BC;AAiBD,oBAEC;AAaD,4BAmBC;AAWD,0BAKC;AAcD,sBAeC;AArRD,uCAAuC;AACvC,6CAIsB;AAGtB;;;;;;;GAOG;AACH,SAAS,MAAM,CACb,IAAgB,EAChB,GAA4C,EAC5C,OAAwB;IAExB,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,OAAO,IAAI,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/E,CAAC;AAED;;;;;;GAMG;AACH,SAAS,SAAS,CAChB,GAAyD,EACzD,OAAwB;IAExB,OAAO,CACL,CAAC,OAAO;QACR,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,IAAI,IAAI;QACX,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC;QAClB,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CACjB,CAAC;AACJ,CAAC;AAuBD,SAAgB,IAAI,CAElB,GAAkD,EAClD,OAAwB;IAExB;;;;;OAKG;IACH,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC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G,IAAI,CAAC,MAAM,CAAC;IAC5B,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;IAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC;QACnB,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ;QAC/B,IAAI,CAAC,MAAM,GAAG,CAAC,EACf,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** @file Types used in signatures of Cheerio methods. */
2
+ type LowercaseLetters = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
3
+ type AlphaNumeric = LowercaseLetters | Uppercase<LowercaseLetters> | `${number}`;
4
+ type SelectorSpecial = '.' | '#' | ':' | '|' | '>' | '+' | '~' | '[';
5
+ /**
6
+ * Type for identifying selectors. Allows us to "upgrade" queries using
7
+ * selectors to return `Element`s.
8
+ */
9
+ export type SelectorType = `${SelectorSpecial}${AlphaNumeric}${string}` | `${AlphaNumeric}${string}`;
10
+ import type { Cheerio } from './cheerio.js';
11
+ import type { AnyNode } from 'domhandler';
12
+ /** Elements that can be passed to manipulation methods. */
13
+ export type BasicAcceptedElems<T extends AnyNode> = ArrayLike<T> | T | string;
14
+ /** Elements that can be passed to manipulation methods, including functions. */
15
+ export type AcceptedElems<T extends AnyNode> = BasicAcceptedElems<T> | ((this: T, i: number, el: T) => BasicAcceptedElems<T>);
16
+ /** Function signature, for traversal methods. */
17
+ export type FilterFunction<T> = (this: T, i: number, el: T) => boolean;
18
+ /** Supported filter types, for traversal methods. */
19
+ export type AcceptedFilters<T> = string | FilterFunction<T> | T | Cheerio<T>;
20
+ export {};
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD,KAAK,gBAAgB,GACjB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAER,KAAK,YAAY,GACb,gBAAgB,GAChB,SAAS,CAAC,gBAAgB,CAAC,GAC3B,GAAG,MAAM,EAAE,CAAC;AAEhB,KAAK,eAAe,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACrE;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,EAAE,GAC5C,GAAG,YAAY,GAAG,MAAM,EAAE,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;AAC9E,gFAAgF;AAChF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,OAAO,IACvC,kBAAkB,CAAC,CAAC,CAAC,GACrB,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,iDAAiD;AACjD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC;AACvE,qDAAqD;AACrD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /** @file Types used in signatures of Cheerio methods. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,yDAAyD"}
@@ -0,0 +1,55 @@
1
+ import type { AnyNode } from 'domhandler';
2
+ import type { Cheerio } from './cheerio.js';
3
+ /**
4
+ * Checks if an object is a Cheerio instance.
5
+ *
6
+ * @category Utils
7
+ * @param maybeCheerio - The object to check.
8
+ * @returns Whether the object is a Cheerio instance.
9
+ */
10
+ export declare function isCheerio<T>(maybeCheerio: unknown): maybeCheerio is Cheerio<T>;
11
+ /**
12
+ * Convert a string to camel case notation.
13
+ *
14
+ * @private
15
+ * @category Utils
16
+ * @param str - The string to be converted.
17
+ * @returns String in camel case notation.
18
+ */
19
+ export declare function camelCase(str: string): string;
20
+ /**
21
+ * Convert a string from camel case to "CSS case", where word boundaries are
22
+ * described by hyphens ("-") and all characters are lower-case.
23
+ *
24
+ * @private
25
+ * @category Utils
26
+ * @param str - The string to be converted.
27
+ * @returns String in "CSS case".
28
+ */
29
+ export declare function cssCase(str: string): string;
30
+ /**
31
+ * Iterate over each DOM element without creating intermediary Cheerio
32
+ * instances.
33
+ *
34
+ * This is indented for use internally to avoid otherwise unnecessary memory
35
+ * pressure introduced by _make.
36
+ *
37
+ * @category Utils
38
+ * @param array - The array to iterate over.
39
+ * @param fn - Function to call.
40
+ * @returns The original instance.
41
+ */
42
+ export declare function domEach<T extends AnyNode, Arr extends ArrayLike<T> = Cheerio<T>>(array: Arr, fn: (elem: T, index: number) => void): Arr;
43
+ /**
44
+ * Check if string is HTML.
45
+ *
46
+ * Tests for a `<` within a string, immediate followed by a letter and
47
+ * eventually followed by a `>`.
48
+ *
49
+ * @private
50
+ * @category Utils
51
+ * @param str - The string to check.
52
+ * @returns Indicates if `str` is HTML.
53
+ */
54
+ export declare function isHtml(str: string): boolean;
55
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC,CAE5B;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CACrB,CAAC,SAAS,OAAO,EACjB,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACrC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,GAAG,CAIvD;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAiB3C"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isCheerio = isCheerio;
4
+ exports.camelCase = camelCase;
5
+ exports.cssCase = cssCase;
6
+ exports.domEach = domEach;
7
+ exports.isHtml = isHtml;
8
+ /**
9
+ * Checks if an object is a Cheerio instance.
10
+ *
11
+ * @category Utils
12
+ * @param maybeCheerio - The object to check.
13
+ * @returns Whether the object is a Cheerio instance.
14
+ */
15
+ function isCheerio(maybeCheerio) {
16
+ return maybeCheerio.cheerio != null;
17
+ }
18
+ /**
19
+ * Convert a string to camel case notation.
20
+ *
21
+ * @private
22
+ * @category Utils
23
+ * @param str - The string to be converted.
24
+ * @returns String in camel case notation.
25
+ */
26
+ function camelCase(str) {
27
+ return str.replace(/[._-](\w|$)/g, (_, x) => x.toUpperCase());
28
+ }
29
+ /**
30
+ * Convert a string from camel case to "CSS case", where word boundaries are
31
+ * described by hyphens ("-") and all characters are lower-case.
32
+ *
33
+ * @private
34
+ * @category Utils
35
+ * @param str - The string to be converted.
36
+ * @returns String in "CSS case".
37
+ */
38
+ function cssCase(str) {
39
+ return str.replace(/[A-Z]/g, '-$&').toLowerCase();
40
+ }
41
+ /**
42
+ * Iterate over each DOM element without creating intermediary Cheerio
43
+ * instances.
44
+ *
45
+ * This is indented for use internally to avoid otherwise unnecessary memory
46
+ * pressure introduced by _make.
47
+ *
48
+ * @category Utils
49
+ * @param array - The array to iterate over.
50
+ * @param fn - Function to call.
51
+ * @returns The original instance.
52
+ */
53
+ function domEach(array, fn) {
54
+ const len = array.length;
55
+ for (let i = 0; i < len; i++)
56
+ fn(array[i], i);
57
+ return array;
58
+ }
59
+ var CharacterCode;
60
+ (function (CharacterCode) {
61
+ CharacterCode[CharacterCode["LowerA"] = 97] = "LowerA";
62
+ CharacterCode[CharacterCode["LowerZ"] = 122] = "LowerZ";
63
+ CharacterCode[CharacterCode["UpperA"] = 65] = "UpperA";
64
+ CharacterCode[CharacterCode["UpperZ"] = 90] = "UpperZ";
65
+ CharacterCode[CharacterCode["Exclamation"] = 33] = "Exclamation";
66
+ })(CharacterCode || (CharacterCode = {}));
67
+ /**
68
+ * Check if string is HTML.
69
+ *
70
+ * Tests for a `<` within a string, immediate followed by a letter and
71
+ * eventually followed by a `>`.
72
+ *
73
+ * @private
74
+ * @category Utils
75
+ * @param str - The string to check.
76
+ * @returns Indicates if `str` is HTML.
77
+ */
78
+ function isHtml(str) {
79
+ if (typeof str !== 'string') {
80
+ return false;
81
+ }
82
+ const tagStart = str.indexOf('<');
83
+ if (tagStart === -1 || tagStart > str.length - 3)
84
+ return false;
85
+ const tagChar = str.charCodeAt(tagStart + 1);
86
+ return (((tagChar >= CharacterCode.LowerA && tagChar <= CharacterCode.LowerZ) ||
87
+ (tagChar >= CharacterCode.UpperA && tagChar <= CharacterCode.UpperZ) ||
88
+ tagChar === CharacterCode.Exclamation) &&
89
+ str.includes('>', tagStart + 2));
90
+ }
91
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[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