@dvaji/cheerox 0.0.0-stage → 0.1.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.
- package/CONTRIBUTING.md +74 -0
- package/Cargo.lock +1091 -0
- package/Cargo.toml +47 -0
- package/LICENSE +21 -0
- package/README.md +121 -2
- package/RELEASING.md +114 -0
- package/THIRD_PARTY_NOTICES.md +7581 -0
- package/build.rs +3 -0
- package/cheerox.darwin-arm64.node +0 -0
- package/cheerox.darwin-x64.node +0 -0
- package/cheerox.linux-arm64-gnu.node +0 -0
- package/cheerox.linux-arm64-musl.node +0 -0
- package/cheerox.linux-x64-gnu.node +0 -0
- package/cheerox.linux-x64-musl.node +0 -0
- package/cheerox.win32-arm64-msvc.node +0 -0
- package/cheerox.win32-x64-msvc.node +0 -0
- package/dist/cheerio-compat-BKkfJEAr.mjs +1648 -0
- package/dist/cheerio-compat-BKkfJEAr.mjs.map +1 -0
- package/dist/cheerio-compat-DRLPzBdX.d.mts +88 -0
- package/dist/cheerio-compat-DRsINTwV.d.cts +88 -0
- package/dist/cheerio-compat-DRsINTwV.d.ts +88 -0
- package/dist/cheerio-compat-DcnYK9OB.cjs +1719 -0
- package/dist/cheerio-compat-DcnYK9OB.cjs.map +1 -0
- package/dist/cheerio-compat.cjs +18 -0
- package/dist/cheerio-compat.d.cts +2 -0
- package/dist/cheerio-compat.d.mts +2 -0
- package/dist/cheerio-compat.d.ts +2 -0
- package/dist/cheerio-compat.mjs +1 -0
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.mjs +53 -0
- package/dist/index.mjs.map +1 -0
- package/dist/legacy-parse.cjs +5 -0
- package/dist/legacy-parse.d.mts +8 -0
- package/dist/legacy-parse.d.ts +7 -0
- package/dist/legacy-parse.mjs +1 -0
- package/dist/modern-B7hyW4cI.d.cts +102 -0
- package/dist/modern-B7hyW4cI.d.ts +102 -0
- package/dist/modern-CHQGP0Yt.cjs +2858 -0
- package/dist/modern-CHQGP0Yt.cjs.map +1 -0
- package/dist/modern-CJvSD_y5.d.mts +102 -0
- package/dist/modern-CvXcTn82.mjs +2769 -0
- package/dist/modern-CvXcTn82.mjs.map +1 -0
- package/dist/modern.cjs +19 -0
- package/dist/modern.d.cts +3 -0
- package/dist/modern.d.mts +3 -0
- package/dist/modern.d.ts +3 -0
- package/dist/modern.mjs +3 -0
- package/dist/nodes-jbWWhssj.cjs +4210 -0
- package/dist/nodes-jbWWhssj.cjs.map +1 -0
- package/dist/nodes-sYxb5qyZ.mjs +3803 -0
- package/dist/nodes-sYxb5qyZ.mjs.map +1 -0
- package/dist/slim.cjs +16 -0
- package/dist/slim.cjs.map +1 -0
- package/dist/slim.d.cts +6 -0
- package/dist/slim.d.mts +6 -0
- package/dist/slim.d.ts +6 -0
- package/dist/slim.mjs +12 -0
- package/dist/slim.mjs.map +1 -0
- package/dist/types-CA01Zg3r.d.cts +526 -0
- package/dist/types-CA01Zg3r.d.mts +526 -0
- package/dist/types-CA01Zg3r.d.ts +526 -0
- package/dist/utils.cjs +31 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.mts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.mjs +25 -0
- package/dist/utils.mjs.map +1 -0
- package/native/src/arena.rs +2109 -0
- package/native/src/attributes.rs +946 -0
- package/native/src/codec.rs +298 -0
- package/native/src/diagnostics.rs +1249 -0
- package/native/src/document_order.rs +711 -0
- package/native/src/extraction.rs +321 -0
- package/native/src/gc.rs +175 -0
- package/native/src/hook_sink.rs +801 -0
- package/native/src/hook_stream.rs +513 -0
- package/native/src/id_hash.rs +42 -0
- package/native/src/immutable.rs +333 -0
- package/native/src/lib.rs +4120 -0
- package/native/src/location.rs +392 -0
- package/native/src/markup_tokenizer.rs +668 -0
- package/native/src/runtime.rs +368 -0
- package/native/src/selector.rs +1596 -0
- package/native/src/sink.rs +274 -0
- package/native/src/snapshot.rs +672 -0
- package/native/src/stream.rs +334 -0
- package/native/src/tokenizer.rs +581 -0
- package/native/src/tracker.rs +232 -0
- package/native/vendor/README.md +35 -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 +530 -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 +2628 -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/native/vendor/scraper-0.24.0/Cargo.toml +52 -0
- package/native/vendor/scraper-0.24.0/LICENSE +15 -0
- package/native/vendor/scraper-0.24.0/src/element_ref/element.rs +212 -0
- package/native/vendor/scraper-0.24.0/src/element_ref/mod.rs +236 -0
- package/native/vendor/scraper-0.24.0/src/element_ref/serializable.rs +15 -0
- package/native/vendor/scraper-0.24.0/src/error/utils.rs +91 -0
- package/native/vendor/scraper-0.24.0/src/error.rs +118 -0
- package/native/vendor/scraper-0.24.0/src/html/mod.rs +270 -0
- package/native/vendor/scraper-0.24.0/src/html/serializable.rs +27 -0
- package/native/vendor/scraper-0.24.0/src/html/tree_sink.rs +285 -0
- package/native/vendor/scraper-0.24.0/src/lib.rs +180 -0
- package/native/vendor/scraper-0.24.0/src/node/serializable.rs +52 -0
- package/native/vendor/scraper-0.24.0/src/node.rs +465 -0
- package/native/vendor/scraper-0.24.0/src/selectable.rs +70 -0
- package/native/vendor/scraper-0.24.0/src/selector.rs +290 -0
- package/package.json +167 -4
- package/scripts/check-native.mjs +15 -0
- package/scripts/check-release.mjs +234 -0
- package/scripts/fix-declarations.mjs +39 -0
- package/scripts/generate-notices.mjs +194 -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/htmlparser2-MIT.txt +18 -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 +561 -0
- package/scripts/notices/xray-MIT.txt +21 -0
- package/src/attribute-object.ts +71 -0
- package/src/attributes.ts +308 -0
- package/src/cheerio-compat/css.ts +58 -0
- package/src/cheerio-compat/render.ts +106 -0
- package/src/cheerio-compat/selectors.ts +51 -0
- package/src/cheerio-compat/types.ts +52 -0
- package/src/cheerio-compat.ts +2055 -0
- package/src/codec.ts +96 -0
- package/src/dom.ts +87 -0
- package/src/extract-plan.ts +97 -0
- package/src/extract.ts +322 -0
- package/src/hooks.ts +369 -0
- package/src/index.ts +48 -0
- package/src/io.ts +491 -0
- package/src/match.ts +207 -0
- package/src/modern.ts +259 -0
- package/src/native.ts +149 -0
- package/src/nodes.ts +831 -0
- package/src/parse.ts +53 -0
- package/src/parser-types.ts +157 -0
- package/src/router.ts +1129 -0
- package/src/selection.ts +682 -0
- package/src/slim.ts +12 -0
- package/src/snapshot.ts +291 -0
- package/src/transport.ts +113 -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/tsdown.config.mjs +17 -0
package/Cargo.toml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "cheerox"
|
|
3
|
+
version = "0.1.2"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "Rust HTML5 parser and CSS selector engine for the cheerox Node.js package"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
|
|
8
|
+
[lib]
|
|
9
|
+
crate-type = ["cdylib", "rlib"]
|
|
10
|
+
path = "native/src/lib.rs"
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
ego-tree = "0.10"
|
|
14
|
+
html5ever = "0.35"
|
|
15
|
+
html5gum = "0.8.4"
|
|
16
|
+
url = "2"
|
|
17
|
+
napi = { version = "2", default-features = false, features = ["napi8", "async"] }
|
|
18
|
+
napi-derive = "2"
|
|
19
|
+
memchr = "2"
|
|
20
|
+
rayon = "1.10"
|
|
21
|
+
scraper = { version = "0.24", default-features = false, features = ["atomic"] }
|
|
22
|
+
serde = { version = "1", features = ["derive"] }
|
|
23
|
+
serde_json = { version = "1", features = ["preserve_order"] }
|
|
24
|
+
smallvec = "1"
|
|
25
|
+
|
|
26
|
+
# Parsing and tree writes allocate many small objects, which glibc's and musl's
|
|
27
|
+
# allocators serve slowly. The addon is loaded with dlopen, so mimalloc uses the
|
|
28
|
+
# dynamic TLS model; other platforms keep their allocator, since macOS mimalloc
|
|
29
|
+
# stores its thread heap in a fixed TLS slot that a second copy would share.
|
|
30
|
+
[target.'cfg(target_os = "linux")'.dependencies]
|
|
31
|
+
mimalloc = { version = "0.1", default-features = false, features = ["local_dynamic_tls"] }
|
|
32
|
+
|
|
33
|
+
[build-dependencies]
|
|
34
|
+
napi-build = "2"
|
|
35
|
+
|
|
36
|
+
[profile.release]
|
|
37
|
+
lto = "thin"
|
|
38
|
+
codegen-units = 1
|
|
39
|
+
strip = "symbols"
|
|
40
|
+
|
|
41
|
+
# Observer hooks retain the upstream HTML5 algorithm while exposing the actual
|
|
42
|
+
# open-element stack to user-supplied parse5-compatible tree adapters.
|
|
43
|
+
[patch.crates-io]
|
|
44
|
+
html5ever = { path = "native/vendor/html5ever-0.35.0" }
|
|
45
|
+
markup5ever = { path = "native/vendor/markup5ever-0.35.0" }
|
|
46
|
+
html5gum = { path = "native/vendor/html5gum-0.8.4" }
|
|
47
|
+
scraper = { path = "native/vendor/scraper-0.24.0" }
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Francisco Pizarro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cheerox
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center"><strong>Cheerio 0.22.0's API on a Rust engine.</strong></p>
|
|
4
|
+
|
|
5
|
+
cheerox is a nearly drop-in replacement for legacy **Cheerio 0.22.0**,
|
|
6
|
+
powered by a native Rust engine (NAPI-RS). Parsing, DOM storage,
|
|
7
|
+
selectors, and mutations run in Rust; TypeScript supplies the familiar API.
|
|
8
|
+
Zero npm runtime dependencies.
|
|
9
|
+
|
|
10
|
+
The vendored Cheerio 0.22.0 test suite runs at the same pass/fail set as the
|
|
11
|
+
real package (576/577 — the one failure is upstream dependency drift that the
|
|
12
|
+
reference itself reproduces; see [COMPATIBILITY.md](COMPATIBILITY.md)).
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @dvaji/cheerox
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Node.js 20.19+ is recommended. Prebuilt native binaries ship for macOS
|
|
21
|
+
arm64/x64, Linux glibc/musl arm64/x64, and Windows arm64/x64 — no Rust
|
|
22
|
+
toolchain needed at install time.
|
|
23
|
+
|
|
24
|
+
## The 0.22.0 API, unchanged
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const cheerio = require('@dvaji/cheerox');
|
|
28
|
+
|
|
29
|
+
const $ = cheerio.load('<div class="item">Hello</div>');
|
|
30
|
+
console.log($('.item').text()); // Hello
|
|
31
|
+
console.log($.html()); // <div class="item">Hello</div>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The module itself is callable, exactly like the original:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const element = cheerio('<div>Hello</div>');
|
|
38
|
+
console.log(cheerio.html(element));
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Legacy selector signatures work:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
$('li', '#container');
|
|
45
|
+
$('li', '<ul><li>Hello</li></ul>');
|
|
46
|
+
$('li', 'ul', '<ul><li>Hello</li></ul>');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Direct DOM access matches the original shapes — `node.type`, `node.name`,
|
|
50
|
+
`node.attribs` (writable), `node.children`, `node.parent`, `node.prev`,
|
|
51
|
+
`node.next`, `node.data`, `node.root`, plus the DOM Lvl 1 aliases
|
|
52
|
+
(`tagName`, `childNodes`, `parentNode`, `firstChild`, …).
|
|
53
|
+
|
|
54
|
+
`$.html()`, `$.xml()`, `$.text()`, `$.parseHTML()`, `$.root()`,
|
|
55
|
+
`$.contains()`, `$.version`, `$.fn`, chaining, `end()`, `each`/`map`,
|
|
56
|
+
`.attr()/.prop()/.data()/.val()`, classes, `.css()`, form serialization —
|
|
57
|
+
all verified by the upstream suite in [`test/legacy/`](test/legacy).
|
|
58
|
+
|
|
59
|
+
TypeScript and ESM:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import * as cheerio from '@dvaji/cheerox';
|
|
63
|
+
import cheerioDefault from '@dvaji/cheerox';
|
|
64
|
+
const $ = cheerio.load('<p>typed</p>');
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Modern extras (additive)
|
|
68
|
+
|
|
69
|
+
The engine's asynchronous, parallel capabilities stay available
|
|
70
|
+
from the same package; they keep the legacy parsing defaults:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { configureWorkers, loadAsync, loadAll, extractAll, workerPoolInfo } from '@dvaji/cheerox';
|
|
74
|
+
|
|
75
|
+
configureWorkers({ threads: 4 });
|
|
76
|
+
const $ = await loadAsync(largeHtml);
|
|
77
|
+
const docs = await loadAll(pages, { threads: 4 });
|
|
78
|
+
const rows = await extractAll(pages, { title: 'h1', links: [{ selector: 'a', value: 'href' }] });
|
|
79
|
+
console.log(workerPoolInfo());
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Performance
|
|
83
|
+
|
|
84
|
+
Parsing is 1.8–2.3x faster than cheerio 0.22.0; per-node operations over
|
|
85
|
+
loaded trees currently trade some speed for the live native DOM (measured,
|
|
86
|
+
with verified outputs, in [docs/BENCHMARK.md](docs/BENCHMARK.md) — run
|
|
87
|
+
`npm run bench:legacy` to reproduce).
|
|
88
|
+
|
|
89
|
+
## Compatibility
|
|
90
|
+
|
|
91
|
+
- [COMPATIBILITY.md](COMPATIBILITY.md) — the full behavioral report,
|
|
92
|
+
known divergences, and node-shape parity notes.
|
|
93
|
+
- `npm run test:legacy` — the untouched Cheerio 0.22.0 suite.
|
|
94
|
+
- `npm run test:legacy-oracle` — the same suite against the real package.
|
|
95
|
+
- `npm run test:differential` — 55 differential operations, machine-readable
|
|
96
|
+
report.
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
git clone https://github.com/dvaJi/cheerox.git
|
|
102
|
+
cd cheerox
|
|
103
|
+
npm ci
|
|
104
|
+
npm run build # native addon + TypeScript
|
|
105
|
+
npm test # runtime + release checks (modern)
|
|
106
|
+
npm run test:legacy # the 0.22.0 acceptance gate
|
|
107
|
+
npm run test:compat # legacy + 1.2.0 upstream suites
|
|
108
|
+
npm run test:native # cargo test
|
|
109
|
+
npm run check # tsc --noEmit
|
|
110
|
+
npm run test:types # consumer type checks
|
|
111
|
+
npm run bench:legacy # cheerox vs cheerio@0.22.0
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
See [COMPATIBILITY.md](COMPATIBILITY.md) for the behavioral report.
|
|
115
|
+
|
|
116
|
+
## Credits and license
|
|
117
|
+
|
|
118
|
+
With thanks to [Cheerio](https://github.com/cheeriojs/cheerio) and its
|
|
119
|
+
contributors for the API and the test suite that defines this project's
|
|
120
|
+
behavior. The vendored Cheerio 0.22.0 tests keep their MIT notice
|
|
121
|
+
([test/legacy/reference/LICENSE-MIT](test/legacy/reference/LICENSE-MIT)).
|
|
122
|
+
cheerox is MIT licensed ([LICENSE](LICENSE)).
|
package/RELEASING.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Releasing cheerox
|
|
2
|
+
|
|
3
|
+
The public npm package name is **`@dvaji/cheerox`**. Releases include all eight
|
|
4
|
+
native binaries, self-contained TypeScript declarations, source files and
|
|
5
|
+
license notices. Consumers install no additional npm packages and need no
|
|
6
|
+
Rust toolchain on supported platforms.
|
|
7
|
+
|
|
8
|
+
## Trusted publishing
|
|
9
|
+
|
|
10
|
+
The repository must be publicly visible for the publishing workflow's
|
|
11
|
+
provenance checks. The workflow publishes exclusively through npm trusted
|
|
12
|
+
publishing with OIDC; it has no token-authentication or bootstrap path.
|
|
13
|
+
|
|
14
|
+
Configure the GitHub Actions trusted publisher in the existing npm package's
|
|
15
|
+
settings:
|
|
16
|
+
|
|
17
|
+
| Field | Value |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| Organization | `dvaJi` |
|
|
20
|
+
| Repository | `dvaJi/cheerox` |
|
|
21
|
+
| Workflow filename | `publish.yml` |
|
|
22
|
+
| Environment | `npm` |
|
|
23
|
+
| Allowed action | Direct publishing with `npm publish` |
|
|
24
|
+
|
|
25
|
+
Configure the GitHub `npm` environment for maintainers and permit releases from
|
|
26
|
+
`master`. The workflow uses GitHub-hosted runners, Node 24, npm 11.5.1 or newer,
|
|
27
|
+
and OIDC authentication. It requires no stored npm token.
|
|
28
|
+
|
|
29
|
+
A new trusted-publisher configuration must complete its first successful
|
|
30
|
+
publication within two days. Prepare and publish a new version within that
|
|
31
|
+
window; an existing npm version cannot be republished to validate the
|
|
32
|
+
configuration. If it expires, delete and recreate it when the next release is
|
|
33
|
+
ready. See [npm's trusted-publishing
|
|
34
|
+
documentation](https://docs.npmjs.com/trusted-publishers/) for configuration and
|
|
35
|
+
expiry details.
|
|
36
|
+
|
|
37
|
+
After the first successful OIDC release, revoke the obsolete bootstrap token
|
|
38
|
+
in npm and delete `NPM_BOOTSTRAP_TOKEN` from the GitHub `npm` environment. That
|
|
39
|
+
credential was used only to establish initial package ownership and is not
|
|
40
|
+
needed by this workflow.
|
|
41
|
+
|
|
42
|
+
## Prepare a version
|
|
43
|
+
|
|
44
|
+
Update `package.json`, `package-lock.json`, `Cargo.toml` and `Cargo.lock` to the
|
|
45
|
+
same semantic version. Regenerate the notices with `npm run notices:generate`
|
|
46
|
+
and merge the release changes to `master`. Use `next` for prerelease versions.
|
|
47
|
+
Confirm the build, tests and packaging checks pass.
|
|
48
|
+
|
|
49
|
+
Create a version tag on the current `master` commit:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
git switch master
|
|
53
|
+
git pull --ff-only
|
|
54
|
+
git tag v0.1.1
|
|
55
|
+
git push origin v0.1.1
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Replace `0.1.1` with the intended version. Dispatch publication before making
|
|
59
|
+
another commit to `master`: the tag, package version, Cargo version and the
|
|
60
|
+
workflow's `master` commit must identify the same release.
|
|
61
|
+
|
|
62
|
+
## Publish a release
|
|
63
|
+
|
|
64
|
+
Run the **Publish to npm** workflow from `master`, with the exact package version
|
|
65
|
+
and npm dist-tag:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
gh workflow run publish.yml \
|
|
69
|
+
--repo dvaJi/cheerox \
|
|
70
|
+
--ref master \
|
|
71
|
+
-f version=0.1.1 \
|
|
72
|
+
-f npm_tag=latest
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The workflow validates the public repository and exact release commit, runs the
|
|
76
|
+
complete build/test matrix, assembles one tarball, and checks its source,
|
|
77
|
+
license, metadata, checksum and all eight native binary architectures. It
|
|
78
|
+
installs and tests that exact artifact before publishing it with provenance.
|
|
79
|
+
|
|
80
|
+
Pushes, pull requests, and ordinary CI runs build and test without publishing.
|
|
81
|
+
Publication requires the separate manual workflow and any configured `npm`
|
|
82
|
+
environment protection. Normal OIDC releases require no stored npm token.
|
|
83
|
+
|
|
84
|
+
## Package checks
|
|
85
|
+
|
|
86
|
+
For a local development build:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
npm run build
|
|
90
|
+
npm run test:package
|
|
91
|
+
npm run release:check -- --local
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
For a complete release artifact containing all targets:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
npm run release:check -- --tarball release --commit <release-commit>
|
|
98
|
+
npm run test:package -- release
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`release:check` rejects missing binaries, incorrect architectures, accidental
|
|
102
|
+
package files, missing notices, version mismatches and npm runtime dependencies.
|
|
103
|
+
The CI-produced `manifest.json` records the commit and tarball checksum for
|
|
104
|
+
publication verification. Provenance is generated by npm's supported CI
|
|
105
|
+
publishing flow; see [npm's provenance
|
|
106
|
+
documentation](https://docs.npmjs.com/generating-provenance-statements/).
|
|
107
|
+
|
|
108
|
+
Linux GNU builds run inside pinned glibc 2.28 images on both architectures.
|
|
109
|
+
The binary audit reads ELF symbol-version requirements and rejects binaries
|
|
110
|
+
requiring newer glibc, a C++ runtime, or the wrong libc. Windows releases include
|
|
111
|
+
both x64 and arm64; their PE machine headers are checked. The package includes
|
|
112
|
+
the exact patched html5ever/markup5ever/html5gum sources and original notices alongside
|
|
113
|
+
cheerox's source. Regenerate third-party notices after any Cargo dependency
|
|
114
|
+
or compiler change.
|