@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes-jbWWhssj.cjs","names":["registryKey","globals","registry","dirname","fileURLToPath","require","createRequire","join","existsSync","STRIDE"],"sources":["../src/codec.ts","../src/transport.ts","../src/native.ts","../src/attribute-object.ts","../src/snapshot.ts","../src/hooks.ts","../src/router.ts","../src/dom.ts","../src/nodes.ts"],"sourcesContent":["/**\n * Node strings use UTF-16, including unpaired surrogates. Rust strings use\n * Unicode scalar values. Reserve a small private-use alphabet on this private\n * boundary so neither representation loses a code unit.\n */\nconst reserved = /[\\ud800-\\ue800]/;\nconst encoded = /[\\ue000-\\ue800]/;\nconst escapeUnit = 0xe800;\nconst isWellFormed = (String.prototype as String & { isWellFormed?(): boolean }).isWellFormed;\n\nexport function encodeString(value: string): string {\n if (!encoded.test(value) && (isWellFormed ? isWellFormed.call(value) : !reserved.test(value))) return value;\n const parts: string[] = [];\n let start = 0;\n for (let index = 0; index < value.length; index++) {\n const unit = value.charCodeAt(index);\n if (unit >= 0xd800 && unit <= 0xdbff) {\n const next = value.charCodeAt(index + 1);\n if (next >= 0xdc00 && next <= 0xdfff) { index++; continue; }\n }\n let replacement: string | undefined;\n if (unit >= 0xd800 && unit <= 0xdfff) replacement = String.fromCharCode(0xe000 + unit - 0xd800);\n else if (unit >= 0xe000 && unit <= escapeUnit) replacement = '\\ue800' + value[index];\n if (replacement !== undefined) {\n parts.push(value.slice(start, index), replacement);\n start = index + 1;\n }\n }\n return start === 0 ? value : parts.join('') + value.slice(start);\n}\n\nexport function decodeString(value: string): string {\n if (!encoded.test(value)) return value;\n const parts: string[] = [];\n let start = 0;\n for (let index = 0; index < value.length; index++) {\n const unit = value.charCodeAt(index);\n if (unit < 0xe000 || unit > escapeUnit) continue;\n const next = value.charCodeAt(index + 1);\n if (unit === escapeUnit) {\n if (next < 0xe000 || next > escapeUnit || Number.isNaN(next)) continue;\n parts.push(value.slice(start, index), value[++index]);\n } else parts.push(value.slice(start, index), String.fromCharCode(0xd800 + unit - 0xe000));\n start = index + 1;\n }\n return start === 0 ? value : parts.join('') + value.slice(start);\n}\n\n// Transform JSON string tokens rather than the whole JSON text: JSON.stringify\n// escapes lone surrogates, while a literal backslash-u sequence is plain data.\nconst encodeJsonCandidate = /[\\ud800-\\ue800]|\\\\u(?:d[89a-f][\\da-f]{2}|e[0-8][\\da-f]{2})/i;\nconst escapedJsonCandidate = /\\\\u(?:d[89a-f][\\da-f]{2}|e[0-8][\\da-f]{2})/i;\nconst decodeJsonCandidate = /[\\ue000-\\ue800]|\\\\ue[0-8][\\da-f]{2}/i;\n\nexport function encodeJson(value: string): string {\n if (!encodeJsonCandidate.test(value)) return value;\n if (isWellFormed?.call(value) && !encoded.test(value) && !escapedJsonCandidate.test(value)) return value;\n return mapJsonStrings(value, encodeString, encodeJsonCandidate);\n}\n\nexport function decodeJson(value: string): string {\n return decodeJsonCandidate.test(value) ? mapJsonStrings(value, decodeString, decodeJsonCandidate) : value;\n}\n\n/**\n * Replaces every string token of the JSON text `json` with `transform` of its\n * value, in one left-to-right pass. A regular expression scanning for tokens\n * retries from every quote of an unterminated token, which is quadratic.\n */\nfunction mapJsonStrings(json: string, transform: (value: string) => string, candidate: RegExp): string {\n const parts: string[] = [];\n let copied = 0;\n let quote = json.indexOf('\"');\n while (quote !== -1) {\n let end = quote + 1;\n while (end < json.length && json.charCodeAt(end) !== 0x22) end += json.charCodeAt(end) === 0x5c ? 2 : 1;\n if (end >= json.length) break;\n const token = json.slice(quote, end + 1);\n if (candidate.test(token)) {\n parts.push(json.slice(copied, quote), JSON.stringify(transform(JSON.parse(token))));\n copied = end + 1;\n }\n quote = json.indexOf('\"', end + 1);\n }\n return copied === 0 ? json : parts.join('') + json.slice(copied);\n}\n\n/** Private parser protocol flag, appended without deserializing large options. */\nexport function encodeOptions(value?: string): string {\n if (value === undefined) return '{\"__utf16Codec\":true}';\n const json = encodeJson(value);\n if (!json.trimStart().startsWith('{')) return '{\"__utf16Codec\":true}';\n const end = json.lastIndexOf('}');\n const prefix = json.slice(0, end);\n return prefix + (prefix.trimEnd().endsWith('{') ? '' : ',') + '\"__utf16Codec\":true' + json.slice(end);\n}\n","import { decodeJson, decodeString, encodeJson, encodeOptions, encodeString } from './codec.js';\nimport type { NativeBinding, NativeDocument } from './native.js';\n\ninterface TransportRegistry {\n userErrors: WeakSet<object>;\n}\nconst registryKey = Symbol.for('cheerox.native-transport.v2');\nconst globals = globalThis as typeof globalThis & { [key: symbol]: TransportRegistry | undefined };\nconst registry = globals[registryKey] ??= { userErrors: new WeakSet() };\nconst transportedKey = Symbol.for('cheerox.native-transport.prototype');\n\nconst jsonMethods = new Set(['op', 'node', 'exportTree', 'exportTreeWithOffset', 'parserDiagnostics', 'adopt']);\n/** String arguments each document method takes, by position, and how to encode them. */\nconst argumentEncoders: Record<string, (args: any[]) => void> = {\n op: (args) => { args[1] = encodeJson(args[1]); },\n create: (args) => { args[0] = encodeString(args[0]); if (typeof args[2] === 'string') args[2] = encodeOptions(args[2]); },\n select: (args) => { args[0] = encodeString(args[0]); },\n matches: (args) => { args[0] = encodeString(args[0]); },\n attr: (args) => { args[1] = encodeString(args[1]); },\n setAttribute: (args) => { args[1] = encodeString(args[1]); if (typeof args[2] === 'string') args[2] = encodeString(args[2]); },\n render: (args) => { if (typeof args[1] === 'string') args[1] = encodeJson(args[1]); },\n};\n\n/** Keep the codec at the private addon boundary, including callback RPC. */\nexport function wrapNativeBinding(binding: NativeBinding): NativeBinding {\n const raw = binding as NativeBinding & Record<string, any>;\n const { userErrors } = registry;\n const restoreError = (error: unknown): never => {\n if (error instanceof Error && !userErrors.has(error)) {\n const message = decodeString(error.message);\n if (message !== error.message) {\n const stack = error.stack;\n error.message = message;\n if (stack) error.stack = decodeString(stack);\n }\n }\n throw error;\n };\n const invoke = <T>(call: () => T): T => {\n try {\n const result = call();\n return result instanceof Promise ? result.catch(restoreError) as T : result;\n } catch (error) { return restoreError(error); }\n };\n const wrapBridge = (bridge: (request: string) => string) => (request: string): string => {\n try { return encodeJson(bridge(decodeJson(request))); }\n catch (error) {\n if (error !== null && (typeof error === 'object' || typeof error === 'function')) userErrors.add(error);\n throw error;\n }\n };\n // Wrapping the class's methods once, rather than each document in a proxy,\n // keeps native calls free of per-document and per-call allocations.\n const transportMethod = (name: string, method: (...args: any[]) => unknown) => {\n const encodeArguments = argumentEncoders[name];\n const decode = jsonMethods.has(name) ? decodeJson : decodeString;\n const isOperation = name === 'op';\n return function transported(this: NativeDocument, ...args: any[]): unknown {\n try {\n if (encodeArguments) encodeArguments(args);\n const result = method.apply(this, args);\n if (typeof result !== 'string') return result;\n if (isOperation && args[0] === 'serialize' && result.startsWith('{')) {\n const error = JSON.parse(result).__nativeError;\n if (error?.name === 'URIError') throw new URIError(error.message);\n }\n return decode(result);\n } catch (error) { return restoreError(error); }\n };\n };\n const prototype = raw.NativeDocument.prototype as Record<PropertyKey, unknown>;\n if (!Object.hasOwn(prototype, transportedKey)) {\n for (const name of Object.getOwnPropertyNames(prototype)) {\n const method = prototype[name];\n if (name !== 'constructor' && typeof method === 'function') prototype[name] = transportMethod(name, method as (...args: any[]) => unknown);\n }\n Object.defineProperty(prototype, transportedKey, { value: true });\n }\n const wrapStream = (stream: any) => {\n let carry = '';\n return {\n async write(chunk: string) {\n let source = carry + chunk;\n carry = '';\n const last = source.charCodeAt(source.length - 1);\n if (last >= 0xd800 && last <= 0xdbff) { carry = source.slice(-1); source = source.slice(0, -1); }\n if (source) await invoke(() => stream.write(encodeString(source)));\n },\n async finish() {\n if (carry) { const final = carry; carry = ''; await invoke(() => stream.write(encodeString(final))); }\n return invoke(() => stream.finish());\n },\n abort() { carry = ''; return invoke(() => stream.abort()); },\n };\n };\n const wrapConstructor = (Constructor: any, argumentsFor: (args: any[]) => any[], wrap: (value: any) => any) => new Proxy(Constructor, {\n construct(target, args) { return wrap(invoke(() => Reflect.construct(target, argumentsFor(args)))); },\n });\n const wrapped: NativeBinding & Record<string, any> = { ...raw };\n const Document = raw.NativeDocument;\n wrapped.NativeDocument = function NativeDocument(html: string, isDocument?: boolean, options?: string) {\n try { return new Document(encodeString(html), isDocument, encodeOptions(options)); }\n catch (error) { return restoreError(error); }\n } as unknown as NativeBinding['NativeDocument'];\n if (raw.NativeStream) wrapped.NativeStream = wrapConstructor(raw.NativeStream, ([options, isDocument, bridge]) => [encodeOptions(options), isDocument, bridge && wrapBridge(bridge)], wrapStream);\n if (raw.NativeHookStream) wrapped.NativeHookStream = wrapConstructor(raw.NativeHookStream, ([isDocument, options, bridge]) => [isDocument, encodeOptions(options), wrapBridge(bridge)], wrapStream);\n if (raw.parseWithTreeAdapter) wrapped.parseWithTreeAdapter = (source: string, isDocument: boolean, options: string, bridge: (request: string) => string) => invoke(() => raw.parseWithTreeAdapter(encodeString(source), isDocument, encodeOptions(options), wrapBridge(bridge)));\n if (raw.parseAsync) wrapped.parseAsync = (source, isDocument, options) => invoke(() => raw.parseAsync!(encodeString(source), isDocument, encodeOptions(options)));\n if (raw.parseManyAsync) wrapped.parseManyAsync = (sources, isDocument, threads, options, plans) => invoke(() => raw.parseManyAsync!(sources.map(encodeString), isDocument, threads, encodeOptions(options), plans === undefined ? undefined : encodeJson(plans)));\n if (raw.extractPlanManyAsync) wrapped.extractPlanManyAsync = async (sources, plan, threads, options) => decodeJson(await invoke(() => raw.extractPlanManyAsync!(sources.map(encodeString), encodeJson(plan), threads, encodeOptions(options))));\n if (raw.extractManyAsync) wrapped.extractManyAsync = async (sources, queries, threads, isDocument, options) => decodeJson(await invoke(() => raw.extractManyAsync!(sources.map(encodeString), queries.map((query) => ({ ...query, key: encodeString(query.key), selector: encodeString(query.selector), ...(query.attr === undefined ? {} : { attr: encodeString(query.attr) }) })), threads, isDocument, encodeOptions(options))));\n return wrapped;\n}\n","import { createRequire } from 'node:module';\nimport { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { wrapNativeBinding } from './transport.js';\nimport type { NativeSnapshot } from './snapshot.js';\n\nexport interface NativeNodeRecord {\n id: number;\n type: 'root' | 'tag' | 'script' | 'style' | 'text' | 'comment' | 'directive' | 'cdata';\n name?: string;\n data?: string;\n attribs?: Record<string, string>;\n children: number[];\n parent?: number;\n namespace?: string;\n prefix?: string;\n attribsNamespace?: Record<string, string>;\n attribsPrefix?: Record<string, string>;\n doctypeName?: string;\n publicId?: string;\n systemId?: string;\n 'x-name'?: string;\n 'x-publicId'?: string;\n 'x-systemId'?: string;\n 'x-mode'?: 'quirks' | 'limited-quirks' | 'no-quirks';\n [key: string]: any;\n}\n\nexport interface NativeDocument {\n readonly nodeSpace?: object;\n retainNode?(id: number): void;\n retainNodeData?(id: number, data: object): void;\n adopt?(source: NativeDocument, ids: number[], detach?: boolean): string;\n op(command: string, argsJson: string): string;\n create?(html: string, contextId?: number, optionsJson?: string): number[];\n select(selector: string, contexts?: number[]): number[];\n text(ids: number[]): string;\n innerHtml(id: number): string;\n outerHtml(ids: number[]): string;\n attr(id: number, name: string): string | undefined | null;\n tagName(id: number): string | undefined | null;\n exportTree(): string;\n exportTreeWithOffset?(base: number): string;\n forestRoots?(): number[];\n rootId(): number;\n takePreparedPlans?(): (string | null)[] | null;\n takePreparedSnapshot?(isWanted: boolean): NativeSnapshot | null;\n parserDiagnostics?(): string;\n}\n\nexport interface NativeStream {\n write(chunk: string): Promise<void>;\n finish(): Promise<NativeDocument>;\n abort(): void;\n}\n\nexport interface NativeWorkerPoolInfo {\n threads: number;\n activeBatches: number;\n activeWorkers: number;\n peakActiveWorkers: number;\n}\n\nexport interface NativeQuery {\n key: string;\n selector: string;\n attr?: string;\n all?: boolean;\n}\n\nexport interface NativeBinding {\n NativeDocument: new (html: string, isDocument?: boolean, optionsJson?: string) => NativeDocument;\n NativeStream?: new (optionsJson: string, isDocument?: boolean, errorBridge?: (request: string) => string) => NativeStream;\n configureWorkerPool?: (threads: number) => void;\n workerPoolInfo?: () => NativeWorkerPoolInfo;\n extractPlanManyAsync?: (html: string[], planJson: string, threads: number, optionsJson?: string) => Promise<string>;\n parseAsync?: (html: string, isDocument?: boolean, optionsJson?: string) => Promise<NativeDocument>;\n parseManyAsync?: (\n html: string[],\n isDocument: boolean,\n threads: number,\n optionsJson?: string,\n plansJson?: string,\n ) => Promise<NativeDocument[]>;\n extractManyAsync?: (\n html: string[],\n queries: NativeQuery[],\n threads: number,\n isDocument?: boolean,\n optionsJson?: string,\n ) => Promise<string>;\n}\n\nlet cached: NativeBinding | undefined;\nlet attempted = false;\nlet bindingError: unknown;\n\n/**\n * The directory of this bundle, shared by the package's CommonJS and ESM\n * entry points and distinct for every installed copy of the package.\n */\nexport function packageDirectory(): string {\n return typeof __dirname === 'string' ? __dirname : dirname(fileURLToPath(import.meta.url));\n}\n\n/** Resolve the native addon bundled with the npm package. */\nexport function nativeBinding(): NativeBinding | undefined {\n if (attempted) return cached;\n attempted = true;\n\n // This module is bundled into both CommonJS and ESM entry points. A synthetic\n // absolute filename lets createRequire work in both module formats.\n const moduleDirectory = packageDirectory();\n const require = createRequire(join(moduleDirectory, 'cheerox-loader.cjs'));\n const directories = [moduleDirectory, dirname(moduleDirectory)];\n const libc = process.platform === 'linux'\n ? ((process.report?.getReport() as { header?: { glibcVersionRuntime?: string } })?.header?.glibcVersionRuntime ? 'gnu' : 'musl')\n : undefined;\n const platform = `${process.platform}-${process.arch}${libc ? `-${libc}` : process.platform === 'win32' ? '-msvc' : ''}`;\n const names = [`cheerox.${platform}.node`, 'cheerox.node'];\n const candidates = [...new Set(directories.flatMap((directory) => names.map((name) => join(directory, name))))];\n\n for (const candidate of candidates) {\n if (!existsSync(candidate)) continue;\n try {\n const loaded: NativeBinding = require(candidate);\n if (typeof loaded.NativeDocument === 'function') {\n cached = wrapNativeBinding(loaded);\n return cached;\n }\n } catch (error) {\n bindingError ??= error;\n }\n }\n return undefined;\n}\n\nexport function requireNative(): NativeBinding {\n const binding = nativeBinding();\n if (binding) return binding;\n throw new Error('Cheerox could not load its Rust native binding. Reinstall cheerox for this platform or run \"npm run build:native\" from a source checkout.', { cause: bindingError });\n}\n\n/** Useful for installation diagnostics and benchmarks that require native code. */\nexport function nativeStatus(): { available: boolean; error?: string } {\n const available = !!nativeBinding();\n return available ? { available } : { available, error: String(bindingError ?? 'Native binding not found') };\n}\n","/**\n * Attribute objects: real objects whose enumerable keys are shared accessor\n * pairs, so reads cost what plain-object reads do while direct writes still\n * reach the node's native record. Values live in one hidden metadata object\n * per attribute object (`values`), attached under a non-enumerable symbol;\n * deep equality and JSON therefore see only the attribute keys. This module\n * is dependency-free: `nodes.ts` and `snapshot.ts` both use it.\n */\n\nexport interface AttributeMeta { view: unknown; generation: number; state: unknown; values: Record<string, any>; write?: (view: unknown, attributes: AttributeObject, key: string, value: unknown) => void }\nexport const ATTR_META: unique symbol = Symbol.for('cheerox.attribs.meta') as any;\nexport interface AttributeObject { [key: string]: any; [ATTR_META]?: AttributeMeta }\n\nconst accessorPairs = new Map<string, PropertyDescriptor>();\n\n/** One shared accessor pair per attribute name; `this` is the attribute object. */\nfunction accessorPairFor(key: string): PropertyDescriptor {\n let pair = accessorPairs.get(key);\n if (pair === undefined) {\n pair = {\n get(this: AttributeObject) { return this[ATTR_META]!.values[key]; },\n set(this: AttributeObject, value: unknown) { const meta = this[ATTR_META]!; meta.write?.(meta.view, this, key, value); },\n enumerable: true, configurable: true,\n };\n accessorPairs.set(key, pair);\n }\n return pair;\n}\n\n/** Defines a shared accessor for `key` when the object has none yet. */\nexport function defineAttributeAccessor(attributes: AttributeObject, key: string): void {\n if (!Object.hasOwn(attributes, key)) Object.defineProperty(attributes, key, accessorPairFor(key));\n}\n\n/**\n * Defines an attribute key with its stored value. `__proto__` must stay a\n * plain data property on both layers: an accessor there would shadow the\n * prototype's setter, reflection expects a value descriptor, and assigning\n * `values.__proto__` would mutate the store's prototype instead of setting a\n * key.\n */\nexport function defineAttributeKey(attributes: AttributeObject, key: string, value: unknown): void {\n const values = attributes[ATTR_META]!.values;\n if (key === '__proto__') {\n Object.defineProperty(attributes, key, { value, writable: true, enumerable: true, configurable: true });\n Object.defineProperty(values, key, { value, writable: true, enumerable: true, configurable: true });\n } else {\n defineAttributeAccessor(attributes, key);\n values[key] = value;\n }\n}\n\n/** Attaches the metadata that accessor setters need to reach the record. */\nexport function setAttributeMeta(attributes: AttributeObject, meta: AttributeMeta): void {\n Object.defineProperty(attributes, ATTR_META, { value: meta, enumerable: false, writable: true, configurable: true });\n}\n\n/** Assigns or removes an attribute from the outside (the router's fast native paths). */\nexport function attributeAssign(attributes: AttributeObject, name: string, value: string | null): void {\n const meta = attributes[ATTR_META];\n if (!meta) return;\n if (value === null) {\n delete attributes[name];\n // `delete values.__proto__` on the store object is safe only for an own\n // data property; `__proto__` keys are defined exactly that way.\n delete meta.values[name];\n } else {\n defineAttributeKey(attributes, name, value);\n }\n meta.generation = -1;\n}\n","import { decodeString } from './codec.js';\nimport type { NativeNodeRecord } from './native.js';\nimport { defineAttributeKey, type AttributeObject } from './attribute-object.js';\n\n/**\n * The compact record copy returned by `NativeDocument.snapshot()`: the\n * lengths of the node, child, attribute and string lists, whether any string\n * holds codec escapes, then the lists.\n */\nexport interface NativeSnapshot {\n data: Uint32Array;\n text: string;\n}\nconst HEADER = 5;\n\nconst STRIDE = 15;\nconst ABSENT = 0xffffffff;\nconst HAS_START_INDEX = 1;\nconst HAS_END_INDEX = 2;\nconst HAS_NAMESPACE = 4;\nconst EMPTY_ATTRIBUTE_MAPS = 8;\nconst OPAQUE = 16;\nconst RELEASED = 32;\nconst noChildren: number[] = Object.freeze([]) as unknown as number[];\nconst noAttributes: Record<string, string> = Object.freeze({}) as Record<string, string>;\n\n/**\n * A record read from a snapshot. It stores only its position; fields decode\n * on read, and strings and lists are kept once decoded. Every instance has\n * the same fields, so reads stay monomorphic. Absent fields read `undefined`.\n */\nclass SnapshotRecord {\n private decodedData: string | undefined;\n private decodedAttributes: Record<string, string> | undefined;\n private decodedChildren: number[] | undefined;\n\n constructor(private readonly snapshot: NodeSnapshot, readonly id: number, private readonly base: number) {\n this.decodedData = undefined;\n this.decodedAttributes = undefined;\n this.decodedChildren = undefined;\n }\n\n get type(): string { return this.snapshot.name(this.snapshot.nodes[this.base]); }\n get name(): string | undefined { const name = this.snapshot.nodes[this.base + 6]; return name ? this.snapshot.name(name - 1) : undefined; }\n get data(): string | undefined {\n if (this.decodedData !== undefined) return this.decodedData;\n const data = this.snapshot.nodes[this.base + 7];\n return data ? this.decodedData = this.snapshot.string(data - 1) : undefined;\n }\n get parent(): number | null { const parent = this.snapshot.nodes[this.base + 1]; return parent ? parent - 1 : null; }\n get prev(): number | null { const prev = this.snapshot.nodes[this.base + 2]; return prev ? prev - 1 : null; }\n get next(): number | null { const next = this.snapshot.nodes[this.base + 3]; return next ? next - 1 : null; }\n get startIndex(): number | null | undefined { return this.index(HAS_START_INDEX, 11); }\n get endIndex(): number | null | undefined { return this.index(HAS_END_INDEX, 12); }\n get namespace(): string | undefined { const nodes = this.snapshot.nodes; return nodes[this.base + 10] & HAS_NAMESPACE ? this.snapshot.name(nodes[this.base + 13]) : undefined; }\n get attribsNamespace(): Record<string, string> | undefined { return this.snapshot.nodes[this.base + 10] & EMPTY_ATTRIBUTE_MAPS ? {} : undefined; }\n get attribsPrefix(): Record<string, string> | undefined { return this.snapshot.nodes[this.base + 10] & EMPTY_ATTRIBUTE_MAPS ? {} : undefined; }\n get attribs(): Record<string, string> { return this.decodedAttributes ??= this.snapshot.attributesOf(this.id); }\n get children(): number[] { return this.decodedChildren ??= this.snapshot.childrenOf(this.id); }\n\n private index(flag: number, offset: number): number | null | undefined {\n const nodes = this.snapshot.nodes;\n if (!(nodes[this.base + 10] & flag)) return undefined;\n const value = nodes[this.base + offset];\n return value === ABSENT ? null : value;\n }\n}\n\n/** Snapshot records extended with fields stored as JSON, which are rare. */\nconst recordFields = ['type', 'name', 'data', 'parent', 'prev', 'next', 'startIndex', 'endIndex', 'namespace', 'attribsNamespace', 'attribsPrefix', 'attribs', 'children'] as const;\n\n/** A plain copy of a record, for callers that spread or serialize it. */\nexport function plainRecord(record: NativeNodeRecord): NativeNodeRecord {\n if (!(record instanceof SnapshotRecord)) return record;\n const copy: Record<string, unknown> = { id: record.id };\n for (const field of recordFields) { const value = (record as any)[field]; if (value !== undefined) copy[field] = value; }\n for (const key of Object.keys(record)) if (!key.startsWith('decoded') && key !== 'snapshot' && key !== 'base' && key !== 'id') copy[key] = (record as any)[key];\n return copy as NativeNodeRecord;\n}\n\n/** Decodes node records from a snapshot on demand, exactly as `node()` returns them. */\nexport class NodeSnapshot {\n readonly size: number;\n readonly nodes: Uint32Array;\n private readonly children: Uint32Array;\n private readonly attributes: Uint32Array;\n private readonly strings: Uint32Array;\n private readonly text: string;\n private readonly isEncoded: boolean;\n private readonly names: (string | undefined)[] = [];\n /** Per interned type: 1 for element types, 2 for root, 3 for text, 0 otherwise. */\n private readonly typeKinds: (number | undefined)[] = [];\n /** Node object constructors by interned type, resolved once per snapshot. */\n viewConstructors: unknown = undefined;\n /** Text nodes too large for the arrays, read individually while this snapshot is current. */\n readonly largeTexts = new Map<number, string>();\n\n constructor(raw: NativeSnapshot) {\n const { data } = raw;\n const childrenStart = HEADER + data[0];\n const attributesStart = childrenStart + data[1];\n const stringsStart = attributesStart + data[2];\n this.text = raw.text;\n this.isEncoded = data[4] === 1;\n this.nodes = data.subarray(HEADER, childrenStart);\n this.children = data.subarray(childrenStart, attributesStart);\n this.attributes = data.subarray(attributesStart, stringsStart);\n this.strings = data.subarray(stringsStart, stringsStart + data[3]);\n this.size = this.nodes.length / STRIDE;\n }\n\n /** The record, `null` for a released node, or `undefined` when it must be read individually. */\n record(local: number): NativeNodeRecord | null | undefined {\n if (local >= this.size) return undefined;\n const base = local * STRIDE;\n const flags = this.nodes[base + 10];\n if (flags & RELEASED) return null;\n if (flags & OPAQUE) return undefined;\n const record = new SnapshotRecord(this, local, base);\n const extras = this.nodes[base + 14];\n if (extras) {\n // Fields stored as JSON, such as foreign attribute namespaces, shadow the decoded getters.\n const fields = JSON.parse(this.string(extras - 1));\n for (const key of Object.keys(fields)) Object.defineProperty(record, key, { value: fields[key], writable: true, enumerable: true, configurable: true });\n }\n return record as unknown as NativeNodeRecord;\n }\n\n /** Whether a node's fields all live in the arrays, so callers may read them without a record. */\n isPlain(local: number): boolean {\n if (local >= this.size) return false;\n const base = local * STRIDE;\n return (this.nodes[base + 10] & (OPAQUE | RELEASED)) === 0 && this.nodes[base + 14] === 0;\n }\n\n typeOf(local: number): string {\n return this.name(this.nodes[local * STRIDE]);\n }\n\n nameOf(local: number): string | undefined {\n const name = this.nodes[local * STRIDE + 6];\n return name ? this.name(name - 1) : undefined;\n }\n\n dataOf(local: number): string | undefined {\n const data = this.nodes[local * STRIDE + 7];\n return data ? this.string(data - 1) : undefined;\n }\n\n /** The parent, previous or next sibling (`offset` 1, 2 or 3), or `null`. */\n linkOf(local: number, offset: number): number | null {\n const link = this.nodes[local * STRIDE + offset];\n return link ? link - 1 : null;\n }\n\n namespaceOf(local: number): string | undefined {\n const base = local * STRIDE;\n return this.nodes[base + 10] & HAS_NAMESPACE ? this.name(this.nodes[base + 13]) : undefined;\n }\n\n /** A node's attributes as parse5 attribute objects; plain nodes have no namespaced ones. */\n attributeObjects(local: number): { name: string; value: string }[] {\n const base = local * STRIDE;\n const count = this.nodes[base + 9];\n const first = this.nodes[base + 8];\n const attributes = this.attributes;\n const result: { name: string; value: string }[] = new Array(count);\n for (let index = 0; index < count; index++) {\n const pair = (first + index) * 2;\n result[index] = { name: this.name(attributes[pair]), value: this.string(attributes[pair + 1]) };\n }\n return result;\n }\n\n /** Copies a node's attributes onto `target`, in order. */\n /** Copies a node's attributes as the shared accessors of `attributes`, in record order. */\n copyAttributes(local: number, attributes: AttributeObject): void {\n const base = local * STRIDE;\n const count = this.nodes[base + 9];\n const first = this.nodes[base + 8];\n const attributes_ = this.attributes;\n for (let index = 0; index < count; index++) {\n const pair = (first + index) * 2;\n defineAttributeKey(attributes, this.name(attributes_[pair]), this.string(attributes_[pair + 1]));\n }\n }\n\n /** The flat child id list; a node's children start at `childStart(local)`. */\n get childIds(): Uint32Array { return this.children; }\n\n childStart(local: number): number {\n return this.nodes[local * STRIDE + 4];\n }\n\n /** Whether a node is an element: a tag, script or style. */\n isElementAt(local: number): boolean {\n return this.typeKind(local) === 1;\n }\n\n isRootAt(local: number): boolean {\n return this.typeKind(local) === 2;\n }\n\n isTextAt(local: number): boolean {\n return this.typeKind(local) === 3;\n }\n\n /** Whether a node's record adds fields stored as JSON, such as source locations. */\n hasExtraFields(local: number): boolean {\n return this.nodes[local * STRIDE + 14] !== 0;\n }\n\n /** Whether the slot holds a node, rather than one a collection released. */\n isPresent(local: number): boolean {\n return local < this.size && (this.nodes[local * STRIDE + 10] & RELEASED) === 0;\n }\n\n private typeKind(local: number): number {\n const reference = this.nodes[local * STRIDE];\n let kind = this.typeKinds[reference];\n if (kind === undefined) {\n const type = this.name(reference);\n kind = this.typeKinds[reference] = type === 'tag' || type === 'script' || type === 'style' ? 1 : type === 'root' ? 2 : type === 'text' ? 3 : 0;\n }\n return kind;\n }\n\n /** The interned reference of a node's type, comparable across nodes of this snapshot. */\n typeReference(local: number): number {\n return this.nodes[local * STRIDE];\n }\n\n /** Child ids without materializing the record. */\n childCount(local: number): number {\n return this.nodes[local * STRIDE + 5];\n }\n\n childAt(local: number, index: number): number {\n return this.children[this.nodes[local * STRIDE + 4] + index];\n }\n\n childrenOf(local: number): number[] {\n const base = local * STRIDE;\n const count = this.nodes[base + 5];\n if (count === 0) return noChildren;\n const first = this.nodes[base + 4];\n return Array.from(this.children.subarray(first, first + count));\n }\n\n attributesOf(local: number): Record<string, string> {\n const base = local * STRIDE;\n const count = this.nodes[base + 9];\n if (count === 0) return noAttributes;\n const first = this.nodes[base + 8];\n const attributes = this.attributes;\n const result: Record<string, string> = {};\n for (let index = 0; index < count; index++) {\n const pair = (first + index) * 2;\n const name = this.name(attributes[pair]);\n const value = this.string(attributes[pair + 1]);\n if (name === '__proto__') Object.defineProperty(result, name, { value, writable: true, enumerable: true, configurable: true });\n else result[name] = value;\n }\n return result;\n }\n\n /** One attribute's value, without decoding the rest. */\n attributeValue(local: number, name: string): string | undefined {\n const base = local * STRIDE;\n const count = this.nodes[base + 9];\n const first = this.nodes[base + 8];\n const attributes = this.attributes;\n // A repeated name keeps its last value, as decoded attribute maps do.\n for (let index = count - 1; index >= 0; index--) {\n const pair = (first + index) * 2;\n if (this.name(attributes[pair]) === name) return this.string(attributes[pair + 1]);\n }\n return undefined;\n }\n\n string(reference: number): string {\n const strings = this.strings;\n const value = this.text.slice(strings[reference * 2], strings[reference * 2 + 1]);\n return this.isEncoded ? decodeString(value) : value;\n }\n\n /** Names repeat across nodes, so each decodes once. */\n name(reference: number): string {\n return this.names[reference] ??= this.string(reference);\n }\n}\n","import { requireNative, type NativeDocument } from './native.js';\nimport { attachParsedNodes, getNode, hydrateLocation, operation } from './nodes.js';\nimport { plainSnapshot, recordAt, routeDocument, type DocumentState, type RoutedDocument } from './router.js';\nimport type { CheerioOptions } from './types.js';\nimport type { TokenizerCallbacks } from './parser-types.js';\n\nconst tokenCallbacks = ['onattribdata', 'onattribentity', 'onattribend', 'onattribname', 'oncdata', 'onclosetag', 'oncomment', 'ondeclaration', 'onend', 'onopentagend', 'onopentagname', 'onprocessinginstruction', 'onselfclosingtag', 'ontext', 'ontextentity'] as const;\n\nexport function createTokenizerSession(options: CheerioOptions): { write(chunk: string): void; end(): CheerioOptions } {\n const events: unknown[][] = [];\n const callbacks = Object.fromEntries(tokenCallbacks.map((name) => [name, (...args: number[]) => {\n if (name === 'ontextentity' || name === 'onattribentity') {\n const codePoint = +args[0];\n // Validate through an indirect call: a bare known-builtin statement is\n // optimized away by the bundler's pure-built-in pass, which would drop\n // the RangeError the 0.22.0-facing behavior depends on.\n (0, String.fromCodePoint)(codePoint);\n args[0] = codePoint;\n }\n events.push([name, ...args]);\n }]));\n const Constructor = options.Tokenizer!;\n const tokenizer = new Constructor(options, callbacks as unknown as TokenizerCallbacks);\n return {\n write(chunk) { if (tokenizer.running) tokenizer.write(chunk); },\n end() { tokenizer.end(); const result = cleanParserOptions(options); result.__tokenEvents = events; return result; },\n };\n}\n\nexport function cleanParserOptions(options: CheerioOptions): CheerioOptions {\n const result = { ...options };\n delete result.Tokenizer; delete result.treeAdapter; delete result.onParseError;\n delete result.__tokenEvents;\n if (!options._useHtmlParser2 && options.onParseError) { result.__collectParseErrors = true; result.sourceCodeLocationInfo = true; }\n return result;\n}\n\n/** User tokenizers run on JavaScript; their actual events are consumed by Rust. */\nexport function parserOptions(source: string, options: CheerioOptions): CheerioOptions {\n if (options._useHtmlParser2 && options.Tokenizer) {\n const session = createTokenizerSession(options);\n session.write(source);\n return session.end();\n }\n return cleanParserOptions(options);\n}\n\nexport function deliverParseErrors(document: NativeDocument, options: CheerioOptions): void {\n if (options._useHtmlParser2 || !options.onParseError) return;\n const diagnostics = (document as NativeDocument & { parserDiagnostics?(): string | unknown[] }).parserDiagnostics?.();\n const errors = typeof diagnostics === 'string' ? JSON.parse(diagnostics) : diagnostics ?? [];\n for (const error of errors) options.onParseError(error);\n}\n\nexport function hasParserHooks(options: CheerioOptions): boolean {\n return !!(options._useHtmlParser2 ? options.Tokenizer : options.treeAdapter || options.onParseError);\n}\n\n/** A live tree adapter bridge. Every tree-builder decision consults the user's adapter. */\nfunction treeAdapterBridge(adapter: any, options: CheerioOptions) {\n const deliveredErrors = new Set<string>();\n const nodes: any[] = [];\n const ids = new WeakMap<object, number>();\n const identify = (node: any): number | null => {\n if (node == null) return null;\n if (typeof node !== 'object') throw new TypeError('treeAdapter methods must return DOM node objects');\n let id = ids.get(node);\n if (id === undefined) { id = nodes.length; ids.set(node, id); nodes.push(node); }\n return id;\n };\n const nodeArgs: Record<string, number[]> = {\n appendChild: [0, 1], insertBefore: [0, 1, 2], setTemplateContent: [0, 1], getTemplateContent: [0],\n setDocumentType: [0], setDocumentMode: [0], getDocumentMode: [0], detachNode: [0], insertText: [0],\n insertTextBefore: [0, 2], adoptAttributes: [0], getFirstChild: [0], getChildNodes: [0], getParentNode: [0],\n getAttrList: [0], getTagName: [0], getNamespaceURI: [0], getTextNodeContent: [0], getCommentNodeContent: [0],\n getDocumentTypeNodeName: [0], getDocumentTypeNodePublicId: [0], getDocumentTypeNodeSystemId: [0],\n isTextNode: [0], isCommentNode: [0], isElementNode: [0], isDocumentTypeNode: [0],\n setNodeSourceCodeLocation: [0], getNodeSourceCodeLocation: [0], updateNodeSourceCodeLocation: [0],\n onItemPop: [0, 1], onItemPush: [0],\n };\n const nodeReturns = new Set(['createDocument', 'createDocumentFragment', 'createElement', 'createCommentNode', 'createTextNode', 'getTemplateContent', 'getFirstChild', 'getParentNode']);\n const invoke = (method: string, args: any[]): any => {\n const fn = adapter[method];\n if (typeof fn !== 'function') {\n if (method === 'onItemPop' || method === 'onItemPush') return undefined;\n throw new TypeError(`treeAdapter.${method} must be a function`);\n }\n return Reflect.apply(fn, adapter, args);\n };\n const snapshot = () => {\n const records: any[] = [];\n for (let id = 0; id < nodes.length; id++) {\n const node = nodes[id];\n const element = invoke('isElementNode', [node]);\n const text = invoke('isTextNode', [node]);\n const comment = invoke('isCommentNode', [node]);\n const doctype = invoke('isDocumentTypeNode', [node]);\n const name = element ? invoke('getTagName', [node]) : doctype ? '!doctype' : node.name;\n const type = element ? name === 'script' || name === 'style' ? name : 'tag' : text ? 'text' : comment ? 'comment' : doctype ? 'directive' : node.type ?? 'root';\n const children = element || type === 'root' || type === 'cdata' ? invoke('getChildNodes', [node]) ?? [] : [];\n const record: any = { id, type, children: Array.from(children, identify), parent: identify(invoke('getParentNode', [node])) };\n if (name !== undefined) record.name = name;\n if (element) {\n record.namespace = invoke('getNamespaceURI', [node]);\n record.attribs = Object.create(null); record.attribsNamespace = Object.create(null); record.attribsPrefix = Object.create(null);\n for (const attr of invoke('getAttrList', [node])) {\n Object.defineProperty(record.attribs, attr.name, { value: attr.value, enumerable: true, configurable: true, writable: true });\n record.attribsNamespace[attr.name] = attr.namespace; record.attribsPrefix[attr.name] = attr.prefix;\n }\n } else if (text || comment) record.data = invoke(text ? 'getTextNodeContent' : 'getCommentNodeContent', [node]);\n else if (doctype) {\n record.data = node.data;\n for (const [field, method] of [['x-name', 'getDocumentTypeNodeName'], ['x-publicId', 'getDocumentTypeNodePublicId'], ['x-systemId', 'getDocumentTypeNodeSystemId']]) record[field] = invoke(method, [node]);\n }\n if (type === 'root' && node['x-mode'] !== undefined) record['x-mode'] = invoke('getDocumentMode', [node]);\n for (const field of ['startIndex', 'endIndex', 'sourceCodeLocation']) if (node[field] !== undefined) record[field] = node[field];\n records.push(record);\n }\n return records;\n };\n const bridge = (request: string): string => {\n const { method, args = [] } = JSON.parse(request);\n if (method === '__parseError') {\n deliveredErrors.add(JSON.stringify(args[0]));\n options.onParseError?.(args[0]);\n return 'null';\n }\n if (method === '__snapshot') return JSON.stringify(snapshot());\n if (method === '__locations') {\n for (const entry of args[0]) invoke('setNodeSourceCodeLocation', [nodes[entry.id], hydrateLocation(entry.location)]);\n return 'null';\n }\n const values = args.slice();\n if (method === 'setNodeSourceCodeLocation' || method === 'updateNodeSourceCodeLocation') hydrateLocation(values[1]);\n for (const index of nodeArgs[method] ?? []) values[index] = values[index] == null ? null : nodes[values[index]];\n const result = invoke(method, values);\n return JSON.stringify(method === 'getChildNodes' ? Array.from(result ?? [], identify) : nodeReturns.has(method) ? identify(result) : result ?? null);\n };\n return { bridge, nodes, deliveredErrors };\n}\n\nfunction bindAdapterDocument(document: NativeDocument, options: CheerioOptions, adapter: ReturnType<typeof treeAdapterBridge>): NativeDocument {\n if (options.onParseError) {\n const errors = (document as NativeDocument & { parserDiagnostics?(): string }).parserDiagnostics?.();\n for (const error of errors ? JSON.parse(errors) : []) if (!adapter.deliveredErrors.has(JSON.stringify(error))) options.onParseError(error);\n }\n const routed = routeDocument(document, options);\n const globalId = (routed as NativeDocument & { localNodeId(id: number): number }).localNodeId.bind(routed);\n for (let id = 0; id < adapter.nodes.length; id++) getNode(routed, globalId(id), adapter.nodes[id]);\n return routed;\n}\n\nexport function createTreeAdapterSession(options: CheerioOptions, isDocument: boolean): { write(chunk: string): Promise<void>; end(): Promise<NativeDocument>; abort(): void } {\n const binding = requireNative() as ReturnType<typeof requireNative> & {\n NativeHookStream?: new (isDocument: boolean, options: string, bridge: (request: string) => string) => { write(chunk: string): Promise<void> | void; finish(): Promise<NativeDocument> | NativeDocument; abort(): void };\n };\n if (!binding.NativeHookStream) throw new Error('This native addon does not support streaming treeAdapter hooks; rebuild the Rust addon.');\n const adapter = treeAdapterBridge(options.treeAdapter, options);\n let hasFailure = false;\n let failure: unknown;\n let aborted = false;\n const bridge = (request: string): string => {\n if (hasFailure || aborted) return '{\"__cheeroxHookError\":true}';\n try { return adapter.bridge(request); }\n catch (error) { hasFailure = true; failure = error; return '{\"__cheeroxHookError\":true}'; }\n };\n const parser = new binding.NativeHookStream(isDocument, JSON.stringify(cleanParserOptions(options)), bridge);\n const restoreFailure = (error: unknown): never => { if (hasFailure) throw failure; throw error; };\n return {\n async write(chunk) {\n try { await parser.write(chunk); if (hasFailure) throw failure; }\n catch (error) { restoreFailure(error); }\n },\n async end() {\n try {\n const document = await parser.finish();\n if (hasFailure) throw failure;\n return bindAdapterDocument(document, options, adapter);\n } catch (error) { return restoreFailure(error); }\n },\n abort() { aborted = true; parser.abort(); },\n };\n}\n\nexport function parseNativeDocument(source: string, options: CheerioOptions, isDocument: boolean): NativeDocument {\n const binding = requireNative();\n const nativeOptions = parserOptions(source, options);\n if (!options._useHtmlParser2 && options.treeAdapter && canReplay(options)) {\n const document = routeDocument(new binding.NativeDocument(source, isDocument, JSON.stringify(nativeOptions)), options) as RoutedDocument;\n const nodes = replayIntoAdapter(document, options.treeAdapter, isDocument);\n if (nodes) { attachParsedNodes(document.state, nodes); return document; }\n }\n if (!options._useHtmlParser2 && options.treeAdapter) {\n const parse = (binding as typeof binding & { parseWithTreeAdapter?(source: string, isDocument: boolean, options: string, bridge: (request: string) => string): NativeDocument }).parseWithTreeAdapter;\n if (!parse) throw new Error('This native addon does not support treeAdapter hooks; rebuild the Rust addon.');\n const adapter = treeAdapterBridge(options.treeAdapter, options);\n return bindAdapterDocument(parse(source, isDocument, JSON.stringify(nativeOptions), adapter.bridge), options, adapter);\n }\n const document = new binding.NativeDocument(source, isDocument, JSON.stringify(nativeOptions));\n deliverParseErrors(document, options);\n return routeDocument(document, options);\n}\n\n/** Error-only streams keep the Rust DOM and deliver diagnostics during writes. */\nexport function createDiagnosticSession(options: CheerioOptions, isDocument = true): { write(chunk: string): Promise<void>; end(): Promise<NativeDocument>; abort(): void } {\n const binding = requireNative() as ReturnType<typeof requireNative> & {\n NativeStream?: new (options: string, isDocument: boolean, bridge: (request: string) => string) => { write(chunk: string): Promise<void>; finish(): Promise<NativeDocument>; abort(): void };\n };\n if (!binding.NativeStream) throw new Error('This native addon does not support incremental parser diagnostics; rebuild the Rust addon.');\n let hasFailure = false;\n let failure: unknown;\n let aborted = false;\n const bridge = (request: string): string => {\n if (hasFailure || aborted) return '{\"__cheeroxHookError\":true}';\n try {\n const { method, args } = JSON.parse(request);\n if (method === '__parseError') options.onParseError?.(args[0]);\n return 'null';\n } catch (error) { hasFailure = true; failure = error; return '{\"__cheeroxHookError\":true}'; }\n };\n const parser = new binding.NativeStream(JSON.stringify(cleanParserOptions(options)), isDocument, bridge);\n const restoreFailure = (error: unknown): never => { if (hasFailure) throw failure; throw error; };\n return {\n async write(chunk) { try { await parser.write(chunk); if (hasFailure) throw failure; } catch (error) { restoreFailure(error); } },\n async end() { try { const document = await parser.finish(); if (hasFailure) throw failure; return routeDocument(document, options); } catch (error) { return restoreFailure(error); } },\n abort() { aborted = true; parser.abort(); },\n };\n}\n\n/**\n * Whether an adapter can be given the finished tree instead of every parser\n * step: it observes neither the open-element stack nor source locations, and\n * no parse-error callback can change it while parsing.\n */\nfunction canReplay(options: CheerioOptions): boolean {\n const adapter = options.treeAdapter as unknown as Record<string, unknown>;\n return !options.onParseError && !options.sourceCodeLocationInfo && adapter.onItemPush === undefined && adapter.onItemPop === undefined;\n}\n\n/**\n * Builds the adapter's tree from a native parse by calling its construction\n * methods in document order, then checks every node against the parse. An\n * adapter whose nodes differ from what it was given (renamed elements,\n * rewritten text, filtered children) could have steered parsing differently,\n * so it returns `undefined` and the caller runs the parser with the adapter\n * live instead.\n */\nfunction replayIntoAdapter(document: RoutedDocument, adapter: any, isDocument: boolean): (object | undefined)[] | undefined {\n const state = document.state;\n const root = document.rootId() - state.base;\n const size = state.baseline;\n const nodes: any[] = new Array(size);\n // Reading every record once builds the snapshot; plain nodes are then read from its arrays.\n for (let local = 0; local < Math.min(size, 65); local++) recordAt(state, local);\n for (let local = 0; local < size; local++) {\n const snapshot = plainSnapshot(state, local);\n const record = snapshot ? undefined : recordAt(state, local);\n if (!snapshot && !record) continue;\n const type = snapshot ? snapshot.typeOf(local) : record!.type;\n if (local === root) {\n nodes[local] = isDocument ? adapter.createDocument() : adapter.createDocumentFragment();\n const mode = record?.['x-mode'];\n if (isDocument && mode !== undefined) adapter.setDocumentMode(nodes[local], mode);\n continue;\n }\n const parentLocal = snapshot ? snapshot.linkOf(local, 1) : record!.parent;\n const parent = parentLocal == null ? undefined : nodes[parentLocal];\n if (parent === undefined) return undefined;\n switch (type) {\n case 'tag': case 'script': case 'style': {\n const element = snapshot\n ? adapter.createElement(snapshot.nameOf(local), snapshot.namespaceOf(local), snapshot.attributeObjects(local))\n : adapter.createElement(record!.name, record!.namespace, attributeList(record));\n adapter.appendChild(parent, element);\n nodes[local] = element;\n break;\n }\n case 'root': {\n const content = adapter.createDocumentFragment();\n adapter.setTemplateContent(parent, content);\n nodes[local] = content;\n break;\n }\n case 'text': {\n adapter.insertText(parent, (snapshot ? snapshot.dataOf(local) : record!.data) ?? '');\n const children = adapter.getChildNodes(parent);\n nodes[local] = children[children.length - 1];\n break;\n }\n case 'comment': {\n const comment = adapter.createCommentNode((snapshot ? snapshot.dataOf(local) : record!.data) ?? '');\n adapter.appendChild(parent, comment);\n nodes[local] = comment;\n break;\n }\n case 'directive': {\n if (!record || record.name !== '!doctype' || !isDocument) return undefined;\n adapter.setDocumentType(parent, record['x-name'] ?? '', record['x-publicId'] ?? '', record['x-systemId'] ?? '');\n nodes[local] = Array.from(adapter.getChildNodes(parent) ?? []).find((child) => adapter.isDocumentTypeNode(child));\n break;\n }\n default: return undefined;\n }\n }\n const changes = differencesFromParse(adapter, nodes, state, root);\n if (!changes) return undefined;\n // Attribute and text rewrites do not steer parsing; the document takes the adapter's values.\n for (const change of changes) operation(document, 'setNode', { id: state.base + change.local, field: change.field, value: change.value });\n return nodes;\n}\n\nfunction attributeList(record: any): { name: string; value: string; namespace?: string; prefix?: string }[] {\n const attributes = record.attribs ?? {};\n return Object.keys(attributes).map((name) => {\n const namespace = record.attribsNamespace?.[name];\n const prefix = record.attribsPrefix?.[name];\n return { name, value: attributes[name], ...(namespace === undefined ? {} : { namespace }), ...(prefix === undefined ? {} : { prefix }) };\n });\n}\n\ninterface DataChange { local: number; field: 'attribs' | 'attribsNamespace' | 'attribsPrefix' | 'data'; value: unknown }\n\n/**\n * The attribute and text values in which the adapter's nodes differ from the\n * parse, or `undefined` when a name, namespace or link differs, since those\n * could have steered parsing.\n */\nfunction differencesFromParse(adapter: any, nodes: any[], state: DocumentState, root: number): DataChange[] | undefined {\n const changes: DataChange[] = [];\n for (let local = 0; local < nodes.length; local++) {\n const node = nodes[local];\n const snapshot = plainSnapshot(state, local);\n const record = snapshot ? undefined : recordAt(state, local);\n if (!snapshot && !record) continue;\n if (!node) return undefined;\n const type = snapshot ? snapshot.typeOf(local) : record!.type;\n if (local !== root && adapter.getParentNode(node) !== nodes[(snapshot ? snapshot.linkOf(local, 1) : record!.parent)!]) return undefined;\n if (type !== 'text' && type !== 'comment' && type !== 'directive') {\n const children = adapter.getChildNodes(node) ?? [];\n const count = snapshot ? snapshot.childCount(local) : record!.children.length;\n if (children.length !== count) return undefined;\n for (let index = 0; index < count; index++) if (children[index] !== nodes[snapshot ? snapshot.childAt(local, index) : record!.children[index]]) return undefined;\n }\n if (type === 'tag' || type === 'script' || type === 'style') {\n const name = snapshot ? snapshot.nameOf(local) : record!.name;\n const namespace = snapshot ? snapshot.namespaceOf(local) : record!.namespace;\n if (!adapter.isElementNode(node) || adapter.getTagName(node) !== name || adapter.getNamespaceURI(node) !== namespace) return undefined;\n const attributes: { name: string; value: string; namespace?: string; prefix?: string }[] = adapter.getAttrList(node) ?? [];\n const expected = snapshot ? snapshot.attributeObjects(local) : attributeList(record);\n const isSame = attributes.length === expected.length && attributes.every((attribute, index) => attribute.name === expected[index].name && attribute.value === expected[index].value);\n if (!isSame) {\n const values: Record<string, string> = Object.create(null);\n const namespaces: Record<string, string> = Object.create(null);\n const prefixes: Record<string, string> = Object.create(null);\n for (const attribute of attributes) {\n values[attribute.name] = attribute.value;\n if (attribute.namespace !== undefined) namespaces[attribute.name] = attribute.namespace;\n if (attribute.prefix !== undefined) prefixes[attribute.name] = attribute.prefix;\n }\n changes.push({ local, field: 'attribs', value: values }, { local, field: 'attribsNamespace', value: namespaces }, { local, field: 'attribsPrefix', value: prefixes });\n }\n } else if (type === 'text' || type === 'comment') {\n if (type === 'text' ? !adapter.isTextNode(node) : !adapter.isCommentNode(node)) return undefined;\n const data = type === 'text' ? adapter.getTextNodeContent(node) : adapter.getCommentNodeContent(node);\n if (data !== (snapshot ? snapshot.dataOf(local) : record!.data)) changes.push({ local, field: 'data', value: data });\n }\n }\n return changes;\n}\n","import { packageDirectory, requireNative, type NativeDocument, type NativeNodeRecord } from './native.js';\nimport { hasParserHooks, parseNativeDocument } from './hooks.js';\nimport type { CheerioOptions } from './types.js';\nimport { NodeSnapshot, plainRecord, type NativeSnapshot } from './snapshot.js';\nimport { attributeAssign, type AttributeObject } from './attribute-object.js';\n\ninterface NativeMemoryStats { live: number; slots: number; retained: number; reclaimed: number; immutableNodes: number; externalBytes: number }\ninterface PinnedCollection extends NativeMemoryStats { free: Uint32Array }\ninterface ManagedNativeDocument extends NativeDocument {\n setAttribute?(ids: number[], name: string, value: string | null): void;\n addClass?(ids: number[], name: string): void;\n insertHtml?(targetIds: number[], html: string, position: string): number[];\n removeNodes?(ids: number[]): void;\n slotCount?(): number;\n routingIndex?(): number;\n detachedSlots?(root: number): Uint32Array;\n render?(ids: number[], optionsJson?: string): string;\n snapshot?(): NativeSnapshot;\n takeTouched?(): Uint32Array | null;\n collectPinned?(pins: Uint32Array, keepBelow?: number): PinnedCollection;\n collectGarbage?(): NativeMemoryStats;\n isCollectionDue?(): boolean;\n}\n\n/**\n * A node id is `state.base + local`, where `local` indexes the node in its\n * native arena. Ids from different documents never collide, so every routed\n * document shares one id space without a lookup table per node.\n */\nconst STRIDE = 2 ** 32;\n/** Ids must stay exact doubles, which bounds how many documents may be alive at once. */\nconst maximumDocuments = 2 ** 21;\n/** A document's root is its first slot; collections keep it and everything attached to it. */\nconst rootSlots = 1;\n\n/**\n * Ids held by a JavaScript owner. Collection keeps them; moves rewrite them in\n * place. The finalization registry holds only the token, which references\n * nothing: its cleanup runs only once the event loop turns, and anything it\n * held would keep documents of a synchronous loop alive until then.\n */\nexport interface Lease { ids: number[]; token: LeaseToken; states: DocumentState[] }\ninterface LeaseToken { isReleased: boolean }\n\n/**\n * JavaScript `.data()` storage for one node; moves carry it to the node's new\n * arena. A collection that frees the node releases it, so data objects still\n * held no longer write to whatever node reuses the slot.\n */\nexport interface DataEntry { state: DocumentState; local: number; data?: object; isReleased?: boolean }\n\n/** Bookkeeping for one native document. */\nexport interface DocumentState {\n readonly raw: ManagedNativeDocument;\n readonly base: number;\n /** The id space the state's base belongs to: another copy of the package numbers its documents separately. */\n readonly space: object;\n readonly options: CheerioOptions;\n rootLocal: number | undefined;\n routed: RoutedDocument | undefined;\n generation: number;\n records: (NativeNodeRecord | null | undefined)[];\n bulk: NodeSnapshot | number;\n snapshotSize: number;\n /** Nodes whose snapshot entry is outdated by a targeted write. */\n stale: Set<number>;\n /**\n * Node objects for slots that existed at parse time, until a collection\n * finds their nodes detached; an array read is far cheaper than a map\n * lookup.\n */\n views: (object | undefined)[];\n /** Node objects for slots created later, until a collection finds their nodes detached. */\n looseViews: Map<number, object>;\n /** Size of `looseViews` at which a collection is scheduled. */\n looseViewLimit: number;\n /** Node objects for detached nodes, kept only while something else holds them. */\n weakViews: Map<number, WeakRef<object>>;\n /** Slots that existed when the document was parsed. */\n baseline: number;\n /** Later collections to run while weakened node objects may still become unreachable. */\n collectionRetries: number;\n /** Whether a collection was due but the document left the pending list; its next use schedules it again. */\n isCollectionEvicted: boolean;\n /** Whether the native document holds a snapshot built while parsing, valid until the first write. */\n hasPreparedSnapshot: boolean;\n leases: Set<Lease>;\n /** Lease count at which released leases are swept. */\n leaseSweepSize: number;\n data: Map<number, DataEntry>;\n /**\n * Whether the id table resolves this document. Only ids that reach another\n * document need it, and the `WeakRef` it takes keeps the document alive\n * until the current job ends.\n */\n isExposed: boolean;\n /**\n * Documents whose ids this document's selections or leases may hold. A\n * document's index is reused once it is collected, so holders keep it.\n */\n /** Some node object holds a child array that must follow structural writes. */\n hasChildLists: boolean;\n /** A tree adapter's nodes not yet returned to the caller, by slot. */\n adapterNodes?: (object | undefined)[];\n}\n\n/** Fields on node objects; registered symbols so ESM and CJS copies share nodes. */\nexport const VIEW_STATE = Symbol.for('cheerox.node.state');\nexport const VIEW_LOCAL = Symbol.for('cheerox.node.local');\nexport const VIEW_ATTRIBUTES = Symbol.for('cheerox.node.attributes');\n/** Points at the node itself, so a spread copy of a node is not mistaken for it. */\nexport const VIEW_SELF = Symbol.for('cheerox.node.self');\n// Internals are own properties under symbols: reads stay plain property\n// loads, which prototype accessors are not on selections of many documents'\n// classes, and selections enumerate like Cheerio's. Registered symbols let\n// the ESM and CommonJS builds read each other's selections.\nexport const DOCUMENT: unique symbol = Symbol.for('cheerox.selection.document');\nexport const API: unique symbol = Symbol.for('cheerox.selection.api');\nexport const IDS: unique symbol = Symbol.for('cheerox.selection.ids');\nexport const VALUES: unique symbol = Symbol.for('cheerox.selection.values');\nexport const LEASE: unique symbol = Symbol.for('cheerox.selection.lease');\nexport const IS_PLAIN: unique symbol = Symbol.for('cheerox.selection.is-plain');\n/** A node object's materialized `children` array, refilled when the node's children change. */\nexport const VIEW_CHILD_TARGET = Symbol.for('cheerox.node.child-target');\n\ninterface Registry {\n space: object;\n /** Writes to any document, so callers can tell whether values they read earlier may be stale. */\n writes: number;\n states: (WeakRef<DocumentState> | undefined)[];\n pending: Set<DocumentState>;\n isScheduled: boolean;\n leaseFinalizer: FinalizationRegistry<LeaseToken>;\n}\n// Each installed copy of the package loads its own addon, which numbers its\n// documents independently, so only entry points of one copy share ids.\nconst registryKey = Symbol.for(`cheerox.native-documents.v5:${packageDirectory()}`);\n/** A native document's state lives on the document itself, so they share one lifetime. */\nconst stateKey = Symbol.for('cheerox.native-documents.state');\nconst globals = globalThis as typeof globalThis & { [key: symbol]: Registry | undefined };\nconst registry: Registry = globals[registryKey] ??= (() => {\n const created: Registry = {\n space: {},\n writes: 0,\n states: [],\n pending: new Set(),\n isScheduled: false,\n leaseFinalizer: new FinalizationRegistry((token) => { token.isReleased = true; }),\n };\n return created;\n})();\n\n/** The states owning `ids`, resolved through `document`. */\nfunction statesOf(document: NativeDocument, ids: readonly number[]): DocumentState[] {\n const states: DocumentState[] = [];\n let previous: DocumentState | undefined;\n for (const id of ids) {\n // Selections may hold holes after direct index writes.\n if (id === undefined) continue;\n if (previous && id >= previous.base && id < previous.base + STRIDE) continue;\n const state = stateIn(document, id);\n if (!states.includes(state)) states.push(state);\n previous = state;\n }\n return states;\n}\n\n/**\n * Collects once a structural write leaves the arena grown by half with nodes\n * removed; collecting sooner costs more than the garbage it would free.\n */\nfunction scheduleCollectionIfDue(state: DocumentState): void {\n if (state.raw.isCollectionDue?.()) scheduleCollection(state);\n}\n\n/**\n * Collections run on a later turn of the event loop: no library call is then\n * between native writes holding ids of nodes it has just detached, and node\n * objects weakened on an earlier turn may have been reclaimed.\n */\nfunction scheduleCollection(state: DocumentState): void {\n registry.pending.add(state);\n // Pending documents are held strongly until the event loop turns; in a\n // synchronous loop only the latest few stay pinned. Holding the others\n // weakly would pin them too: a WeakRef keeps its target until the\n // synchronous job ends. An evicted document is scheduled again on its next\n // use; one never used again is either collected whole or idle.\n if (registry.pending.size > maximumPendingCollections) {\n const evicted = registry.pending.values().next().value!;\n registry.pending.delete(evicted);\n evicted.isCollectionEvicted = true;\n }\n if (registry.isScheduled) return;\n registry.isScheduled = true;\n setImmediate(() => {\n registry.isScheduled = false;\n const states = [...registry.pending];\n registry.pending.clear();\n for (const pending of states) collectState(pending);\n }).unref();\n}\n\nconst maximumPendingCollections = 4;\n\n/** Increases with every write to any document. */\nexport function writeCount(): number {\n return registry.writes;\n}\n\n/**\n * The state of a native document, created on first use. The addon hands out\n * routing indexes and takes one back when its document is finalized, which\n * happens during garbage collection, so indexes recycle even within a\n * synchronous loop.\n */\nexport function stateFor(raw: NativeDocument, options: CheerioOptions = {}): DocumentState {\n const holder = raw as unknown as { [stateKey]?: DocumentState };\n const existing = holder[stateKey];\n if (existing) return existing;\n const index = (raw as ManagedNativeDocument).routingIndex!();\n if (index >= maximumDocuments) throw new RangeError('Too many documents are alive at once.');\n const baseline = (raw as ManagedNativeDocument).slotCount?.() ?? 0;\n const state: DocumentState = {\n raw: raw as ManagedNativeDocument, base: index * STRIDE, space: registry.space, options, rootLocal: undefined, routed: undefined,\n // Sized up front: node objects are cached out of order, and regrowing a holey array is costly.\n generation: 0, records: [], bulk: 0, snapshotSize: 0, stale: new Set(), views: new Array(baseline), looseViews: new Map(), looseViewLimit: minimumLooseViewLimit, weakViews: new Map(), baseline,\n leases: new Set(), leaseSweepSize: 64, data: new Map(), isExposed: false, hasChildLists: false, collectionRetries: 0, isCollectionEvicted: false, hasPreparedSnapshot: false,\n };\n holder[stateKey] = state;\n return state;\n}\n\n/** Lets ids of `state` be resolved from documents other than its own. */\nfunction exposeState(state: DocumentState): void {\n if (state.isExposed) return;\n state.isExposed = true;\n registry.states[state.base / STRIDE] = new WeakRef(state);\n}\n\n/**\n * Called before ids of `state` enter operations or selections of `document`.\n * Leases keep the documents of the ids a selection holds; node objects keep\n * their own.\n */\nexport function exposeTo(document: NativeDocument, state: DocumentState): void {\n if ((document as Partial<RoutedDocument>).state === state) return;\n exposeState(state);\n}\n\n/** Called before a selection's ids enter operations of `document`. */\nexport function exposeDocumentTo(document: NativeDocument, source: NativeDocument | undefined): void {\n const state = (source as Partial<RoutedDocument> | undefined)?.state;\n if (state) exposeTo(document, state);\n}\n\n/** The node object cached for a slot, if any. */\nexport function cachedView(state: DocumentState, local: number): object | undefined {\n const view = local < state.baseline ? state.views[local] : state.looseViews.get(local);\n return view ?? (state.weakViews.size ? state.weakViews.get(local)?.deref() : undefined);\n}\n\n/** Created nodes held as objects only become collectable through a collection. */\nconst minimumLooseViewLimit = 1024;\n\nexport function cacheView(state: DocumentState, local: number, view: object): void {\n if (local < state.baseline) { state.views[local] = view; return; }\n state.looseViews.set(local, view);\n if (state.looseViews.size >= state.looseViewLimit) {\n state.looseViewLimit = state.looseViews.size * 2;\n scheduleCollection(state);\n }\n}\n\nfunction uncacheView(state: DocumentState, local: number): object | undefined {\n const view = cachedView(state, local);\n if (local < state.baseline) state.views[local] = undefined;\n state.looseViews.delete(local);\n state.weakViews.delete(local);\n return view;\n}\n\n/** A collection drops released slots at the arena's end; later nodes reuse their indexes. */\nfunction releaseSlotsFrom(state: DocumentState, end: number): void {\n for (const local of state.data.keys()) if (local >= end) releaseSlot(state, local);\n for (const local of state.weakViews.keys()) if (local >= end) state.weakViews.delete(local);\n if (state.adapterNodes && state.adapterNodes.length > end) {\n for (let local = end; local < state.adapterNodes.length; local++) releaseAdapterNode(state, local);\n state.adapterNodes.length = end;\n }\n}\n\n/** Forgets everything bound to a slot a collection freed. */\nfunction releaseSlot(state: DocumentState, local: number): void {\n uncacheView(state, local);\n const entry = state.data.get(local);\n if (entry) { entry.isReleased = true; state.data.delete(local); }\n releaseAdapterNode(state, local);\n}\n\n/** Hands a freed slot's tree adapter object back to the caller: passed in again, it is imported like any other node. */\nfunction releaseAdapterNode(state: DocumentState, local: number): void {\n const adapterNode = state.adapterNodes?.[local] as Record<symbol, unknown> | undefined;\n if (!adapterNode) return;\n adapterNode[VIEW_SELF] = undefined;\n state.adapterNodes![local] = undefined;\n}\n\nfunction hasViews(state: DocumentState): boolean {\n return state.views.length > 0 || state.looseViews.size > 0 || state.weakViews.size > 0;\n}\n\nfunction forEachView(state: DocumentState, visit: (view: object, local: number) => void): void {\n state.views.forEach((view, local) => { if (view) visit(view, local); });\n for (const [local, view] of state.looseViews) visit(view, local);\n for (const [local, reference] of state.weakViews) { const view = reference.deref(); if (view) visit(view, local); }\n}\n\n/**\n * Node objects of detached nodes stay cached only while something else holds\n * them, so a later collection can reclaim their nodes. The `WeakRef`s are\n * taken during a collection rather than on removal: taking one keeps its\n * target, and so its document, alive until the current job ends. Returns\n * whether any node object was weakened.\n */\nfunction weakenDetachedViews(state: DocumentState): boolean {\n if (!state.raw.detachedSlots) return false;\n let isWeakened = false;\n for (const local of state.raw.detachedSlots(state.rootLocal ??= state.raw.rootId())) {\n const view = local < state.baseline ? state.views[local] : state.looseViews.get(local);\n if (!view) continue;\n if (local < state.baseline) state.views[local] = undefined;\n else state.looseViews.delete(local);\n state.weakViews.set(local, new WeakRef(view));\n isWeakened = true;\n }\n return isWeakened;\n}\n\n/** The state owning `id` of a document whose ids have reached other documents. */\nfunction exposedStateOf(id: number): DocumentState {\n const state = registry.states[Math.floor(id / STRIDE)]?.deref();\n if (!state || !(id >= 0)) throw new RangeError(`Unknown native node handle ${id}`);\n return state;\n}\n\n/** The state owning `id`, resolved without the weak table when `document` owns it. */\nexport function stateIn(document: NativeDocument, id: number): DocumentState {\n const own = (document as Partial<RoutedDocument>).state;\n if (own === undefined || id < own.base || id >= own.base + STRIDE) return exposedStateOf(id);\n if (own.isCollectionEvicted) resumeCollection(document);\n return own;\n}\n\n/** Schedules again a collection that left the pending list before it ran. */\nexport function resumeCollection(document: NativeDocument): void {\n const state = (document as Partial<RoutedDocument>).state;\n if (!state?.isCollectionEvicted) return;\n state.isCollectionEvicted = false;\n scheduleCollection(state);\n}\n\n/** The node's record for the current generation, with ids local to `state`. */\nexport function recordAt(state: DocumentState, local: number): NativeNodeRecord | null {\n const cached = state.records[local];\n if (cached !== undefined) return cached;\n const record = readRecord(state, local);\n state.records[local] = record;\n return record;\n}\n\nconst minimumReadsBeforeSnapshot = 64;\n\n/**\n * Once individual reads in a generation cost about as much as copying every\n * record, take one snapshot and decode the rest locally. A snapshot costs\n * about two reads plus one read per hundred nodes, and a document read once\n * is usually read again, so an unchanged document of under a hundred nodes\n * takes one on its first read. Mutations start a new generation.\n */\nfunction readRecord(state: DocumentState, local: number): NativeNodeRecord | null {\n const bulk = state.bulk;\n if (bulk instanceof NodeSnapshot) {\n const record = state.stale.size && state.stale.has(local) ? undefined : bulk.record(local);\n if (record !== undefined) return record;\n } else if (state.raw.snapshot) {\n const reads = bulk + 1;\n const size = Math.max(state.snapshotSize, state.baseline);\n // An unchanged small document is read throughout; after a write, often only a few nodes are.\n const firstSnapshotRead = state.generation === 0 ? size / 100 : 1 + size / 100;\n if (reads >= Math.min(minimumReadsBeforeSnapshot, firstSnapshotRead)) {\n const snapshot = new NodeSnapshot(takePreparedSnapshot(state, true) ?? state.raw.snapshot());\n state.snapshotSize = snapshot.size;\n state.bulk = snapshot;\n const record = snapshot.record(local);\n if (record !== undefined) return record;\n } else state.bulk = reads;\n }\n return rawOperation(state.raw, 'node', { id: local });\n}\n\n/**\n * Lets a routed document nothing has read or changed yet use the snapshot\n * its native document built while parsing, when its reads first need one.\n */\nexport function usePreparedSnapshot(document: NativeDocument): void {\n if (!(document instanceof RoutedDocument)) return;\n const state = document.state;\n state.hasPreparedSnapshot = state.generation === 0 && state.bulk === 0;\n}\n\nfunction takePreparedSnapshot(state: DocumentState, isWanted: boolean): NativeSnapshot | undefined {\n if (!state.hasPreparedSnapshot) return undefined;\n state.hasPreparedSnapshot = false;\n return state.raw.takePreparedSnapshot?.(isWanted) ?? undefined;\n}\n\n/** Start a full-tree walk from one compact record snapshot instead of a series of individual node reads. */\nexport function prepareWalkSnapshot(state: DocumentState): void {\n if (state.generation !== 0 || state.bulk instanceof NodeSnapshot || !state.raw.snapshot || state.adapterNodes) return;\n const snapshot = new NodeSnapshot(takePreparedSnapshot(state, true) ?? state.raw.snapshot());\n state.snapshotSize = snapshot.size;\n state.bulk = snapshot;\n}\n\n/** Prepare one compact snapshot before materializing a large selection from an unchanged document. */\nexport function prepareBulkViews(document: NativeDocument, ids: readonly number[]): void {\n if (ids.length < 64 || !(document instanceof RoutedDocument)) return;\n const state = document.state;\n if (state.generation !== 0 || state.bulk instanceof NodeSnapshot || !state.raw.snapshot || state.adapterNodes) return;\n // Avoid copying the whole tree for repeated IDs or already materialized\n // views. Either case can satisfy toArray without many native record reads.\n let unseen = 0;\n let previous = -1;\n for (const id of ids) {\n const local = id - state.base;\n if (local < 0 || local >= state.baseline) return;\n if (unseen < 64 && !state.views[local] && (!state.weakViews.size || !cachedView(state, local))) {\n // Document-ordered IDs are the common case. Other orders use the\n // regular lazy path rather than allocating a set for this heuristic.\n if (local <= previous) return;\n previous = local;\n unseen++;\n }\n }\n if (unseen < 64) return;\n const snapshot = new NodeSnapshot(takePreparedSnapshot(state, true) ?? state.raw.snapshot());\n state.snapshotSize = snapshot.size;\n state.bulk = snapshot;\n}\n\n/** The current snapshot when it holds `local` exactly, so its fields can be read without a record. */\nexport function plainSnapshot(state: DocumentState, local: number): NodeSnapshot | undefined {\n const bulk = state.bulk;\n return bulk instanceof NodeSnapshot && !(state.stale.size && state.stale.has(local)) && bulk.isPlain(local) ? bulk : undefined;\n}\n\n/**\n * The current snapshot when it holds `local`'s type, name, links and\n * children. Those are kept for every node, also one whose large text or\n * attributes must be read individually.\n */\nexport function structureSnapshot(state: DocumentState, local: number): NodeSnapshot | undefined {\n const bulk = state.bulk;\n return bulk instanceof NodeSnapshot && !(state.stale.size && state.stale.has(local)) && bulk.isPresent(local) ? bulk : undefined;\n}\n\n/** Nodes a JavaScript `text()` reads before leaving larger subtrees to the native engine. */\nconst snapshotTextBudget = 256;\n\n/**\n * The text of a small subtree read from the snapshot, as the native `text`\n * concatenates it, or `undefined` to ask the native engine. Text too large\n * for the snapshot is read once per snapshot, so repeated reads do not copy\n * it out of the native tree again.\n */\nfunction textFromSnapshot(state: DocumentState, local: number): string | undefined {\n let text = '';\n const stack = [local];\n for (let visited = 0; stack.length; visited++) {\n const node = stack.pop()!;\n const snapshot = structureSnapshot(state, node);\n if (!snapshot || visited === snapshotTextBudget) return undefined;\n if (snapshot.isTextAt(node)) {\n text += snapshot.dataOf(node) ?? largeText(state, snapshot, node);\n continue;\n }\n for (let index = snapshot.childCount(node) - 1; index >= 0; index--) stack.push(snapshot.childAt(node, index));\n }\n return text;\n}\n\nfunction largeText(state: DocumentState, snapshot: NodeSnapshot, local: number): string {\n let text = snapshot.largeTexts.get(local);\n if (text === undefined) snapshot.largeTexts.set(local, text = state.raw.text([local]));\n return text;\n}\n\n/** A string attribute of an element, read like the native `attr` lookup. */\nexport function attributeAt(state: DocumentState, local: number, name: string): string | undefined {\n const snapshot = plainSnapshot(state, local);\n if (snapshot) return snapshot.attributeValue(local, name);\n const attributes = recordAt(state, local)?.attribs as Record<string, unknown> | undefined;\n const value = attributes && Object.hasOwn(attributes, name) ? attributes[name] : undefined;\n return typeof value === 'string' ? value : undefined;\n}\n\n/** Starts a new generation: cached records may no longer match the arena. */\nexport function invalidate(state: DocumentState): void {\n takePreparedSnapshot(state, false);\n state.generation++;\n state.records = [];\n state.bulk = 0;\n state.stale.clear();\n}\n\nfunction refreshSerializedNodes(state: DocumentState, options: CheerioOptions): void {\n if (!options._useHtmlParser2 || options.xmlMode) return;\n const touched = state.raw.takeTouched?.();\n if (touched === null) invalidate(state);\n else if (touched?.length) invalidateNodes(state, touched);\n}\n\n/** Discards the records of nodes a write changed without touching the tree's shape. */\nfunction invalidateNodes(state: DocumentState, locals: Iterable<number>): void {\n takePreparedSnapshot(state, false);\n const isSnapshot = state.bulk instanceof NodeSnapshot;\n const { records } = state;\n for (const local of locals) {\n // Writing past the end would grow the cache with holes, which V8 turns\n // into a slow dictionary for far indexes.\n if (records[local] !== undefined) records[local] = undefined;\n if (isSnapshot) state.stale.add(local);\n }\n}\n\n/** Keeps the ids of `document` that `owner` holds alive, and rewrites them when their nodes move. */\nexport function leaseNodes(document: NativeDocument, owner: object, ids: number[]): Lease {\n const token: LeaseToken = { isReleased: false };\n const states = statesOf(document, ids);\n const lease: Lease = { ids, token, states };\n for (const state of states) addLease(state, lease);\n registry.leaseFinalizer.register(owner, token);\n return lease;\n}\n\n/** Points a lease at a replacement id list. */\nexport function updateLease(document: NativeDocument, lease: Lease, ids: number[]): void {\n lease.ids = ids;\n lease.states = statesOf(document, ids);\n for (const state of lease.states) addLease(state, lease);\n}\n\nfunction addLease(state: DocumentState, lease: Lease): void {\n state.leases.add(lease);\n if (state.leases.size < state.leaseSweepSize) return;\n for (const held of state.leases) if (held.token.isReleased) state.leases.delete(held);\n state.leaseSweepSize = state.leases.size * 2 + 64;\n}\n\n/** Weakened node objects become unreachable only after a later garbage collection. */\nconst collectionRetries = 3;\n\n/** Reclaims removed nodes that no JavaScript owner references. */\nexport function collectState(state: DocumentState): NativeMemoryStats | undefined {\n registry.pending.delete(state);\n state.isCollectionEvicted = false;\n if (!state.raw.collectPinned) return state.raw.collectGarbage?.();\n if (weakenDetachedViews(state)) state.collectionRetries = collectionRetries;\n const pins: number[] = [];\n const { base } = state;\n const end = base + STRIDE;\n for (const lease of state.leases) {\n if (lease.token.isReleased) { state.leases.delete(lease); continue; }\n for (const id of lease.ids) if (id >= base && id < end) pins.push(id - base);\n }\n state.views.forEach((view, local) => { if (view) pins.push(local); });\n for (const local of state.looseViews.keys()) pins.push(local);\n for (const [local, reference] of state.weakViews) {\n if (reference.deref()) pins.push(local);\n else state.weakViews.delete(local);\n }\n const { free, ...stats } = state.raw.collectPinned(Uint32Array.from(pins), rootSlots);\n invalidate(state);\n for (const local of free) releaseSlot(state, local);\n releaseSlotsFrom(state, stats.slots);\n state.looseViewLimit = Math.max(minimumLooseViewLimit, state.looseViews.size * 2);\n if (state.collectionRetries > 0 && state.weakViews.size > 0) {\n state.collectionRetries--;\n scheduleCollection(state);\n }\n return stats;\n}\n\nfunction rawOperation<T = any>(document: NativeDocument, command: string, args: any): T {\n const result = document.op(command, JSON.stringify(args));\n return result === '' || result === undefined ? undefined as T : JSON.parse(result);\n}\n\n/** Converts a record's local links to ids. */\nfunction globalRecord(state: DocumentState, record: NativeNodeRecord | null): NativeNodeRecord | null {\n if (!record) return null;\n const { base } = state;\n const link = (local: number | null | undefined): number | null => local == null ? null : base + local;\n return { ...plainRecord(record), id: base + record.id, children: (record.children ?? []).map((child) => base + child), parent: link(record.parent), prev: link(record.prev), next: link(record.next) } as NativeNodeRecord;\n}\n\nconst parentTypes = new Set(['root', 'tag', 'script', 'style', 'cdata']);\nconst pointerFields = new Set(['parent', 'parentNode', 'prev', 'previousSibling', 'next', 'nextSibling']);\nconst idResultCommands = new Set(['select', 'matches', 'uniqueSort', 'traverse', 'clone']);\nconst scratchCommands = new Set(['select', 'matches', 'uniqueSort', 'serializeArray', 'serialize', 'extractPlan']);\nconst writeCommands = new Set(['create', 'createNode', 'setNode', 'setAttrs', 'import', 'insert', 'clone', 'remove', 'removeAttr', 'removeData', 'addClass', 'removeClass', 'toggleClass']);\nconst attributeFields = new Set(['attribs', 'x-attribsNamespace', 'x-attribsPrefix']);\nconst targetedAttributeWrites = new Set(['attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'css']);\n/** Writes that only change the records of their own ids. */\nconst recordOnlyWrites = new Set([...targetedAttributeWrites, 'data', 'removeData', 'setAttrs']);\nconst structuralWrites = new Set(['create', 'createNode', 'import', 'insert', 'clone', 'remove', 'html', 'text', 'data', 'removeData']);\n\n/**\n * Routes commands for ids from any document to the arena that owns them.\n * Native adoption moves nodes between arenas; `moveInto` rewrites the ids that\n * live owners hold so node identities survive the move.\n */\nexport class RoutedDocument implements NativeDocument {\n readonly nodeSpace = registry.space;\n readonly options: CheerioOptions;\n readonly state: DocumentState;\n get raw(): ManagedNativeDocument { return this.state.raw; }\n\n constructor(document: NativeDocument, options: CheerioOptions = {}) {\n this.options = options;\n this.state = stateFor(document, options);\n }\n\n /**\n * Sets (or with `null` removes) an attribute, as the `attr` command does,\n * through a typed native call. Attribute objects already handed out are\n * updated in place instead of being read back.\n */\n setAttribute(ids: number[], name: string, value: string | null): void {\n const own = this.state;\n if (ids.length === 1 && own.raw.setAttribute) {\n const id = ids[0];\n if (id >= own.base && id < own.base + STRIDE) {\n registry.writes++;\n const local = id - own.base;\n invalidateNodes(own, [local]);\n own.raw.setAttribute([local], name, value);\n const attributes = (cachedView(own, local) as Record<symbol, AttributeObject | undefined> | undefined)?.[VIEW_ATTRIBUTES];\n if (attributes) attributeAssign(attributes, name, value);\n return;\n }\n }\n registry.writes++;\n for (const { state, locals } of this.groups(ids)) {\n if (!state.raw.setAttribute) { this.call(state, 'attr', { ids: locals, name, value }); continue; }\n invalidateNodes(state, locals);\n state.raw.setAttribute(locals, name, value);\n for (const local of locals) {\n const attributes = (cachedView(state, local) as Record<symbol, AttributeObject | undefined> | undefined)?.[VIEW_ATTRIBUTES];\n if (attributes) attributeAssign(attributes, name, value);\n }\n }\n }\n\n addClass(ids: number[], name: string): void {\n const own = this.state;\n if (ids.length === 1 && own.raw.addClass) {\n const id = ids[0];\n if (id >= own.base && id < own.base + STRIDE) {\n registry.writes++;\n const local = id - own.base;\n invalidateNodes(own, [local]);\n own.raw.addClass([local], name);\n const attributes = (cachedView(own, local) as Record<symbol, AttributeObject | undefined> | undefined)?.[VIEW_ATTRIBUTES];\n if (attributes) attributeAssign(attributes, 'class', own.raw.attr(local, 'class') ?? null);\n return;\n }\n }\n registry.writes++;\n for (const { state, locals } of this.groups(ids)) {\n if (!state.raw.addClass) { this.call(state, 'addClass', { ids: locals, name }); continue; }\n invalidateNodes(state, locals);\n state.raw.addClass(locals, name);\n for (const local of locals) {\n const attributes = (cachedView(state, local) as Record<symbol, AttributeObject | undefined> | undefined)?.[VIEW_ATTRIBUTES];\n if (attributes) attributeAssign(attributes, 'class', state.raw.attr(local, 'class') ?? null);\n }\n }\n }\n\n retainNode(id: number): void { this.owner(id); }\n collectGarbage(): NativeMemoryStats | undefined { return collectState(this.state); }\n retainNodeData(id: number, data: object): void { dataEntry(this.owner(id), id).data = data; }\n nodeData(id: number): object | undefined { const state = this.owner(id); return state.data.get(id - state.base)?.data; }\n nodeDataOperation(id: number): (command: string, args: any) => any {\n const entry = dataEntry(this.owner(id), id);\n const options = this.options;\n // Resolve the entry's current arena on each call: the node may have moved.\n return (command, args) => entry.isReleased ? undefined : routedFor(entry.state).operate(command, { ...args, ids: [entry.state.base + entry.local], options });\n }\n localNodeId(local: number): number { return this.state.base + local; }\n rootId(): number { return this.state.base + (this.state.rootLocal ??= this.raw.rootId()); }\n isOwnNode(id: number): boolean { return id >= this.state.base && id < this.state.base + STRIDE; }\n private owner(id: number): DocumentState { return stateIn(this, id); }\n\n private globals(state: DocumentState, locals: number[]): number[] {\n const { base } = state;\n return locals.map((local) => base + local);\n }\n\n private groups(ids: number[]): { state: DocumentState; locals: number[] }[] {\n const groups: { state: DocumentState; locals: number[] }[] = [];\n const own = this.state;\n let last: { state: DocumentState; locals: number[] } | undefined;\n for (const id of ids) {\n const state = id >= own.base && id < own.base + STRIDE ? own : exposedStateOf(id);\n if (last?.state === state) last.locals.push(id - state.base);\n else groups.push(last = { state, locals: [id - state.base] });\n }\n return groups;\n }\n\n private call<T = any>(state: DocumentState, command: string, args: any): T {\n if (command === 'extractPlan' && JSON.stringify(args.plan).includes('innerHTML')) invalidate(state);\n const isWrite = Object.hasOwn(args, 'value') || writeCommands.has(command);\n const recordOnlyWrite = recordOnlyWrites.has(command) || command === 'setNode' && attributeFields.has(args.field);\n if (isWrite) {\n registry.writes++;\n const changed = recordOnlyWrites.has(command) ? args.ids ?? [] : command === 'setNode' && attributeFields.has(args.field) ? [args.id] : undefined;\n if (changed) invalidateNodes(state, changed);\n else invalidate(state);\n }\n const result = rawOperation(state.raw, command, { ...args, options: args.options ?? this.options });\n const hasSerializedHtml = command === 'render' || command === 'outerHtml' || (command === 'html' && !isWrite) || (command === 'prop' && (args.name === 'innerHTML' || args.name === 'outerHTML'));\n if (hasSerializedHtml) refreshSerializedNodes(state, args.options ?? this.options);\n if (isWrite) {\n refreshWrittenAttributes(state, command, args);\n if (!recordOnlyWrite) { refreshChildLists(state); scheduleCollectionIfDue(state); }\n }\n return result;\n }\n\n /** Moves or copies nodes into `target`; returns their local ids there. */\n private moveInto(target: DocumentState, ids: number[], isCopy = false): number[] {\n if (!isCopy) {\n for (const group of this.groups(ids)) {\n if (group.state === target) continue;\n if (!target.raw.adopt) throw new Error('The native addon does not support cross-document adoption. Rebuild the Rust addon.');\n const adopted: { mapping: [number, number][] } = JSON.parse(target.raw.adopt(group.state.raw, group.locals, true));\n rehome(group.state, target, adopted.mapping, ids);\n refreshChildLists(group.state);\n refreshChildLists(target);\n scheduleCollectionIfDue(group.state);\n }\n return ids.map((id) => id - target.base);\n }\n const result: number[] = [];\n for (const group of this.groups(ids)) {\n if (group.state === target) {\n result.push(...this.call<number[]>(target, 'clone', { ids: group.locals, deep: true }));\n continue;\n }\n if (!target.raw.adopt) throw new Error('The native addon does not support cross-document adoption. Rebuild the Rust addon.');\n invalidate(target);\n const adopted: { roots: number[] } = JSON.parse(target.raw.adopt(group.state.raw, group.locals, false));\n result.push(...adopted.roots);\n }\n return result;\n }\n\n private scratch(command: string, args: any, ids: number[]): any {\n const states = [...new Set(ids.map((id) => this.owner(id)))];\n const scratch = new (requireNative().NativeDocument)('', false, JSON.stringify(args.options ?? this.options));\n const toScratch = new Map<number, number>();\n const fromScratch = new Map<number, number>();\n for (const state of states) {\n const roots = state.raw.forestRoots?.() ?? (JSON.parse(state.raw.exportTree()) as NativeNodeRecord[]).filter((record) => record.parent == null).map((record) => record.id);\n if (!scratch.adopt) throw new Error('The native addon does not support native document copies.');\n const copied: { mapping: [number, number][] } = JSON.parse(scratch.adopt(state.raw, roots, false));\n for (const [local, copy] of copied.mapping) {\n const global = state.base + local;\n toScratch.set(global, copy); fromScratch.set(copy, global);\n }\n }\n const translated = { ...args };\n for (const key of ['ids', 'contexts']) if (Array.isArray(args[key])) translated[key] = args[key].map((id: number) => toScratch.get(id)).filter((id: number | undefined) => id !== undefined);\n if (args.pseudoMatches) translated.pseudoMatches = Object.fromEntries(Object.entries(args.pseudoMatches).map(([key, values]) => [key, (values as number[]).map((id) => toScratch.get(id)).filter((id) => id !== undefined)]));\n const result = rawOperation(scratch, command, { ...translated, options: translated.options ?? this.options });\n return ['select', 'matches', 'uniqueSort'].includes(command) ? (result as number[]).map((id) => fromScratch.get(id)!).filter((id) => id !== undefined) : result;\n }\n\n private isMixed(groups: { state: DocumentState }[]): boolean {\n return groups.length > 1 && groups.some((group) => group.state !== groups[0].state);\n }\n\n select(selector: string, contexts?: number[]): number[] {\n const ids = contexts ?? [this.rootId()];\n if (!ids.length) return this.call(this.state, 'select', { selector, contexts: [] });\n if (ids.length === 1) {\n const own = this.state;\n const id = ids[0];\n if (id >= own.base && id < own.base + STRIDE) {\n const found = own.raw.select(selector, [id - own.base]);\n return this.globals(own, found);\n }\n }\n const groups = this.groups(ids);\n if (this.isMixed(groups)) return this.scratch('select', { selector, contexts: ids }, ids);\n const group = groups[0];\n const found = group.state === this.state ? group.state.raw.select(selector, group.locals) : this.call<number[]>(group.state, 'select', { selector, contexts: group.locals });\n return this.globals(group.state, found);\n }\n text(ids: number[]): string {\n if (ids.length === 1) {\n const state = this.owner(ids[0]);\n const text = textFromSnapshot(state, ids[0] - state.base);\n if (text !== undefined) return text;\n }\n return this.groups(ids).map((group) => group.state.raw.text(group.locals)).join('');\n }\n innerHtml(id: number): string {\n const state = this.owner(id);\n const local = id - state.base;\n // Serializing template content splices its fragment into the element.\n const isSplicing = recordAt(state, local)?.children?.some((child) => recordAt(state, child)?.type === 'root') ?? false;\n if (isSplicing) invalidate(state);\n const html = state === this.state ? state.raw.innerHtml(local) : this.call<string>(state, 'html', { ids: [local] });\n if (state === this.state) refreshSerializedNodes(state, state.options);\n if (isSplicing && state.hasChildLists && childRefresher) forEachView(state, childRefresher);\n return html;\n }\n outerHtml(ids: number[]): string {\n return this.groups(ids).map((group) => {\n if (group.state !== this.state) return this.call<string>(group.state, 'render', { ids: group.locals });\n const html = group.state.raw.outerHtml(group.locals);\n refreshSerializedNodes(group.state, group.state.options);\n return html;\n }).join('');\n }\n attr(id: number, name: string): string | undefined { const state = this.owner(id); return this.call(state, 'attr', { ids: [id - state.base], name }) ?? undefined; }\n tagName(id: number): string | undefined { const state = this.owner(id); return recordAt(state, id - state.base)?.name; }\n exportTree(): string {\n if (this.raw.exportTreeWithOffset) return this.raw.exportTreeWithOffset(this.state.base);\n return JSON.stringify((JSON.parse(this.raw.exportTree()) as NativeNodeRecord[]).map((record) => globalRecord(this.state, record)));\n }\n create(html: string, contextId?: number): number[] { return this.operate('create', { html, contextId }); }\n\n insertHtml(targetIds: number[], html: string, position: string): number[] | undefined {\n const groups = this.groups(targetIds);\n if (groups.length !== 1) return undefined;\n const { state, locals } = groups[0];\n const insertHtml = state.raw.insertHtml;\n if (!insertHtml) return undefined;\n registry.writes++;\n invalidate(state);\n const inserted = insertHtml.call(state.raw, locals, html, position);\n if (state.hasChildLists) refreshChildLists(state);\n scheduleCollectionIfDue(state);\n return this.globals(state, inserted);\n }\n\n remove(ids: number[]): void {\n registry.writes++;\n for (const { state, locals } of this.groups(ids)) {\n if (!state.raw.removeNodes) { this.call(state, 'remove', { ids: locals }); continue; }\n invalidate(state);\n state.raw.removeNodes(locals);\n if (state.hasChildLists) refreshChildLists(state);\n scheduleCollectionIfDue(state);\n }\n }\n\n op(command: string, json: string): string { return JSON.stringify(this.operate(command, JSON.parse(json)) ?? null); }\n\n operate(command: string, args: any): any {\n const options = args.options ?? this.options;\n const hasValue = Object.hasOwn(args, 'value');\n if (command === 'node') { const state = this.owner(args.id); return globalRecord(state, recordAt(state, args.id - state.base)); }\n if (command === 'createNode') return this.state.base + this.call<number>(this.state, command, args);\n if (command === 'import') return this.globals(this.state, this.call(this.state, command, args));\n if (command === 'create') {\n const context = args.contextId == null ? undefined : this.owner(args.contextId);\n const state = context ?? this.state;\n const contextLocal = context ? args.contextId - context.base : undefined;\n if (hasParserHooks(options)) {\n const contextRecord = context ? recordAt(context, contextLocal!) : undefined;\n const children = parsedChildren(args.html, { ...options, ...(contextRecord ? { __contextName: contextRecord.name, __contextNamespace: contextRecord.namespace } : {}) });\n return this.globals(state, this.moveInto(state, children));\n }\n return this.globals(state, this.call(state, command, { ...args, contextId: contextLocal }));\n }\n if (command === 'setNode' || command === 'prop' && hasValue && (args.name === 'children' || args.name === 'childNodes' || pointerFields.has(args.name))) {\n const field = command === 'setNode' ? args.field : args.name;\n let result = null;\n for (const id of command === 'setNode' ? [args.id] : args.ids ?? []) {\n let state = this.owner(id);\n let nodeId = id;\n let value = args.value;\n if (field === 'children' || field === 'childNodes') value = this.moveInto(state, value ?? []);\n else if (pointerFields.has(field) && value != null) {\n const pointer = this.owner(value);\n if (pointer !== state) { const moved = [id]; this.moveInto(pointer, moved); nodeId = moved[0]; state = pointer; }\n value = args.value - pointer.base;\n }\n const local = nodeId - state.base;\n result = this.call(state, command, command === 'setNode' ? { ...args, id: local, value } : { ...args, ids: [local], value });\n }\n return result;\n }\n if (command === 'setAttrs') {\n // Batched attribute writes: one native call per document group.\n const groups = this.groups((args.writes ?? []).map((write: { id: number }) => write.id));\n for (const group of groups) {\n const byId = new Map<number, Array<{ name: string; value?: unknown }>>();\n for (const write of args.writes ?? []) {\n const state = this.owner(write.id);\n if (state !== group.state) continue;\n const local = write.id - state.base;\n const list = byId.get(local) ?? [];\n list.push({ name: write.name, value: write.value });\n byId.set(local, list);\n }\n const writes = [...byId.entries()].map(([id, attrs]) => ({ id, attrs }));\n this.call(group.state, command, { ids: [...byId.keys()], writes });\n }\n return null;\n }\n if (command === 'insert') {\n const targets: number[] = args.targetIds ?? [];\n const nodes: number[] = args.nodeIds ?? [];\n const sameDocument = targets.length > 0 && this.groups([...targets, ...nodes]);\n if (sameDocument && sameDocument.length === 1) {\n // One native call clones for every target but the last, as the loop below does per target.\n const { state } = sameDocument[0];\n const inserted = this.call<number[]>(state, command, { ...args, targetIds: targets.map((id) => id - state.base), nodeIds: nodes.map((id) => id - state.base) });\n return this.globals(state, inserted);\n }\n const result: number[] = [];\n const isBesideTarget = args.position === 'before' || args.position === 'after';\n for (let index = 0; index < targets.length; index++) {\n const target = this.owner(targets[index]);\n const targetLocal = targets[index] - target.base;\n // As the native insert, skip targets that cannot receive nodes before\n // moving any there: the nodes would leave their document for nothing.\n const record = recordAt(target, targetLocal);\n if (!record || !parentTypes.has(record.type) || (isBesideTarget && record.parent == null)) continue;\n const local = this.moveInto(target, nodes, index + 1 < targets.length);\n const inserted = this.call<number[]>(target, command, { ...args, targetIds: [targetLocal], nodeIds: local });\n result.push(...this.globals(target, inserted));\n }\n return result;\n }\n if (command === 'html' && hasValue && hasParserHooks(options)) {\n let result = null;\n for (const id of args.ids ?? []) {\n const state = this.owner(id);\n const local = id - state.base;\n const record = recordAt(state, local);\n if (!record || !parentTypes.has(record.type)) continue;\n const children = parsedChildren(String(args.value), { ...options, __contextName: record.name, __contextNamespace: record.namespace });\n result = this.call(state, 'setNode', { id: local, field: 'children', value: this.moveInto(state, children), options });\n }\n return result;\n }\n if (command === 'contains') {\n const container = args.container ?? args.parent;\n const contained = args.contained ?? args.child;\n const parent = this.owner(container);\n const isSameDocument = contained >= parent.base && contained < parent.base + STRIDE;\n return isSameDocument && this.call(parent, command, { container: container - parent.base, contained: contained - parent.base });\n }\n const ids: number[] = command === 'select' ? args.contexts ?? [this.rootId()] : args.ids ?? [];\n const groups = this.groups(ids);\n // Nodes owned by different documents compare equal in domutils' sort.\n if (command === 'uniqueSort' && ids.length === 2 && groups.length === 2 && groups[0].state !== groups[1].state) return ids.slice();\n // Positional filters operate on the input selection, so they need only the\n // first or last matching element rather than copies of every source tree.\n if (command === 'matches' && this.isMixed(groups) && !options.pseudos && !args.pseudoMatches && (args.selector === ':first' || args.selector === ':last')) {\n const ordered = args.selector === ':first' ? groups : [...groups].reverse();\n for (const group of ordered) {\n const matches = this.call<number[]>(group.state, 'matches', { selector: '*', ids: group.locals, options });\n if (matches.length) return [group.state.base + (args.selector === ':first' ? matches[0] : matches[matches.length - 1])];\n }\n return [];\n }\n if (this.isMixed(groups) && scratchCommands.has(command)) return this.scratch(command, { ...args, options }, ids) ?? null;\n if (command === 'extractPlan') { const group = groups[0]; return this.call(group?.state ?? this.state, command, { ...args, options, ids: group?.locals ?? [] }) ?? null; }\n if (idResultCommands.has(command)) {\n const isSelect = command === 'select';\n if (!groups.length && (isSelect || command === 'matches')) return this.call(this.state, command, { ...args, options, ids: [], ...(isSelect ? { contexts: [] } : {}) });\n const result: number[] = [];\n for (const group of groups) {\n const pseudoMatches = args.pseudoMatches ? Object.fromEntries(Object.entries(args.pseudoMatches as Record<string, number[]>).map(([key, values]) => [key, values.filter((id) => id >= group.state.base && id < group.state.base + STRIDE).map((id) => id - group.state.base)])) : undefined;\n const values = this.call<number[]>(group.state, command, { ...args, options, ids: group.locals, ...(isSelect ? { contexts: group.locals } : {}), ...(pseudoMatches ? { pseudoMatches } : {}) });\n result.push(...this.globals(group.state, values));\n }\n return result;\n }\n if (command === 'render' && !hasValue) {\n const optionsJson = JSON.stringify(options);\n return groups.map((group) => group.state.raw.render ? group.state.raw.render(group.locals, optionsJson) : this.call<string>(group.state, command, { ...args, options, ids: group.locals })).join('');\n }\n if ((command === 'outerHtml' || command === 'text') && !hasValue) return groups.map((group) => this.call<string>(group.state, command, { ...args, options, ids: group.locals })).join('');\n if (command === 'hasClass') return groups.some((group) => this.call<boolean>(group.state, command, { ...args, options, ids: group.locals }));\n if (command === 'serializeArray' || command === 'serialize') return groups.length ? this.call(groups[0].state, command, { ...args, options, ids: groups[0].locals }) : command === 'serializeArray' ? [] : '';\n if (command === 'html') for (const group of groups) invalidate(group.state);\n const isWrite = hasValue || writeCommands.has(command);\n let result = null;\n for (const group of isWrite ? groups : groups.slice(0, 1)) result = this.call(group.state, command, { ...args, options, ids: group.locals });\n return result ?? null;\n }\n}\n\n/** Parses `html` into a document of its own, whose children the caller then moves. */\nfunction parsedChildren(html: string, options: CheerioOptions): number[] {\n const parsed = parseNativeDocument(html, options, false) as RoutedDocument;\n exposeState(parsed.state);\n return (parsed.operate('node', { id: parsed.rootId() }) as NativeNodeRecord).children;\n}\n\nfunction dataEntry(state: DocumentState, id: number): DataEntry {\n const local = id - state.base;\n let entry = state.data.get(local);\n if (!entry) state.data.set(local, entry = { state, local });\n return entry;\n}\n\n/**\n * Moves the bookkeeping of adopted nodes to their new arena. Live owners'\n * id lists, node objects and data follow the nodes; `ids` is updated too.\n */\nfunction rehome(source: DocumentState, target: DocumentState, mapping: [number, number][], ids: number[]): void {\n registry.writes++;\n invalidate(source); invalidate(target);\n // Owners of the moved ids, including selections of the source's API, now hold ids of the target.\n exposeState(target);\n const moved = new Map<number, number>();\n for (const [oldLocal, newLocal] of mapping) {\n moved.set(source.base + oldLocal, target.base + newLocal);\n const node = uncacheView(source, oldLocal) as Record<symbol, unknown> | undefined;\n if (node) {\n node[VIEW_STATE] = target; node[VIEW_LOCAL] = newLocal; cacheView(target, newLocal, node);\n if (node[VIEW_CHILD_TARGET]) target.hasChildLists = true;\n }\n const entry = source.data.get(oldLocal);\n if (entry) { source.data.delete(oldLocal); entry.state = target; entry.local = newLocal; target.data.set(newLocal, entry); }\n const adapterNode = source.adapterNodes?.[oldLocal] as Record<symbol, unknown> | undefined;\n if (adapterNode) {\n source.adapterNodes![oldLocal] = undefined;\n (target.adapterNodes ??= [])[newLocal] = adapterNode;\n adapterNode[VIEW_STATE] = target; adapterNode[VIEW_LOCAL] = newLocal;\n }\n }\n const rewrite = (list: number[]): boolean => {\n let isTouched = false;\n for (let index = 0; index < list.length; index++) {\n const next = moved.get(list[index]);\n if (next !== undefined) { list[index] = next; isTouched = true; }\n }\n return isTouched;\n };\n // Leases first: `ids` may be a lease's own list, which must still hold the\n // moved ids for the lease to be found.\n for (const lease of [...source.leases]) {\n if (!rewrite(lease.ids)) continue;\n target.leases.add(lease);\n if (!lease.states.includes(target)) lease.states.push(target);\n if (!lease.ids.some((id) => id >= source.base && id < source.base + STRIDE)) {\n source.leases.delete(lease);\n lease.states = lease.states.filter((state) => state !== source);\n }\n }\n rewrite(ids);\n}\n\n/** Keeps attribute objects that callers hold in step with native writes. */\nfunction refreshWrittenAttributes(state: DocumentState, command: string, args: any): void {\n if (!hasViews(state)) return;\n let locals: number[] | undefined;\n if (command === 'setAttrs') {\n locals = (args.writes ?? []).map((write: { id: number }) => write.id);\n } else if (targetedAttributeWrites.has(command)) locals = args.ids ?? [];\n else if (command === 'setNode') { if (!attributeFields.has(args.field)) return; locals = [args.id]; }\n else if (structuralWrites.has(command)) return;\n const refresh = (view: object | undefined): void => { if (view && (view as Record<symbol, unknown>)[VIEW_ATTRIBUTES]) attributeRefresher?.(view); };\n if (locals) for (const local of locals) refresh(cachedView(state, local));\n else forEachView(state, refresh);\n}\n\nlet attributeRefresher: ((view: object) => void) | undefined;\nlet childRefresher: ((view: object) => void) | undefined;\n\n/** Registers how node objects re-read their attributes and children after a native write. */\nexport function onViewRefresh(attributes: (view: object) => void, children: (view: object) => void): void {\n attributeRefresher = attributes;\n childRefresher = children;\n}\n\n/** Refills the child arrays of parents whose children a native write changed. */\nfunction refreshChildLists(state: DocumentState): void {\n if (!state.hasChildLists || !childRefresher) return;\n const touched = state.raw.takeTouched?.();\n if (touched === undefined) return;\n if (touched === null) { forEachView(state, childRefresher); return; }\n for (const local of touched) { const view = cachedView(state, local); if (view) childRefresher(view); }\n}\n\nexport function routeDocument(document: NativeDocument, options: CheerioOptions = {}): NativeDocument {\n return document.nodeSpace === registry.space ? document : new RoutedDocument(document, options);\n}\n\n/** The unanchored routed document node objects of `state` use. */\nexport function routedFor(state: DocumentState): RoutedDocument {\n return state.routed ??= new RoutedDocument(state.raw, state.options);\n}\n\nexport function sameNodeSpace(first: NativeDocument, second: NativeDocument): boolean {\n return first === second || !!first.nodeSpace && first.nodeSpace === second.nodeSpace;\n}\n\n/** Whether ids of `state` belong to this copy of the package; nodes of another copy are foreign objects here. */\nexport function isLocalState(state: DocumentState): boolean {\n return state.space === registry.space;\n}\n\n/** Whether `document` routes ids through this registry. */\nexport function isRouted(document: NativeDocument): boolean {\n return document.nodeSpace === registry.space;\n}\n","import { requireNative } from './native.js';\nimport { getNode, importNodes, nodeBinding, operation, cloneNode } from './nodes.js';\nimport { routeDocument } from './router.js';\nimport type * as Shape from './types.js';\n\nexport const ElementType = Object.freeze({ Root: 'root', Text: 'text', Directive: 'directive', Comment: 'comment', Script: 'script', Style: 'style', Tag: 'tag', CDATA: 'cdata', Doctype: 'doctype' } as typeof Shape.ElementType);\n\nfunction initialize<T extends Node>(node: T, type: string, fields: Record<string, unknown>, children: readonly Shape.AnyNode[] = []): T {\n const document = routeDocument(new (requireNative().NativeDocument)('', false));\n const id = operation<number>(document, 'createNode', { type, ...fields });\n if (children.length) operation(document, 'setNode', { id, field: 'children', value: importNodes(document, children) });\n return getNode(document, id, node) as unknown as T;\n}\n\n/** DOM constructors backed by native storage, also shared across ESM/CJS views. */\nexport abstract class Node {\n static [Symbol.hasInstance](value: unknown): boolean {\n const binding = nodeBinding(value);\n if (!binding) return Function.prototype[Symbol.hasInstance].call(this, value);\n const type = (value as Shape.AnyNode).type;\n switch (this.name) {\n case 'Node': return true;\n case 'DataNode': return ['text', 'comment', 'directive'].includes(type);\n case 'NodeWithChildren': return ['root', 'tag', 'script', 'style', 'cdata'].includes(type);\n case 'Element': return ['tag', 'script', 'style'].includes(type);\n case 'Document': return type === 'root';\n case 'CDATA': return type === 'cdata';\n case 'Text': return type === 'text';\n case 'Comment': return type === 'comment';\n case 'ProcessingInstruction': return type === 'directive';\n default: return Function.prototype[Symbol.hasInstance].call(this, value);\n }\n }\n}\nexport interface Node extends Shape.Node {}\nexport abstract class DataNode extends Node {}\nexport interface DataNode extends Shape.DataNode {}\nexport abstract class NodeWithChildren extends Node {}\nexport interface NodeWithChildren extends Shape.NodeWithChildren {}\nexport class Text extends DataNode { declare readonly nodeType: 3; declare type: Shape.Text['type']; constructor(data: string) { super(); return initialize(this, 'text', { data }); } }\nexport interface Text extends Shape.Text {}\nexport class Comment extends DataNode { declare readonly nodeType: 8; declare type: Shape.Comment['type']; constructor(data: string) { super(); return initialize(this, 'comment', { data }); } }\nexport interface Comment extends Shape.Comment {}\nexport class ProcessingInstruction extends DataNode { declare readonly nodeType: 1; declare type: Shape.ProcessingInstruction['type']; constructor(name: string, data: string) { super(); return initialize(this, 'directive', { name, data }); } }\nexport interface ProcessingInstruction extends Shape.ProcessingInstruction {}\nexport class Document extends NodeWithChildren { declare readonly nodeType: 9; declare type: Shape.Document['type']; constructor(children: Shape.ChildNode[]) { super(); return initialize(this, 'root', {}, children); } }\nexport interface Document extends Shape.Document {}\nexport class CDATA extends NodeWithChildren { declare readonly nodeType: 4; declare type: Shape.CDATA['type']; constructor(children: Shape.ChildNode[]) { super(); return initialize(this, 'cdata', {}, children); } }\nexport interface CDATA extends Shape.CDATA {}\nexport class Element extends NodeWithChildren { declare readonly nodeType: 1; declare type: Shape.Element['type']; declare sourceCodeLocation?: Shape.TagSourceCodeLocation | null;\n constructor(name: string, attribs: Record<string, string>, children: Shape.ChildNode[] = [], type?: Shape.Element['type']) {\n super(); return initialize(this, type ?? (name === 'script' || name === 'style' ? name : 'tag'), { name, attribs }, children);\n }\n}\nexport interface Element extends Shape.Element {}\n\n/** @internal */\nexport function nodePrototype(type: string): object {\n return ({ root: Document, text: Text, comment: Comment, directive: ProcessingInstruction, cdata: CDATA, tag: Element, script: Element, style: Element }[type] ?? Node).prototype;\n}\nexport const isTag = (node: Shape.Node): node is Shape.Element => ['tag', 'script', 'style'].includes(node.type);\nexport const isText = (node: Shape.Node): node is Shape.Text => node.type === 'text';\nexport const isComment = (node: Shape.Node): node is Shape.Comment => node.type === 'comment';\nexport const isDirective = (node: Shape.Node): node is Shape.ProcessingInstruction => node.type === 'directive';\nexport const isDocument = (node: Shape.Node): node is Shape.Document => node.type === 'root';\nexport const isCDATA = (node: Shape.Node): node is Shape.CDATA => node.type === 'cdata';\nexport const hasChildren = (node: Shape.Node): node is Shape.NodeWithChildren => 'children' in node;\n\n// DOM aliases live on their class prototypes, as they do in domhandler. Native\n// views intercept the underlying fields; external supplied nodes keep theirs.\nObject.defineProperties(Node.prototype, {\n cloneNode: { configurable: true, writable: true, value: cloneNode },\n parentNode: { configurable: true, get(this: Shape.Node) { return this.parent; }, set(this: Shape.Node, value: Shape.ParentNode | null) { this.parent = value; } },\n previousSibling: { configurable: true, get(this: Shape.Node) { return this.prev; }, set(this: Shape.Node, value: Shape.ChildNode | null) { this.prev = value; } },\n nextSibling: { configurable: true, get(this: Shape.Node) { return this.next; }, set(this: Shape.Node, value: Shape.ChildNode | null) { this.next = value; } },\n nodeType: { configurable: true, get(this: Shape.Node) { return ({ root: 9, text: 3, comment: 8, cdata: 4 } as Record<string, number>)[this.type] ?? 1; } },\n});\nObject.defineProperty(DataNode.prototype, 'nodeValue', { configurable: true, get(this: Shape.DataNode) { return this.data; }, set(this: Shape.DataNode, value: string) { this.data = value; } });\nObject.defineProperties(NodeWithChildren.prototype, {\n childNodes: { configurable: true, get(this: Shape.NodeWithChildren) { return this.children; }, set(this: Shape.NodeWithChildren, value: Shape.ChildNode[]) { this.children = value; } },\n firstChild: { configurable: true, get(this: Shape.NodeWithChildren) { return this.children[0] ?? null; } },\n lastChild: { configurable: true, get(this: Shape.NodeWithChildren) { return this.children[this.children.length - 1] ?? null; } },\n});\nObject.defineProperties(Element.prototype, {\n tagName: { configurable: true, get(this: Shape.Element) { return this.name; }, set(this: Shape.Element, value: string) { this.name = value; } },\n attributes: { configurable: true, get(this: Shape.Element) { return Object.keys(this.attribs).map((name) => ({ name, value: this.attribs[name], namespace: this['x-attribsNamespace']?.[name], prefix: this['x-attribsPrefix']?.[name] })); } },\n});\n","import type { NativeDocument, NativeNodeRecord } from './native.js';\nimport { NodeSnapshot } from './snapshot.js';\nimport type { AnyNode } from './types.js';\nimport { nodePrototype } from './dom.js';\nimport { ATTR_META, attributeAssign, defineAttributeKey, setAttributeMeta, type AttributeMeta, type AttributeObject } from './attribute-object.js';\nimport { cachedView, cacheView, exposeTo, isLocalState, isRouted, onViewRefresh, plainSnapshot, prepareWalkSnapshot, recordAt, routedFor, stateIn, structureSnapshot, VIEW_ATTRIBUTES, VIEW_CHILD_TARGET, VIEW_LOCAL, VIEW_SELF, VIEW_STATE, type DocumentState } from './router.js';\n\nexport interface NodeBinding { document: NativeDocument; id: number }\n\n/** A node object: its fields read the native record for the node's current location. */\ninterface View { [VIEW_STATE]: DocumentState; [VIEW_LOCAL]: number; [VIEW_SELF]: View; [VIEW_ATTRIBUTES]: AttributeObject | undefined; [VIEW_CHILDREN]: AnyNode[] | undefined; [VIEW_CHILD_TARGET]: AnyNode[] | undefined; [key: string]: any }\n\nconst VIEW_CHILDREN = Symbol.for('cheerox.node.children');\n\nconst arrayIndex = /^(?:0|[1-9]\\d*)$/;\nconst emptyRecord = Object.freeze({ id: -1, type: 'released', children: [] }) as unknown as NativeNodeRecord;\n\nexport function operation<T = any>(document: NativeDocument, command: string, args: unknown = {}): T {\n const direct = (document as NativeDocument & { operate?(command: string, args: unknown): T }).operate;\n if (direct) return direct.call(document, command, args);\n const value = document.op(command, JSON.stringify(args));\n return (value === undefined || value === '' ? undefined : JSON.parse(value)) as T;\n}\n\n/** The id of a native node object, without allocating a binding. */\nexport function viewId(node: unknown): number | undefined {\n const view = node as View | null | undefined;\n const state = view?.[VIEW_STATE];\n return state !== undefined && view![VIEW_SELF] === view && isLocalState(state) ? state.base + view![VIEW_LOCAL] : undefined;\n}\n\n/** Whether `node` is a node object of a native document, of this or another copy of the package. */\nfunction isNativeNode(node: unknown): boolean {\n const view = node as View | null | undefined;\n return view?.[VIEW_STATE] !== undefined && view[VIEW_SELF] === view;\n}\n\n/** The id of a native node object, made resolvable by `document`'s operations. */\nexport function viewIdIn(document: NativeDocument, node: unknown): number | undefined {\n const id = viewId(node);\n if (id !== undefined) exposeTo(document, (node as View)[VIEW_STATE]);\n return id;\n}\n\nexport function nodeBinding(node: unknown): NodeBinding | undefined {\n const id = node && typeof node === 'object' ? viewId(node) : undefined;\n return id === undefined ? undefined : { document: routedFor((node as View)[VIEW_STATE]), id };\n}\n\nexport function hasMaterializedChildren(node: unknown): boolean {\n return !!(node as View | null | undefined)?.[VIEW_CHILD_TARGET];\n}\n\nexport function hasMaterializedAttributes(node: unknown): boolean {\n return !!(node as View | null | undefined)?.[VIEW_ATTRIBUTES];\n}\n\nexport function nodeId(node: unknown, document?: NativeDocument): number | undefined {\n const id = node && typeof node === 'object' ? viewId(node) : undefined;\n return id !== undefined && (!document || isRouted(document)) ? id : undefined;\n}\n\n/** Recreate parse5's null-prototype attribute maps and shared start-tag map. */\nexport function hydrateLocation<T>(location: T): T {\n if (!location || typeof location !== 'object') return location;\n const value = location as Record<string, any>;\n if (value.attrs && typeof value.attrs === 'object') Object.setPrototypeOf(value.attrs, null);\n if (value.startTag?.attrs && typeof value.startTag.attrs === 'object') {\n Object.setPrototypeOf(value.startTag.attrs, null);\n if (value.attrs && JSON.stringify(value.attrs) === JSON.stringify(value.startTag.attrs)) value.startTag.attrs = value.attrs;\n }\n return location;\n}\n\n/** The node's record; its links are ids local to the node's document. */\nexport function nodeRecord(document: NativeDocument, id: number): NativeNodeRecord {\n if (!isRouted(document)) return operation(document, 'node', { id });\n const state = stateIn(document, id);\n return recordAt(state, id - state.base) as NativeNodeRecord;\n}\n\nconst isElementType = (type: string | undefined): boolean => type === 'tag' || type === 'script' || type === 'style';\n\n/** Mirrors the native `traverse` operation over cached records; `undefined` defers to it. */\nexport function traverseRecords(document: NativeDocument, ids: number[], kind: string): number[] | undefined {\n if (!isRouted(document)) return undefined;\n const result: number[] = [];\n for (const id of ids) {\n const state = stateIn(document, id);\n const { base } = state;\n // Attribute writes leave a snapshot's links and types current, and other\n // writes discard it, so its arrays answer without records.\n const snapshot = state.bulk instanceof NodeSnapshot ? state.bulk : undefined;\n if (snapshot?.isPresent(id - base) && traverseSnapshot(snapshot, base, id - base, kind, result)) continue;\n const node = recordAt(state, id - base);\n if (!node) continue;\n const isElement = (local: number): boolean => isElementType(recordAt(state, local)?.type);\n if (kind === 'children') {\n for (const child of node.children ?? []) if (isElement(child)) result.push(base + child);\n } else if (kind === 'contents') {\n for (const child of node.children ?? []) result.push(base + child);\n } else if (kind === 'parent') {\n if (node.parent != null && isElement(node.parent)) result.push(base + node.parent);\n } else if (kind === 'parents' || kind === 'ancestors') {\n const seen = new Set<number>();\n for (let parent = node.parent; parent != null && !seen.has(parent);) {\n seen.add(parent);\n const ancestor = recordAt(state, parent);\n if (!ancestor || ancestor.type === 'root') break;\n if (isElementType(ancestor.type)) result.push(base + parent);\n parent = ancestor.parent;\n }\n } else if (kind === 'next' || kind === 'prev' || kind === 'nextAll' || kind === 'prevAll') {\n const isForward = kind === 'next' || kind === 'nextAll';\n const isSingle = kind === 'next' || kind === 'prev';\n const seen = new Set<number>();\n for (let sibling = isForward ? node.next : node.prev; sibling != null && !seen.has(sibling);) {\n seen.add(sibling);\n const record = recordAt(state, sibling);\n if (!record) break;\n if (isElementType(record.type)) {\n result.push(base + sibling);\n if (isSingle) break;\n }\n sibling = isForward ? record.next : record.prev;\n }\n } else if (kind === 'siblings') {\n const parent = node.parent == null ? null : recordAt(state, node.parent);\n const local = id - base;\n for (const other of parent?.children ?? []) if (other !== local && isElement(other)) result.push(base + other);\n } else return undefined;\n }\n return result;\n}\n\n/** `traverseRecords` for one node of a current snapshot; false for kinds it leaves to records. */\nfunction traverseSnapshot(snapshot: NodeSnapshot, base: number, local: number, kind: string, result: number[]): boolean {\n const pushChildren = (parent: number, isElementsOnly: boolean, except: number): void => {\n const count = snapshot.childCount(parent);\n for (let index = 0; index < count; index++) {\n const child = snapshot.childAt(parent, index);\n if (child !== except && (!isElementsOnly || snapshot.isElementAt(child))) result.push(base + child);\n }\n };\n switch (kind) {\n case 'children': pushChildren(local, true, -1); return true;\n case 'contents': pushChildren(local, false, -1); return true;\n case 'siblings': {\n const parent = snapshot.linkOf(local, 1);\n if (parent !== null && snapshot.isPresent(parent)) pushChildren(parent, true, local);\n return true;\n }\n case 'parent': {\n const parent = snapshot.linkOf(local, 1);\n if (parent !== null && snapshot.isPresent(parent) && snapshot.isElementAt(parent)) result.push(base + parent);\n return true;\n }\n case 'parents': case 'ancestors': {\n let parent = snapshot.linkOf(local, 1);\n for (let steps = 0; parent !== null && steps < snapshot.size && snapshot.isPresent(parent) && !snapshot.isRootAt(parent); steps++) {\n if (snapshot.isElementAt(parent)) result.push(base + parent);\n parent = snapshot.linkOf(parent, 1);\n }\n return true;\n }\n case 'next': case 'prev': case 'nextAll': case 'prevAll': {\n const offset = kind === 'next' || kind === 'nextAll' ? 3 : 2;\n const isSingle = kind === 'next' || kind === 'prev';\n let sibling = snapshot.linkOf(local, offset);\n for (let steps = 0; sibling !== null && steps < snapshot.size && snapshot.isPresent(sibling); steps++) {\n if (snapshot.isElementAt(sibling)) {\n result.push(base + sibling);\n if (isSingle) break;\n }\n sibling = snapshot.linkOf(sibling, offset);\n }\n return true;\n }\n default: return false;\n }\n}\n\n/** The node object for an arena slot, created on first use and then shared. */\nexport function viewAt(state: DocumentState, local: number, knownType?: string): AnyNode | undefined {\n const existing = state.views[local] ?? cachedView(state, local);\n if (existing) { applyPendingRoot(state, local, existing); return existing as AnyNode; }\n const parsed = state.adapterNodes?.[local];\n if (parsed) {\n state.adapterNodes![local] = undefined;\n const view = adoptObject(state, local, parsed);\n applyPendingRoot(state, local, view);\n return view;\n }\n const snapshot = knownType ? undefined : structureSnapshot(state, local);\n let constructor: ViewConstructor;\n if (knownType && !state.options.sourceCodeLocationInfo) constructor = viewConstructor(state, knownType, false);\n else if (snapshot && !snapshot.hasExtraFields(local)) constructor = viewConstructor(state, snapshot.typeOf(local), false);\n else {\n const record = recordAt(state, local);\n if (!record) return undefined;\n constructor = viewConstructor(state, record.type, record.sourceCodeLocation !== undefined);\n }\n const view = constructor(state, local);\n cacheView(state, local, view);\n applyPendingRoot(state, local, view);\n return view as unknown as AnyNode;\n}\n\n/** A document root's node object, built without reading its record: its type is known. */\nexport function rootNode(document: NativeDocument, id: number): AnyNode {\n if (!isRouted(document)) throw new TypeError('Native nodes require a routed document');\n const state = stateIn(document, id);\n const local = id - state.base;\n const existing = cachedView(state, local);\n if (existing) { applyPendingRoot(state, local, existing); return existing as AnyNode; }\n if (state.adapterNodes?.[local] || state.options.sourceCodeLocationInfo) return viewAt(state, local) as AnyNode;\n const view = (viewConstructor(state, 'root', false))(state, local);\n cacheView(state, local, view);\n applyPendingRoot(state, local, view);\n return view as unknown as AnyNode;\n}\n\n/** Stable DOM node identities; each property reads or updates the Rust arena. */\nexport function getNode(document: NativeDocument, id: number, original?: any, knownType?: string): AnyNode {\n if (!isRouted(document)) throw new TypeError('Native nodes require a routed document');\n const state = stateIn(document, id);\n const local = id - state.base;\n if (original === undefined) return viewAt(state, local, knownType) as AnyNode;\n const view = adoptObject(state, local, original);\n applyPendingRoot(state, local, view);\n return view;\n}\n\nexport function getNodesOfType(document: NativeDocument, ids: number[], type: string): AnyNode[] {\n if (!ids.length) return [];\n const state = stateIn(document, ids[0]);\n if (state.options.sourceCodeLocationInfo || state.adapterNodes) return ids.map((id) => getNode(document, id));\n const constructor = viewConstructor(state, type, false);\n const result = new Array<AnyNode>(ids.length);\n for (let index = 0; index < ids.length; index++) {\n const id = ids[index];\n if (stateIn(document, id) !== state) {\n result[index] = getNode(document, id);\n continue;\n }\n const local = id - state.base;\n let view = state.views[local] as AnyNode | undefined;\n if (!view && (local >= state.baseline || state.weakViews.size)) view = cachedView(state, local) as AnyNode | undefined;\n if (!view) {\n view = constructor(state, local) as unknown as AnyNode;\n cacheView(state, local, view);\n }\n if ((state as any)._pendingRoots) applyPendingRoot(state, local, view);\n result[index] = view;\n }\n return result;\n}\n\nfunction viewRecord(view: View): NativeNodeRecord {\n const state = view[VIEW_STATE];\n const local = view[VIEW_LOCAL];\n return state.records[local] ?? recordAt(state, local) ?? emptyRecord;\n}\n\nfunction linkedView(view: View, local: number | null | undefined): AnyNode | null {\n return local == null ? null : viewAt(view[VIEW_STATE], local) ?? null;\n}\n\nfunction setField(view: View, field: string, value: unknown): void {\n const state = view[VIEW_STATE];\n operation(routedFor(state), 'setNode', { id: state.base + view[VIEW_LOCAL], field, value });\n}\n\nfunction setPointer(view: View, field: string, value: unknown): void {\n setField(view, field, value == null ? null : importNodes(routedFor(view[VIEW_STATE]), [value])[0]);\n}\n\nfunction attributesOf(view: View): Record<string, string> {\n const state = view[VIEW_STATE];\n let attributes = view[VIEW_ATTRIBUTES];\n if (!attributes) view[VIEW_ATTRIBUTES] = attributes = createAttributes(view, state.options._useHtmlParser2 === false ? null : Object.prototype);\n const meta = attributes[ATTR_META]!;\n if (meta.generation !== state.generation || meta.state !== state) syncAttributes(view, attributes);\n return attributes;\n}\n\n/** Pushes a direct attribute write through to the node's native record (shared; no per-object closure). */\nfunction writeAttributeThrough(view: unknown, attributes: AttributeObject, key: string, value: unknown): void {\n const owner = view as View;\n setField(owner, 'attribs', { ...viewRecord(owner).attribs, [key]: String(value) });\n (attributes[ATTR_META] as AttributeMeta).values[key] = String(value);\n}\n\nfunction createAttributes(view: View, prototype: object | null): AttributeObject {\n const attributes = Object.create(prototype) as AttributeObject;\n setAttributeMeta(attributes, {\n view,\n generation: -1,\n state: view[VIEW_STATE],\n values: {},\n write: writeAttributeThrough,\n });\n return attributes;\n}\n\n/** Copies the record's attributes into the shared accessors, preserving key order. */\nfunction syncAttributes(view: View, attributes: AttributeObject): void {\n const meta = attributes[ATTR_META]!;\n const state = view[VIEW_STATE];\n const local = view[VIEW_LOCAL];\n if (meta.generation === -1) {\n const snapshot = plainSnapshot(state, local);\n if (snapshot) {\n snapshot.copyAttributes(local, attributes);\n meta.generation = state.generation;\n return;\n }\n }\n const values = viewRecord(view).attribs ?? {};\n const nextKeys = Object.keys(values);\n const currentKeys = Object.keys(attributes);\n let isSameOrder = currentKeys.length === nextKeys.length;\n for (let index = 0; isSameOrder && index < nextKeys.length; index++) isSameOrder = currentKeys[index] === nextKeys[index];\n const stored = meta.values;\n if (!isSameOrder) {\n for (const key of currentKeys) {\n delete attributes[key];\n delete stored[key];\n }\n for (const key of nextKeys) defineAttributeKey(attributes, key, values[key]);\n } else {\n for (const key of nextKeys) {\n // `__proto__` cannot be assigned through the store object: plain\n // assignment would mutate the store's prototype.\n if (key === '__proto__') { defineAttributeKey(attributes, key, values[key]); continue; }\n if (stored[key] !== values[key]) stored[key] = values[key];\n }\n }\n meta.generation = state.generation;\n meta.state = state;\n}\n\n/** Re-reads attributes for a node whose attributes a native command changed. */\nfunction refreshAttributes(view: object): void {\n const attributes = (view as View)[VIEW_ATTRIBUTES];\n if (attributes) syncAttributes(view as View, attributes);\n}\nonViewRefresh(refreshAttributes, fillChildren);\n\n/** Namespace and prefix maps are rare; they read the record on every access. */\nfunction attributeMap(view: View, field: 'attribsNamespace' | 'attribsPrefix'): Record<string, string> {\n const read = (): Record<string, string> => (viewRecord(view) as any)[field] ?? {};\n const target = Object.create(view[VIEW_STATE].options._useHtmlParser2 === false ? null : Object.prototype);\n const viewField = `x-${field}`;\n return new Proxy(target, {\n get(_target, key) {\n if (typeof key === 'symbol') return Reflect.get(target, key);\n const values = read();\n return Object.hasOwn(values, key) ? values[key] : Reflect.get(target, key);\n },\n set(_target, key, value) { setField(view, viewField, { ...read(), [key]: String(value) }); return true; },\n deleteProperty(_target, key) { const values = { ...read() }; delete values[key as string]; setField(view, viewField, values); return true; },\n ownKeys() { return Reflect.ownKeys(read()); },\n has(_target, key) { return Object.hasOwn(read(), key) || key in target; },\n getOwnPropertyDescriptor(_target, key) { const values = read(); return Object.hasOwn(values, key) ? { value: values[key as string], writable: true, enumerable: true, configurable: true } : undefined; },\n defineProperty(_target, key, descriptor) { setField(view, viewField, { ...read(), [key]: String(descriptor.value) }); return true; },\n });\n}\n\n/**\n * A node's children: a real array of node objects, so reads cost what\n * Cheerio's do. Its mutating methods write the whole list to Rust once, and\n * the router refills the array in place whenever Rust reports the parent\n * changed. Assigning an index or `length` directly changes only this array.\n * `constructor` is `Array`, so arrays derived from it are plain.\n */\nclass ChildArray extends Array<AnyNode> {\n readonly #view: View;\n constructor(view: View) {\n super();\n this.#view = view;\n }\n static viewOf(list: unknown): View | undefined {\n return list instanceof ChildArray ? list.#view : undefined;\n }\n}\nObject.defineProperty(ChildArray.prototype, 'constructor', { configurable: true, writable: true, value: Array });\nfor (const method of ['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse', 'copyWithin', 'fill'] as const) {\n Object.defineProperty(ChildArray.prototype, method, {\n configurable: true, writable: true,\n value(this: ChildArray, ...args: unknown[]) {\n const view = ChildArray.viewOf(this);\n if (!view) return Reflect.apply((Array.prototype as any)[method], this, args);\n const values = Array.from(this);\n const result = Reflect.apply((Array.prototype as any)[method], values, args);\n saveChildren(view, values);\n return result === values ? this : result;\n },\n });\n}\n\nfunction saveChildren(view: View, values: unknown[]): void {\n setField(view, 'children', importNodes(routedFor(view[VIEW_STATE]), values));\n}\n\nfunction childList(view: View): AnyNode[] {\n const existing = view[VIEW_CHILDREN];\n if (existing) return existing;\n const state = view[VIEW_STATE];\n if (state.baseline > 4096 && state.rootLocal !== undefined && view[VIEW_LOCAL] === state.rootLocal + 1) prepareWalkSnapshot(state);\n if (!state.hasChildLists) { state.hasChildLists = true; state.raw.takeTouched?.(); }\n const list = new ChildArray(view);\n view[VIEW_CHILD_TARGET] = list;\n view[VIEW_CHILDREN] = list;\n fillChildren(view);\n return list;\n}\n\n/** Rebuilds a materialized child array from the node's current record. */\nfunction fillChildren(view: object): void {\n const target = (view as View)[VIEW_CHILD_TARGET];\n if (!target) return;\n const state = (view as View)[VIEW_STATE];\n const local = (view as View)[VIEW_LOCAL];\n const snapshot = structureSnapshot(state, local);\n if (snapshot && state.stale.size === 0) {\n fillFromSnapshot(state, snapshot, local, target);\n return;\n }\n const locals = viewRecord(view as View).children ?? [];\n for (let index = 0; index < locals.length; index++) target[index] = viewAt(state, locals[index])!;\n truncate(target, locals.length);\n}\n\n/**\n * Children are written in order and the length is trimmed afterwards:\n * presetting the length of a fresh array makes it holey and costs more than\n * filling it.\n */\nfunction truncate(target: AnyNode[], length: number): void {\n if (target.length !== length) target.length = length;\n}\n\n/**\n * The common case of a walk: a node's children read straight from the\n * snapshot arrays and cached strongly, with each type's constructor resolved\n * once per snapshot instead of once per node.\n */\nfunction fillFromSnapshot(state: DocumentState, snapshot: NodeSnapshot, local: number, target: AnyNode[]): void {\n const count = snapshot.childCount(local);\n const first = snapshot.childStart(local);\n const childIds = snapshot.childIds;\n const views = state.views;\n const isStrong = !state.adapterNodes;\n const hasWeakViews = state.weakViews.size > 0;\n const hasPendingRoots = !!(state as any)._pendingRoots;\n const constructors = snapshotConstructors(state, snapshot);\n for (let index = 0; index < count; index++) {\n const child = childIds[first + index];\n let node = (views[child] ?? (hasWeakViews ? cachedView(state, child) : undefined)) as AnyNode | undefined;\n if (node === undefined) {\n const constructor = isStrong && child < state.baseline && snapshot.isPlain(child) ? constructors(snapshot.typeReference(child)) : undefined;\n if (constructor) views[child] = node = constructor(state, child) as unknown as AnyNode;\n else node = viewAt(state, child)!;\n }\n if (hasPendingRoots) applyPendingRoot(state, child, node);\n target[index] = node;\n }\n truncate(target, count);\n}\n\nfunction snapshotConstructors(state: DocumentState, snapshot: NodeSnapshot): (reference: number) => ViewConstructor {\n let lookup = snapshot.viewConstructors as ((reference: number) => ViewConstructor) | undefined;\n if (!lookup) {\n const byReference: ViewConstructor[] = [];\n lookup = (reference) => byReference[reference] ??= viewConstructor(state, snapshot.name(reference), false);\n snapshot.viewConstructors = lookup;\n }\n return lookup;\n}\n\ntype Accessor = { get(this: View): unknown; set(this: View, value: any): void };\nconst recordField = (field: string, fallback?: null): Accessor => ({\n get() { return (viewRecord(this) as any)[field] ?? fallback; },\n set(value) { setField(this, field, value); },\n});\n/** Fields read straight from the snapshot when it holds the node, without building a record. */\nconst snapshotField = (field: 'type' | 'name' | 'data'): Accessor => ({\n get() {\n const state = this[VIEW_STATE];\n const local = this[VIEW_LOCAL];\n const snapshot = field === 'data' ? plainSnapshot(state, local) : structureSnapshot(state, local);\n if (snapshot) return field === 'type' ? snapshot.typeOf(local) : field === 'name' ? snapshot.nameOf(local) : snapshot.dataOf(local);\n return (viewRecord(this) as any)[field];\n },\n set(value) { setField(this, field, value); },\n});\nconst linkOffsets = { parent: 1, prev: 2, next: 3 } as const;\nconst pointerField = (field: 'parent' | 'prev' | 'next'): Accessor => ({\n get() {\n const state = this[VIEW_STATE];\n const local = this[VIEW_LOCAL];\n const snapshot = structureSnapshot(state, local);\n return linkedView(this, snapshot ? snapshot.linkOf(local, linkOffsets[field]) : viewRecord(this)[field]);\n },\n set(value) { setPointer(this, field, value); },\n});\nconst nodeAccessors: Record<string, Accessor> = {\n type: snapshotField('type'),\n parent: pointerField('parent'),\n prev: pointerField('prev'),\n next: pointerField('next'),\n startIndex: recordField('startIndex', null),\n endIndex: recordField('endIndex', null),\n};\n/** Present only on nodes parsed with location info, as in Cheerio. */\nconst locationAccessor: Accessor = { get() { return hydrateLocation(viewRecord(this).sourceCodeLocation); }, set(value) { setField(this, 'sourceCodeLocation', value); } };\nconst childAccessors: Record<string, Accessor> = {\n children: { get() { return childList(this); }, set(value) { setField(this, 'children', importNodes(routedFor(this[VIEW_STATE]), value)); } },\n};\nconst elementAccessors: Record<string, Accessor> = {\n name: snapshotField('name'),\n attribs: { get() { return attributesOf(this); }, set(value) { setField(this, 'attribs', value); } },\n namespace: recordField('namespace'),\n prefix: recordField('prefix'),\n 'x-attribsNamespace': { get() { return viewRecord(this).attribsNamespace !== undefined ? attributeMap(this, 'attribsNamespace') : undefined; }, set(value) { setField(this, 'x-attribsNamespace', value); } },\n 'x-attribsPrefix': { get() { return viewRecord(this).attribsPrefix !== undefined ? attributeMap(this, 'attribsPrefix') : undefined; }, set(value) { setField(this, 'x-attribsPrefix', value); } },\n};\nconst dataAccessors: Record<string, Accessor> = { data: snapshotField('data') };\nconst directiveAccessors: Record<string, Accessor> = { name: recordField('name'), 'x-name': recordField('x-name'), 'x-publicId': recordField('x-publicId'), 'x-systemId': recordField('x-systemId') };\nconst documentAccessors: Record<string, Accessor> = { 'x-mode': recordField('x-mode') };\n\nfunction accessorsFor(type: string): Record<string, Accessor> {\n switch (type) {\n case 'tag': case 'script': case 'style': return { ...nodeAccessors, ...childAccessors, ...elementAccessors };\n case 'root': return { ...nodeAccessors, ...childAccessors, ...documentAccessors };\n case 'cdata': return { ...nodeAccessors, ...childAccessors };\n case 'directive': return { ...nodeAccessors, ...dataAccessors, ...directiveAccessors };\n case 'text': case 'comment': return { ...nodeAccessors, ...dataAccessors };\n default: return { ...nodeAccessors, ...childAccessors, ...dataAccessors, name: recordField('name') };\n }\n}\n\ntype ViewConstructor = (state: DocumentState, local: number) => View;\nconst viewConstructors = new Map<string, ViewConstructor>();\nconst plainConstructors: Record<string, ViewConstructor | undefined> = Object.create(null);\n\n/**\n * Legacy (Cheerio 0.22.0) node-shape rules, enabled per document through the\n * `_legacyDom` option:\n * - a top-level node's `parent` reads as null; its document root is exposed\n * through the separate `root` field instead;\n * - every node carries a writable `root` field, stored on the JavaScript side\n * exactly like the plain-object field of the original library;\n * - the synthetic root keeps its `name` of \"root\" and an `attribs` object.\n */\nconst rootReferences = new WeakMap<object, unknown>();\nfunction applyPendingRoot(state: DocumentState, local: number, view: unknown): void {\n const pending = (state as any)._pendingRoots as Map<number, unknown> | undefined;\n if (pending === undefined) return;\n if (pending.has(local)) {\n rootReferences.set(view as object, pending.get(local));\n pending.delete(local);\n if (pending.size === 0) (state as any)._pendingRoots = undefined;\n }\n}\nexport function setRootIfCached(document: NativeDocument, id: number, root: unknown): void {\n const state = stateIn(document, id);\n const local = id - state.base;\n const view = cachedView(state, local);\n if (view) { rootReferences.set(view, root); return; }\n let pending = (state as any)._pendingRoots as Map<number, unknown> | undefined;\n if (!pending) (state as any)._pendingRoots = pending = new Map();\n pending.set(local, root);\n}\n/** Fast path for callers that already resolved state+local (e.g. static adjacent insert). */\nexport function setRootIfCachedLocal(state: DocumentState, local: number, root: unknown): void {\n const view = cachedView(state, local);\n if (view) { rootReferences.set(view, root); return; }\n let pending = (state as any)._pendingRoots as Map<number, unknown> | undefined;\n if (!pending) (state as any)._pendingRoots = pending = new Map();\n pending.set(local, root);\n}\nconst legacyParentAccessor: Accessor = {\n get() {\n const state = this[VIEW_STATE];\n const local = this[VIEW_LOCAL];\n const snapshot = structureSnapshot(state, local);\n const parentLocal = snapshot ? snapshot.linkOf(local, 1) : viewRecord(this).parent;\n if (parentLocal == null) return null;\n if (parentLocal === state.rootLocal) return null;\n return linkedView(this, parentLocal);\n },\n set(value) { setPointer(this, 'parent', value); },\n};\nconst legacyRootAccessor: Accessor = {\n get() { return rootReferences.get(this); },\n set(value) { rootReferences.set(this, value); },\n};\n\nfunction legacyAccessors(type: string): Record<string, Accessor> {\n const accessors: Record<string, Accessor> = { parent: legacyParentAccessor, root: legacyRootAccessor };\n if (type === 'root') accessors.name = { get: () => 'root', set(value) { setField(this, 'name', value); } };\n // domhandler 2.4.2 defines the DOM Lvl 1 aliases on every node prototype.\n accessors.tagName = { get() { return this.name || null; }, set(value) { this.name = value; } };\n accessors.nodeValue = { get() { return this.data || null; }, set(value) { this.data = value; } };\n return accessors;\n}\n\n/**\n * The own fields of a 0.22.0 node object, per node kind. Legacy views define\n * these as own enumerable accessor properties so that enumeration\n * (`Object.keys(node)`) and deep-equality checks behave like they do on the\n * original plain-object nodes.\n */\nconst legacyOwnFields: Record<string, string[]> = {\n root: ['type', 'name', 'attribs', 'children', 'parent', 'prev', 'next'],\n tag: ['type', 'name', 'attribs', 'children', 'parent', 'prev', 'next'],\n script: ['type', 'name', 'attribs', 'children', 'parent', 'prev', 'next'],\n style: ['type', 'name', 'attribs', 'children', 'parent', 'prev', 'next'],\n cdata: ['type', 'children', 'parent', 'prev', 'next'],\n directive: ['type', 'name', 'data', 'parent', 'prev', 'next'],\n text: ['type', 'data', 'parent', 'prev', 'next'],\n comment: ['type', 'data', 'parent', 'prev', 'next'],\n};\n\n/** One constructor per node shape so node objects share a hidden class and prototype. */\nfunction viewConstructor(state: DocumentState, type: string, hasLocation: boolean): ViewConstructor {\n const legacy = state.options._legacyDom === true;\n const suffix = hasLocation ? ':location' : '';\n const key = legacy ? `${type}${suffix}:legacy` : `${type}${suffix}`;\n if (!hasLocation && !legacy) { const plain = plainConstructors[type]; if (plain) return plain; }\n let constructor = viewConstructors.get(key);\n if (constructor) return constructor;\n const prototype = Object.create(nodePrototype(type));\n let accessors = hasLocation ? { ...accessorsFor(type), sourceCodeLocation: locationAccessor } : accessorsFor(type);\n if (legacy) accessors = { ...accessors, ...legacyAccessors(type), ...(type === 'root' ? { attribs: elementAccessors.attribs } : {}) };\n const childrenDescriptor = 'children' in accessors ? { ...childAccessors.children, configurable: true, enumerable: true } : undefined;\n for (const [field, accessor] of Object.entries(accessors)) Object.defineProperty(prototype, field, { ...accessor, configurable: true, enumerable: false });\n const ownDescriptors: PropertyDescriptorMap = {};\n if (childrenDescriptor) ownDescriptors.children = childrenDescriptor;\n if (legacy) {\n const fields = legacyOwnFields[type];\n if (fields) {\n for (const field of fields) {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, field);\n if (descriptor && (descriptor.get || descriptor.set)) ownDescriptors[field] = { get: descriptor.get, set: descriptor.set, configurable: true, enumerable: true };\n }\n }\n }\n const createView = legacy\n ? () => Object.create(prototype, ownDescriptors) as View\n : childrenDescriptor\n ? () => Object.defineProperty(Object.create(prototype), 'children', childrenDescriptor) as View\n : () => Object.create(prototype) as View;\n constructor = function (state: DocumentState, local: number): View {\n const view = createView();\n view[VIEW_STATE] = state;\n view[VIEW_LOCAL] = local;\n view[VIEW_SELF] = view;\n view[VIEW_ATTRIBUTES] = undefined;\n view[VIEW_CHILD_TARGET] = undefined;\n view[VIEW_CHILDREN] = undefined;\n return view;\n };\n Object.defineProperty(prototype, inspectSymbol, { configurable: true, writable: true, value: inspectNode });\n constructor.prototype = prototype;\n viewConstructors.set(key, constructor);\n if (!hasLocation && !legacy) plainConstructors[type] = constructor;\n return constructor;\n}\n\nconst inspectSymbol = Symbol.for('nodejs.util.inspect.custom');\nconst inspectedFields = ['type', 'name', 'data', 'attribs', 'namespace', 'startIndex', 'endIndex'];\n\n/** Console output shows the node's fields instead of its native bookkeeping. */\nfunction inspectNode(this: View, depth: number, options: object, inspect: (value: unknown, options: object) => string): string {\n const fields: Record<string, unknown> = {};\n for (const field of inspectedFields) if (field in this && this[field] != null) fields[field] = field === 'attribs' ? { ...this.attribs } : this[field];\n if ('children' in this) fields.children = `[${this.children.length} nodes]`;\n const name = Object.getPrototypeOf(Object.getPrototypeOf(this))?.constructor?.name ?? 'Node';\n return depth < 0 ? `[${name}]` : `${name} ${inspect(fields, { ...options, depth: 1 })}`;\n}\n\nconst adoptedAliases: PropertyDescriptorMap = {\n parentNode: { configurable: true, enumerable: false, get(this: View) { return this.parent; }, set(this: View, value) { this.parent = value; } },\n previousSibling: { configurable: true, enumerable: false, get(this: View) { return this.prev; }, set(this: View, value) { this.prev = value; } },\n nextSibling: { configurable: true, enumerable: false, get(this: View) { return this.next; }, set(this: View, value) { this.next = value; } },\n nodeType: { configurable: true, enumerable: false, get(this: View) { return ({ root: 9, text: 3, comment: 8, cdata: 4 } as Record<string, number>)[viewRecord(this).type] ?? 1; } },\n cloneNode: { configurable: true, enumerable: false, writable: true, value: cloneNode },\n};\nconst adoptedChildAliases: PropertyDescriptorMap = {\n childNodes: { configurable: true, enumerable: false, get(this: View) { return this.children; }, set(this: View, value) { this.children = value; } },\n firstChild: { configurable: true, enumerable: false, get(this: View) { return this.children[0] ?? null; } },\n lastChild: { configurable: true, enumerable: false, get(this: View) { return this.children[this.children.length - 1] ?? null; } },\n};\nconst adoptedElementAliases: PropertyDescriptorMap = {\n tagName: { configurable: true, enumerable: false, get(this: View) { return this.name; }, set(this: View, value) { this.name = value; } },\n attributes: { configurable: true, enumerable: false, get(this: View) { const attributes = this.attribs; const record = viewRecord(this); return Object.keys(attributes).map((name) => ({ name, value: attributes[name], namespace: record.attribsNamespace?.[name], prefix: record.attribsPrefix?.[name] })); } },\n};\nconst adoptedDataAliases: PropertyDescriptorMap = {\n nodeValue: { configurable: true, enumerable: false, get(this: View) { return this.data; }, set(this: View, value) { this.data = value; } },\n};\nconst adoptedFields = new Map<string, PropertyDescriptorMap>();\nconst optionalAdoptedKeys = ['name', 'data', 'namespace', 'prefix', 'sourceCodeLocation', 'x-name', 'x-publicId', 'x-systemId', 'x-mode', 'x-attribsNamespace', 'x-attribsPrefix'];\nconst optionalAdoptedFields = new Set(optionalAdoptedKeys);\nconst adoptedShapes = new Map<string, PropertyDescriptorMap>();\n\n/**\n * Binds an object created outside the arena (a DOM constructor or a parser\n * hook's node) to its native node, keeping the caller's object identity.\n */\nfunction adoptObject(state: DocumentState, local: number, original: any): AnyNode {\n const record = recordAt(state, local);\n if (!record) return undefined as unknown as AnyNode;\n const view = original as View;\n const attributesPrototype = original.attribs && typeof original.attribs === 'object' ? Object.getPrototypeOf(original.attribs) : undefined;\n view[VIEW_STATE] = state;\n view[VIEW_LOCAL] = local;\n view[VIEW_SELF] = view;\n view[VIEW_ATTRIBUTES] = undefined;\n view[VIEW_CHILD_TARGET] = undefined;\n view[VIEW_CHILDREN] = undefined;\n let fields = adoptedFields.get(record.type);\n if (!fields) {\n fields = {};\n for (const [key, accessor] of Object.entries({ ...accessorsFor(record.type), sourceCodeLocation: locationAccessor })) fields[key] = { ...accessor, configurable: true, enumerable: true };\n adoptedFields.set(record.type, fields);\n }\n // Which optional fields a node has varies; each combination's full descriptor map is built once.\n let shape = record.type;\n for (const key of optionalAdoptedKeys) {\n if (!(key in fields)) continue;\n const field = key === 'x-attribsNamespace' ? 'attribsNamespace' : key === 'x-attribsPrefix' ? 'attribsPrefix' : key;\n shape += (record as any)[field] !== undefined || Object.hasOwn(original, key) ? '1' : '0';\n }\n let descriptors = adoptedShapes.get(shape);\n if (!descriptors) {\n const present: PropertyDescriptorMap = {};\n for (const key in fields) {\n const field = key === 'x-attribsNamespace' ? 'attribsNamespace' : key === 'x-attribsPrefix' ? 'attribsPrefix' : key;\n if (optionalAdoptedFields.has(key) && (record as any)[field] === undefined && !Object.hasOwn(original, key)) continue;\n present[key] = fields[key];\n }\n const isParent = 'children' in present;\n const isData = record.type === 'text' || record.type === 'comment' || record.type === 'directive';\n descriptors = { ...present, ...adoptedAliases, ...(isParent ? adoptedChildAliases : {}), ...(isElementType(record.type) ? adoptedElementAliases : {}), ...(isData ? adoptedDataAliases : {}) };\n adoptedShapes.set(shape, descriptors);\n }\n const isElement = isElementType(record.type);\n try {\n Object.defineProperties(view, descriptors);\n } catch {\n // Foreign user properties may be non-configurable; those keep their values.\n }\n if (isElement && attributesPrototype !== undefined) view[VIEW_ATTRIBUTES] = createAttributes(view, attributesPrototype);\n cacheView(state, local, view);\n return view as unknown as AnyNode;\n}\n\n/**\n * Registers a tree adapter's nodes for the document's slots. Each node can be\n * passed back to the API at once; its fields become live when first returned.\n */\nexport function attachParsedNodes(state: DocumentState, nodes: (object | undefined)[]): void {\n state.adapterNodes = nodes;\n for (let local = 0; local < nodes.length; local++) {\n const node = nodes[local] as View | undefined;\n if (!node) continue;\n node[VIEW_STATE] = state;\n node[VIEW_LOCAL] = local;\n node[VIEW_SELF] = node;\n }\n}\n\n/** Clone through the receiver's current native owner, including borrowed calls. */\nexport function cloneNode<T extends AnyNode>(this: T, recursive = false): T {\n const binding = nodeBinding(this);\n if (!binding) throw new TypeError('cloneNode requires a native DOM node receiver');\n return getNode(binding.document, operation<number[]>(binding.document, 'clone', { ids: [binding.id], deep: recursive })[0]) as T;\n}\n\nfunction childIds(document: NativeDocument, id: number): number[] {\n const state = stateIn(document, id);\n return (recordAt(state, id - state.base)?.children ?? []).map((child) => state.base + child);\n}\n\n/** Import external DOM nodes once and keep their object identities as handles. */\nexport function importNodes(document: NativeDocument, input: unknown): number[] {\n if (input == null || input === false) return [];\n const values: any[] = Array.isArray(input) || (typeof input === 'object' && 'length' in input && !('type' in input)) ? Array.from(input as ArrayLike<any>) : [input];\n const result: number[] = [];\n for (const node of values) {\n if (node == null) continue;\n const existing = node && typeof node === 'object' ? viewIdIn(document, node) : undefined;\n if (existing !== undefined) { result.push(existing); continue; }\n if (typeof node !== 'object' || typeof node.type !== 'string') continue;\n const records: any[] = [];\n const originals = new Map<number, any>();\n const visit = (value: any, parent?: number): number => {\n const id = records.length;\n const record: any = { id, type: value.type, children: [], ...(parent === undefined ? {} : { parent }) };\n records.push(record); originals.set(id, value);\n for (const field of ['name', 'data', 'namespace', 'prefix', 'startIndex', 'endIndex', 'sourceCodeLocation', 'x-name', 'x-publicId', 'x-systemId', 'x-mode']) if (value[field] !== undefined) record[field] = value[field];\n if (value.attribs) record.attribs = { ...value.attribs };\n if (value['x-attribsNamespace']) record.attribsNamespace = { ...value['x-attribsNamespace'] };\n if (value['x-attribsPrefix']) record.attribsPrefix = { ...value['x-attribsPrefix'] };\n record.children = (value.children ?? []).map((child: any) => visit(child, id));\n return id;\n };\n const root = visit(node);\n const imported = operation<number[]>(document, 'import', { nodes: records, roots: [root] });\n if (!imported.length) continue;\n const adopt = (oldId: number, newId: number): void => {\n const source = originals.get(oldId);\n const oldChildren = records[oldId].children;\n const newChildren = childIds(document, newId);\n // A node already belonging to another Rust document must retain its\n // original document handle. Imported clones receive their own handles.\n getNode(document, newId, isNativeNode(source) ? undefined : source);\n for (let i = 0; i < oldChildren.length; i++) if (newChildren[i] !== undefined) adopt(oldChildren[i], newChildren[i]);\n };\n adopt(root, imported[0]);\n result.push(imported[0]);\n }\n return result;\n}\n\nexport const isTag = (node: any): boolean => !!node && isElementType(node.type);\nexport const isDocument = (node: any): boolean => node?.type === 'root';\nexport const hasChildren = (node: any): boolean => !!node && 'children' in node;\n"],"mappings":";;;;;;;;;;AAKA,MAAM,WAAW;AACjB,MAAM,UAAU;AAChB,MAAM,aAAa;AACnB,MAAM,eAAgB,OAAO,UAAoD;AAEjF,SAAgB,aAAa,OAAuB;CAClD,IAAI,CAAC,QAAQ,KAAK,KAAK,MAAM,eAAe,aAAa,KAAK,KAAK,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI,OAAO;CACtG,MAAM,QAAkB,CAAC;CACzB,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,OAAO,MAAM,WAAW,KAAK;EACnC,IAAI,QAAQ,SAAU,QAAQ,OAAQ;GACpC,MAAM,OAAO,MAAM,WAAW,QAAQ,CAAC;GACvC,IAAI,QAAQ,SAAU,QAAQ,OAAQ;IAAE;IAAS;GAAU;EAC7D;EACA,IAAI;EACJ,IAAI,QAAQ,SAAU,QAAQ,OAAQ,cAAc,OAAO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