rusteerio 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +73 -0
- package/Cargo.lock +1051 -0
- package/Cargo.toml +36 -0
- package/LICENSE +21 -0
- package/README.md +252 -2
- package/RELEASING.md +138 -0
- package/THIRD_PARTY_NOTICES.md +7443 -0
- package/build.rs +3 -0
- package/dist/chunk-DKULX6VO.mjs +3185 -0
- package/dist/chunk-DKULX6VO.mjs.map +1 -0
- package/dist/chunk-OHPGEY3E.mjs +32 -0
- package/dist/chunk-OHPGEY3E.mjs.map +1 -0
- package/dist/index.cjs +3230 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.mjs +38 -0
- package/dist/index.mjs.map +1 -0
- package/dist/slim.cjs +2441 -0
- package/dist/slim.cjs.map +1 -0
- package/dist/slim.d.mts +11 -0
- package/dist/slim.d.ts +11 -0
- package/dist/slim.mjs +19 -0
- package/dist/slim.mjs.map +1 -0
- package/dist/types-BP6TpxE5.d.mts +532 -0
- package/dist/types-BP6TpxE5.d.ts +532 -0
- package/dist/utils.cjs +61 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.mts +13 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.mjs +17 -0
- package/dist/utils.mjs.map +1 -0
- package/native/src/arena.rs +1781 -0
- package/native/src/attributes.rs +923 -0
- package/native/src/codec.rs +172 -0
- package/native/src/diagnostics.rs +1249 -0
- package/native/src/extraction.rs +226 -0
- package/native/src/gc.rs +166 -0
- package/native/src/hook_sink.rs +727 -0
- package/native/src/hook_stream.rs +513 -0
- package/native/src/lib.rs +2095 -0
- package/native/src/location.rs +392 -0
- package/native/src/runtime.rs +189 -0
- package/native/src/selector.rs +1287 -0
- package/native/src/sink.rs +261 -0
- package/native/src/stream.rs +334 -0
- package/native/src/tokenizer.rs +355 -0
- package/native/src/tracker.rs +232 -0
- package/native/vendor/README.md +25 -0
- package/native/vendor/html5ever-0.35.0/.cargo_vcs_info.json +6 -0
- package/native/vendor/html5ever-0.35.0/Cargo.lock +828 -0
- package/native/vendor/html5ever-0.35.0/Cargo.toml +85 -0
- package/native/vendor/html5ever-0.35.0/LICENSE-APACHE +201 -0
- package/native/vendor/html5ever-0.35.0/LICENSE-MIT +25 -0
- package/native/vendor/html5ever-0.35.0/README.md +60 -0
- package/native/vendor/html5ever-0.35.0/benches/html5ever.rs +86 -0
- package/native/vendor/html5ever-0.35.0/data/bench/lipsum-zh.html +19 -0
- package/native/vendor/html5ever-0.35.0/data/bench/lipsum.html +40 -0
- package/native/vendor/html5ever-0.35.0/data/bench/medium-fragment.html +24 -0
- package/native/vendor/html5ever-0.35.0/data/bench/small-fragment.html +7 -0
- package/native/vendor/html5ever-0.35.0/data/bench/strong.html +1 -0
- package/native/vendor/html5ever-0.35.0/data/bench/tiny-fragment.html +1 -0
- package/native/vendor/html5ever-0.35.0/examples/arena.rs +356 -0
- package/native/vendor/html5ever-0.35.0/examples/capi/tokenize.c +74 -0
- package/native/vendor/html5ever-0.35.0/examples/noop-tokenize.rs +47 -0
- package/native/vendor/html5ever-0.35.0/examples/noop-tree-builder.rs +132 -0
- package/native/vendor/html5ever-0.35.0/examples/print-tree-actions.rs +185 -0
- package/native/vendor/html5ever-0.35.0/examples/tokenize.rs +111 -0
- package/native/vendor/html5ever-0.35.0/src/driver.rs +148 -0
- package/native/vendor/html5ever-0.35.0/src/lib.rs +30 -0
- package/native/vendor/html5ever-0.35.0/src/macros.rs +34 -0
- package/native/vendor/html5ever-0.35.0/src/serialize/mod.rs +255 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/char_ref/mod.rs +451 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/interface.rs +99 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/mod.rs +2305 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/states.rs +97 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/data.rs +170 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/mod.rs +1848 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/rules.rs +1494 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/tag_sets.rs +114 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/types.rs +91 -0
- package/native/vendor/html5ever-0.35.0/src/util/str.rs +52 -0
- package/native/vendor/html5gum-0.8.4/Cargo.lock +1006 -0
- package/native/vendor/html5gum-0.8.4/Cargo.toml +109 -0
- package/native/vendor/html5gum-0.8.4/LICENSE +19 -0
- package/native/vendor/html5gum-0.8.4/README.md +110 -0
- package/native/vendor/html5gum-0.8.4/benches/files/0050.html +2131 -0
- package/native/vendor/html5gum-0.8.4/benches/files/6D30.html +1004 -0
- package/native/vendor/html5gum-0.8.4/benches/files.rs +32 -0
- package/native/vendor/html5gum-0.8.4/benches/patterns.rs +31 -0
- package/native/vendor/html5gum-0.8.4/src/arrayvec.rs +29 -0
- package/native/vendor/html5gum-0.8.4/src/char_validator.rs +134 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/callback.rs +676 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/default.rs +207 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/emitter.rs +344 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/html5ever.rs +306 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/mod.rs +25 -0
- package/native/vendor/html5gum-0.8.4/src/entities.rs +3342 -0
- package/native/vendor/html5gum-0.8.4/src/error.rs +96 -0
- package/native/vendor/html5gum-0.8.4/src/htmlstring.rs +130 -0
- package/native/vendor/html5gum-0.8.4/src/lib.rs +66 -0
- package/native/vendor/html5gum-0.8.4/src/machine.rs +2136 -0
- package/native/vendor/html5gum-0.8.4/src/machine_helper.rs +277 -0
- package/native/vendor/html5gum-0.8.4/src/read_helper.rs +244 -0
- package/native/vendor/html5gum-0.8.4/src/reader.rs +440 -0
- package/native/vendor/html5gum-0.8.4/src/span.rs +98 -0
- package/native/vendor/html5gum-0.8.4/src/state.rs +16 -0
- package/native/vendor/html5gum-0.8.4/src/testutils.rs +71 -0
- package/native/vendor/html5gum-0.8.4/src/tokenizer.rs +189 -0
- package/native/vendor/html5gum-0.8.4/src/utils.rs +88 -0
- package/native/vendor/markup5ever-0.35.0/.cargo_vcs_info.json +6 -0
- package/native/vendor/markup5ever-0.35.0/Cargo.toml +45 -0
- package/native/vendor/markup5ever-0.35.0/LICENSE-APACHE +201 -0
- package/native/vendor/markup5ever-0.35.0/LICENSE-MIT +25 -0
- package/native/vendor/markup5ever-0.35.0/interface/mod.rs +422 -0
- package/native/vendor/markup5ever-0.35.0/interface/tree_builder.rs +280 -0
- package/native/vendor/markup5ever-0.35.0/lib.rs +59 -0
- package/native/vendor/markup5ever-0.35.0/serialize.rs +77 -0
- package/native/vendor/markup5ever-0.35.0/util/buffer_queue.rs +333 -0
- package/native/vendor/markup5ever-0.35.0/util/smallcharset.rs +88 -0
- package/package.json +137 -4
- package/rusteerio.darwin-arm64.node +0 -0
- package/rusteerio.darwin-x64.node +0 -0
- package/rusteerio.linux-arm64-gnu.node +0 -0
- package/rusteerio.linux-arm64-musl.node +0 -0
- package/rusteerio.linux-x64-gnu.node +0 -0
- package/rusteerio.linux-x64-musl.node +0 -0
- package/rusteerio.win32-arm64-msvc.node +0 -0
- package/rusteerio.win32-x64-msvc.node +0 -0
- package/scripts/check-native.mjs +15 -0
- package/scripts/check-release.mjs +235 -0
- package/scripts/fix-declarations.mjs +27 -0
- package/scripts/generate-notices.mjs +176 -0
- package/scripts/notices/README.md +13 -0
- package/scripts/notices/cheerio-MIT.txt +21 -0
- package/scripts/notices/html5ever-AUTHORS.txt +20 -0
- package/scripts/notices/html5ever-COPYRIGHT.txt +8 -0
- package/scripts/notices/html5ever-LICENSE-APACHE.txt +201 -0
- package/scripts/notices/html5ever-LICENSE-MIT.txt +25 -0
- package/scripts/notices/napi-rs-MIT.txt +43 -0
- package/scripts/notices/neon-MIT.txt +19 -0
- package/scripts/notices/runtime-01c266bced4a434da005.txt +3 -0
- package/scripts/notices/runtime-0a54e647fe54104658b5.txt +14 -0
- package/scripts/notices/runtime-0b74dfa0bcee5c420c6b.txt +25 -0
- package/scripts/notices/runtime-0d542e0c8804e39aa7f3.txt +177 -0
- package/scripts/notices/runtime-0f96a83840e146e43c0e.txt +21 -0
- package/scripts/notices/runtime-123a331b5dbf04c30097.txt +25 -0
- package/scripts/notices/runtime-172020dbfd5b53a226df.txt +34 -0
- package/scripts/notices/runtime-209fbbe0ad52d9235e37.txt +26 -0
- package/scripts/notices/runtime-23f18e03dc49df91622f.txt +23 -0
- package/scripts/notices/runtime-268872b9816f90fd8e85.txt +220 -0
- package/scripts/notices/runtime-35242e7a83f69875e6ed.txt +176 -0
- package/scripts/notices/runtime-378f5840b258e2779c39.txt +25 -0
- package/scripts/notices/runtime-4108245a1f2df9d4e94d.txt +25 -0
- package/scripts/notices/runtime-4455bf75a91154108304.txt +21 -0
- package/scripts/notices/runtime-553fffcd9b1cb158bc3e.txt +13 -0
- package/scripts/notices/runtime-62c7a1e35f56406896d7.txt +176 -0
- package/scripts/notices/runtime-6485b8ed310d3f0340bf.txt +25 -0
- package/scripts/notices/runtime-69fef7b0f322a6555415.txt +201 -0
- package/scripts/notices/runtime-6df43f6f4b5d4587f3d8.txt +187 -0
- package/scripts/notices/runtime-799e9ca9d179295ef372.txt +24 -0
- package/scripts/notices/runtime-7b63ecd5f1902af1b637.txt +25 -0
- package/scripts/notices/runtime-7bc7d5de2a0b793d4e1a.txt +21 -0
- package/scripts/notices/runtime-7e12e5df4bae12cb2158.txt +24 -0
- package/scripts/notices/runtime-861399f8c21c042b1105.txt +12 -0
- package/scripts/notices/runtime-8ada45cd9f843acf64e4.txt +201 -0
- package/scripts/notices/runtime-90eb64f0279b0d9432ac.txt +12 -0
- package/scripts/notices/runtime-a60eea817514531668d7.txt +201 -0
- package/scripts/notices/runtime-a7c936ff1ed8fa340172.txt +25 -0
- package/scripts/notices/runtime-ab6eec6caf0fa5775e41.txt +275 -0
- package/scripts/notices/runtime-b1181a40b2a7b25cf66f.txt +19 -0
- package/scripts/notices/runtime-b71bd43a069ca0641a9e.txt +25 -0
- package/scripts/notices/runtime-c16f8dcf1a368b83be78.txt +201 -0
- package/scripts/notices/runtime-c2cfccb812fe482101a8.txt +21 -0
- package/scripts/notices/runtime-e99d88d232bf57d70f0f.txt +25 -0
- package/scripts/notices/runtime-f32fb3b417a194167cfa.txt +9 -0
- package/scripts/notices/runtime-f5062c9a188d81dfe66b.txt +39 -0
- package/scripts/notices/runtime-f9070a832833fa7488fd.txt +4 -0
- package/scripts/notices/runtime-fab3dd6bdab226f1c086.txt +373 -0
- package/scripts/notices/runtime-fba3318d0c600380177e.txt +62 -0
- package/scripts/notices/runtime-ff8f68cb076caf8cefe7.txt +25 -0
- package/scripts/notices/runtime-ff92bed461f50338dd70.txt +74 -0
- package/scripts/notices/runtime.json +1632 -0
- package/scripts/notices/sources.json +555 -0
- package/scripts/notices/xray-MIT.txt +21 -0
- package/src/attributes.ts +271 -0
- package/src/codec.ts +74 -0
- package/src/dom.ts +87 -0
- package/src/extract-plan.ts +97 -0
- package/src/extract.ts +130 -0
- package/src/hooks.ts +220 -0
- package/src/index.ts +223 -0
- package/src/io.ts +491 -0
- package/src/native.ts +135 -0
- package/src/nodes.ts +290 -0
- package/src/parse.ts +53 -0
- package/src/parser-types.ts +157 -0
- package/src/router.ts +327 -0
- package/src/selection.ts +566 -0
- package/src/slim.ts +12 -0
- package/src/transport.ts +104 -0
- package/src/types.ts +186 -0
- package/src/utils.ts +29 -0
- package/src/workers.ts +21 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +16 -0
package/dist/slim.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { contains, dom, merge } from './index.mjs';
|
|
2
|
+
import { L as LoadContent, C as CheerioOptions, a as CheerioAPI } from './types-BP6TpxE5.mjs';
|
|
3
|
+
export { A as AcceptedElems, b as AcceptedFilters, c as AnyNode, B as BasicAcceptedElems, d as CDATA, type e as Cheerio, f as CheerioRequestOptions, g as ChildNode, h as Comment, D as DataNode, i as DecodeStreamOptions, j as Document, k as DocumentMode, E as Element, type l as ElementType, m as EncodingOptions, n as ExtractDescriptor, o as ExtractMap, p as ExtractedMap, q as ExtractedValue, r as ExtractionDescriptor, s as ExtractionMap, t as ExtractionResult, F as FilterFunction, u as FormDataLike, H as HTMLParser2Options, I as InternalOptions, N as NamespaceURI, v as Node, w as NodeWithChildren, P as ParallelOptions, x as ParentNode, y as ParserError, z as ParserErrorCode, G as ParserErrorHandler, J as ProcessingInstruction, S as SelectorType, K as SerializedField, M as SourceCodeLocation, T as TagSourceCodeLocation, O as Text, Q as Tokenizer, R as TokenizerCallbacks, U as TokenizerConstructor, V as TokenizerOptions, W as TreeAdapter, X as TreeAdapterAttribute } from './types-BP6TpxE5.mjs';
|
|
4
|
+
import 'node:stream';
|
|
5
|
+
import 'node:querystring';
|
|
6
|
+
import 'node:buffer';
|
|
7
|
+
|
|
8
|
+
/** Parser-compatible slim entry point, backed by the native fragment parser. */
|
|
9
|
+
declare function load(content: LoadContent, options?: CheerioOptions | null, _isDocument?: boolean): CheerioAPI;
|
|
10
|
+
|
|
11
|
+
export { CheerioAPI, CheerioOptions, LoadContent, load };
|
package/dist/slim.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { contains, dom, merge } from './index.js';
|
|
2
|
+
import { L as LoadContent, C as CheerioOptions, a as CheerioAPI } from './types-BP6TpxE5.js';
|
|
3
|
+
export { A as AcceptedElems, b as AcceptedFilters, c as AnyNode, B as BasicAcceptedElems, d as CDATA, type e as Cheerio, f as CheerioRequestOptions, g as ChildNode, h as Comment, D as DataNode, i as DecodeStreamOptions, j as Document, k as DocumentMode, E as Element, type l as ElementType, m as EncodingOptions, n as ExtractDescriptor, o as ExtractMap, p as ExtractedMap, q as ExtractedValue, r as ExtractionDescriptor, s as ExtractionMap, t as ExtractionResult, F as FilterFunction, u as FormDataLike, H as HTMLParser2Options, I as InternalOptions, N as NamespaceURI, v as Node, w as NodeWithChildren, P as ParallelOptions, x as ParentNode, y as ParserError, z as ParserErrorCode, G as ParserErrorHandler, J as ProcessingInstruction, S as SelectorType, K as SerializedField, M as SourceCodeLocation, T as TagSourceCodeLocation, O as Text, Q as Tokenizer, R as TokenizerCallbacks, U as TokenizerConstructor, V as TokenizerOptions, W as TreeAdapter, X as TreeAdapterAttribute } from './types-BP6TpxE5.js';
|
|
4
|
+
import 'node:stream';
|
|
5
|
+
import 'node:querystring';
|
|
6
|
+
import 'node:buffer';
|
|
7
|
+
|
|
8
|
+
/** Parser-compatible slim entry point, backed by the native fragment parser. */
|
|
9
|
+
declare function load(content: LoadContent, options?: CheerioOptions | null, _isDocument?: boolean): CheerioAPI;
|
|
10
|
+
|
|
11
|
+
export { CheerioAPI, CheerioOptions, LoadContent, load };
|
package/dist/slim.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
contains,
|
|
3
|
+
dom,
|
|
4
|
+
load,
|
|
5
|
+
merge
|
|
6
|
+
} from "./chunk-DKULX6VO.mjs";
|
|
7
|
+
import "./chunk-OHPGEY3E.mjs";
|
|
8
|
+
|
|
9
|
+
// src/slim.ts
|
|
10
|
+
function load2(content, options, _isDocument) {
|
|
11
|
+
return load(content, { ...options, _useHtmlParser2: true }, false);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
contains,
|
|
15
|
+
dom,
|
|
16
|
+
load2 as load,
|
|
17
|
+
merge
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=slim.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/slim.ts"],"sourcesContent":["import { load as loadNative, contains, merge } from './index.js';\nimport type { CheerioAPI, CheerioOptions, LoadContent } from './types.js';\n\nexport { contains, merge };\nexport { dom } from './index.js';\nexport type * from './types.js';\nexport type { Cheerio } from './selection.js';\n\n/** Parser-compatible slim entry point, backed by the native fragment parser. */\nexport function load(content: LoadContent, options?: CheerioOptions | null, _isDocument?: boolean): CheerioAPI {\n return loadNative(content, { ...options, _useHtmlParser2: true }, false);\n}\n"],"mappings":";;;;;;;;;AASO,SAASA,MAAK,SAAsB,SAAiC,aAAmC;AAC7G,SAAO,KAAW,SAAS,EAAE,GAAG,SAAS,iBAAiB,KAAK,GAAG,KAAK;AACzE;","names":["load"]}
|
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import * as node_querystring from 'node:querystring';
|
|
2
|
+
import * as node_stream from 'node:stream';
|
|
3
|
+
import * as node_buffer from 'node:buffer';
|
|
4
|
+
|
|
5
|
+
interface NativeDocument {
|
|
6
|
+
readonly nodeSpace?: object;
|
|
7
|
+
retainNode?(id: number): void;
|
|
8
|
+
retainNodeData?(id: number, data: object): void;
|
|
9
|
+
adopt?(source: NativeDocument, ids: number[], detach?: boolean): string;
|
|
10
|
+
op(command: string, argsJson: string): string;
|
|
11
|
+
create?(html: string, contextId?: number, optionsJson?: string): number[];
|
|
12
|
+
select(selector: string, contexts?: number[]): number[];
|
|
13
|
+
text(ids: number[]): string;
|
|
14
|
+
innerHtml(id: number): string;
|
|
15
|
+
outerHtml(ids: number[]): string;
|
|
16
|
+
attr(id: number, name: string): string | undefined | null;
|
|
17
|
+
tagName(id: number): string | undefined | null;
|
|
18
|
+
exportTree(): string;
|
|
19
|
+
rootId(): number;
|
|
20
|
+
parserDiagnostics?(): string;
|
|
21
|
+
}
|
|
22
|
+
interface NativeWorkerPoolInfo {
|
|
23
|
+
threads: number;
|
|
24
|
+
activeBatches: number;
|
|
25
|
+
activeWorkers: number;
|
|
26
|
+
peakActiveWorkers: number;
|
|
27
|
+
}
|
|
28
|
+
/** Useful for installation diagnostics and benchmarks that require native code. */
|
|
29
|
+
declare function nativeStatus(): {
|
|
30
|
+
available: boolean;
|
|
31
|
+
error?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
interface StyleProp {
|
|
35
|
+
length: number;
|
|
36
|
+
[key: string]: string | number;
|
|
37
|
+
[index: number]: string;
|
|
38
|
+
}
|
|
39
|
+
interface AttributeMethods<T = AnyNode> {
|
|
40
|
+
attr<U extends AnyNode>(this: Cheerio<U>, name: string): string | undefined;
|
|
41
|
+
attr<U extends AnyNode>(this: Cheerio<U>): Record<string, string> | undefined;
|
|
42
|
+
attr<U extends AnyNode>(this: Cheerio<U>, name: string, value?: string | null | ((this: Element, index: number, value: string) => string | null)): Cheerio<U>;
|
|
43
|
+
attr<U extends AnyNode>(this: Cheerio<U>, values: Record<string, string | null>): Cheerio<U>;
|
|
44
|
+
prop<U extends AnyNode>(this: Cheerio<U>, name: 'tagName' | 'nodeName'): string | undefined;
|
|
45
|
+
prop<U extends AnyNode>(this: Cheerio<U>, name: 'innerHTML' | 'outerHTML' | 'innerText' | 'textContent'): string | null;
|
|
46
|
+
prop<U extends AnyNode>(this: Cheerio<U>, name: 'style'): StyleProp | undefined;
|
|
47
|
+
prop<U extends AnyNode>(this: Cheerio<U>, name: 'href' | 'src'): string | undefined;
|
|
48
|
+
prop<U extends AnyNode, K extends keyof Element>(this: Cheerio<U>, name: K): Element[K];
|
|
49
|
+
prop<U extends AnyNode, K extends keyof Element>(this: Cheerio<U>, name: K, value: Element[K] | ((this: Element, index: number, property: K) => Element[keyof Element])): Cheerio<U>;
|
|
50
|
+
prop<U extends AnyNode>(this: Cheerio<U>, values: Record<string, string | Element[keyof Element] | boolean>): Cheerio<U>;
|
|
51
|
+
prop<U extends AnyNode>(this: Cheerio<U>, name: string, value: string | boolean | null | ((this: Element, index: number, property: string) => string | boolean)): Cheerio<U>;
|
|
52
|
+
prop<U extends AnyNode>(this: Cheerio<U>, name: string): string;
|
|
53
|
+
data<U extends AnyNode>(this: Cheerio<U>, name: string): unknown;
|
|
54
|
+
data<U extends AnyNode>(this: Cheerio<U>): Record<string, unknown>;
|
|
55
|
+
data<U extends AnyNode>(this: Cheerio<U>, name: string, value: unknown): Cheerio<U>;
|
|
56
|
+
data<U extends AnyNode>(this: Cheerio<U>, values: Record<string, unknown>): Cheerio<U>;
|
|
57
|
+
val<U extends AnyNode>(this: Cheerio<U>): string | string[] | undefined;
|
|
58
|
+
val<U extends AnyNode>(this: Cheerio<U>, value: string | string[]): Cheerio<U>;
|
|
59
|
+
removeAttr<U extends AnyNode>(this: Cheerio<U>, name: string): Cheerio<U>;
|
|
60
|
+
hasClass<U extends AnyNode>(this: Cheerio<U>, name: string): boolean;
|
|
61
|
+
addClass<U extends AnyNode, R extends ArrayLike<U>>(this: R, name?: string | ((this: Element, index: number, current: string) => string | undefined)): R;
|
|
62
|
+
removeClass<U extends AnyNode, R extends ArrayLike<U>>(this: R, name?: string | ((this: Element, index: number, current: string) => string | undefined)): R;
|
|
63
|
+
toggleClass<U extends AnyNode, R extends ArrayLike<U>>(this: R, name?: string | ((this: Element, index: number, current: string, state?: boolean) => string), state?: boolean): R;
|
|
64
|
+
css<U extends AnyNode>(this: Cheerio<U>, names?: string[]): Record<string, string> | undefined;
|
|
65
|
+
css<U extends AnyNode>(this: Cheerio<U>, name: string): string | undefined;
|
|
66
|
+
css<U extends AnyNode>(this: Cheerio<U>, name: string, value: string | ((this: Element, index: number, current: string) => string | undefined)): Cheerio<U>;
|
|
67
|
+
css<U extends AnyNode>(this: Cheerio<U>, values: Record<string, string>): Cheerio<U>;
|
|
68
|
+
serializeArray<U extends AnyNode>(this: Cheerio<U>): SerializedField[];
|
|
69
|
+
serialize<U extends AnyNode>(this: Cheerio<U>): string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** An array-like selection of stable handles into the Rust document arena. */
|
|
73
|
+
declare class Cheerio<T = AnyNode> implements ArrayLike<T>, Iterable<T> {
|
|
74
|
+
[index: number]: T;
|
|
75
|
+
options: CheerioOptions;
|
|
76
|
+
_root: Cheerio<Document> | null;
|
|
77
|
+
prevObject: Cheerio<any> | undefined;
|
|
78
|
+
length: number;
|
|
79
|
+
cheerio: "[cheerio object]";
|
|
80
|
+
constructor(api: CheerioAPI, document: NativeDocument, ids?: number[], root?: Cheerio<Document> | null, options?: CheerioOptions, values?: T[]);
|
|
81
|
+
_make<R>(value: ArrayLike<R> | R | string, context?: BasicAcceptedElems<AnyNode>): Cheerio<R>;
|
|
82
|
+
_parse(content: any, options: CheerioOptions, isDocument: boolean, context: ParentNode | null): Document;
|
|
83
|
+
_render(content: any): string;
|
|
84
|
+
_makeDomArray<T extends AnyNode>(this: Cheerio<T>, elem?: BasicAcceptedElems<AnyNode> | BasicAcceptedElems<AnyNode>[], clone?: boolean): AnyNode[];
|
|
85
|
+
find<T extends AnyNode>(this: Cheerio<T>, selectorOrHaystack?: string | Cheerio<Element> | Element): Cheerio<Element>;
|
|
86
|
+
_findBySelector<T extends AnyNode>(this: Cheerio<T>, selector: string, limit: number): Cheerio<Element>;
|
|
87
|
+
parent<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
88
|
+
parents<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
89
|
+
next<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
90
|
+
prev<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
91
|
+
nextAll<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
92
|
+
prevAll<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
93
|
+
siblings<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
94
|
+
children<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
95
|
+
contents<T extends AnyNode>(this: Cheerio<T>): Cheerio<AnyNode>;
|
|
96
|
+
parentsUntil<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null, filterSelector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
97
|
+
nextUntil<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null, filterSelector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
98
|
+
prevUntil<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null, filterSelector?: AcceptedFilters<Element>): Cheerio<Element>;
|
|
99
|
+
closest<T extends AnyNode>(this: Cheerio<T>, selector?: AcceptedFilters<Element>): Cheerio<AnyNode>;
|
|
100
|
+
each<T>(this: Cheerio<T>, fn: (this: T, i: number, el: T) => void | boolean): Cheerio<T>;
|
|
101
|
+
map<T, M>(this: Cheerio<T>, fn: (this: T, i: number, el: T) => M[] | M | null | undefined): Cheerio<M>;
|
|
102
|
+
filter<T, S extends T>(this: Cheerio<T>, match: (this: T, index: number, value: T) => value is S): Cheerio<S>;
|
|
103
|
+
filter<T, S extends AcceptedFilters<T>>(this: Cheerio<T>, match: S): Cheerio<S extends string ? Element : T>;
|
|
104
|
+
filterArray<T>(nodes: T[], match: AcceptedFilters<T>, xmlMode?: boolean, root?: Document): Element[] | T[];
|
|
105
|
+
not<T extends AnyNode>(this: Cheerio<T>, match: AcceptedFilters<T>): Cheerio<T>;
|
|
106
|
+
is<T>(this: Cheerio<T>, selector?: AcceptedFilters<T>): boolean;
|
|
107
|
+
has(this: Cheerio<AnyNode | Element>, selectorOrHaystack: string | Cheerio<Element> | Element): Cheerio<AnyNode | Element>;
|
|
108
|
+
first<T extends AnyNode>(this: Cheerio<T>): Cheerio<T>;
|
|
109
|
+
last<T>(this: Cheerio<T>): Cheerio<T>;
|
|
110
|
+
eq<T>(this: Cheerio<T>, i: number): Cheerio<T>;
|
|
111
|
+
get<T>(this: Cheerio<T>, i: number): T | undefined;
|
|
112
|
+
get<T>(this: Cheerio<T>): T[];
|
|
113
|
+
toArray<T>(this: Cheerio<T>): T[];
|
|
114
|
+
slice<T>(this: Cheerio<T>, start?: number, end?: number): Cheerio<T>;
|
|
115
|
+
end<T>(this: Cheerio<T>): Cheerio<AnyNode>;
|
|
116
|
+
add<S extends AnyNode, T extends AnyNode>(this: Cheerio<T>, other: string | Cheerio<S> | S | S[], context?: Cheerio<S> | string): Cheerio<S | T>;
|
|
117
|
+
addBack<T extends AnyNode>(this: Cheerio<T>, selector?: string): Cheerio<AnyNode>;
|
|
118
|
+
index<T extends AnyNode>(this: Cheerio<T>, selectorOrNeedle?: string | Cheerio<AnyNode> | AnyNode): number;
|
|
119
|
+
splice(start: number, deleteCount?: number): any[];
|
|
120
|
+
splice(start: number, deleteCount: number, ...items: any[]): any[];
|
|
121
|
+
[Symbol.iterator](): Iterator<T>;
|
|
122
|
+
append<T extends AnyNode>(this: Cheerio<T>, ...elems: [
|
|
123
|
+
(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>
|
|
124
|
+
] | BasicAcceptedElems<AnyNode>[]): Cheerio<T>;
|
|
125
|
+
prepend<T extends AnyNode>(this: Cheerio<T>, ...elems: [
|
|
126
|
+
(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>
|
|
127
|
+
] | BasicAcceptedElems<AnyNode>[]): Cheerio<T>;
|
|
128
|
+
before<T extends AnyNode>(this: Cheerio<T>, ...elems: [
|
|
129
|
+
(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>
|
|
130
|
+
] | BasicAcceptedElems<AnyNode>[]): Cheerio<T>;
|
|
131
|
+
after<T extends AnyNode>(this: Cheerio<T>, ...elems: [
|
|
132
|
+
(this: AnyNode, i: number, html: string) => BasicAcceptedElems<AnyNode>
|
|
133
|
+
] | BasicAcceptedElems<AnyNode>[]): Cheerio<T>;
|
|
134
|
+
appendTo<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
|
|
135
|
+
prependTo<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
|
|
136
|
+
insertBefore<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
|
|
137
|
+
insertAfter<T extends AnyNode>(this: Cheerio<T>, target: BasicAcceptedElems<AnyNode>): Cheerio<T>;
|
|
138
|
+
remove<T extends AnyNode>(this: Cheerio<T>, selector?: string): Cheerio<T>;
|
|
139
|
+
replaceWith<T extends AnyNode>(this: Cheerio<T>, content: AcceptedElems<AnyNode>): Cheerio<T>;
|
|
140
|
+
empty<T extends AnyNode>(this: Cheerio<T>): Cheerio<T>;
|
|
141
|
+
html<T extends AnyNode>(this: Cheerio<T>): string | null;
|
|
142
|
+
html<T extends AnyNode>(this: Cheerio<T>, str: string | Cheerio<T>): Cheerio<T>;
|
|
143
|
+
text<T extends AnyNode>(this: Cheerio<T>): string;
|
|
144
|
+
text<T extends AnyNode>(this: Cheerio<T>, str: string | ((this: AnyNode, i: number, text: string) => string)): Cheerio<T>;
|
|
145
|
+
toString<T extends AnyNode>(this: Cheerio<T>): string;
|
|
146
|
+
clone<T extends AnyNode>(this: Cheerio<T>): Cheerio<T>;
|
|
147
|
+
wrap<T extends AnyNode>(this: Cheerio<T>, wrapper: AcceptedElems<AnyNode>): Cheerio<T>;
|
|
148
|
+
wrapInner<T extends AnyNode>(this: Cheerio<T>, wrapper: AcceptedElems<AnyNode>): Cheerio<T>;
|
|
149
|
+
unwrap<T extends AnyNode>(this: Cheerio<T>, selector?: string): Cheerio<T>;
|
|
150
|
+
wrapAll<T extends AnyNode>(this: Cheerio<T>, wrapper: AcceptedElems<T>): Cheerio<T>;
|
|
151
|
+
extract<M extends ExtractMap, T extends AnyNode>(this: Cheerio<T>, map: M): ExtractedMap<M>;
|
|
152
|
+
extract<M extends ExtractMap, T extends AnyNode>(this: Cheerio<T>, map: M): Record<string, unknown>;
|
|
153
|
+
}
|
|
154
|
+
interface Cheerio<T = AnyNode> extends AttributeMethods<T> {
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Parse5-compatible diagnostics, declared locally without a parser dependency. */
|
|
158
|
+
declare enum ERR {
|
|
159
|
+
controlCharacterInInputStream = "control-character-in-input-stream",
|
|
160
|
+
noncharacterInInputStream = "noncharacter-in-input-stream",
|
|
161
|
+
surrogateInInputStream = "surrogate-in-input-stream",
|
|
162
|
+
nonVoidHtmlElementStartTagWithTrailingSolidus = "non-void-html-element-start-tag-with-trailing-solidus",
|
|
163
|
+
endTagWithAttributes = "end-tag-with-attributes",
|
|
164
|
+
endTagWithTrailingSolidus = "end-tag-with-trailing-solidus",
|
|
165
|
+
unexpectedSolidusInTag = "unexpected-solidus-in-tag",
|
|
166
|
+
unexpectedNullCharacter = "unexpected-null-character",
|
|
167
|
+
unexpectedQuestionMarkInsteadOfTagName = "unexpected-question-mark-instead-of-tag-name",
|
|
168
|
+
invalidFirstCharacterOfTagName = "invalid-first-character-of-tag-name",
|
|
169
|
+
unexpectedEqualsSignBeforeAttributeName = "unexpected-equals-sign-before-attribute-name",
|
|
170
|
+
missingEndTagName = "missing-end-tag-name",
|
|
171
|
+
unexpectedCharacterInAttributeName = "unexpected-character-in-attribute-name",
|
|
172
|
+
unknownNamedCharacterReference = "unknown-named-character-reference",
|
|
173
|
+
missingSemicolonAfterCharacterReference = "missing-semicolon-after-character-reference",
|
|
174
|
+
unexpectedCharacterAfterDoctypeSystemIdentifier = "unexpected-character-after-doctype-system-identifier",
|
|
175
|
+
unexpectedCharacterInUnquotedAttributeValue = "unexpected-character-in-unquoted-attribute-value",
|
|
176
|
+
eofBeforeTagName = "eof-before-tag-name",
|
|
177
|
+
eofInTag = "eof-in-tag",
|
|
178
|
+
missingAttributeValue = "missing-attribute-value",
|
|
179
|
+
missingWhitespaceBetweenAttributes = "missing-whitespace-between-attributes",
|
|
180
|
+
missingWhitespaceAfterDoctypePublicKeyword = "missing-whitespace-after-doctype-public-keyword",
|
|
181
|
+
missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers = "missing-whitespace-between-doctype-public-and-system-identifiers",
|
|
182
|
+
missingWhitespaceAfterDoctypeSystemKeyword = "missing-whitespace-after-doctype-system-keyword",
|
|
183
|
+
missingQuoteBeforeDoctypePublicIdentifier = "missing-quote-before-doctype-public-identifier",
|
|
184
|
+
missingQuoteBeforeDoctypeSystemIdentifier = "missing-quote-before-doctype-system-identifier",
|
|
185
|
+
missingDoctypePublicIdentifier = "missing-doctype-public-identifier",
|
|
186
|
+
missingDoctypeSystemIdentifier = "missing-doctype-system-identifier",
|
|
187
|
+
abruptDoctypePublicIdentifier = "abrupt-doctype-public-identifier",
|
|
188
|
+
abruptDoctypeSystemIdentifier = "abrupt-doctype-system-identifier",
|
|
189
|
+
cdataInHtmlContent = "cdata-in-html-content",
|
|
190
|
+
incorrectlyOpenedComment = "incorrectly-opened-comment",
|
|
191
|
+
eofInScriptHtmlCommentLikeText = "eof-in-script-html-comment-like-text",
|
|
192
|
+
eofInDoctype = "eof-in-doctype",
|
|
193
|
+
nestedComment = "nested-comment",
|
|
194
|
+
abruptClosingOfEmptyComment = "abrupt-closing-of-empty-comment",
|
|
195
|
+
eofInComment = "eof-in-comment",
|
|
196
|
+
incorrectlyClosedComment = "incorrectly-closed-comment",
|
|
197
|
+
eofInCdata = "eof-in-cdata",
|
|
198
|
+
absenceOfDigitsInNumericCharacterReference = "absence-of-digits-in-numeric-character-reference",
|
|
199
|
+
nullCharacterReference = "null-character-reference",
|
|
200
|
+
surrogateCharacterReference = "surrogate-character-reference",
|
|
201
|
+
characterReferenceOutsideUnicodeRange = "character-reference-outside-unicode-range",
|
|
202
|
+
controlCharacterReference = "control-character-reference",
|
|
203
|
+
noncharacterCharacterReference = "noncharacter-character-reference",
|
|
204
|
+
missingWhitespaceBeforeDoctypeName = "missing-whitespace-before-doctype-name",
|
|
205
|
+
missingDoctypeName = "missing-doctype-name",
|
|
206
|
+
invalidCharacterSequenceAfterDoctypeName = "invalid-character-sequence-after-doctype-name",
|
|
207
|
+
duplicateAttribute = "duplicate-attribute",
|
|
208
|
+
nonConformingDoctype = "non-conforming-doctype",
|
|
209
|
+
missingDoctype = "missing-doctype",
|
|
210
|
+
misplacedDoctype = "misplaced-doctype",
|
|
211
|
+
endTagWithoutMatchingOpenElement = "end-tag-without-matching-open-element",
|
|
212
|
+
closingOfElementWithOpenChildElements = "closing-of-element-with-open-child-elements",
|
|
213
|
+
disallowedContentInNoscriptInHead = "disallowed-content-in-noscript-in-head",
|
|
214
|
+
openElementsLeftAfterEof = "open-elements-left-after-eof",
|
|
215
|
+
abandonedHeadElementChild = "abandoned-head-element-child",
|
|
216
|
+
misplacedStartTagForHeadElement = "misplaced-start-tag-for-head-element",
|
|
217
|
+
nestedNoscriptInHead = "nested-noscript-in-head",
|
|
218
|
+
eofInElementThatCanContainOnlyText = "eof-in-element-that-can-contain-only-text"
|
|
219
|
+
}
|
|
220
|
+
type ParserErrorCode = ERR;
|
|
221
|
+
interface ParserError extends SourceCodeLocation {
|
|
222
|
+
code: ParserErrorCode;
|
|
223
|
+
}
|
|
224
|
+
type ParserErrorHandler = (error: ParserError) => void;
|
|
225
|
+
declare enum NS {
|
|
226
|
+
HTML = "http://www.w3.org/1999/xhtml",
|
|
227
|
+
MATHML = "http://www.w3.org/1998/Math/MathML",
|
|
228
|
+
SVG = "http://www.w3.org/2000/svg",
|
|
229
|
+
XLINK = "http://www.w3.org/1999/xlink",
|
|
230
|
+
XML = "http://www.w3.org/XML/1998/namespace",
|
|
231
|
+
XMLNS = "http://www.w3.org/2000/xmlns/"
|
|
232
|
+
}
|
|
233
|
+
declare enum DOCUMENT_MODE {
|
|
234
|
+
NO_QUIRKS = "no-quirks",
|
|
235
|
+
QUIRKS = "quirks",
|
|
236
|
+
LIMITED_QUIRKS = "limited-quirks"
|
|
237
|
+
}
|
|
238
|
+
type NamespaceURI = NS;
|
|
239
|
+
type DocumentMode = DOCUMENT_MODE;
|
|
240
|
+
interface TreeAdapterAttribute {
|
|
241
|
+
name: string;
|
|
242
|
+
value: string;
|
|
243
|
+
namespace?: string;
|
|
244
|
+
prefix?: string;
|
|
245
|
+
}
|
|
246
|
+
/** The HTML5 adapter shape used by Cheerio's DOM representation. */
|
|
247
|
+
interface TreeAdapter {
|
|
248
|
+
adoptAttributes(recipient: Element, attrs: TreeAdapterAttribute[]): void;
|
|
249
|
+
appendChild(parentNode: ParentNode, newNode: ChildNode): void;
|
|
250
|
+
createCommentNode(data: string): Comment;
|
|
251
|
+
createTextNode(value: string): Text;
|
|
252
|
+
createDocument(): Document;
|
|
253
|
+
createDocumentFragment(): Document;
|
|
254
|
+
createElement(tagName: string, namespaceURI: NamespaceURI, attrs: TreeAdapterAttribute[]): Element;
|
|
255
|
+
detachNode(node: ChildNode): void;
|
|
256
|
+
getAttrList(element: Element): TreeAdapterAttribute[];
|
|
257
|
+
getChildNodes(node: ParentNode): ChildNode[];
|
|
258
|
+
getCommentNodeContent(node: Comment): string;
|
|
259
|
+
getDocumentMode(document: Document): DocumentMode;
|
|
260
|
+
getDocumentTypeNodeName(node: ProcessingInstruction): string;
|
|
261
|
+
getDocumentTypeNodePublicId(node: ProcessingInstruction): string;
|
|
262
|
+
getDocumentTypeNodeSystemId(node: ProcessingInstruction): string;
|
|
263
|
+
getFirstChild(node: ParentNode): ChildNode | null;
|
|
264
|
+
getNamespaceURI(element: Element): NamespaceURI;
|
|
265
|
+
getNodeSourceCodeLocation(node: AnyNode): TagSourceCodeLocation | undefined | null;
|
|
266
|
+
getParentNode(node: AnyNode): ParentNode | null;
|
|
267
|
+
getTagName(element: Element): string;
|
|
268
|
+
getTextNodeContent(node: Text): string;
|
|
269
|
+
getTemplateContent(element: Element): Document;
|
|
270
|
+
insertBefore(parent: ParentNode, child: ChildNode, reference: ChildNode): void;
|
|
271
|
+
insertText(parent: ParentNode, text: string): void;
|
|
272
|
+
insertTextBefore(parent: ParentNode, text: string, reference: ChildNode): void;
|
|
273
|
+
isCommentNode(node: AnyNode): node is Comment;
|
|
274
|
+
isDocumentTypeNode(node: AnyNode): node is ProcessingInstruction;
|
|
275
|
+
isElementNode(node: AnyNode): node is Element;
|
|
276
|
+
isTextNode(node: AnyNode): node is Text;
|
|
277
|
+
setDocumentMode(document: Document, mode: DocumentMode): void;
|
|
278
|
+
setDocumentType(document: Document, name: string, publicId: string, systemId: string): void;
|
|
279
|
+
setNodeSourceCodeLocation(node: AnyNode, location: TagSourceCodeLocation | null): void;
|
|
280
|
+
updateNodeSourceCodeLocation(node: AnyNode, location: Partial<TagSourceCodeLocation>): void;
|
|
281
|
+
setTemplateContent(element: Element, content: Document): void;
|
|
282
|
+
onItemPush?: (item: Element) => void;
|
|
283
|
+
onItemPop?: (item: Element, newTop: ParentNode) => void;
|
|
284
|
+
}
|
|
285
|
+
declare enum QuoteType {
|
|
286
|
+
NoValue = 0,
|
|
287
|
+
Unquoted = 1,
|
|
288
|
+
Single = 2,
|
|
289
|
+
Double = 3
|
|
290
|
+
}
|
|
291
|
+
interface TokenizerCallbacks {
|
|
292
|
+
onattribdata(start: number, endIndex: number): void;
|
|
293
|
+
onattribentity(codepoint: number): void;
|
|
294
|
+
onattribend(quote: QuoteType, endIndex: number): void;
|
|
295
|
+
onattribname(start: number, endIndex: number): void;
|
|
296
|
+
oncdata(start: number, endIndex: number, endOffset: number): void;
|
|
297
|
+
onclosetag(start: number, endIndex: number): void;
|
|
298
|
+
oncomment(start: number, endIndex: number, endOffset: number): void;
|
|
299
|
+
ondeclaration(start: number, endIndex: number): void;
|
|
300
|
+
onend(): void;
|
|
301
|
+
onopentagend(endIndex: number): void;
|
|
302
|
+
onopentagname(start: number, endIndex: number): void;
|
|
303
|
+
onprocessinginstruction(start: number, endIndex: number): void;
|
|
304
|
+
onselfclosingtag(endIndex: number): void;
|
|
305
|
+
ontext(start: number, endIndex: number): void;
|
|
306
|
+
ontextentity(codepoint: number, endIndex: number): void;
|
|
307
|
+
}
|
|
308
|
+
interface Tokenizer {
|
|
309
|
+
running: boolean;
|
|
310
|
+
reset(): void;
|
|
311
|
+
write(chunk: string): void;
|
|
312
|
+
end(): void;
|
|
313
|
+
pause(): void;
|
|
314
|
+
resume(): void;
|
|
315
|
+
}
|
|
316
|
+
interface TokenizerOptions {
|
|
317
|
+
xmlMode?: boolean;
|
|
318
|
+
decodeEntities?: boolean;
|
|
319
|
+
}
|
|
320
|
+
interface TokenizerConstructor {
|
|
321
|
+
new (options: TokenizerOptions, callbacks: TokenizerCallbacks): Tokenizer;
|
|
322
|
+
new (options: TokenizerOptions, callbacks: TokenizerCallbacks): any;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** DOM-compatible views over stable nodes owned by the native document. */
|
|
326
|
+
declare enum ElementType {
|
|
327
|
+
Root = "root",
|
|
328
|
+
Text = "text",
|
|
329
|
+
Directive = "directive",
|
|
330
|
+
Comment = "comment",
|
|
331
|
+
Script = "script",
|
|
332
|
+
Style = "style",
|
|
333
|
+
Tag = "tag",
|
|
334
|
+
CDATA = "cdata",
|
|
335
|
+
Doctype = "doctype"
|
|
336
|
+
}
|
|
337
|
+
interface SourceCodeLocation {
|
|
338
|
+
startLine: number;
|
|
339
|
+
startCol: number;
|
|
340
|
+
startOffset: number;
|
|
341
|
+
endLine: number;
|
|
342
|
+
endCol: number;
|
|
343
|
+
endOffset: number;
|
|
344
|
+
}
|
|
345
|
+
interface TagSourceCodeLocation extends SourceCodeLocation {
|
|
346
|
+
startTag?: SourceCodeLocation;
|
|
347
|
+
endTag?: SourceCodeLocation;
|
|
348
|
+
attrs?: Record<string, SourceCodeLocation>;
|
|
349
|
+
}
|
|
350
|
+
interface Node {
|
|
351
|
+
readonly type: ElementType;
|
|
352
|
+
parent: ParentNode | null;
|
|
353
|
+
prev: ChildNode | null;
|
|
354
|
+
next: ChildNode | null;
|
|
355
|
+
startIndex: number | null;
|
|
356
|
+
endIndex: number | null;
|
|
357
|
+
readonly nodeType: number;
|
|
358
|
+
parentNode: ParentNode | null;
|
|
359
|
+
previousSibling: ChildNode | null;
|
|
360
|
+
nextSibling: ChildNode | null;
|
|
361
|
+
sourceCodeLocation?: SourceCodeLocation | null;
|
|
362
|
+
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
|
363
|
+
}
|
|
364
|
+
interface DataNode extends Node {
|
|
365
|
+
data: string;
|
|
366
|
+
nodeValue: string;
|
|
367
|
+
}
|
|
368
|
+
interface Text extends DataNode {
|
|
369
|
+
type: ElementType.Text;
|
|
370
|
+
readonly nodeType: 3;
|
|
371
|
+
}
|
|
372
|
+
interface Comment extends DataNode {
|
|
373
|
+
type: ElementType.Comment;
|
|
374
|
+
readonly nodeType: 8;
|
|
375
|
+
}
|
|
376
|
+
interface ProcessingInstruction extends DataNode {
|
|
377
|
+
type: ElementType.Directive;
|
|
378
|
+
name: string;
|
|
379
|
+
readonly nodeType: 1;
|
|
380
|
+
'x-name'?: string;
|
|
381
|
+
'x-publicId'?: string;
|
|
382
|
+
'x-systemId'?: string;
|
|
383
|
+
}
|
|
384
|
+
interface NodeWithChildren extends Node {
|
|
385
|
+
children: ChildNode[];
|
|
386
|
+
childNodes: ChildNode[];
|
|
387
|
+
readonly firstChild: ChildNode | null;
|
|
388
|
+
readonly lastChild: ChildNode | null;
|
|
389
|
+
}
|
|
390
|
+
interface Document extends NodeWithChildren {
|
|
391
|
+
type: ElementType.Root;
|
|
392
|
+
readonly nodeType: 9;
|
|
393
|
+
'x-mode'?: 'quirks' | 'limited-quirks' | 'no-quirks';
|
|
394
|
+
}
|
|
395
|
+
interface CDATA extends NodeWithChildren {
|
|
396
|
+
type: ElementType.CDATA;
|
|
397
|
+
readonly nodeType: 4;
|
|
398
|
+
}
|
|
399
|
+
interface Element extends NodeWithChildren {
|
|
400
|
+
type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
|
401
|
+
readonly nodeType: 1;
|
|
402
|
+
name: string;
|
|
403
|
+
tagName: string;
|
|
404
|
+
attribs: Record<string, string>;
|
|
405
|
+
namespace?: string;
|
|
406
|
+
sourceCodeLocation?: TagSourceCodeLocation | null;
|
|
407
|
+
readonly attributes: {
|
|
408
|
+
name: string;
|
|
409
|
+
value: string;
|
|
410
|
+
namespace?: string;
|
|
411
|
+
prefix?: string;
|
|
412
|
+
}[];
|
|
413
|
+
'x-attribsNamespace'?: Record<string, string>;
|
|
414
|
+
'x-attribsPrefix'?: Record<string, string>;
|
|
415
|
+
}
|
|
416
|
+
type ParentNode = Document | Element | CDATA;
|
|
417
|
+
type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
|
418
|
+
type AnyNode = ParentNode | ChildNode;
|
|
419
|
+
interface HTMLParser2Options {
|
|
420
|
+
xmlMode?: boolean;
|
|
421
|
+
decodeEntities?: boolean;
|
|
422
|
+
encodeEntities?: boolean | 'utf8';
|
|
423
|
+
lowerCaseTags?: boolean;
|
|
424
|
+
lowerCaseAttributeNames?: boolean;
|
|
425
|
+
recognizeCDATA?: boolean;
|
|
426
|
+
recognizeSelfClosing?: boolean;
|
|
427
|
+
withStartIndices?: boolean;
|
|
428
|
+
withEndIndices?: boolean;
|
|
429
|
+
emptyAttrs?: boolean;
|
|
430
|
+
selfClosingTags?: boolean;
|
|
431
|
+
Tokenizer?: TokenizerConstructor;
|
|
432
|
+
[key: string]: any;
|
|
433
|
+
}
|
|
434
|
+
interface CheerioOptions extends HTMLParser2Options {
|
|
435
|
+
xml?: boolean | HTMLParser2Options;
|
|
436
|
+
baseURI?: string | URL;
|
|
437
|
+
quirksMode?: boolean;
|
|
438
|
+
scriptingEnabled?: boolean;
|
|
439
|
+
sourceCodeLocationInfo?: boolean;
|
|
440
|
+
treeAdapter?: TreeAdapter;
|
|
441
|
+
onParseError?: ParserErrorHandler | null;
|
|
442
|
+
pseudos?: Record<string, string | ((element: Element, value?: string | null) => boolean)>;
|
|
443
|
+
_useHtmlParser2?: boolean;
|
|
444
|
+
}
|
|
445
|
+
type InternalOptions = CheerioOptions;
|
|
446
|
+
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';
|
|
447
|
+
type AlphaNumeric = LowercaseLetters | Uppercase<LowercaseLetters> | `${number}`;
|
|
448
|
+
type SelectorType = `${'.' | '#' | ':' | '|' | '>' | '+' | '~' | '['}${AlphaNumeric}${string}` | `${AlphaNumeric}${string}`;
|
|
449
|
+
type BasicAcceptedElems<T extends AnyNode = AnyNode> = ArrayLike<T> | T | string;
|
|
450
|
+
type AcceptedElems<T extends AnyNode = AnyNode> = BasicAcceptedElems<T> | ((this: T, index: number, element: T) => BasicAcceptedElems<T>);
|
|
451
|
+
type FilterFunction<T> = (this: T, index: number, element: T) => boolean;
|
|
452
|
+
type AcceptedFilters<T> = string | FilterFunction<T> | T | Cheerio<T>;
|
|
453
|
+
type LoadContent = string | Buffer | AnyNode | ArrayLike<AnyNode>;
|
|
454
|
+
interface CheerioAPI {
|
|
455
|
+
<T extends AnyNode, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<AnyNode> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<S extends SelectorType ? Element : T>;
|
|
456
|
+
<T extends AnyNode, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<AnyNode> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<AnyNode>;
|
|
457
|
+
html(options?: CheerioOptions): string;
|
|
458
|
+
html(dom?: BasicAcceptedElems<AnyNode> | Cheerio<AnyNode>, options?: CheerioOptions): string;
|
|
459
|
+
xml(dom?: BasicAcceptedElems<AnyNode> | Cheerio<AnyNode>): string;
|
|
460
|
+
text(elements?: ArrayLike<AnyNode>): string;
|
|
461
|
+
root(): Cheerio<Document>;
|
|
462
|
+
contains(container: AnyNode, contained: AnyNode): boolean;
|
|
463
|
+
merge<T>(first: ArrayLike<T>, second: ArrayLike<T>): ArrayLike<T> | undefined;
|
|
464
|
+
parseHTML(data: string, context?: unknown, keepScripts?: boolean): AnyNode[];
|
|
465
|
+
parseHTML(data?: '' | null): null;
|
|
466
|
+
load(content: LoadContent, options?: CheerioOptions | null, isDocument?: boolean): CheerioAPI;
|
|
467
|
+
extract<M extends ExtractMap>(this: CheerioAPI, map: M): ExtractedMap<M>;
|
|
468
|
+
extract<M extends ExtractMap>(this: CheerioAPI, map: M): Record<string, unknown>;
|
|
469
|
+
fn: typeof Cheerio.prototype;
|
|
470
|
+
_root: Document;
|
|
471
|
+
_options: InternalOptions;
|
|
472
|
+
[key: string]: any;
|
|
473
|
+
}
|
|
474
|
+
type ExtractDescriptorFn = (element: Element, key: string, result: Record<string, unknown>) => unknown;
|
|
475
|
+
interface ExtractDescriptor {
|
|
476
|
+
selector: string;
|
|
477
|
+
value?: string | ExtractDescriptorFn | ExtractMap;
|
|
478
|
+
}
|
|
479
|
+
type ExtractValue = string | ExtractDescriptor | [string | ExtractDescriptor];
|
|
480
|
+
type ExtractMap = Record<string, ExtractValue>;
|
|
481
|
+
type ExtractedValue<V extends ExtractValue> = V extends [string | ExtractDescriptor] ? NonNullable<ExtractedValue<V[0]>>[] : V extends string ? string | undefined : V extends ExtractDescriptor ? V['value'] extends infer U ? U extends ExtractMap ? ExtractedMap<U> | undefined : U extends ExtractDescriptorFn ? ReturnType<U> | undefined : string | undefined : never : never;
|
|
482
|
+
type ExtractedMap<M extends ExtractMap> = {
|
|
483
|
+
[key in keyof M]: ExtractedValue<M[key]>;
|
|
484
|
+
};
|
|
485
|
+
type ExtractionDescriptor = ExtractDescriptor;
|
|
486
|
+
type ExtractionMap = ExtractMap;
|
|
487
|
+
type ExtractionResult<M extends ExtractMap> = ExtractedMap<M>;
|
|
488
|
+
interface EncodingOptions {
|
|
489
|
+
defaultEncoding?: string;
|
|
490
|
+
transportLayerEncodingLabel?: string | null;
|
|
491
|
+
userEncoding?: string;
|
|
492
|
+
maxBytes?: number;
|
|
493
|
+
}
|
|
494
|
+
interface DecodeStreamOptions extends CheerioOptions {
|
|
495
|
+
encoding?: EncodingOptions;
|
|
496
|
+
}
|
|
497
|
+
/** Structural Node/Undici FormData compatibility without importing its package. */
|
|
498
|
+
interface FormDataLike extends Iterable<[string, string | node_buffer.Blob]> {
|
|
499
|
+
append(name: string, value: unknown, filename?: string): void;
|
|
500
|
+
get(name: string): string | node_buffer.Blob | null;
|
|
501
|
+
}
|
|
502
|
+
interface CheerioRequestOptions extends DecodeStreamOptions {
|
|
503
|
+
requestOptions?: {
|
|
504
|
+
method?: string;
|
|
505
|
+
headers?: Record<string, string | string[] | undefined> | string[] | Iterable<[string, string | string[] | undefined]> | Headers | null;
|
|
506
|
+
body?: string | Buffer | Uint8Array | node_stream.Readable | FormData | FormDataLike | null;
|
|
507
|
+
query?: node_querystring.ParsedUrlQueryInput;
|
|
508
|
+
onInfo?: (info: {
|
|
509
|
+
statusCode: number;
|
|
510
|
+
headers: Record<string, string | string[]>;
|
|
511
|
+
}) => void;
|
|
512
|
+
reset?: boolean;
|
|
513
|
+
typeOfService?: number | null;
|
|
514
|
+
highWaterMark?: number;
|
|
515
|
+
maxRedirections?: number;
|
|
516
|
+
throwOnError?: boolean;
|
|
517
|
+
signal?: unknown;
|
|
518
|
+
headersTimeout?: number | null;
|
|
519
|
+
bodyTimeout?: number | null;
|
|
520
|
+
dispatcher?: unknown;
|
|
521
|
+
[key: string]: unknown;
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
interface ParallelOptions extends CheerioOptions {
|
|
525
|
+
threads?: number;
|
|
526
|
+
}
|
|
527
|
+
type SerializedField = {
|
|
528
|
+
name: string;
|
|
529
|
+
value: string;
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
export { type AcceptedElems as A, type BasicAcceptedElems as B, type CheerioOptions as C, type DataNode as D, type Element as E, type FilterFunction as F, type ParserErrorHandler as G, type HTMLParser2Options as H, type InternalOptions as I, type ProcessingInstruction as J, type SerializedField as K, type LoadContent as L, type SourceCodeLocation as M, type NamespaceURI as N, type Text as O, type ParallelOptions as P, type Tokenizer as Q, type TokenizerCallbacks as R, type SelectorType as S, type TagSourceCodeLocation as T, type TokenizerConstructor as U, type TokenizerOptions as V, type TreeAdapter as W, type TreeAdapterAttribute as X, type NativeWorkerPoolInfo as Y, type NativeDocument as Z, nativeStatus as _, type CheerioAPI as a, type AcceptedFilters as b, type AnyNode as c, type CDATA as d, Cheerio as e, type CheerioRequestOptions as f, type ChildNode as g, type Comment as h, type DecodeStreamOptions as i, type Document as j, type DocumentMode as k, ElementType as l, type EncodingOptions as m, type ExtractDescriptor as n, type ExtractMap as o, type ExtractedMap as p, type ExtractedValue as q, type ExtractionDescriptor as r, type ExtractionMap as s, type ExtractionResult as t, type FormDataLike as u, type Node as v, type NodeWithChildren as w, type ParentNode as x, type ParserError as y, type ParserErrorCode as z };
|