├── .gitignore ├── CHANGELOG.md ├── Cargo.lock ├── Cargo.toml ├── README.md ├── browser.js ├── bun.js ├── cloudflare.js ├── default.js ├── dist ├── asyncify.js ├── html_rewriter.d.ts ├── html_rewriter.js ├── html_rewriter_bg.js ├── html_rewriter_bg.wasm ├── html_rewriter_bg.wasm.d.ts ├── html_rewriter_wrapper.d.ts ├── html_rewriter_wrapper.js ├── html_rewriter_wrapper.js.map ├── index.d.ts └── types.d.ts ├── node.mjs ├── package.json ├── pnpm-lock.yaml ├── scripts ├── build.ts ├── index.html └── try.js ├── src ├── asyncify.js ├── comment.rs ├── doctype.rs ├── document_end.rs ├── element.rs ├── end_tag.rs ├── errors.test.ts ├── handlers.rs ├── html_rewriter.rs ├── html_rewriter_wrapper.ts ├── index.d.ts ├── lib.rs ├── text_chunk.rs └── types.d.ts ├── tsconfig.json └── vercel.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | node_modules 4 | target 5 | node 6 | pkg 7 | play.mjs -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # htmlrewriter 2 | 3 | ## 0.0.12 4 | 5 | ### Patch Changes 6 | 7 | - Fix dist/html_rewriter 8 | 9 | ## 0.0.11 10 | 11 | ### Patch Changes 12 | 13 | - Add export for dist/html_rewriter 14 | 15 | ## 0.0.10 16 | 17 | ### Patch Changes 18 | 19 | - Added more exports for individual files 20 | 21 | ## 0.0.7 22 | 23 | ### Patch Changes 24 | 25 | - HTMLRewriter initPromise is static, fix typescript declaration bug 26 | 27 | ## 0.0.6 28 | 29 | ### Patch Changes 30 | 31 | - Fix types for HtmlRewriter 32 | 33 | ## 0.0.5 34 | 35 | ### Patch Changes 36 | 37 | - Add types export 38 | 39 | ## 0.0.4 40 | 41 | ### Patch Changes 42 | 43 | - Remove dep on assert 44 | 45 | ## 0.0.3 46 | 47 | ### Patch Changes 48 | 49 | - add missing vercel.js file to npm 50 | 51 | ## 0.0.2 52 | 53 | ### Patch Changes 54 | 55 | - fix next.js condition using browser 56 | 57 | ## 0.0.1 58 | 59 | ### Patch Changes 60 | 61 | - use the workerd condition to build 62 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "ahash" 7 | version = "0.7.6" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 10 | dependencies = [ 11 | "getrandom 0.2.4", 12 | "once_cell", 13 | "version_check", 14 | ] 15 | 16 | [[package]] 17 | name = "bitflags" 18 | version = "1.2.1" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 21 | 22 | [[package]] 23 | name = "bumpalo" 24 | version = "3.7.0" 25 | source = "registry+https://github.com/rust-lang/crates.io-index" 26 | checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" 27 | 28 | [[package]] 29 | name = "byteorder" 30 | version = "1.3.2" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" 33 | 34 | [[package]] 35 | name = "cfg-if" 36 | version = "0.1.10" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 39 | 40 | [[package]] 41 | name = "cfg-if" 42 | version = "1.0.0" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 45 | 46 | [[package]] 47 | name = "convert_case" 48 | version = "0.4.0" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 51 | 52 | [[package]] 53 | name = "cssparser" 54 | version = "0.27.2" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a" 57 | dependencies = [ 58 | "cssparser-macros", 59 | "dtoa-short", 60 | "itoa", 61 | "matches", 62 | "phf", 63 | "proc-macro2", 64 | "quote", 65 | "smallvec", 66 | "syn", 67 | ] 68 | 69 | [[package]] 70 | name = "cssparser-macros" 71 | version = "0.6.0" 72 | source = "registry+https://github.com/rust-lang/crates.io-index" 73 | checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e" 74 | dependencies = [ 75 | "quote", 76 | "syn", 77 | ] 78 | 79 | [[package]] 80 | name = "derive_more" 81 | version = "0.99.17" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" 84 | dependencies = [ 85 | "convert_case", 86 | "proc-macro2", 87 | "quote", 88 | "rustc_version", 89 | "syn", 90 | ] 91 | 92 | [[package]] 93 | name = "dtoa" 94 | version = "0.4.4" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" 97 | 98 | [[package]] 99 | name = "dtoa-short" 100 | version = "0.3.2" 101 | source = "registry+https://github.com/rust-lang/crates.io-index" 102 | checksum = "59020b8513b76630c49d918c33db9f4c91638e7d3404a28084083b87e33f76f2" 103 | dependencies = [ 104 | "dtoa", 105 | ] 106 | 107 | [[package]] 108 | name = "encoding_rs" 109 | version = "0.8.22" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28" 112 | dependencies = [ 113 | "cfg-if 0.1.10", 114 | ] 115 | 116 | [[package]] 117 | name = "fnv" 118 | version = "1.0.6" 119 | source = "registry+https://github.com/rust-lang/crates.io-index" 120 | checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" 121 | 122 | [[package]] 123 | name = "fxhash" 124 | version = "0.2.1" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" 127 | dependencies = [ 128 | "byteorder", 129 | ] 130 | 131 | [[package]] 132 | name = "getrandom" 133 | version = "0.1.16" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" 136 | dependencies = [ 137 | "cfg-if 1.0.0", 138 | "libc", 139 | "wasi 0.9.0+wasi-snapshot-preview1", 140 | ] 141 | 142 | [[package]] 143 | name = "getrandom" 144 | version = "0.2.4" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" 147 | dependencies = [ 148 | "cfg-if 1.0.0", 149 | "libc", 150 | "wasi 0.10.2+wasi-snapshot-preview1", 151 | ] 152 | 153 | [[package]] 154 | name = "hashbrown" 155 | version = "0.11.2" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 158 | dependencies = [ 159 | "ahash", 160 | ] 161 | 162 | [[package]] 163 | name = "html-rewriter" 164 | version = "0.3.0" 165 | dependencies = [ 166 | "js-sys", 167 | "lol_html", 168 | "serde", 169 | "serde-wasm-bindgen", 170 | "thiserror", 171 | "wasm-bindgen", 172 | ] 173 | 174 | [[package]] 175 | name = "itoa" 176 | version = "0.4.4" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" 179 | 180 | [[package]] 181 | name = "js-sys" 182 | version = "0.3.33" 183 | source = "registry+https://github.com/rust-lang/crates.io-index" 184 | checksum = "367647c532db6f1555d7151e619540ec5f713328235b8c062c6b4f63e84adfe3" 185 | dependencies = [ 186 | "wasm-bindgen", 187 | ] 188 | 189 | [[package]] 190 | name = "lazy_static" 191 | version = "1.4.0" 192 | source = "registry+https://github.com/rust-lang/crates.io-index" 193 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 194 | 195 | [[package]] 196 | name = "lazycell" 197 | version = "1.3.0" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" 200 | 201 | [[package]] 202 | name = "libc" 203 | version = "0.2.66" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" 206 | 207 | [[package]] 208 | name = "log" 209 | version = "0.4.8" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 212 | dependencies = [ 213 | "cfg-if 0.1.10", 214 | ] 215 | 216 | [[package]] 217 | name = "lol_html" 218 | version = "0.3.0" 219 | source = "git+https://github.com/cloudflare/lol-html?rev=f32bd14#f32bd14b229ed1088c25725cce242817ea2fe43a" 220 | dependencies = [ 221 | "bitflags", 222 | "cfg-if 1.0.0", 223 | "cssparser", 224 | "encoding_rs", 225 | "hashbrown", 226 | "lazy_static", 227 | "lazycell", 228 | "memchr", 229 | "safemem", 230 | "selectors", 231 | "thiserror", 232 | ] 233 | 234 | [[package]] 235 | name = "matches" 236 | version = "0.1.8" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 239 | 240 | [[package]] 241 | name = "memchr" 242 | version = "2.2.1" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" 245 | 246 | [[package]] 247 | name = "nodrop" 248 | version = "0.1.14" 249 | source = "registry+https://github.com/rust-lang/crates.io-index" 250 | checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" 251 | 252 | [[package]] 253 | name = "once_cell" 254 | version = "1.9.0" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" 257 | 258 | [[package]] 259 | name = "phf" 260 | version = "0.8.0" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" 263 | dependencies = [ 264 | "phf_macros", 265 | "phf_shared", 266 | "proc-macro-hack", 267 | ] 268 | 269 | [[package]] 270 | name = "phf_codegen" 271 | version = "0.8.0" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" 274 | dependencies = [ 275 | "phf_generator", 276 | "phf_shared", 277 | ] 278 | 279 | [[package]] 280 | name = "phf_generator" 281 | version = "0.8.0" 282 | source = "registry+https://github.com/rust-lang/crates.io-index" 283 | checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" 284 | dependencies = [ 285 | "phf_shared", 286 | "rand", 287 | ] 288 | 289 | [[package]] 290 | name = "phf_macros" 291 | version = "0.8.0" 292 | source = "registry+https://github.com/rust-lang/crates.io-index" 293 | checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" 294 | dependencies = [ 295 | "phf_generator", 296 | "phf_shared", 297 | "proc-macro-hack", 298 | "proc-macro2", 299 | "quote", 300 | "syn", 301 | ] 302 | 303 | [[package]] 304 | name = "phf_shared" 305 | version = "0.8.0" 306 | source = "registry+https://github.com/rust-lang/crates.io-index" 307 | checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" 308 | dependencies = [ 309 | "siphasher", 310 | ] 311 | 312 | [[package]] 313 | name = "ppv-lite86" 314 | version = "0.2.16" 315 | source = "registry+https://github.com/rust-lang/crates.io-index" 316 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 317 | 318 | [[package]] 319 | name = "precomputed-hash" 320 | version = "0.1.1" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" 323 | 324 | [[package]] 325 | name = "proc-macro-hack" 326 | version = "0.5.19" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 329 | 330 | [[package]] 331 | name = "proc-macro2" 332 | version = "1.0.27" 333 | source = "registry+https://github.com/rust-lang/crates.io-index" 334 | checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" 335 | dependencies = [ 336 | "unicode-xid", 337 | ] 338 | 339 | [[package]] 340 | name = "quote" 341 | version = "1.0.2" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" 344 | dependencies = [ 345 | "proc-macro2", 346 | ] 347 | 348 | [[package]] 349 | name = "rand" 350 | version = "0.7.3" 351 | source = "registry+https://github.com/rust-lang/crates.io-index" 352 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" 353 | dependencies = [ 354 | "getrandom 0.1.16", 355 | "libc", 356 | "rand_chacha", 357 | "rand_core", 358 | "rand_hc", 359 | "rand_pcg", 360 | ] 361 | 362 | [[package]] 363 | name = "rand_chacha" 364 | version = "0.2.2" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" 367 | dependencies = [ 368 | "ppv-lite86", 369 | "rand_core", 370 | ] 371 | 372 | [[package]] 373 | name = "rand_core" 374 | version = "0.5.1" 375 | source = "registry+https://github.com/rust-lang/crates.io-index" 376 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 377 | dependencies = [ 378 | "getrandom 0.1.16", 379 | ] 380 | 381 | [[package]] 382 | name = "rand_hc" 383 | version = "0.2.0" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 386 | dependencies = [ 387 | "rand_core", 388 | ] 389 | 390 | [[package]] 391 | name = "rand_pcg" 392 | version = "0.2.1" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" 395 | dependencies = [ 396 | "rand_core", 397 | ] 398 | 399 | [[package]] 400 | name = "rustc_version" 401 | version = "0.4.0" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 404 | dependencies = [ 405 | "semver", 406 | ] 407 | 408 | [[package]] 409 | name = "safemem" 410 | version = "0.3.3" 411 | source = "registry+https://github.com/rust-lang/crates.io-index" 412 | checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" 413 | 414 | [[package]] 415 | name = "selectors" 416 | version = "0.22.0" 417 | source = "registry+https://github.com/rust-lang/crates.io-index" 418 | checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" 419 | dependencies = [ 420 | "bitflags", 421 | "cssparser", 422 | "derive_more", 423 | "fxhash", 424 | "log", 425 | "matches", 426 | "phf", 427 | "phf_codegen", 428 | "precomputed-hash", 429 | "servo_arc", 430 | "smallvec", 431 | "thin-slice", 432 | ] 433 | 434 | [[package]] 435 | name = "semver" 436 | version = "1.0.4" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" 439 | 440 | [[package]] 441 | name = "serde" 442 | version = "1.0.104" 443 | source = "registry+https://github.com/rust-lang/crates.io-index" 444 | checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" 445 | dependencies = [ 446 | "serde_derive", 447 | ] 448 | 449 | [[package]] 450 | name = "serde-wasm-bindgen" 451 | version = "0.1.3" 452 | source = "registry+https://github.com/rust-lang/crates.io-index" 453 | checksum = "7ee6f12f7ed0e7ad2e55200da37dbabc2cadeb942355c5b629aa3771f5ac5636" 454 | dependencies = [ 455 | "fnv", 456 | "js-sys", 457 | "serde", 458 | "wasm-bindgen", 459 | ] 460 | 461 | [[package]] 462 | name = "serde_derive" 463 | version = "1.0.104" 464 | source = "registry+https://github.com/rust-lang/crates.io-index" 465 | checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" 466 | dependencies = [ 467 | "proc-macro2", 468 | "quote", 469 | "syn", 470 | ] 471 | 472 | [[package]] 473 | name = "servo_arc" 474 | version = "0.1.1" 475 | source = "registry+https://github.com/rust-lang/crates.io-index" 476 | checksum = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" 477 | dependencies = [ 478 | "nodrop", 479 | "stable_deref_trait", 480 | ] 481 | 482 | [[package]] 483 | name = "siphasher" 484 | version = "0.3.9" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e" 487 | 488 | [[package]] 489 | name = "smallvec" 490 | version = "1.8.0" 491 | source = "registry+https://github.com/rust-lang/crates.io-index" 492 | checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" 493 | 494 | [[package]] 495 | name = "stable_deref_trait" 496 | version = "1.1.1" 497 | source = "registry+https://github.com/rust-lang/crates.io-index" 498 | checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 499 | 500 | [[package]] 501 | name = "syn" 502 | version = "1.0.73" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" 505 | dependencies = [ 506 | "proc-macro2", 507 | "quote", 508 | "unicode-xid", 509 | ] 510 | 511 | [[package]] 512 | name = "thin-slice" 513 | version = "0.1.1" 514 | source = "registry+https://github.com/rust-lang/crates.io-index" 515 | checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" 516 | 517 | [[package]] 518 | name = "thiserror" 519 | version = "1.0.9" 520 | source = "registry+https://github.com/rust-lang/crates.io-index" 521 | checksum = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" 522 | dependencies = [ 523 | "thiserror-impl", 524 | ] 525 | 526 | [[package]] 527 | name = "thiserror-impl" 528 | version = "1.0.9" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" 531 | dependencies = [ 532 | "proc-macro2", 533 | "quote", 534 | "syn", 535 | ] 536 | 537 | [[package]] 538 | name = "unicode-xid" 539 | version = "0.2.0" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" 542 | 543 | [[package]] 544 | name = "version_check" 545 | version = "0.9.4" 546 | source = "registry+https://github.com/rust-lang/crates.io-index" 547 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 548 | 549 | [[package]] 550 | name = "wasi" 551 | version = "0.9.0+wasi-snapshot-preview1" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" 554 | 555 | [[package]] 556 | name = "wasi" 557 | version = "0.10.2+wasi-snapshot-preview1" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 560 | 561 | [[package]] 562 | name = "wasm-bindgen" 563 | version = "0.2.74" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" 566 | dependencies = [ 567 | "cfg-if 1.0.0", 568 | "wasm-bindgen-macro", 569 | ] 570 | 571 | [[package]] 572 | name = "wasm-bindgen-backend" 573 | version = "0.2.74" 574 | source = "registry+https://github.com/rust-lang/crates.io-index" 575 | checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" 576 | dependencies = [ 577 | "bumpalo", 578 | "lazy_static", 579 | "log", 580 | "proc-macro2", 581 | "quote", 582 | "syn", 583 | "wasm-bindgen-shared", 584 | ] 585 | 586 | [[package]] 587 | name = "wasm-bindgen-macro" 588 | version = "0.2.74" 589 | source = "registry+https://github.com/rust-lang/crates.io-index" 590 | checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" 591 | dependencies = [ 592 | "quote", 593 | "wasm-bindgen-macro-support", 594 | ] 595 | 596 | [[package]] 597 | name = "wasm-bindgen-macro-support" 598 | version = "0.2.74" 599 | source = "registry+https://github.com/rust-lang/crates.io-index" 600 | checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" 601 | dependencies = [ 602 | "proc-macro2", 603 | "quote", 604 | "syn", 605 | "wasm-bindgen-backend", 606 | "wasm-bindgen-shared", 607 | ] 608 | 609 | [[package]] 610 | name = "wasm-bindgen-shared" 611 | version = "0.2.74" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" 614 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "html-rewriter" 3 | version = "0.3.0" 4 | authors = ["Ivan Nikulin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | js-sys = "0.3.33" 9 | lol_html = { git = "https://github.com/cloudflare/lol-html", rev = "f32bd14" } 10 | serde = { version = "1.0.104", features = ["derive"] } 11 | serde-wasm-bindgen = "0.1.3" 12 | wasm-bindgen = "0.2.74" 13 | thiserror = "1.0.2" 14 | 15 | [lib] 16 | crate-type = ["cdylib", "rlib"] 17 | 18 | [package.metadata.wasm-pack.profile.dev] 19 | wasm-opt = ["--asyncify"] 20 | [package.metadata.wasm-pack.profile.release] 21 | wasm-opt = ["-Os", "--asyncify"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

htmlrewriter

6 |

7 |
8 |
9 |
10 | 11 | Cloudflare `HTMLRewriter` packaged to work with 12 | 13 | - Node.js (reading the wasm from file system) 14 | - Next.js (appending `?module` to wasm imports) 15 | - browser (fetching the wasm file at runtime) 16 | - Deno (fetching the wasm file at runtime with file:// protocol) 17 | - Bun & Cloudflare (simply using the global `HTMLRewriter` object) 18 | 19 | ## Install 20 | 21 | ``` 22 | npm i htmlrewriter 23 | ``` 24 | 25 | ## Usage 26 | 27 | ```ts 28 | import { HTMLRewriter } from 'htmlrewriter' 29 | 30 | const rewriter = new HTMLRewriter() 31 | 32 | rewriter.on('a', { 33 | element(element) { 34 | element.setAttribute('href', 'https://www.baidu.com') 35 | }, 36 | }) 37 | const res = rewriter.transform( 38 | new Response('google'), 39 | ) 40 | console.log(await res.text()) 41 | ``` 42 | 43 | ## License 44 | 45 | `html-rewriter-wasm` uses [lol-html](https://github.com/cloudflare/lol-html/) 46 | which is BSD 3-Clause licensed: 47 | 48 | ``` 49 | Copyright (C) 2019, Cloudflare, Inc. 50 | All rights reserved. 51 | 52 | Redistribution and use in source and binary forms, with or without modification, 53 | are permitted provided that the following conditions are met: 54 | 55 | 1. Redistributions of source code must retain the above copyright notice, this 56 | list of conditions and the following disclaimer. 57 | 58 | 2. Redistributions in binary form must reproduce the above copyright notice, 59 | this list of conditions and the following disclaimer in the documentation and/or 60 | other materials provided with the distribution. 61 | 62 | 3. Neither the name of the copyright holder nor the names of its contributors 63 | may be used to endorse or promote products derived from this software without 64 | specific prior written permission. 65 | 66 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 67 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 68 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 69 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 70 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 71 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 72 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 73 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 74 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 75 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 76 | ``` 77 | -------------------------------------------------------------------------------- /browser.js: -------------------------------------------------------------------------------- 1 | import init from './dist/html_rewriter' 2 | 3 | import { HTMLRewriterWrapper } from './dist/html_rewriter_wrapper' 4 | 5 | export const HTMLRewriter = HTMLRewriterWrapper( 6 | init(fetch(new URL('./dist/html_rewriter_bg.wasm', import.meta.url))), 7 | ) 8 | -------------------------------------------------------------------------------- /bun.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | const GlobalHtmlRewriter = HTMLRewriter 4 | export { GlobalHtmlRewriter as HTMLRewriter } 5 | -------------------------------------------------------------------------------- /cloudflare.js: -------------------------------------------------------------------------------- 1 | // https://github.com/cloudflare/workers-sdk/blob/ff8603b6e1320d5c136712b8100e86c552eade46/packages/wrangler/src/deployment-bundle/bundle.ts#L351 2 | 3 | const GlobalHtmlRewriter = HTMLRewriter 4 | export { GlobalHtmlRewriter as HTMLRewriter } 5 | -------------------------------------------------------------------------------- /default.js: -------------------------------------------------------------------------------- 1 | import init from './dist/html_rewriter' 2 | 3 | import wasm from './dist/html_rewriter_bg.wasm' 4 | import { HTMLRewriterWrapper } from './dist/html_rewriter_wrapper' 5 | 6 | export const HTMLRewriter = HTMLRewriterWrapper(init(wasm)) 7 | -------------------------------------------------------------------------------- /dist/asyncify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef {object} WasmExports 3 | * @property {WebAssembly.Memory} memory 4 | * @property {function} asyncify_get_state 5 | * @property {function} asyncify_start_unwind 6 | * @property {function} asyncify_stop_unwind 7 | * @property {function} asyncify_start_rewind 8 | * @property {function} asyncify_stop_rewind 9 | */ 10 | 11 | /** 12 | * @type {WasmExports} 13 | */ 14 | let wasm 15 | 16 | /** 17 | * @param {WasmExports} wasmExports 18 | */ 19 | function setWasmExports(wasmExports) { 20 | wasm = wasmExports 21 | } 22 | 23 | /** 24 | * @type {Int32Array} 25 | */ 26 | let cachedInt32Memory = null 27 | 28 | /** 29 | * @returns {Int32Array} 30 | */ 31 | function getInt32Memory() { 32 | if ( 33 | cachedInt32Memory === null || 34 | cachedInt32Memory.buffer !== wasm.memory.buffer 35 | ) { 36 | cachedInt32Memory = new Int32Array(wasm.memory.buffer) 37 | } 38 | return cachedInt32Memory 39 | } 40 | 41 | // https://github.com/WebAssembly/binaryen/blob/fb9de9d391a7272548dcc41cd8229076189d7398/src/passes/Asyncify.cpp#L99 42 | const State = { 43 | NONE: 0, 44 | UNWINDING: 1, 45 | REWINDING: 2, 46 | } 47 | 48 | function assertStrictEqual(actual, expected) { 49 | if (actual !== expected) { 50 | throw new Error(`Expected ${actual} to equal ${expected}`) 51 | } 52 | } 53 | 54 | function assert(condition) { 55 | if (!condition) { 56 | throw new Error('Assertion failed') 57 | } 58 | } 59 | 60 | function assertNoneState() { 61 | assertStrictEqual(wasm.asyncify_get_state(), State.NONE) 62 | } 63 | 64 | /** 65 | * Maps `HTMLRewriter`s (their `asyncifyStackPtr`s) to `Promise`s. 66 | * `asyncifyStackPtr` acts as unique reference to `HTMLRewriter`. 67 | * Each rewriter MUST have AT MOST ONE pending promise at any time. 68 | * @type {Map} 69 | */ 70 | const promises = new Map() 71 | 72 | /** 73 | * @param {number} stackPtr 74 | * @param {Promise} promise 75 | */ 76 | function awaitPromise(stackPtr, promise) { 77 | if (wasm.asyncify_get_state() === State.REWINDING) { 78 | wasm.asyncify_stop_rewind() 79 | return 80 | } 81 | 82 | assertNoneState() 83 | 84 | // https://github.com/WebAssembly/binaryen/blob/fb9de9d391a7272548dcc41cd8229076189d7398/src/passes/Asyncify.cpp#L106 85 | assertStrictEqual(stackPtr % 4, 0) 86 | getInt32Memory().set([stackPtr + 8, stackPtr + 1024], stackPtr / 4) 87 | 88 | wasm.asyncify_start_unwind(stackPtr) 89 | 90 | assert(!promises.has(stackPtr)) 91 | promises.set(stackPtr, promise) 92 | } 93 | 94 | /** 95 | * @param {HTMLRewriter} rewriter 96 | * @param {Function} fn 97 | * @param args 98 | */ 99 | async function wrap(rewriter, fn, ...args) { 100 | const stackPtr = rewriter.asyncifyStackPtr 101 | 102 | assertNoneState() 103 | let result = fn(...args) 104 | 105 | while (wasm.asyncify_get_state() === State.UNWINDING) { 106 | wasm.asyncify_stop_unwind() 107 | 108 | assertNoneState() 109 | assert(promises.has(stackPtr)) 110 | await promises.get(stackPtr) 111 | promises.delete(stackPtr) 112 | 113 | assertNoneState() 114 | wasm.asyncify_start_rewind(stackPtr) 115 | result = fn() 116 | } 117 | 118 | assertNoneState() 119 | return result 120 | } 121 | 122 | export { awaitPromise, setWasmExports, wrap } 123 | -------------------------------------------------------------------------------- /dist/html_rewriter.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | */ 5 | export class Comment { 6 | free(): void; 7 | /** 8 | * @param {string} content 9 | * @param {any | undefined} content_type 10 | */ 11 | before(content: string, content_type?: any): void; 12 | /** 13 | * @param {string} content 14 | * @param {any | undefined} content_type 15 | */ 16 | after(content: string, content_type?: any): void; 17 | /** 18 | * @param {string} content 19 | * @param {any | undefined} content_type 20 | */ 21 | replace(content: string, content_type?: any): void; 22 | /** 23 | */ 24 | remove(): void; 25 | /** 26 | * @returns {boolean} 27 | */ 28 | readonly removed: boolean; 29 | /** 30 | * @returns {string} 31 | */ 32 | text: string; 33 | } 34 | /** 35 | */ 36 | export class Doctype { 37 | free(): void; 38 | /** 39 | * @returns {any} 40 | */ 41 | readonly name: any; 42 | /** 43 | * @returns {any} 44 | */ 45 | readonly publicId: any; 46 | /** 47 | * @returns {any} 48 | */ 49 | readonly systemId: any; 50 | } 51 | /** 52 | */ 53 | export class DocumentEnd { 54 | free(): void; 55 | /** 56 | * @param {string} content 57 | * @param {any | undefined} content_type 58 | */ 59 | append(content: string, content_type?: any): void; 60 | } 61 | /** 62 | */ 63 | export class Element { 64 | free(): void; 65 | /** 66 | * @param {string} content 67 | * @param {any | undefined} content_type 68 | */ 69 | before(content: string, content_type?: any): void; 70 | /** 71 | * @param {string} content 72 | * @param {any | undefined} content_type 73 | */ 74 | after(content: string, content_type?: any): void; 75 | /** 76 | * @param {string} content 77 | * @param {any | undefined} content_type 78 | */ 79 | replace(content: string, content_type?: any): void; 80 | /** 81 | */ 82 | remove(): void; 83 | /** 84 | * @param {string} name 85 | * @returns {any} 86 | */ 87 | getAttribute(name: string): any; 88 | /** 89 | * @param {string} name 90 | * @returns {boolean} 91 | */ 92 | hasAttribute(name: string): boolean; 93 | /** 94 | * @param {string} name 95 | * @param {string} value 96 | */ 97 | setAttribute(name: string, value: string): void; 98 | /** 99 | * @param {string} name 100 | */ 101 | removeAttribute(name: string): void; 102 | /** 103 | * @param {string} content 104 | * @param {any | undefined} content_type 105 | */ 106 | prepend(content: string, content_type?: any): void; 107 | /** 108 | * @param {string} content 109 | * @param {any | undefined} content_type 110 | */ 111 | append(content: string, content_type?: any): void; 112 | /** 113 | * @param {string} content 114 | * @param {any | undefined} content_type 115 | */ 116 | setInnerContent(content: string, content_type?: any): void; 117 | /** 118 | */ 119 | removeAndKeepContent(): void; 120 | /** 121 | * @param {any} handler 122 | */ 123 | onEndTag(handler: any): void; 124 | /** 125 | * @returns {any} 126 | */ 127 | readonly attributes: any; 128 | /** 129 | * @returns {any} 130 | */ 131 | readonly namespaceURI: any; 132 | /** 133 | * @returns {boolean} 134 | */ 135 | readonly removed: boolean; 136 | /** 137 | * @returns {string} 138 | */ 139 | tagName: string; 140 | } 141 | /** 142 | */ 143 | export class EndTag { 144 | free(): void; 145 | /** 146 | * @param {string} content 147 | * @param {any | undefined} content_type 148 | */ 149 | before(content: string, content_type?: any): void; 150 | /** 151 | * @param {string} content 152 | * @param {any | undefined} content_type 153 | */ 154 | after(content: string, content_type?: any): void; 155 | /** 156 | */ 157 | remove(): void; 158 | /** 159 | * @returns {string} 160 | */ 161 | name: string; 162 | } 163 | /** 164 | */ 165 | export class HTMLRewriter { 166 | free(): void; 167 | /** 168 | * @param {any} output_sink 169 | * @param {any | undefined} options 170 | */ 171 | constructor(output_sink: any, options?: any); 172 | /** 173 | * @param {string} selector 174 | * @param {any} handlers 175 | */ 176 | on(selector: string, handlers: any): void; 177 | /** 178 | * @param {any} handlers 179 | */ 180 | onDocument(handlers: any): void; 181 | /** 182 | * @param {Uint8Array} chunk 183 | */ 184 | write(chunk: Uint8Array): void; 185 | /** 186 | */ 187 | end(): void; 188 | /** 189 | * @returns {number} 190 | */ 191 | readonly asyncifyStackPtr: number; 192 | } 193 | /** 194 | */ 195 | export class TextChunk { 196 | free(): void; 197 | /** 198 | * @param {string} content 199 | * @param {any | undefined} content_type 200 | */ 201 | before(content: string, content_type?: any): void; 202 | /** 203 | * @param {string} content 204 | * @param {any | undefined} content_type 205 | */ 206 | after(content: string, content_type?: any): void; 207 | /** 208 | * @param {string} content 209 | * @param {any | undefined} content_type 210 | */ 211 | replace(content: string, content_type?: any): void; 212 | /** 213 | */ 214 | remove(): void; 215 | /** 216 | * @returns {boolean} 217 | */ 218 | readonly lastInTextNode: boolean; 219 | /** 220 | * @returns {boolean} 221 | */ 222 | readonly removed: boolean; 223 | /** 224 | * @returns {string} 225 | */ 226 | readonly text: string; 227 | } 228 | 229 | export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; 230 | 231 | export interface InitOutput { 232 | readonly memory: WebAssembly.Memory; 233 | readonly __wbg_endtag_free: (a: number) => void; 234 | readonly endtag_name: (a: number, b: number) => void; 235 | readonly endtag_set_name: (a: number, b: number, c: number) => void; 236 | readonly endtag_before: (a: number, b: number, c: number, d: number) => void; 237 | readonly endtag_after: (a: number, b: number, c: number, d: number) => void; 238 | readonly endtag_remove: (a: number) => void; 239 | readonly __wbg_documentend_free: (a: number) => void; 240 | readonly documentend_append: (a: number, b: number, c: number, d: number) => void; 241 | readonly __wbg_htmlrewriter_free: (a: number) => void; 242 | readonly htmlrewriter_new: (a: number, b: number) => number; 243 | readonly htmlrewriter_on: (a: number, b: number, c: number, d: number) => void; 244 | readonly htmlrewriter_onDocument: (a: number, b: number) => void; 245 | readonly htmlrewriter_write: (a: number, b: number, c: number) => void; 246 | readonly htmlrewriter_end: (a: number) => void; 247 | readonly htmlrewriter_asyncify_stack_ptr: (a: number) => number; 248 | readonly __wbg_comment_free: (a: number) => void; 249 | readonly comment_before: (a: number, b: number, c: number, d: number) => void; 250 | readonly comment_after: (a: number, b: number, c: number, d: number) => void; 251 | readonly comment_replace: (a: number, b: number, c: number, d: number) => void; 252 | readonly comment_remove: (a: number) => void; 253 | readonly comment_removed: (a: number) => number; 254 | readonly comment_text: (a: number, b: number) => void; 255 | readonly comment_set_text: (a: number, b: number, c: number) => void; 256 | readonly __wbg_element_free: (a: number) => void; 257 | readonly element_before: (a: number, b: number, c: number, d: number) => void; 258 | readonly element_after: (a: number, b: number, c: number, d: number) => void; 259 | readonly element_replace: (a: number, b: number, c: number, d: number) => void; 260 | readonly element_remove: (a: number) => void; 261 | readonly element_removed: (a: number) => number; 262 | readonly element_tag_name: (a: number, b: number) => void; 263 | readonly element_set_tag_name: (a: number, b: number, c: number) => void; 264 | readonly element_namespace_uri: (a: number) => number; 265 | readonly element_attributes: (a: number) => number; 266 | readonly element_getAttribute: (a: number, b: number, c: number) => number; 267 | readonly element_hasAttribute: (a: number, b: number, c: number) => number; 268 | readonly element_setAttribute: (a: number, b: number, c: number, d: number, e: number) => void; 269 | readonly element_removeAttribute: (a: number, b: number, c: number) => void; 270 | readonly element_prepend: (a: number, b: number, c: number, d: number) => void; 271 | readonly element_append: (a: number, b: number, c: number, d: number) => void; 272 | readonly element_setInnerContent: (a: number, b: number, c: number, d: number) => void; 273 | readonly element_removeAndKeepContent: (a: number) => void; 274 | readonly element_onEndTag: (a: number, b: number) => void; 275 | readonly __wbg_textchunk_free: (a: number) => void; 276 | readonly textchunk_before: (a: number, b: number, c: number, d: number) => void; 277 | readonly textchunk_after: (a: number, b: number, c: number, d: number) => void; 278 | readonly textchunk_replace: (a: number, b: number, c: number, d: number) => void; 279 | readonly textchunk_remove: (a: number) => void; 280 | readonly textchunk_removed: (a: number) => number; 281 | readonly textchunk_text: (a: number, b: number) => void; 282 | readonly textchunk_last_in_text_node: (a: number) => number; 283 | readonly __wbg_doctype_free: (a: number) => void; 284 | readonly doctype_name: (a: number) => number; 285 | readonly doctype_public_id: (a: number) => number; 286 | readonly doctype_system_id: (a: number) => number; 287 | readonly __wbindgen_malloc: (a: number) => number; 288 | readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; 289 | readonly __wbindgen_add_to_stack_pointer: (a: number) => number; 290 | readonly __wbindgen_free: (a: number, b: number) => void; 291 | readonly __wbindgen_exn_store: (a: number) => void; 292 | } 293 | 294 | /** 295 | * If `module_or_path` is {RequestInfo} or {URL}, makes a request and 296 | * for everything else, calls `WebAssembly.instantiate` directly. 297 | * 298 | * @param {InitInput | Promise} module_or_path 299 | * 300 | * @returns {Promise} 301 | */ 302 | export default function init (module_or_path?: InitInput | Promise): Promise; 303 | -------------------------------------------------------------------------------- /dist/html_rewriter.js: -------------------------------------------------------------------------------- 1 | import { awaitPromise } from './asyncify.js'; 2 | 3 | let wasm; 4 | 5 | const heap = new Array(32).fill(undefined); 6 | 7 | heap.push(undefined, null, true, false); 8 | 9 | function getObject(idx) { return heap[idx]; } 10 | 11 | let heap_next = heap.length; 12 | 13 | function dropObject(idx) { 14 | if (idx < 36) return; 15 | heap[idx] = heap_next; 16 | heap_next = idx; 17 | } 18 | 19 | function takeObject(idx) { 20 | const ret = getObject(idx); 21 | dropObject(idx); 22 | return ret; 23 | } 24 | 25 | let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 26 | 27 | cachedTextDecoder.decode(); 28 | 29 | let cachegetUint8Memory0 = null; 30 | function getUint8Memory0() { 31 | if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { 32 | cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); 33 | } 34 | return cachegetUint8Memory0; 35 | } 36 | 37 | function getStringFromWasm0(ptr, len) { 38 | return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); 39 | } 40 | 41 | function addHeapObject(obj) { 42 | if (heap_next === heap.length) heap.push(heap.length + 1); 43 | const idx = heap_next; 44 | heap_next = heap[idx]; 45 | 46 | heap[idx] = obj; 47 | return idx; 48 | } 49 | 50 | function debugString(val) { 51 | // primitive types 52 | const type = typeof val; 53 | if (type == 'number' || type == 'boolean' || val == null) { 54 | return `${val}`; 55 | } 56 | if (type == 'string') { 57 | return `"${val}"`; 58 | } 59 | if (type == 'symbol') { 60 | const description = val.description; 61 | if (description == null) { 62 | return 'Symbol'; 63 | } else { 64 | return `Symbol(${description})`; 65 | } 66 | } 67 | if (type == 'function') { 68 | const name = val.name; 69 | if (typeof name == 'string' && name.length > 0) { 70 | return `Function(${name})`; 71 | } else { 72 | return 'Function'; 73 | } 74 | } 75 | // objects 76 | if (Array.isArray(val)) { 77 | const length = val.length; 78 | let debug = '['; 79 | if (length > 0) { 80 | debug += debugString(val[0]); 81 | } 82 | for(let i = 1; i < length; i++) { 83 | debug += ', ' + debugString(val[i]); 84 | } 85 | debug += ']'; 86 | return debug; 87 | } 88 | // Test for built-in 89 | const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); 90 | let className; 91 | if (builtInMatches.length > 1) { 92 | className = builtInMatches[1]; 93 | } else { 94 | // Failed to match the standard '[object ClassName]' 95 | return toString.call(val); 96 | } 97 | if (className == 'Object') { 98 | // we're a user defined class or Object 99 | // JSON.stringify avoids problems with cycles, and is generally much 100 | // easier than looping through ownProperties of `val`. 101 | try { 102 | return 'Object(' + JSON.stringify(val) + ')'; 103 | } catch (_) { 104 | return 'Object'; 105 | } 106 | } 107 | // errors 108 | if (val instanceof Error) { 109 | return `${val.name}: ${val.message}\n${val.stack}`; 110 | } 111 | // TODO we could test for more things here, like `Set`s and `Map`s. 112 | return className; 113 | } 114 | 115 | let WASM_VECTOR_LEN = 0; 116 | 117 | let cachedTextEncoder = new TextEncoder('utf-8'); 118 | 119 | const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' 120 | ? function (arg, view) { 121 | return cachedTextEncoder.encodeInto(arg, view); 122 | } 123 | : function (arg, view) { 124 | const buf = cachedTextEncoder.encode(arg); 125 | view.set(buf); 126 | return { 127 | read: arg.length, 128 | written: buf.length 129 | }; 130 | }); 131 | 132 | function passStringToWasm0(arg, malloc, realloc) { 133 | 134 | if (realloc === undefined) { 135 | const buf = cachedTextEncoder.encode(arg); 136 | const ptr = malloc(buf.length); 137 | getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); 138 | WASM_VECTOR_LEN = buf.length; 139 | return ptr; 140 | } 141 | 142 | let len = arg.length; 143 | let ptr = malloc(len); 144 | 145 | const mem = getUint8Memory0(); 146 | 147 | let offset = 0; 148 | 149 | for (; offset < len; offset++) { 150 | const code = arg.charCodeAt(offset); 151 | if (code > 0x7F) break; 152 | mem[ptr + offset] = code; 153 | } 154 | 155 | if (offset !== len) { 156 | if (offset !== 0) { 157 | arg = arg.slice(offset); 158 | } 159 | ptr = realloc(ptr, len, len = offset + arg.length * 3); 160 | const view = getUint8Memory0().subarray(ptr + offset, ptr + len); 161 | const ret = encodeString(arg, view); 162 | 163 | offset += ret.written; 164 | } 165 | 166 | WASM_VECTOR_LEN = offset; 167 | return ptr; 168 | } 169 | 170 | let cachegetInt32Memory0 = null; 171 | function getInt32Memory0() { 172 | if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { 173 | cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); 174 | } 175 | return cachegetInt32Memory0; 176 | } 177 | 178 | function isLikeNone(x) { 179 | return x === undefined || x === null; 180 | } 181 | 182 | let stack_pointer = 32; 183 | 184 | function addBorrowedObject(obj) { 185 | if (stack_pointer == 1) throw new Error('out of js stack'); 186 | heap[--stack_pointer] = obj; 187 | return stack_pointer; 188 | } 189 | 190 | function passArray8ToWasm0(arg, malloc) { 191 | const ptr = malloc(arg.length * 1); 192 | getUint8Memory0().set(arg, ptr / 1); 193 | WASM_VECTOR_LEN = arg.length; 194 | return ptr; 195 | } 196 | 197 | function handleError(f, args) { 198 | try { 199 | return f.apply(this, args); 200 | } catch (e) { 201 | wasm.__wbindgen_exn_store(addHeapObject(e)); 202 | } 203 | } 204 | /** 205 | */ 206 | export class Comment { 207 | 208 | static __wrap(ptr) { 209 | const obj = Object.create(Comment.prototype); 210 | obj.ptr = ptr; 211 | 212 | return obj; 213 | } 214 | 215 | __destroy_into_raw() { 216 | const ptr = this.ptr; 217 | this.ptr = 0; 218 | 219 | return ptr; 220 | } 221 | 222 | free() { 223 | const ptr = this.__destroy_into_raw(); 224 | wasm.__wbg_comment_free(ptr); 225 | } 226 | /** 227 | * @param {string} content 228 | * @param {any | undefined} content_type 229 | */ 230 | before(content, content_type) { 231 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 232 | var len0 = WASM_VECTOR_LEN; 233 | wasm.comment_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 234 | } 235 | /** 236 | * @param {string} content 237 | * @param {any | undefined} content_type 238 | */ 239 | after(content, content_type) { 240 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 241 | var len0 = WASM_VECTOR_LEN; 242 | wasm.comment_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 243 | } 244 | /** 245 | * @param {string} content 246 | * @param {any | undefined} content_type 247 | */ 248 | replace(content, content_type) { 249 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 250 | var len0 = WASM_VECTOR_LEN; 251 | wasm.comment_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 252 | } 253 | /** 254 | */ 255 | remove() { 256 | wasm.comment_remove(this.ptr); 257 | } 258 | /** 259 | * @returns {boolean} 260 | */ 261 | get removed() { 262 | var ret = wasm.comment_removed(this.ptr); 263 | return ret !== 0; 264 | } 265 | /** 266 | * @returns {string} 267 | */ 268 | get text() { 269 | try { 270 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 271 | wasm.comment_text(retptr, this.ptr); 272 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 273 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 274 | return getStringFromWasm0(r0, r1); 275 | } finally { 276 | wasm.__wbindgen_add_to_stack_pointer(16); 277 | wasm.__wbindgen_free(r0, r1); 278 | } 279 | } 280 | /** 281 | * @param {string} text 282 | */ 283 | set text(text) { 284 | var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 285 | var len0 = WASM_VECTOR_LEN; 286 | wasm.comment_set_text(this.ptr, ptr0, len0); 287 | } 288 | } 289 | /** 290 | */ 291 | export class Doctype { 292 | 293 | static __wrap(ptr) { 294 | const obj = Object.create(Doctype.prototype); 295 | obj.ptr = ptr; 296 | 297 | return obj; 298 | } 299 | 300 | __destroy_into_raw() { 301 | const ptr = this.ptr; 302 | this.ptr = 0; 303 | 304 | return ptr; 305 | } 306 | 307 | free() { 308 | const ptr = this.__destroy_into_raw(); 309 | wasm.__wbg_doctype_free(ptr); 310 | } 311 | /** 312 | * @returns {any} 313 | */ 314 | get name() { 315 | var ret = wasm.doctype_name(this.ptr); 316 | return takeObject(ret); 317 | } 318 | /** 319 | * @returns {any} 320 | */ 321 | get publicId() { 322 | var ret = wasm.doctype_public_id(this.ptr); 323 | return takeObject(ret); 324 | } 325 | /** 326 | * @returns {any} 327 | */ 328 | get systemId() { 329 | var ret = wasm.doctype_system_id(this.ptr); 330 | return takeObject(ret); 331 | } 332 | } 333 | /** 334 | */ 335 | export class DocumentEnd { 336 | 337 | static __wrap(ptr) { 338 | const obj = Object.create(DocumentEnd.prototype); 339 | obj.ptr = ptr; 340 | 341 | return obj; 342 | } 343 | 344 | __destroy_into_raw() { 345 | const ptr = this.ptr; 346 | this.ptr = 0; 347 | 348 | return ptr; 349 | } 350 | 351 | free() { 352 | const ptr = this.__destroy_into_raw(); 353 | wasm.__wbg_documentend_free(ptr); 354 | } 355 | /** 356 | * @param {string} content 357 | * @param {any | undefined} content_type 358 | */ 359 | append(content, content_type) { 360 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 361 | var len0 = WASM_VECTOR_LEN; 362 | wasm.documentend_append(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 363 | } 364 | } 365 | /** 366 | */ 367 | export class Element { 368 | 369 | static __wrap(ptr) { 370 | const obj = Object.create(Element.prototype); 371 | obj.ptr = ptr; 372 | 373 | return obj; 374 | } 375 | 376 | __destroy_into_raw() { 377 | const ptr = this.ptr; 378 | this.ptr = 0; 379 | 380 | return ptr; 381 | } 382 | 383 | free() { 384 | const ptr = this.__destroy_into_raw(); 385 | wasm.__wbg_element_free(ptr); 386 | } 387 | /** 388 | * @param {string} content 389 | * @param {any | undefined} content_type 390 | */ 391 | before(content, content_type) { 392 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 393 | var len0 = WASM_VECTOR_LEN; 394 | wasm.element_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 395 | } 396 | /** 397 | * @param {string} content 398 | * @param {any | undefined} content_type 399 | */ 400 | after(content, content_type) { 401 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 402 | var len0 = WASM_VECTOR_LEN; 403 | wasm.element_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 404 | } 405 | /** 406 | * @param {string} content 407 | * @param {any | undefined} content_type 408 | */ 409 | replace(content, content_type) { 410 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 411 | var len0 = WASM_VECTOR_LEN; 412 | wasm.element_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 413 | } 414 | /** 415 | */ 416 | remove() { 417 | wasm.element_remove(this.ptr); 418 | } 419 | /** 420 | * @returns {boolean} 421 | */ 422 | get removed() { 423 | var ret = wasm.element_removed(this.ptr); 424 | return ret !== 0; 425 | } 426 | /** 427 | * @returns {string} 428 | */ 429 | get tagName() { 430 | try { 431 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 432 | wasm.element_tag_name(retptr, this.ptr); 433 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 434 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 435 | return getStringFromWasm0(r0, r1); 436 | } finally { 437 | wasm.__wbindgen_add_to_stack_pointer(16); 438 | wasm.__wbindgen_free(r0, r1); 439 | } 440 | } 441 | /** 442 | * @param {string} name 443 | */ 444 | set tagName(name) { 445 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 446 | var len0 = WASM_VECTOR_LEN; 447 | wasm.element_set_tag_name(this.ptr, ptr0, len0); 448 | } 449 | /** 450 | * @returns {any} 451 | */ 452 | get namespaceURI() { 453 | var ret = wasm.element_namespace_uri(this.ptr); 454 | return takeObject(ret); 455 | } 456 | /** 457 | * @returns {any} 458 | */ 459 | get attributes() { 460 | var ret = wasm.element_attributes(this.ptr); 461 | return takeObject(ret); 462 | } 463 | /** 464 | * @param {string} name 465 | * @returns {any} 466 | */ 467 | getAttribute(name) { 468 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 469 | var len0 = WASM_VECTOR_LEN; 470 | var ret = wasm.element_getAttribute(this.ptr, ptr0, len0); 471 | return takeObject(ret); 472 | } 473 | /** 474 | * @param {string} name 475 | * @returns {boolean} 476 | */ 477 | hasAttribute(name) { 478 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 479 | var len0 = WASM_VECTOR_LEN; 480 | var ret = wasm.element_hasAttribute(this.ptr, ptr0, len0); 481 | return ret !== 0; 482 | } 483 | /** 484 | * @param {string} name 485 | * @param {string} value 486 | */ 487 | setAttribute(name, value) { 488 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 489 | var len0 = WASM_VECTOR_LEN; 490 | var ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 491 | var len1 = WASM_VECTOR_LEN; 492 | wasm.element_setAttribute(this.ptr, ptr0, len0, ptr1, len1); 493 | } 494 | /** 495 | * @param {string} name 496 | */ 497 | removeAttribute(name) { 498 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 499 | var len0 = WASM_VECTOR_LEN; 500 | wasm.element_removeAttribute(this.ptr, ptr0, len0); 501 | } 502 | /** 503 | * @param {string} content 504 | * @param {any | undefined} content_type 505 | */ 506 | prepend(content, content_type) { 507 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 508 | var len0 = WASM_VECTOR_LEN; 509 | wasm.element_prepend(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 510 | } 511 | /** 512 | * @param {string} content 513 | * @param {any | undefined} content_type 514 | */ 515 | append(content, content_type) { 516 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 517 | var len0 = WASM_VECTOR_LEN; 518 | wasm.element_append(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 519 | } 520 | /** 521 | * @param {string} content 522 | * @param {any | undefined} content_type 523 | */ 524 | setInnerContent(content, content_type) { 525 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 526 | var len0 = WASM_VECTOR_LEN; 527 | wasm.element_setInnerContent(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 528 | } 529 | /** 530 | */ 531 | removeAndKeepContent() { 532 | wasm.element_removeAndKeepContent(this.ptr); 533 | } 534 | /** 535 | * @param {any} handler 536 | */ 537 | onEndTag(handler) { 538 | wasm.element_onEndTag(this.ptr, addHeapObject(handler)); 539 | } 540 | } 541 | /** 542 | */ 543 | export class EndTag { 544 | 545 | static __wrap(ptr) { 546 | const obj = Object.create(EndTag.prototype); 547 | obj.ptr = ptr; 548 | 549 | return obj; 550 | } 551 | 552 | __destroy_into_raw() { 553 | const ptr = this.ptr; 554 | this.ptr = 0; 555 | 556 | return ptr; 557 | } 558 | 559 | free() { 560 | const ptr = this.__destroy_into_raw(); 561 | wasm.__wbg_endtag_free(ptr); 562 | } 563 | /** 564 | * @returns {string} 565 | */ 566 | get name() { 567 | try { 568 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 569 | wasm.endtag_name(retptr, this.ptr); 570 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 571 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 572 | return getStringFromWasm0(r0, r1); 573 | } finally { 574 | wasm.__wbindgen_add_to_stack_pointer(16); 575 | wasm.__wbindgen_free(r0, r1); 576 | } 577 | } 578 | /** 579 | * @param {string} name 580 | */ 581 | set name(name) { 582 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 583 | var len0 = WASM_VECTOR_LEN; 584 | wasm.endtag_set_name(this.ptr, ptr0, len0); 585 | } 586 | /** 587 | * @param {string} content 588 | * @param {any | undefined} content_type 589 | */ 590 | before(content, content_type) { 591 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 592 | var len0 = WASM_VECTOR_LEN; 593 | wasm.endtag_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 594 | } 595 | /** 596 | * @param {string} content 597 | * @param {any | undefined} content_type 598 | */ 599 | after(content, content_type) { 600 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 601 | var len0 = WASM_VECTOR_LEN; 602 | wasm.endtag_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 603 | } 604 | /** 605 | */ 606 | remove() { 607 | wasm.endtag_remove(this.ptr); 608 | } 609 | } 610 | /** 611 | */ 612 | export class HTMLRewriter { 613 | 614 | static __wrap(ptr) { 615 | const obj = Object.create(HTMLRewriter.prototype); 616 | obj.ptr = ptr; 617 | 618 | return obj; 619 | } 620 | 621 | __destroy_into_raw() { 622 | const ptr = this.ptr; 623 | this.ptr = 0; 624 | 625 | return ptr; 626 | } 627 | 628 | free() { 629 | const ptr = this.__destroy_into_raw(); 630 | wasm.__wbg_htmlrewriter_free(ptr); 631 | } 632 | /** 633 | * @param {any} output_sink 634 | * @param {any | undefined} options 635 | */ 636 | constructor(output_sink, options) { 637 | try { 638 | var ret = wasm.htmlrewriter_new(addBorrowedObject(output_sink), isLikeNone(options) ? 0 : addHeapObject(options)); 639 | return HTMLRewriter.__wrap(ret); 640 | } finally { 641 | heap[stack_pointer++] = undefined; 642 | } 643 | } 644 | /** 645 | * @param {string} selector 646 | * @param {any} handlers 647 | */ 648 | on(selector, handlers) { 649 | var ptr0 = passStringToWasm0(selector, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 650 | var len0 = WASM_VECTOR_LEN; 651 | wasm.htmlrewriter_on(this.ptr, ptr0, len0, addHeapObject(handlers)); 652 | } 653 | /** 654 | * @param {any} handlers 655 | */ 656 | onDocument(handlers) { 657 | wasm.htmlrewriter_onDocument(this.ptr, addHeapObject(handlers)); 658 | } 659 | /** 660 | * @param {Uint8Array} chunk 661 | */ 662 | write(chunk) { 663 | var ptr0 = passArray8ToWasm0(chunk, wasm.__wbindgen_malloc); 664 | var len0 = WASM_VECTOR_LEN; 665 | wasm.htmlrewriter_write(this.ptr, ptr0, len0); 666 | } 667 | /** 668 | */ 669 | end() { 670 | wasm.htmlrewriter_end(this.ptr); 671 | } 672 | /** 673 | * @returns {number} 674 | */ 675 | get asyncifyStackPtr() { 676 | var ret = wasm.htmlrewriter_asyncify_stack_ptr(this.ptr); 677 | return ret; 678 | } 679 | } 680 | /** 681 | */ 682 | export class TextChunk { 683 | 684 | static __wrap(ptr) { 685 | const obj = Object.create(TextChunk.prototype); 686 | obj.ptr = ptr; 687 | 688 | return obj; 689 | } 690 | 691 | __destroy_into_raw() { 692 | const ptr = this.ptr; 693 | this.ptr = 0; 694 | 695 | return ptr; 696 | } 697 | 698 | free() { 699 | const ptr = this.__destroy_into_raw(); 700 | wasm.__wbg_textchunk_free(ptr); 701 | } 702 | /** 703 | * @param {string} content 704 | * @param {any | undefined} content_type 705 | */ 706 | before(content, content_type) { 707 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 708 | var len0 = WASM_VECTOR_LEN; 709 | wasm.textchunk_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 710 | } 711 | /** 712 | * @param {string} content 713 | * @param {any | undefined} content_type 714 | */ 715 | after(content, content_type) { 716 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 717 | var len0 = WASM_VECTOR_LEN; 718 | wasm.textchunk_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 719 | } 720 | /** 721 | * @param {string} content 722 | * @param {any | undefined} content_type 723 | */ 724 | replace(content, content_type) { 725 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 726 | var len0 = WASM_VECTOR_LEN; 727 | wasm.textchunk_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 728 | } 729 | /** 730 | */ 731 | remove() { 732 | wasm.textchunk_remove(this.ptr); 733 | } 734 | /** 735 | * @returns {boolean} 736 | */ 737 | get removed() { 738 | var ret = wasm.textchunk_removed(this.ptr); 739 | return ret !== 0; 740 | } 741 | /** 742 | * @returns {string} 743 | */ 744 | get text() { 745 | try { 746 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 747 | wasm.textchunk_text(retptr, this.ptr); 748 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 749 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 750 | return getStringFromWasm0(r0, r1); 751 | } finally { 752 | wasm.__wbindgen_add_to_stack_pointer(16); 753 | wasm.__wbindgen_free(r0, r1); 754 | } 755 | } 756 | /** 757 | * @returns {boolean} 758 | */ 759 | get lastInTextNode() { 760 | var ret = wasm.textchunk_last_in_text_node(this.ptr); 761 | return ret !== 0; 762 | } 763 | } 764 | 765 | async function load(module, imports) { 766 | if (typeof Response === 'function' && module instanceof Response) { 767 | if (typeof WebAssembly.instantiateStreaming === 'function') { 768 | try { 769 | return await WebAssembly.instantiateStreaming(module, imports); 770 | 771 | } catch (e) { 772 | if (module.headers.get('Content-Type') != 'application/wasm') { 773 | console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); 774 | 775 | } else { 776 | throw e; 777 | } 778 | } 779 | } 780 | 781 | const bytes = await module.arrayBuffer(); 782 | return await WebAssembly.instantiate(bytes, imports); 783 | 784 | } else { 785 | const instance = await WebAssembly.instantiate(module, imports); 786 | 787 | if (instance instanceof WebAssembly.Instance) { 788 | return { instance, module }; 789 | 790 | } else { 791 | return instance; 792 | } 793 | } 794 | } 795 | 796 | async function init(input) { 797 | if (typeof input === 'undefined') { 798 | input = new URL('html_rewriter_bg.wasm', import.meta.url); 799 | } 800 | const imports = {}; 801 | imports.wbg = {}; 802 | imports.wbg.__wbindgen_object_drop_ref = function(arg0) { 803 | takeObject(arg0); 804 | }; 805 | imports.wbg.__wbg_html_cd9a0f328493678b = function(arg0) { 806 | var ret = getObject(arg0).html; 807 | return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; 808 | }; 809 | imports.wbg.__wbg_documentend_new = function(arg0) { 810 | var ret = DocumentEnd.__wrap(arg0); 811 | return addHeapObject(ret); 812 | }; 813 | imports.wbg.__wbg_awaitPromise_39a1101fd8518869 = function(arg0, arg1) { 814 | awaitPromise(arg0, getObject(arg1)); 815 | }; 816 | imports.wbg.__wbindgen_string_new = function(arg0, arg1) { 817 | var ret = getStringFromWasm0(arg0, arg1); 818 | return addHeapObject(ret); 819 | }; 820 | imports.wbg.__wbindgen_object_clone_ref = function(arg0) { 821 | var ret = getObject(arg0); 822 | return addHeapObject(ret); 823 | }; 824 | imports.wbg.__wbg_element_c38470ed972aea27 = function(arg0) { 825 | var ret = getObject(arg0).element; 826 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 827 | }; 828 | imports.wbg.__wbg_comments_ba86bc03331d9378 = function(arg0) { 829 | var ret = getObject(arg0).comments; 830 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 831 | }; 832 | imports.wbg.__wbg_text_7800bf26cb443911 = function(arg0) { 833 | var ret = getObject(arg0).text; 834 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 835 | }; 836 | imports.wbg.__wbg_doctype_ac58c0964a59b61b = function(arg0) { 837 | var ret = getObject(arg0).doctype; 838 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 839 | }; 840 | imports.wbg.__wbg_comments_94d876f6c0502e82 = function(arg0) { 841 | var ret = getObject(arg0).comments; 842 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 843 | }; 844 | imports.wbg.__wbg_text_4606a16c30e4ae91 = function(arg0) { 845 | var ret = getObject(arg0).text; 846 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 847 | }; 848 | imports.wbg.__wbg_end_34efb9402eac8a4e = function(arg0) { 849 | var ret = getObject(arg0).end; 850 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 851 | }; 852 | imports.wbg.__wbg_element_new = function(arg0) { 853 | var ret = Element.__wrap(arg0); 854 | return addHeapObject(ret); 855 | }; 856 | imports.wbg.__wbg_comment_new = function(arg0) { 857 | var ret = Comment.__wrap(arg0); 858 | return addHeapObject(ret); 859 | }; 860 | imports.wbg.__wbg_textchunk_new = function(arg0) { 861 | var ret = TextChunk.__wrap(arg0); 862 | return addHeapObject(ret); 863 | }; 864 | imports.wbg.__wbg_doctype_new = function(arg0) { 865 | var ret = Doctype.__wrap(arg0); 866 | return addHeapObject(ret); 867 | }; 868 | imports.wbg.__wbg_enableEsiTags_de6b91cc61a25874 = function(arg0) { 869 | var ret = getObject(arg0).enableEsiTags; 870 | return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; 871 | }; 872 | imports.wbg.__wbg_endtag_new = function(arg0) { 873 | var ret = EndTag.__wrap(arg0); 874 | return addHeapObject(ret); 875 | }; 876 | imports.wbg.__wbg_String_60c4ba333b5ca1c6 = function(arg0, arg1) { 877 | var ret = String(getObject(arg1)); 878 | var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 879 | var len0 = WASM_VECTOR_LEN; 880 | getInt32Memory0()[arg0 / 4 + 1] = len0; 881 | getInt32Memory0()[arg0 / 4 + 0] = ptr0; 882 | }; 883 | imports.wbg.__wbg_new_4fee7e2900033464 = function() { 884 | var ret = new Array(); 885 | return addHeapObject(ret); 886 | }; 887 | imports.wbg.__wbg_push_ba9b5e3c25cff8f9 = function(arg0, arg1) { 888 | var ret = getObject(arg0).push(getObject(arg1)); 889 | return ret; 890 | }; 891 | imports.wbg.__wbg_call_6c4ea719458624eb = function() { return handleError(function (arg0, arg1, arg2) { 892 | var ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); 893 | return addHeapObject(ret); 894 | }, arguments) }; 895 | imports.wbg.__wbg_new_917809a3e20a4b00 = function(arg0, arg1) { 896 | var ret = new TypeError(getStringFromWasm0(arg0, arg1)); 897 | return addHeapObject(ret); 898 | }; 899 | imports.wbg.__wbg_instanceof_Promise_c6535fc791fcc4d2 = function(arg0) { 900 | var ret = getObject(arg0) instanceof Promise; 901 | return ret; 902 | }; 903 | imports.wbg.__wbg_buffer_89a8560ab6a3d9c6 = function(arg0) { 904 | var ret = getObject(arg0).buffer; 905 | return addHeapObject(ret); 906 | }; 907 | imports.wbg.__wbg_newwithbyteoffsetandlength_e45d8b33c02dc3b5 = function(arg0, arg1, arg2) { 908 | var ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); 909 | return addHeapObject(ret); 910 | }; 911 | imports.wbg.__wbg_new_bd2e1d010adb8a1a = function(arg0) { 912 | var ret = new Uint8Array(getObject(arg0)); 913 | return addHeapObject(ret); 914 | }; 915 | imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { 916 | var ret = debugString(getObject(arg1)); 917 | var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 918 | var len0 = WASM_VECTOR_LEN; 919 | getInt32Memory0()[arg0 / 4 + 1] = len0; 920 | getInt32Memory0()[arg0 / 4 + 0] = ptr0; 921 | }; 922 | imports.wbg.__wbindgen_throw = function(arg0, arg1) { 923 | throw new Error(getStringFromWasm0(arg0, arg1)); 924 | }; 925 | imports.wbg.__wbindgen_rethrow = function(arg0) { 926 | throw takeObject(arg0); 927 | }; 928 | imports.wbg.__wbindgen_memory = function() { 929 | var ret = wasm.memory; 930 | return addHeapObject(ret); 931 | }; 932 | 933 | if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { 934 | input = fetch(input); 935 | } 936 | 937 | 938 | 939 | const { instance, module } = await load(await input, imports); 940 | 941 | wasm = instance.exports; 942 | init.__wbindgen_wasm_module = module; 943 | 944 | return wasm; 945 | } 946 | 947 | export default init; 948 | 949 | -------------------------------------------------------------------------------- /dist/html_rewriter_bg.js: -------------------------------------------------------------------------------- 1 | import { awaitPromise } from './asyncify.js'; 2 | import * as wasm from './html_rewriter_bg.wasm'; 3 | 4 | const heap = new Array(32).fill(undefined); 5 | 6 | heap.push(undefined, null, true, false); 7 | 8 | function getObject(idx) { return heap[idx]; } 9 | 10 | let heap_next = heap.length; 11 | 12 | function dropObject(idx) { 13 | if (idx < 36) return; 14 | heap[idx] = heap_next; 15 | heap_next = idx; 16 | } 17 | 18 | function takeObject(idx) { 19 | const ret = getObject(idx); 20 | dropObject(idx); 21 | return ret; 22 | } 23 | 24 | const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; 25 | 26 | let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 27 | 28 | cachedTextDecoder.decode(); 29 | 30 | let cachegetUint8Memory0 = null; 31 | function getUint8Memory0() { 32 | if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { 33 | cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); 34 | } 35 | return cachegetUint8Memory0; 36 | } 37 | 38 | function getStringFromWasm0(ptr, len) { 39 | return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); 40 | } 41 | 42 | function addHeapObject(obj) { 43 | if (heap_next === heap.length) heap.push(heap.length + 1); 44 | const idx = heap_next; 45 | heap_next = heap[idx]; 46 | 47 | heap[idx] = obj; 48 | return idx; 49 | } 50 | 51 | function debugString(val) { 52 | // primitive types 53 | const type = typeof val; 54 | if (type == 'number' || type == 'boolean' || val == null) { 55 | return `${val}`; 56 | } 57 | if (type == 'string') { 58 | return `"${val}"`; 59 | } 60 | if (type == 'symbol') { 61 | const description = val.description; 62 | if (description == null) { 63 | return 'Symbol'; 64 | } else { 65 | return `Symbol(${description})`; 66 | } 67 | } 68 | if (type == 'function') { 69 | const name = val.name; 70 | if (typeof name == 'string' && name.length > 0) { 71 | return `Function(${name})`; 72 | } else { 73 | return 'Function'; 74 | } 75 | } 76 | // objects 77 | if (Array.isArray(val)) { 78 | const length = val.length; 79 | let debug = '['; 80 | if (length > 0) { 81 | debug += debugString(val[0]); 82 | } 83 | for(let i = 1; i < length; i++) { 84 | debug += ', ' + debugString(val[i]); 85 | } 86 | debug += ']'; 87 | return debug; 88 | } 89 | // Test for built-in 90 | const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); 91 | let className; 92 | if (builtInMatches.length > 1) { 93 | className = builtInMatches[1]; 94 | } else { 95 | // Failed to match the standard '[object ClassName]' 96 | return toString.call(val); 97 | } 98 | if (className == 'Object') { 99 | // we're a user defined class or Object 100 | // JSON.stringify avoids problems with cycles, and is generally much 101 | // easier than looping through ownProperties of `val`. 102 | try { 103 | return 'Object(' + JSON.stringify(val) + ')'; 104 | } catch (_) { 105 | return 'Object'; 106 | } 107 | } 108 | // errors 109 | if (val instanceof Error) { 110 | return `${val.name}: ${val.message}\n${val.stack}`; 111 | } 112 | // TODO we could test for more things here, like `Set`s and `Map`s. 113 | return className; 114 | } 115 | 116 | let WASM_VECTOR_LEN = 0; 117 | 118 | const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; 119 | 120 | let cachedTextEncoder = new lTextEncoder('utf-8'); 121 | 122 | const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' 123 | ? function (arg, view) { 124 | return cachedTextEncoder.encodeInto(arg, view); 125 | } 126 | : function (arg, view) { 127 | const buf = cachedTextEncoder.encode(arg); 128 | view.set(buf); 129 | return { 130 | read: arg.length, 131 | written: buf.length 132 | }; 133 | }); 134 | 135 | function passStringToWasm0(arg, malloc, realloc) { 136 | 137 | if (realloc === undefined) { 138 | const buf = cachedTextEncoder.encode(arg); 139 | const ptr = malloc(buf.length); 140 | getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); 141 | WASM_VECTOR_LEN = buf.length; 142 | return ptr; 143 | } 144 | 145 | let len = arg.length; 146 | let ptr = malloc(len); 147 | 148 | const mem = getUint8Memory0(); 149 | 150 | let offset = 0; 151 | 152 | for (; offset < len; offset++) { 153 | const code = arg.charCodeAt(offset); 154 | if (code > 0x7F) break; 155 | mem[ptr + offset] = code; 156 | } 157 | 158 | if (offset !== len) { 159 | if (offset !== 0) { 160 | arg = arg.slice(offset); 161 | } 162 | ptr = realloc(ptr, len, len = offset + arg.length * 3); 163 | const view = getUint8Memory0().subarray(ptr + offset, ptr + len); 164 | const ret = encodeString(arg, view); 165 | 166 | offset += ret.written; 167 | } 168 | 169 | WASM_VECTOR_LEN = offset; 170 | return ptr; 171 | } 172 | 173 | let cachegetInt32Memory0 = null; 174 | function getInt32Memory0() { 175 | if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { 176 | cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); 177 | } 178 | return cachegetInt32Memory0; 179 | } 180 | 181 | function isLikeNone(x) { 182 | return x === undefined || x === null; 183 | } 184 | 185 | let stack_pointer = 32; 186 | 187 | function addBorrowedObject(obj) { 188 | if (stack_pointer == 1) throw new Error('out of js stack'); 189 | heap[--stack_pointer] = obj; 190 | return stack_pointer; 191 | } 192 | 193 | function passArray8ToWasm0(arg, malloc) { 194 | const ptr = malloc(arg.length * 1); 195 | getUint8Memory0().set(arg, ptr / 1); 196 | WASM_VECTOR_LEN = arg.length; 197 | return ptr; 198 | } 199 | 200 | function handleError(f, args) { 201 | try { 202 | return f.apply(this, args); 203 | } catch (e) { 204 | wasm.__wbindgen_exn_store(addHeapObject(e)); 205 | } 206 | } 207 | /** 208 | */ 209 | export class Comment { 210 | 211 | static __wrap(ptr) { 212 | const obj = Object.create(Comment.prototype); 213 | obj.ptr = ptr; 214 | 215 | return obj; 216 | } 217 | 218 | __destroy_into_raw() { 219 | const ptr = this.ptr; 220 | this.ptr = 0; 221 | 222 | return ptr; 223 | } 224 | 225 | free() { 226 | const ptr = this.__destroy_into_raw(); 227 | wasm.__wbg_comment_free(ptr); 228 | } 229 | /** 230 | * @param {string} content 231 | * @param {any | undefined} content_type 232 | */ 233 | before(content, content_type) { 234 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 235 | var len0 = WASM_VECTOR_LEN; 236 | wasm.comment_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 237 | } 238 | /** 239 | * @param {string} content 240 | * @param {any | undefined} content_type 241 | */ 242 | after(content, content_type) { 243 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 244 | var len0 = WASM_VECTOR_LEN; 245 | wasm.comment_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 246 | } 247 | /** 248 | * @param {string} content 249 | * @param {any | undefined} content_type 250 | */ 251 | replace(content, content_type) { 252 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 253 | var len0 = WASM_VECTOR_LEN; 254 | wasm.comment_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 255 | } 256 | /** 257 | */ 258 | remove() { 259 | wasm.comment_remove(this.ptr); 260 | } 261 | /** 262 | * @returns {boolean} 263 | */ 264 | get removed() { 265 | var ret = wasm.comment_removed(this.ptr); 266 | return ret !== 0; 267 | } 268 | /** 269 | * @returns {string} 270 | */ 271 | get text() { 272 | try { 273 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 274 | wasm.comment_text(retptr, this.ptr); 275 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 276 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 277 | return getStringFromWasm0(r0, r1); 278 | } finally { 279 | wasm.__wbindgen_add_to_stack_pointer(16); 280 | wasm.__wbindgen_free(r0, r1); 281 | } 282 | } 283 | /** 284 | * @param {string} text 285 | */ 286 | set text(text) { 287 | var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 288 | var len0 = WASM_VECTOR_LEN; 289 | wasm.comment_set_text(this.ptr, ptr0, len0); 290 | } 291 | } 292 | /** 293 | */ 294 | export class Doctype { 295 | 296 | static __wrap(ptr) { 297 | const obj = Object.create(Doctype.prototype); 298 | obj.ptr = ptr; 299 | 300 | return obj; 301 | } 302 | 303 | __destroy_into_raw() { 304 | const ptr = this.ptr; 305 | this.ptr = 0; 306 | 307 | return ptr; 308 | } 309 | 310 | free() { 311 | const ptr = this.__destroy_into_raw(); 312 | wasm.__wbg_doctype_free(ptr); 313 | } 314 | /** 315 | * @returns {any} 316 | */ 317 | get name() { 318 | var ret = wasm.doctype_name(this.ptr); 319 | return takeObject(ret); 320 | } 321 | /** 322 | * @returns {any} 323 | */ 324 | get publicId() { 325 | var ret = wasm.doctype_public_id(this.ptr); 326 | return takeObject(ret); 327 | } 328 | /** 329 | * @returns {any} 330 | */ 331 | get systemId() { 332 | var ret = wasm.doctype_system_id(this.ptr); 333 | return takeObject(ret); 334 | } 335 | } 336 | /** 337 | */ 338 | export class DocumentEnd { 339 | 340 | static __wrap(ptr) { 341 | const obj = Object.create(DocumentEnd.prototype); 342 | obj.ptr = ptr; 343 | 344 | return obj; 345 | } 346 | 347 | __destroy_into_raw() { 348 | const ptr = this.ptr; 349 | this.ptr = 0; 350 | 351 | return ptr; 352 | } 353 | 354 | free() { 355 | const ptr = this.__destroy_into_raw(); 356 | wasm.__wbg_documentend_free(ptr); 357 | } 358 | /** 359 | * @param {string} content 360 | * @param {any | undefined} content_type 361 | */ 362 | append(content, content_type) { 363 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 364 | var len0 = WASM_VECTOR_LEN; 365 | wasm.documentend_append(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 366 | } 367 | } 368 | /** 369 | */ 370 | export class Element { 371 | 372 | static __wrap(ptr) { 373 | const obj = Object.create(Element.prototype); 374 | obj.ptr = ptr; 375 | 376 | return obj; 377 | } 378 | 379 | __destroy_into_raw() { 380 | const ptr = this.ptr; 381 | this.ptr = 0; 382 | 383 | return ptr; 384 | } 385 | 386 | free() { 387 | const ptr = this.__destroy_into_raw(); 388 | wasm.__wbg_element_free(ptr); 389 | } 390 | /** 391 | * @param {string} content 392 | * @param {any | undefined} content_type 393 | */ 394 | before(content, content_type) { 395 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 396 | var len0 = WASM_VECTOR_LEN; 397 | wasm.element_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 398 | } 399 | /** 400 | * @param {string} content 401 | * @param {any | undefined} content_type 402 | */ 403 | after(content, content_type) { 404 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 405 | var len0 = WASM_VECTOR_LEN; 406 | wasm.element_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 407 | } 408 | /** 409 | * @param {string} content 410 | * @param {any | undefined} content_type 411 | */ 412 | replace(content, content_type) { 413 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 414 | var len0 = WASM_VECTOR_LEN; 415 | wasm.element_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 416 | } 417 | /** 418 | */ 419 | remove() { 420 | wasm.element_remove(this.ptr); 421 | } 422 | /** 423 | * @returns {boolean} 424 | */ 425 | get removed() { 426 | var ret = wasm.element_removed(this.ptr); 427 | return ret !== 0; 428 | } 429 | /** 430 | * @returns {string} 431 | */ 432 | get tagName() { 433 | try { 434 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 435 | wasm.element_tag_name(retptr, this.ptr); 436 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 437 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 438 | return getStringFromWasm0(r0, r1); 439 | } finally { 440 | wasm.__wbindgen_add_to_stack_pointer(16); 441 | wasm.__wbindgen_free(r0, r1); 442 | } 443 | } 444 | /** 445 | * @param {string} name 446 | */ 447 | set tagName(name) { 448 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 449 | var len0 = WASM_VECTOR_LEN; 450 | wasm.element_set_tag_name(this.ptr, ptr0, len0); 451 | } 452 | /** 453 | * @returns {any} 454 | */ 455 | get namespaceURI() { 456 | var ret = wasm.element_namespace_uri(this.ptr); 457 | return takeObject(ret); 458 | } 459 | /** 460 | * @returns {any} 461 | */ 462 | get attributes() { 463 | var ret = wasm.element_attributes(this.ptr); 464 | return takeObject(ret); 465 | } 466 | /** 467 | * @param {string} name 468 | * @returns {any} 469 | */ 470 | getAttribute(name) { 471 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 472 | var len0 = WASM_VECTOR_LEN; 473 | var ret = wasm.element_getAttribute(this.ptr, ptr0, len0); 474 | return takeObject(ret); 475 | } 476 | /** 477 | * @param {string} name 478 | * @returns {boolean} 479 | */ 480 | hasAttribute(name) { 481 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 482 | var len0 = WASM_VECTOR_LEN; 483 | var ret = wasm.element_hasAttribute(this.ptr, ptr0, len0); 484 | return ret !== 0; 485 | } 486 | /** 487 | * @param {string} name 488 | * @param {string} value 489 | */ 490 | setAttribute(name, value) { 491 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 492 | var len0 = WASM_VECTOR_LEN; 493 | var ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 494 | var len1 = WASM_VECTOR_LEN; 495 | wasm.element_setAttribute(this.ptr, ptr0, len0, ptr1, len1); 496 | } 497 | /** 498 | * @param {string} name 499 | */ 500 | removeAttribute(name) { 501 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 502 | var len0 = WASM_VECTOR_LEN; 503 | wasm.element_removeAttribute(this.ptr, ptr0, len0); 504 | } 505 | /** 506 | * @param {string} content 507 | * @param {any | undefined} content_type 508 | */ 509 | prepend(content, content_type) { 510 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 511 | var len0 = WASM_VECTOR_LEN; 512 | wasm.element_prepend(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 513 | } 514 | /** 515 | * @param {string} content 516 | * @param {any | undefined} content_type 517 | */ 518 | append(content, content_type) { 519 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 520 | var len0 = WASM_VECTOR_LEN; 521 | wasm.element_append(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 522 | } 523 | /** 524 | * @param {string} content 525 | * @param {any | undefined} content_type 526 | */ 527 | setInnerContent(content, content_type) { 528 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 529 | var len0 = WASM_VECTOR_LEN; 530 | wasm.element_setInnerContent(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 531 | } 532 | /** 533 | */ 534 | removeAndKeepContent() { 535 | wasm.element_removeAndKeepContent(this.ptr); 536 | } 537 | /** 538 | * @param {any} handler 539 | */ 540 | onEndTag(handler) { 541 | wasm.element_onEndTag(this.ptr, addHeapObject(handler)); 542 | } 543 | } 544 | /** 545 | */ 546 | export class EndTag { 547 | 548 | static __wrap(ptr) { 549 | const obj = Object.create(EndTag.prototype); 550 | obj.ptr = ptr; 551 | 552 | return obj; 553 | } 554 | 555 | __destroy_into_raw() { 556 | const ptr = this.ptr; 557 | this.ptr = 0; 558 | 559 | return ptr; 560 | } 561 | 562 | free() { 563 | const ptr = this.__destroy_into_raw(); 564 | wasm.__wbg_endtag_free(ptr); 565 | } 566 | /** 567 | * @returns {string} 568 | */ 569 | get name() { 570 | try { 571 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 572 | wasm.endtag_name(retptr, this.ptr); 573 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 574 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 575 | return getStringFromWasm0(r0, r1); 576 | } finally { 577 | wasm.__wbindgen_add_to_stack_pointer(16); 578 | wasm.__wbindgen_free(r0, r1); 579 | } 580 | } 581 | /** 582 | * @param {string} name 583 | */ 584 | set name(name) { 585 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 586 | var len0 = WASM_VECTOR_LEN; 587 | wasm.endtag_set_name(this.ptr, ptr0, len0); 588 | } 589 | /** 590 | * @param {string} content 591 | * @param {any | undefined} content_type 592 | */ 593 | before(content, content_type) { 594 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 595 | var len0 = WASM_VECTOR_LEN; 596 | wasm.endtag_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 597 | } 598 | /** 599 | * @param {string} content 600 | * @param {any | undefined} content_type 601 | */ 602 | after(content, content_type) { 603 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 604 | var len0 = WASM_VECTOR_LEN; 605 | wasm.endtag_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 606 | } 607 | /** 608 | */ 609 | remove() { 610 | wasm.endtag_remove(this.ptr); 611 | } 612 | } 613 | /** 614 | */ 615 | export class HTMLRewriter { 616 | 617 | static __wrap(ptr) { 618 | const obj = Object.create(HTMLRewriter.prototype); 619 | obj.ptr = ptr; 620 | 621 | return obj; 622 | } 623 | 624 | __destroy_into_raw() { 625 | const ptr = this.ptr; 626 | this.ptr = 0; 627 | 628 | return ptr; 629 | } 630 | 631 | free() { 632 | const ptr = this.__destroy_into_raw(); 633 | wasm.__wbg_htmlrewriter_free(ptr); 634 | } 635 | /** 636 | * @param {any} output_sink 637 | * @param {any | undefined} options 638 | */ 639 | constructor(output_sink, options) { 640 | try { 641 | var ret = wasm.htmlrewriter_new(addBorrowedObject(output_sink), isLikeNone(options) ? 0 : addHeapObject(options)); 642 | return HTMLRewriter.__wrap(ret); 643 | } finally { 644 | heap[stack_pointer++] = undefined; 645 | } 646 | } 647 | /** 648 | * @param {string} selector 649 | * @param {any} handlers 650 | */ 651 | on(selector, handlers) { 652 | var ptr0 = passStringToWasm0(selector, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 653 | var len0 = WASM_VECTOR_LEN; 654 | wasm.htmlrewriter_on(this.ptr, ptr0, len0, addHeapObject(handlers)); 655 | } 656 | /** 657 | * @param {any} handlers 658 | */ 659 | onDocument(handlers) { 660 | wasm.htmlrewriter_onDocument(this.ptr, addHeapObject(handlers)); 661 | } 662 | /** 663 | * @param {Uint8Array} chunk 664 | */ 665 | write(chunk) { 666 | var ptr0 = passArray8ToWasm0(chunk, wasm.__wbindgen_malloc); 667 | var len0 = WASM_VECTOR_LEN; 668 | wasm.htmlrewriter_write(this.ptr, ptr0, len0); 669 | } 670 | /** 671 | */ 672 | end() { 673 | wasm.htmlrewriter_end(this.ptr); 674 | } 675 | /** 676 | * @returns {number} 677 | */ 678 | get asyncifyStackPtr() { 679 | var ret = wasm.htmlrewriter_asyncify_stack_ptr(this.ptr); 680 | return ret; 681 | } 682 | } 683 | /** 684 | */ 685 | export class TextChunk { 686 | 687 | static __wrap(ptr) { 688 | const obj = Object.create(TextChunk.prototype); 689 | obj.ptr = ptr; 690 | 691 | return obj; 692 | } 693 | 694 | __destroy_into_raw() { 695 | const ptr = this.ptr; 696 | this.ptr = 0; 697 | 698 | return ptr; 699 | } 700 | 701 | free() { 702 | const ptr = this.__destroy_into_raw(); 703 | wasm.__wbg_textchunk_free(ptr); 704 | } 705 | /** 706 | * @param {string} content 707 | * @param {any | undefined} content_type 708 | */ 709 | before(content, content_type) { 710 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 711 | var len0 = WASM_VECTOR_LEN; 712 | wasm.textchunk_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 713 | } 714 | /** 715 | * @param {string} content 716 | * @param {any | undefined} content_type 717 | */ 718 | after(content, content_type) { 719 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 720 | var len0 = WASM_VECTOR_LEN; 721 | wasm.textchunk_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 722 | } 723 | /** 724 | * @param {string} content 725 | * @param {any | undefined} content_type 726 | */ 727 | replace(content, content_type) { 728 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 729 | var len0 = WASM_VECTOR_LEN; 730 | wasm.textchunk_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type)); 731 | } 732 | /** 733 | */ 734 | remove() { 735 | wasm.textchunk_remove(this.ptr); 736 | } 737 | /** 738 | * @returns {boolean} 739 | */ 740 | get removed() { 741 | var ret = wasm.textchunk_removed(this.ptr); 742 | return ret !== 0; 743 | } 744 | /** 745 | * @returns {string} 746 | */ 747 | get text() { 748 | try { 749 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); 750 | wasm.textchunk_text(retptr, this.ptr); 751 | var r0 = getInt32Memory0()[retptr / 4 + 0]; 752 | var r1 = getInt32Memory0()[retptr / 4 + 1]; 753 | return getStringFromWasm0(r0, r1); 754 | } finally { 755 | wasm.__wbindgen_add_to_stack_pointer(16); 756 | wasm.__wbindgen_free(r0, r1); 757 | } 758 | } 759 | /** 760 | * @returns {boolean} 761 | */ 762 | get lastInTextNode() { 763 | var ret = wasm.textchunk_last_in_text_node(this.ptr); 764 | return ret !== 0; 765 | } 766 | } 767 | 768 | export function __wbindgen_object_drop_ref(arg0) { 769 | takeObject(arg0); 770 | }; 771 | 772 | export function __wbg_comment_new(arg0) { 773 | var ret = Comment.__wrap(arg0); 774 | return addHeapObject(ret); 775 | }; 776 | 777 | export function __wbg_doctype_new(arg0) { 778 | var ret = Doctype.__wrap(arg0); 779 | return addHeapObject(ret); 780 | }; 781 | 782 | export function __wbg_documentend_new(arg0) { 783 | var ret = DocumentEnd.__wrap(arg0); 784 | return addHeapObject(ret); 785 | }; 786 | 787 | export function __wbg_element_new(arg0) { 788 | var ret = Element.__wrap(arg0); 789 | return addHeapObject(ret); 790 | }; 791 | 792 | export function __wbg_endtag_new(arg0) { 793 | var ret = EndTag.__wrap(arg0); 794 | return addHeapObject(ret); 795 | }; 796 | 797 | export function __wbg_textchunk_new(arg0) { 798 | var ret = TextChunk.__wrap(arg0); 799 | return addHeapObject(ret); 800 | }; 801 | 802 | export function __wbg_html_cd9a0f328493678b(arg0) { 803 | var ret = getObject(arg0).html; 804 | return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; 805 | }; 806 | 807 | export function __wbindgen_string_new(arg0, arg1) { 808 | var ret = getStringFromWasm0(arg0, arg1); 809 | return addHeapObject(ret); 810 | }; 811 | 812 | export function __wbg_awaitPromise_39a1101fd8518869(arg0, arg1) { 813 | awaitPromise(arg0, getObject(arg1)); 814 | }; 815 | 816 | export function __wbindgen_object_clone_ref(arg0) { 817 | var ret = getObject(arg0); 818 | return addHeapObject(ret); 819 | }; 820 | 821 | export function __wbg_element_c38470ed972aea27(arg0) { 822 | var ret = getObject(arg0).element; 823 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 824 | }; 825 | 826 | export function __wbg_comments_ba86bc03331d9378(arg0) { 827 | var ret = getObject(arg0).comments; 828 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 829 | }; 830 | 831 | export function __wbg_text_7800bf26cb443911(arg0) { 832 | var ret = getObject(arg0).text; 833 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 834 | }; 835 | 836 | export function __wbg_doctype_ac58c0964a59b61b(arg0) { 837 | var ret = getObject(arg0).doctype; 838 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 839 | }; 840 | 841 | export function __wbg_comments_94d876f6c0502e82(arg0) { 842 | var ret = getObject(arg0).comments; 843 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 844 | }; 845 | 846 | export function __wbg_text_4606a16c30e4ae91(arg0) { 847 | var ret = getObject(arg0).text; 848 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 849 | }; 850 | 851 | export function __wbg_end_34efb9402eac8a4e(arg0) { 852 | var ret = getObject(arg0).end; 853 | return isLikeNone(ret) ? 0 : addHeapObject(ret); 854 | }; 855 | 856 | export function __wbg_enableEsiTags_de6b91cc61a25874(arg0) { 857 | var ret = getObject(arg0).enableEsiTags; 858 | return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; 859 | }; 860 | 861 | export function __wbg_String_60c4ba333b5ca1c6(arg0, arg1) { 862 | var ret = String(getObject(arg1)); 863 | var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 864 | var len0 = WASM_VECTOR_LEN; 865 | getInt32Memory0()[arg0 / 4 + 1] = len0; 866 | getInt32Memory0()[arg0 / 4 + 0] = ptr0; 867 | }; 868 | 869 | export function __wbg_new_4fee7e2900033464() { 870 | var ret = new Array(); 871 | return addHeapObject(ret); 872 | }; 873 | 874 | export function __wbg_push_ba9b5e3c25cff8f9(arg0, arg1) { 875 | var ret = getObject(arg0).push(getObject(arg1)); 876 | return ret; 877 | }; 878 | 879 | export function __wbg_call_6c4ea719458624eb() { return handleError(function (arg0, arg1, arg2) { 880 | var ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); 881 | return addHeapObject(ret); 882 | }, arguments) }; 883 | 884 | export function __wbg_new_917809a3e20a4b00(arg0, arg1) { 885 | var ret = new TypeError(getStringFromWasm0(arg0, arg1)); 886 | return addHeapObject(ret); 887 | }; 888 | 889 | export function __wbg_instanceof_Promise_c6535fc791fcc4d2(arg0) { 890 | var ret = getObject(arg0) instanceof Promise; 891 | return ret; 892 | }; 893 | 894 | export function __wbg_buffer_89a8560ab6a3d9c6(arg0) { 895 | var ret = getObject(arg0).buffer; 896 | return addHeapObject(ret); 897 | }; 898 | 899 | export function __wbg_newwithbyteoffsetandlength_e45d8b33c02dc3b5(arg0, arg1, arg2) { 900 | var ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); 901 | return addHeapObject(ret); 902 | }; 903 | 904 | export function __wbg_new_bd2e1d010adb8a1a(arg0) { 905 | var ret = new Uint8Array(getObject(arg0)); 906 | return addHeapObject(ret); 907 | }; 908 | 909 | export function __wbindgen_debug_string(arg0, arg1) { 910 | var ret = debugString(getObject(arg1)); 911 | var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 912 | var len0 = WASM_VECTOR_LEN; 913 | getInt32Memory0()[arg0 / 4 + 1] = len0; 914 | getInt32Memory0()[arg0 / 4 + 0] = ptr0; 915 | }; 916 | 917 | export function __wbindgen_throw(arg0, arg1) { 918 | throw new Error(getStringFromWasm0(arg0, arg1)); 919 | }; 920 | 921 | export function __wbindgen_rethrow(arg0) { 922 | throw takeObject(arg0); 923 | }; 924 | 925 | export function __wbindgen_memory() { 926 | var ret = wasm.memory; 927 | return addHeapObject(ret); 928 | }; 929 | 930 | -------------------------------------------------------------------------------- /dist/html_rewriter_bg.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remorses/htmlrewriter/c55a0b1414747ebdad41f72c7b9feb790481eca5/dist/html_rewriter_bg.wasm -------------------------------------------------------------------------------- /dist/html_rewriter_bg.wasm.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | export const memory: WebAssembly.Memory; 4 | export function __wbg_endtag_free(a: number): void; 5 | export function endtag_name(a: number, b: number): void; 6 | export function endtag_set_name(a: number, b: number, c: number): void; 7 | export function endtag_before(a: number, b: number, c: number, d: number): void; 8 | export function endtag_after(a: number, b: number, c: number, d: number): void; 9 | export function endtag_remove(a: number): void; 10 | export function __wbg_documentend_free(a: number): void; 11 | export function documentend_append(a: number, b: number, c: number, d: number): void; 12 | export function __wbg_htmlrewriter_free(a: number): void; 13 | export function htmlrewriter_new(a: number, b: number): number; 14 | export function htmlrewriter_on(a: number, b: number, c: number, d: number): void; 15 | export function htmlrewriter_onDocument(a: number, b: number): void; 16 | export function htmlrewriter_write(a: number, b: number, c: number): void; 17 | export function htmlrewriter_end(a: number): void; 18 | export function htmlrewriter_asyncify_stack_ptr(a: number): number; 19 | export function __wbg_comment_free(a: number): void; 20 | export function comment_before(a: number, b: number, c: number, d: number): void; 21 | export function comment_after(a: number, b: number, c: number, d: number): void; 22 | export function comment_replace(a: number, b: number, c: number, d: number): void; 23 | export function comment_remove(a: number): void; 24 | export function comment_removed(a: number): number; 25 | export function comment_text(a: number, b: number): void; 26 | export function comment_set_text(a: number, b: number, c: number): void; 27 | export function __wbg_element_free(a: number): void; 28 | export function element_before(a: number, b: number, c: number, d: number): void; 29 | export function element_after(a: number, b: number, c: number, d: number): void; 30 | export function element_replace(a: number, b: number, c: number, d: number): void; 31 | export function element_remove(a: number): void; 32 | export function element_removed(a: number): number; 33 | export function element_tag_name(a: number, b: number): void; 34 | export function element_set_tag_name(a: number, b: number, c: number): void; 35 | export function element_namespace_uri(a: number): number; 36 | export function element_attributes(a: number): number; 37 | export function element_getAttribute(a: number, b: number, c: number): number; 38 | export function element_hasAttribute(a: number, b: number, c: number): number; 39 | export function element_setAttribute(a: number, b: number, c: number, d: number, e: number): void; 40 | export function element_removeAttribute(a: number, b: number, c: number): void; 41 | export function element_prepend(a: number, b: number, c: number, d: number): void; 42 | export function element_append(a: number, b: number, c: number, d: number): void; 43 | export function element_setInnerContent(a: number, b: number, c: number, d: number): void; 44 | export function element_removeAndKeepContent(a: number): void; 45 | export function element_onEndTag(a: number, b: number): void; 46 | export function __wbg_textchunk_free(a: number): void; 47 | export function textchunk_before(a: number, b: number, c: number, d: number): void; 48 | export function textchunk_after(a: number, b: number, c: number, d: number): void; 49 | export function textchunk_replace(a: number, b: number, c: number, d: number): void; 50 | export function textchunk_remove(a: number): void; 51 | export function textchunk_removed(a: number): number; 52 | export function textchunk_text(a: number, b: number): void; 53 | export function textchunk_last_in_text_node(a: number): number; 54 | export function __wbg_doctype_free(a: number): void; 55 | export function doctype_name(a: number): number; 56 | export function doctype_public_id(a: number): number; 57 | export function doctype_system_id(a: number): number; 58 | export function __wbindgen_malloc(a: number): number; 59 | export function __wbindgen_realloc(a: number, b: number, c: number): number; 60 | export function __wbindgen_add_to_stack_pointer(a: number): number; 61 | export function __wbindgen_free(a: number, b: number): void; 62 | export function __wbindgen_exn_store(a: number): void; 63 | -------------------------------------------------------------------------------- /dist/html_rewriter_wrapper.d.ts: -------------------------------------------------------------------------------- 1 | import { DocumentHandlers, ElementHandlers } from './types'; 2 | declare class HTMLRewriter { 3 | static initPromise?: Promise; 4 | constructor(options?: any); 5 | elementHandlers: [selector: string, handlers: ElementHandlers][]; 6 | documentHandlers: DocumentHandlers[]; 7 | on(selector: string, handlers: ElementHandlers): this; 8 | onDocument(handlers: DocumentHandlers): this; 9 | transform(response: Response): Response; 10 | } 11 | export declare function HTMLRewriterWrapper(initPromise: Promise): typeof HTMLRewriter; 12 | export {}; 13 | -------------------------------------------------------------------------------- /dist/html_rewriter_wrapper.js: -------------------------------------------------------------------------------- 1 | import { HTMLRewriter as RawHTMLRewriter } from '../dist/html_rewriter.js'; 2 | const encoder = new TextEncoder(); 3 | const decoder = new TextDecoder(); 4 | // console.log(wasm) 5 | class HTMLRewriter { 6 | constructor(options = {}) { 7 | this.elementHandlers = []; 8 | this.documentHandlers = []; 9 | } 10 | on(selector, handlers) { 11 | this.elementHandlers.push([selector, handlers]); 12 | return this; 13 | } 14 | onDocument(handlers) { 15 | this.documentHandlers.push(handlers); 16 | return this; 17 | } 18 | transform(response) { 19 | const body = response.body; 20 | // HTMLRewriter doesn't run the end handler if the body is null, so it's 21 | // pointless to setup the readable stream. 22 | if (body === null) 23 | return new Response(body, response); 24 | if (response instanceof Response) { 25 | // Make sure we validate chunks are BufferSources and convert them to 26 | // Uint8Arrays as required by the Rust glue code. 27 | response = new Response(response.body, response); 28 | } 29 | let rewriter; 30 | const readable = new ReadableStream({ 31 | start: async (controller) => { 32 | // Create a rewriter instance for this transformation that writes its 33 | // output to the transformed response's stream. Note that each 34 | // BaseHTMLRewriter can only be used once. 35 | await HTMLRewriter.initPromise; 36 | // console.log('creating rewriter') 37 | rewriter = new RawHTMLRewriter((chunk) => { 38 | // enqueue will throw on empty chunks 39 | if (chunk.length !== 0) 40 | controller.enqueue(chunk); 41 | }, { enableEsiTags: false }); 42 | // Add all registered handlers 43 | for (const [selector, handlers] of this.elementHandlers) { 44 | rewriter.on(selector, handlers); 45 | } 46 | for (const handlers of this.documentHandlers) { 47 | rewriter.onDocument(handlers); 48 | } 49 | // Pipe the response body to the rewriter 50 | const reader = body.getReader(); 51 | try { 52 | while (true) { 53 | // console.log('reading') 54 | const { done, value } = await reader.read(); 55 | if (done) 56 | break; 57 | rewriter.write(value); 58 | } 59 | rewriter.end(); 60 | } 61 | catch (error) { 62 | // rewriter.end() 63 | controller.error(error); 64 | } 65 | finally { 66 | rewriter.free(); 67 | reader.releaseLock(); 68 | controller.close(); 69 | } 70 | }, 71 | }); 72 | // Return a response with the transformed body, copying over headers, etc 73 | const res = new Response(readable, response); 74 | // If Content-Length is set, it's probably going to be wrong, since we're 75 | // rewriting content, so remove it 76 | res.headers.delete('Content-Length'); 77 | return res; 78 | } 79 | } 80 | export function HTMLRewriterWrapper(initPromise) { 81 | HTMLRewriter.initPromise = initPromise; 82 | return HTMLRewriter; 83 | } 84 | //# sourceMappingURL=html_rewriter_wrapper.js.map -------------------------------------------------------------------------------- /dist/html_rewriter_wrapper.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"html_rewriter_wrapper.js","sourceRoot":"","sources":["../src/html_rewriter_wrapper.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAGhF,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AACjC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC,oBAAoB;AAEpB,MAAM,YAAY;IAGd,YAAY,UAAe,EAAE;QAE7B,oBAAe,GAAoD,EAAE,CAAA;QACrE,qBAAgB,GAAuB,EAAE,CAAA;IAHT,CAAC;IAKjC,EAAE,CAAC,QAAgB,EAAE,QAAyB;QAC1C,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;QAC/C,OAAO,IAAI,CAAA;IACf,CAAC;IAED,UAAU,CAAC,QAA0B;QACjC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACpC,OAAO,IAAI,CAAA;IACf,CAAC;IACD,SAAS,CAAC,QAAkB;QACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAyC,CAAA;QAC/D,wEAAwE;QACxE,0CAA0C;QAC1C,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QAEtD,IAAI,QAAQ,YAAY,QAAQ,EAAE;YAC9B,qEAAqE;YACrE,iDAAiD;YACjD,QAAQ,GAAG,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;SACnD;QAED,IAAI,QAAyB,CAAA;QAC7B,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAa;YAC5C,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;gBACxB,qEAAqE;gBACrE,8DAA8D;gBAC9D,0CAA0C;gBAC1C,MAAM,YAAY,CAAC,WAAW,CAAA;gBAC9B,mCAAmC;gBACnC,QAAQ,GAAG,IAAI,eAAe,CAC1B,CAAC,KAAU,EAAE,EAAE;oBACX,qCAAqC;oBACrC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;wBAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;gBACrD,CAAC,EACD,EAAE,aAAa,EAAE,KAAK,EAAE,CAC3B,CAAA;gBACD,8BAA8B;gBAC9B,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE;oBACrD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;iBAClC;gBACD,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,gBAAgB,EAAE;oBAC1C,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;iBAChC;gBAED,yCAAyC;gBACzC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;gBAC/B,IAAI;oBACA,OAAO,IAAI,EAAE;wBACT,yBAAyB;wBACzB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;wBAC3C,IAAI,IAAI;4BAAE,MAAK;wBACf,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;qBACxB;oBAED,QAAQ,CAAC,GAAG,EAAE,CAAA;iBACjB;gBAAC,OAAO,KAAK,EAAE;oBACZ,iBAAiB;oBACjB,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;iBAC1B;wBAAS;oBACN,QAAQ,CAAC,IAAI,EAAE,CAAA;oBACf,MAAM,CAAC,WAAW,EAAE,CAAA;oBACpB,UAAU,CAAC,KAAK,EAAE,CAAA;iBACrB;YACL,CAAC;SACJ,CAAC,CAAA;QAEF,yEAAyE;QACzE,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC5C,yEAAyE;QACzE,kCAAkC;QAClC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;QACpC,OAAO,GAAG,CAAA;IACd,CAAC;CACJ;AAED,MAAM,UAAU,mBAAmB,CAAC,WAAyB;IACzD,YAAY,CAAC,WAAW,GAAG,WAAW,CAAA;IACtC,OAAO,YAAY,CAAA;AACvB,CAAC"} -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import { HTMLRewriterWrapper } from './html_rewriter_wrapper' 2 | 3 | export const HTMLRewriter: ReturnType 4 | -------------------------------------------------------------------------------- /dist/types.d.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/cloudflare/html-rewriter-wasm/blob/de05e01f225e6d4c316b19b9aae8b9aa68db9524/src/html_rewriter.d.ts#L67 2 | 3 | export interface ContentTypeOptions { 4 | html?: boolean 5 | } 6 | 7 | export class Element { 8 | before(content: string, options?: ContentTypeOptions): this 9 | after(content: string, options?: ContentTypeOptions): this 10 | replace(content: string, options?: ContentTypeOptions): this 11 | remove(): this 12 | getAttribute(name: string): string | null 13 | hasAttribute(name: string): boolean 14 | setAttribute(name: string, value: string): this 15 | removeAttribute(name: string): this 16 | prepend(content: string, options?: ContentTypeOptions): this 17 | append(content: string, options?: ContentTypeOptions): this 18 | setInnerContent(content: string, options?: ContentTypeOptions): this 19 | removeAndKeepContent(): this 20 | readonly attributes: IterableIterator<[string, string]> 21 | readonly namespaceURI: string 22 | readonly removed: boolean 23 | tagName: string 24 | onEndTag( 25 | handler: (this: this, endTag: EndTag) => void | Promise, 26 | ): void 27 | } 28 | 29 | export class EndTag { 30 | before(content: string, options?: ContentTypeOptions): this 31 | after(content: string, options?: ContentTypeOptions): this 32 | remove(): this 33 | name: string 34 | } 35 | 36 | export class Comment { 37 | before(content: string, options?: ContentTypeOptions): this 38 | after(content: string, options?: ContentTypeOptions): this 39 | replace(content: string, options?: ContentTypeOptions): this 40 | remove(): this 41 | readonly removed: boolean 42 | text: string 43 | } 44 | 45 | export class TextChunk { 46 | before(content: string, options?: ContentTypeOptions): this 47 | after(content: string, options?: ContentTypeOptions): this 48 | replace(content: string, options?: ContentTypeOptions): this 49 | remove(): this 50 | readonly lastInTextNode: boolean 51 | readonly removed: boolean 52 | readonly text: string 53 | } 54 | 55 | export class Doctype { 56 | readonly name: string | null 57 | readonly publicId: string | null 58 | readonly systemId: string | null 59 | } 60 | 61 | export class DocumentEnd { 62 | append(content: string, options?: ContentTypeOptions): this 63 | } 64 | 65 | export interface ElementHandlers { 66 | element?(element: Element): void | Promise 67 | comments?(comment: Comment): void | Promise 68 | text?(text: TextChunk): void | Promise 69 | } 70 | 71 | export interface DocumentHandlers { 72 | doctype?(doctype: Doctype): void | Promise 73 | comments?(comment: Comment): void | Promise 74 | text?(text: TextChunk): void | Promise 75 | end?(end: DocumentEnd): void | Promise 76 | } 77 | 78 | export interface HTMLRewriterOptions { 79 | enableEsiTags?: boolean 80 | } 81 | 82 | export class HTMLRewriter { 83 | constructor( 84 | outputSink: (chunk: Uint8Array) => void, 85 | options?: HTMLRewriterOptions, 86 | ) 87 | on(selector: string, handlers: ElementHandlers): this 88 | onDocument(handlers: DocumentHandlers): this 89 | write(chunk: Uint8Array): Promise 90 | end(): Promise 91 | free(): void 92 | } 93 | -------------------------------------------------------------------------------- /node.mjs: -------------------------------------------------------------------------------- 1 | import init from './dist/html_rewriter.js' 2 | import fs from 'fs' 3 | import path from 'path' 4 | import url from 'url' 5 | 6 | import { HTMLRewriterWrapper } from './dist/html_rewriter_wrapper.js' 7 | 8 | const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) 9 | 10 | const bytes = fs.readFileSync( 11 | path.join(__dirname, 'dist/html_rewriter_bg.wasm'), 12 | ) 13 | 14 | const wasm = new WebAssembly.Module(bytes) 15 | 16 | export const HTMLRewriter = HTMLRewriterWrapper(init(wasm)) 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "htmlrewriter", 3 | "version": "0.0.12", 4 | "description": "Use Cloudflare HTMLRewriter in Node.js, Browser, Next.js and more", 5 | "type": "module", 6 | "files": [ 7 | "dist", 8 | "src", 9 | "README.md", 10 | "bun.js", 11 | "vercel.js", 12 | "browser.js", 13 | "cloudflare.js", 14 | "default.js", 15 | "node.mjs" 16 | ], 17 | "types": "dist/index.d.ts", 18 | "exports": { 19 | ".": { 20 | "types": "./dist/index.d.ts", 21 | "bun": "./bun.js", 22 | "workerd": "./cloudflare.js", 23 | "edge-light": "./vercel.js", 24 | "node": "./node.mjs", 25 | "browser": "./browser.js", 26 | "default": "./default.js" 27 | }, 28 | "./dist/html_rewriter_bg.wasm": "./dist/html_rewriter_bg.wasm", 29 | "./dist/html_rewriter_wrapper.js": "./dist/html_rewriter_wrapper.js", 30 | "./dist/html_rewriter.js": "./dist/html_rewriter.js", 31 | "./package.json": "./package.json" 32 | }, 33 | "scripts": { 34 | "try": "bun scripts/try.js && node scripts/try.js && deno run --allow-read scripts/try.js && pnpm vite dev scripts", 35 | "prepublishOnly": "pnpm build", 36 | "test": "pnpm vitest", 37 | "build": "tsx scripts/build.ts" 38 | }, 39 | "repository": { 40 | "type": "git", 41 | "url": "git+https://github.com/remorses/htmlrewriter.git" 42 | }, 43 | "keywords": [ 44 | "cloudflare", 45 | "workers", 46 | "vercel", 47 | "worker", 48 | "htmlrewriter", 49 | "lol" 50 | ], 51 | "author": "Tommaso De Rossi, morse ", 52 | "license": "BSD-3-Clause", 53 | "bugs": { 54 | "url": "https://github.com/remorses/htmlrewriter/issues" 55 | }, 56 | "homepage": "https://github.com/remorses/htmlrewriter#readme", 57 | "devDependencies": { 58 | "@types/fs-extra": "^11.0.1", 59 | "@types/node": "^20.11.13", 60 | "@xmorse/deployment-utils": "^0.2.19", 61 | "fs-extra": "^11.1.1", 62 | "htmlrewriter": "^0.0.12", 63 | "prettier": "^2.3.2", 64 | "vitest": "^3.1.1" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '9.0' 2 | 3 | settings: 4 | autoInstallPeers: true 5 | excludeLinksFromLockfile: false 6 | 7 | importers: 8 | 9 | .: 10 | devDependencies: 11 | '@types/fs-extra': 12 | specifier: ^11.0.1 13 | version: 11.0.4 14 | '@types/node': 15 | specifier: ^20.11.13 16 | version: 20.14.12 17 | '@xmorse/deployment-utils': 18 | specifier: ^0.1.10 19 | version: 0.1.10 20 | fs-extra: 21 | specifier: ^11.1.1 22 | version: 11.2.0 23 | htmlrewriter: 24 | specifier: ^0.0.7 25 | version: 0.0.7 26 | prettier: 27 | specifier: ^2.3.2 28 | version: 2.8.8 29 | vitest: 30 | specifier: ^2.0.4 31 | version: 2.0.4(@types/node@20.14.12) 32 | 33 | packages: 34 | 35 | '@actions/cache@3.2.4': 36 | resolution: {integrity: sha512-RuHnwfcDagtX+37s0ZWy7clbOfnZ7AlDJQ7k/9rzt2W4Gnwde3fa/qjSjVuz4vLcLIpc7fUob27CMrqiWZytYA==} 37 | 38 | '@actions/core@1.10.1': 39 | resolution: {integrity: sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==} 40 | 41 | '@actions/exec@1.1.1': 42 | resolution: {integrity: sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==} 43 | 44 | '@actions/glob@0.1.2': 45 | resolution: {integrity: sha512-SclLR7Ia5sEqjkJTPs7Sd86maMDw43p769YxBOxvPvEWuPEhpAnBsQfENOpXjFYMmhCqd127bmf+YdvJqVqR4A==} 46 | 47 | '@actions/http-client@2.2.1': 48 | resolution: {integrity: sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==} 49 | 50 | '@actions/io@1.1.3': 51 | resolution: {integrity: sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==} 52 | 53 | '@ampproject/remapping@2.3.0': 54 | resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} 55 | engines: {node: '>=6.0.0'} 56 | 57 | '@azure/abort-controller@1.1.0': 58 | resolution: {integrity: sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==} 59 | engines: {node: '>=12.0.0'} 60 | 61 | '@azure/abort-controller@2.1.2': 62 | resolution: {integrity: sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==} 63 | engines: {node: '>=18.0.0'} 64 | 65 | '@azure/core-auth@1.7.2': 66 | resolution: {integrity: sha512-Igm/S3fDYmnMq1uKS38Ae1/m37B3zigdlZw+kocwEhh5GjyKjPrXKO2J6rzpC1wAxrNil/jX9BJRqBshyjnF3g==} 67 | engines: {node: '>=18.0.0'} 68 | 69 | '@azure/core-client@1.9.2': 70 | resolution: {integrity: sha512-kRdry/rav3fUKHl/aDLd/pDLcB+4pOFwPPTVEExuMyaI5r+JBbMWqRbCY1pn5BniDaU3lRxO9eaQ1AmSMehl/w==} 71 | engines: {node: '>=18.0.0'} 72 | 73 | '@azure/core-http-compat@2.1.2': 74 | resolution: {integrity: sha512-5MnV1yqzZwgNLLjlizsU3QqOeQChkIXw781Fwh1xdAqJR5AA32IUaq6xv1BICJvfbHoa+JYcaij2HFkhLbNTJQ==} 75 | engines: {node: '>=18.0.0'} 76 | 77 | '@azure/core-lro@2.7.2': 78 | resolution: {integrity: sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw==} 79 | engines: {node: '>=18.0.0'} 80 | 81 | '@azure/core-paging@1.6.2': 82 | resolution: {integrity: sha512-YKWi9YuCU04B55h25cnOYZHxXYtEvQEbKST5vqRga7hWY9ydd3FZHdeQF8pyh+acWZvppw13M/LMGx0LABUVMA==} 83 | engines: {node: '>=18.0.0'} 84 | 85 | '@azure/core-rest-pipeline@1.16.2': 86 | resolution: {integrity: sha512-Hnhm/PG9/SQ07JJyLDv3l9Qr8V3xgAe1hFoBYzt6LaalMxfL/ZqFaZf/bz5VN3pMcleCPwl8ivlS2Fjxq/iC8Q==} 87 | engines: {node: '>=18.0.0'} 88 | 89 | '@azure/core-tracing@1.1.2': 90 | resolution: {integrity: sha512-dawW9ifvWAWmUm9/h+/UQ2jrdvjCJ7VJEuCJ6XVNudzcOwm53BFZH4Q845vjfgoUAM8ZxokvVNxNxAITc502YA==} 91 | engines: {node: '>=18.0.0'} 92 | 93 | '@azure/core-util@1.9.1': 94 | resolution: {integrity: sha512-OLsq0etbHO1MA7j6FouXFghuHrAFGk+5C1imcpQ2e+0oZhYF07WLA+NW2Vqs70R7d+zOAWiWM3tbE1sXcDN66g==} 95 | engines: {node: '>=18.0.0'} 96 | 97 | '@azure/core-xml@1.4.2': 98 | resolution: {integrity: sha512-CW3MZhApe/S4iikbYKE7s83fjDBPIr2kpidX+hlGRwh7N4o1nIpQ/PfJTeioqhfqdMvRtheEl+ft64fyTaLNaA==} 99 | engines: {node: '>=18.0.0'} 100 | 101 | '@azure/logger@1.1.3': 102 | resolution: {integrity: sha512-J8/cIKNQB1Fc9fuYqBVnrppiUtW+5WWJPCj/tAokC5LdSTwkWWttN+jsRgw9BLYD7JDBx7PceiqOBxJJ1tQz3Q==} 103 | engines: {node: '>=18.0.0'} 104 | 105 | '@azure/ms-rest-js@2.7.0': 106 | resolution: {integrity: sha512-ngbzWbqF+NmztDOpLBVDxYM+XLcUj7nKhxGbSU9WtIsXfRB//cf2ZbAG5HkOrhU9/wd/ORRB6lM/d69RKVjiyA==} 107 | 108 | '@azure/storage-blob@12.24.0': 109 | resolution: {integrity: sha512-l8cmWM4C7RoNCBOImoFMxhTXe1Lr+8uQ/IgnhRNMpfoA9bAFWoLG4XrWm6O5rKXortreVQuD+fc1hbzWklOZbw==} 110 | engines: {node: '>=18.0.0'} 111 | 112 | '@esbuild/aix-ppc64@0.21.5': 113 | resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} 114 | engines: {node: '>=12'} 115 | cpu: [ppc64] 116 | os: [aix] 117 | 118 | '@esbuild/android-arm64@0.21.5': 119 | resolution: {integrity: sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==} 120 | engines: {node: '>=12'} 121 | cpu: [arm64] 122 | os: [android] 123 | 124 | '@esbuild/android-arm@0.21.5': 125 | resolution: {integrity: sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==} 126 | engines: {node: '>=12'} 127 | cpu: [arm] 128 | os: [android] 129 | 130 | '@esbuild/android-x64@0.21.5': 131 | resolution: {integrity: sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==} 132 | engines: {node: '>=12'} 133 | cpu: [x64] 134 | os: [android] 135 | 136 | '@esbuild/darwin-arm64@0.21.5': 137 | resolution: {integrity: sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==} 138 | engines: {node: '>=12'} 139 | cpu: [arm64] 140 | os: [darwin] 141 | 142 | '@esbuild/darwin-x64@0.21.5': 143 | resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==} 144 | engines: {node: '>=12'} 145 | cpu: [x64] 146 | os: [darwin] 147 | 148 | '@esbuild/freebsd-arm64@0.21.5': 149 | resolution: {integrity: sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==} 150 | engines: {node: '>=12'} 151 | cpu: [arm64] 152 | os: [freebsd] 153 | 154 | '@esbuild/freebsd-x64@0.21.5': 155 | resolution: {integrity: sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==} 156 | engines: {node: '>=12'} 157 | cpu: [x64] 158 | os: [freebsd] 159 | 160 | '@esbuild/linux-arm64@0.21.5': 161 | resolution: {integrity: sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==} 162 | engines: {node: '>=12'} 163 | cpu: [arm64] 164 | os: [linux] 165 | 166 | '@esbuild/linux-arm@0.21.5': 167 | resolution: {integrity: sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==} 168 | engines: {node: '>=12'} 169 | cpu: [arm] 170 | os: [linux] 171 | 172 | '@esbuild/linux-ia32@0.21.5': 173 | resolution: {integrity: sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==} 174 | engines: {node: '>=12'} 175 | cpu: [ia32] 176 | os: [linux] 177 | 178 | '@esbuild/linux-loong64@0.21.5': 179 | resolution: {integrity: sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==} 180 | engines: {node: '>=12'} 181 | cpu: [loong64] 182 | os: [linux] 183 | 184 | '@esbuild/linux-mips64el@0.21.5': 185 | resolution: {integrity: sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==} 186 | engines: {node: '>=12'} 187 | cpu: [mips64el] 188 | os: [linux] 189 | 190 | '@esbuild/linux-ppc64@0.21.5': 191 | resolution: {integrity: sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==} 192 | engines: {node: '>=12'} 193 | cpu: [ppc64] 194 | os: [linux] 195 | 196 | '@esbuild/linux-riscv64@0.21.5': 197 | resolution: {integrity: sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==} 198 | engines: {node: '>=12'} 199 | cpu: [riscv64] 200 | os: [linux] 201 | 202 | '@esbuild/linux-s390x@0.21.5': 203 | resolution: {integrity: sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==} 204 | engines: {node: '>=12'} 205 | cpu: [s390x] 206 | os: [linux] 207 | 208 | '@esbuild/linux-x64@0.21.5': 209 | resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==} 210 | engines: {node: '>=12'} 211 | cpu: [x64] 212 | os: [linux] 213 | 214 | '@esbuild/netbsd-x64@0.21.5': 215 | resolution: {integrity: sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==} 216 | engines: {node: '>=12'} 217 | cpu: [x64] 218 | os: [netbsd] 219 | 220 | '@esbuild/openbsd-x64@0.21.5': 221 | resolution: {integrity: sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==} 222 | engines: {node: '>=12'} 223 | cpu: [x64] 224 | os: [openbsd] 225 | 226 | '@esbuild/sunos-x64@0.21.5': 227 | resolution: {integrity: sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==} 228 | engines: {node: '>=12'} 229 | cpu: [x64] 230 | os: [sunos] 231 | 232 | '@esbuild/win32-arm64@0.21.5': 233 | resolution: {integrity: sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==} 234 | engines: {node: '>=12'} 235 | cpu: [arm64] 236 | os: [win32] 237 | 238 | '@esbuild/win32-ia32@0.21.5': 239 | resolution: {integrity: sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==} 240 | engines: {node: '>=12'} 241 | cpu: [ia32] 242 | os: [win32] 243 | 244 | '@esbuild/win32-x64@0.21.5': 245 | resolution: {integrity: sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==} 246 | engines: {node: '>=12'} 247 | cpu: [x64] 248 | os: [win32] 249 | 250 | '@fastify/busboy@2.1.1': 251 | resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} 252 | engines: {node: '>=14'} 253 | 254 | '@iarna/toml@2.2.5': 255 | resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} 256 | 257 | '@jridgewell/gen-mapping@0.3.5': 258 | resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} 259 | engines: {node: '>=6.0.0'} 260 | 261 | '@jridgewell/resolve-uri@3.1.2': 262 | resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} 263 | engines: {node: '>=6.0.0'} 264 | 265 | '@jridgewell/set-array@1.2.1': 266 | resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} 267 | engines: {node: '>=6.0.0'} 268 | 269 | '@jridgewell/sourcemap-codec@1.5.0': 270 | resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} 271 | 272 | '@jridgewell/trace-mapping@0.3.25': 273 | resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} 274 | 275 | '@rollup/rollup-android-arm-eabi@4.19.0': 276 | resolution: {integrity: sha512-JlPfZ/C7yn5S5p0yKk7uhHTTnFlvTgLetl2VxqE518QgyM7C9bSfFTYvB/Q/ftkq0RIPY4ySxTz+/wKJ/dXC0w==} 277 | cpu: [arm] 278 | os: [android] 279 | 280 | '@rollup/rollup-android-arm64@4.19.0': 281 | resolution: {integrity: sha512-RDxUSY8D1tWYfn00DDi5myxKgOk6RvWPxhmWexcICt/MEC6yEMr4HNCu1sXXYLw8iAsg0D44NuU+qNq7zVWCrw==} 282 | cpu: [arm64] 283 | os: [android] 284 | 285 | '@rollup/rollup-darwin-arm64@4.19.0': 286 | resolution: {integrity: sha512-emvKHL4B15x6nlNTBMtIaC9tLPRpeA5jMvRLXVbl/W9Ie7HhkrE7KQjvgS9uxgatL1HmHWDXk5TTS4IaNJxbAA==} 287 | cpu: [arm64] 288 | os: [darwin] 289 | 290 | '@rollup/rollup-darwin-x64@4.19.0': 291 | resolution: {integrity: sha512-fO28cWA1dC57qCd+D0rfLC4VPbh6EOJXrreBmFLWPGI9dpMlER2YwSPZzSGfq11XgcEpPukPTfEVFtw2q2nYJg==} 292 | cpu: [x64] 293 | os: [darwin] 294 | 295 | '@rollup/rollup-linux-arm-gnueabihf@4.19.0': 296 | resolution: {integrity: sha512-2Rn36Ubxdv32NUcfm0wB1tgKqkQuft00PtM23VqLuCUR4N5jcNWDoV5iBC9jeGdgS38WK66ElncprqgMUOyomw==} 297 | cpu: [arm] 298 | os: [linux] 299 | 300 | '@rollup/rollup-linux-arm-musleabihf@4.19.0': 301 | resolution: {integrity: sha512-gJuzIVdq/X1ZA2bHeCGCISe0VWqCoNT8BvkQ+BfsixXwTOndhtLUpOg0A1Fcx/+eA6ei6rMBzlOz4JzmiDw7JQ==} 302 | cpu: [arm] 303 | os: [linux] 304 | 305 | '@rollup/rollup-linux-arm64-gnu@4.19.0': 306 | resolution: {integrity: sha512-0EkX2HYPkSADo9cfeGFoQ7R0/wTKb7q6DdwI4Yn/ULFE1wuRRCHybxpl2goQrx4c/yzK3I8OlgtBu4xvted0ug==} 307 | cpu: [arm64] 308 | os: [linux] 309 | 310 | '@rollup/rollup-linux-arm64-musl@4.19.0': 311 | resolution: {integrity: sha512-GlIQRj9px52ISomIOEUq/IojLZqzkvRpdP3cLgIE1wUWaiU5Takwlzpz002q0Nxxr1y2ZgxC2obWxjr13lvxNQ==} 312 | cpu: [arm64] 313 | os: [linux] 314 | 315 | '@rollup/rollup-linux-powerpc64le-gnu@4.19.0': 316 | resolution: {integrity: sha512-N6cFJzssruDLUOKfEKeovCKiHcdwVYOT1Hs6dovDQ61+Y9n3Ek4zXvtghPPelt6U0AH4aDGnDLb83uiJMkWYzQ==} 317 | cpu: [ppc64] 318 | os: [linux] 319 | 320 | '@rollup/rollup-linux-riscv64-gnu@4.19.0': 321 | resolution: {integrity: sha512-2DnD3mkS2uuam/alF+I7M84koGwvn3ZVD7uG+LEWpyzo/bq8+kKnus2EVCkcvh6PlNB8QPNFOz6fWd5N8o1CYg==} 322 | cpu: [riscv64] 323 | os: [linux] 324 | 325 | '@rollup/rollup-linux-s390x-gnu@4.19.0': 326 | resolution: {integrity: sha512-D6pkaF7OpE7lzlTOFCB2m3Ngzu2ykw40Nka9WmKGUOTS3xcIieHe82slQlNq69sVB04ch73thKYIWz/Ian8DUA==} 327 | cpu: [s390x] 328 | os: [linux] 329 | 330 | '@rollup/rollup-linux-x64-gnu@4.19.0': 331 | resolution: {integrity: sha512-HBndjQLP8OsdJNSxpNIN0einbDmRFg9+UQeZV1eiYupIRuZsDEoeGU43NQsS34Pp166DtwQOnpcbV/zQxM+rWA==} 332 | cpu: [x64] 333 | os: [linux] 334 | 335 | '@rollup/rollup-linux-x64-musl@4.19.0': 336 | resolution: {integrity: sha512-HxfbvfCKJe/RMYJJn0a12eiOI9OOtAUF4G6ozrFUK95BNyoJaSiBjIOHjZskTUffUrB84IPKkFG9H9nEvJGW6A==} 337 | cpu: [x64] 338 | os: [linux] 339 | 340 | '@rollup/rollup-win32-arm64-msvc@4.19.0': 341 | resolution: {integrity: sha512-HxDMKIhmcguGTiP5TsLNolwBUK3nGGUEoV/BO9ldUBoMLBssvh4J0X8pf11i1fTV7WShWItB1bKAKjX4RQeYmg==} 342 | cpu: [arm64] 343 | os: [win32] 344 | 345 | '@rollup/rollup-win32-ia32-msvc@4.19.0': 346 | resolution: {integrity: sha512-xItlIAZZaiG/u0wooGzRsx11rokP4qyc/79LkAOdznGRAbOFc+SfEdfUOszG1odsHNgwippUJavag/+W/Etc6Q==} 347 | cpu: [ia32] 348 | os: [win32] 349 | 350 | '@rollup/rollup-win32-x64-msvc@4.19.0': 351 | resolution: {integrity: sha512-xNo5fV5ycvCCKqiZcpB65VMR11NJB+StnxHz20jdqRAktfdfzhgjTiJ2doTDQE/7dqGaV5I7ZGqKpgph6lCIag==} 352 | cpu: [x64] 353 | os: [win32] 354 | 355 | '@types/estree@1.0.5': 356 | resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} 357 | 358 | '@types/folder-hash@4.0.4': 359 | resolution: {integrity: sha512-c+PwHm51Dw3fXM8SDK+93PO3oXdk4XNouCCvV67lj4aijRkZz5g67myk+9wqWWnyv3go6q96hT6ywcd3XtoZiQ==} 360 | 361 | '@types/fs-extra@11.0.4': 362 | resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==} 363 | 364 | '@types/jsonfile@6.1.4': 365 | resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} 366 | 367 | '@types/node@20.14.12': 368 | resolution: {integrity: sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==} 369 | 370 | '@vitest/expect@2.0.4': 371 | resolution: {integrity: sha512-39jr5EguIoanChvBqe34I8m1hJFI4+jxvdOpD7gslZrVQBKhh8H9eD7J/LJX4zakrw23W+dITQTDqdt43xVcJw==} 372 | 373 | '@vitest/pretty-format@2.0.4': 374 | resolution: {integrity: sha512-RYZl31STbNGqf4l2eQM1nvKPXE0NhC6Eq0suTTePc4mtMQ1Fn8qZmjV4emZdEdG2NOWGKSCrHZjmTqDCDoeFBw==} 375 | 376 | '@vitest/runner@2.0.4': 377 | resolution: {integrity: sha512-Gk+9Su/2H2zNfNdeJR124gZckd5st4YoSuhF1Rebi37qTXKnqYyFCd9KP4vl2cQHbtuVKjfEKrNJxHHCW8thbQ==} 378 | 379 | '@vitest/snapshot@2.0.4': 380 | resolution: {integrity: sha512-or6Mzoz/pD7xTvuJMFYEtso1vJo1S5u6zBTinfl+7smGUhqybn6VjzCDMhmTyVOFWwkCMuNjmNNxnyXPgKDoPw==} 381 | 382 | '@vitest/spy@2.0.4': 383 | resolution: {integrity: sha512-uTXU56TNoYrTohb+6CseP8IqNwlNdtPwEO0AWl+5j7NelS6x0xZZtP0bDWaLvOfUbaYwhhWp1guzXUxkC7mW7Q==} 384 | 385 | '@vitest/utils@2.0.4': 386 | resolution: {integrity: sha512-Zc75QuuoJhOBnlo99ZVUkJIuq4Oj0zAkrQ2VzCqNCx6wAwViHEh5Fnp4fiJTE9rA+sAoXRf00Z9xGgfEzV6fzQ==} 387 | 388 | '@xmorse/deployment-utils@0.1.10': 389 | resolution: {integrity: sha512-9qeDLLGqwUN6c97LepjpkJszK3/vbY+55/JrepNCkyrzwLzvMtxIL9SSbxTgh6W2IwUWs2tZBytIwEqHnquZcg==} 390 | 391 | abort-controller@3.0.0: 392 | resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} 393 | engines: {node: '>=6.5'} 394 | 395 | agent-base@7.1.1: 396 | resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} 397 | engines: {node: '>= 14'} 398 | 399 | assertion-error@2.0.1: 400 | resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} 401 | engines: {node: '>=12'} 402 | 403 | async-sema@3.1.1: 404 | resolution: {integrity: sha512-tLRNUXati5MFePdAk8dw7Qt7DpxPB60ofAgn8WRhW6a2rcimZnYBP9oxHiv0OHy+Wz7kPMG+t4LGdt31+4EmGg==} 405 | 406 | asynckit@0.4.0: 407 | resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} 408 | 409 | balanced-match@1.0.2: 410 | resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} 411 | 412 | brace-expansion@1.1.11: 413 | resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} 414 | 415 | brace-expansion@2.0.1: 416 | resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} 417 | 418 | cac@6.7.14: 419 | resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} 420 | engines: {node: '>=8'} 421 | 422 | chai@5.1.1: 423 | resolution: {integrity: sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==} 424 | engines: {node: '>=12'} 425 | 426 | check-error@2.1.1: 427 | resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} 428 | engines: {node: '>= 16'} 429 | 430 | combined-stream@1.0.8: 431 | resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} 432 | engines: {node: '>= 0.8'} 433 | 434 | concat-map@0.0.1: 435 | resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} 436 | 437 | cross-spawn@7.0.3: 438 | resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} 439 | engines: {node: '>= 8'} 440 | 441 | debug@4.3.5: 442 | resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} 443 | engines: {node: '>=6.0'} 444 | peerDependencies: 445 | supports-color: '*' 446 | peerDependenciesMeta: 447 | supports-color: 448 | optional: true 449 | 450 | deep-eql@5.0.2: 451 | resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} 452 | engines: {node: '>=6'} 453 | 454 | delayed-stream@1.0.0: 455 | resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} 456 | engines: {node: '>=0.4.0'} 457 | 458 | esbuild@0.21.5: 459 | resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==} 460 | engines: {node: '>=12'} 461 | hasBin: true 462 | 463 | estree-walker@3.0.3: 464 | resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} 465 | 466 | event-target-shim@5.0.1: 467 | resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} 468 | engines: {node: '>=6'} 469 | 470 | events@3.3.0: 471 | resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} 472 | engines: {node: '>=0.8.x'} 473 | 474 | execa@8.0.1: 475 | resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} 476 | engines: {node: '>=16.17'} 477 | 478 | fast-xml-parser@4.4.0: 479 | resolution: {integrity: sha512-kLY3jFlwIYwBNDojclKsNAC12sfD6NwW74QB2CoNGPvtVxjliYehVunB3HYyNi+n4Tt1dAcgwYvmKF/Z18flqg==} 480 | hasBin: true 481 | 482 | folder-hash@4.0.4: 483 | resolution: {integrity: sha512-zEyYH+UsHEfJJcCRSf9ai5I4CTZwZ8ObONRuEI5hcEmJY5pS0FUWKruX9mMnYJrgC7MlPFDYnGsK1R+WFYjLlQ==} 484 | engines: {node: '>=10.10.0'} 485 | hasBin: true 486 | 487 | form-data@2.5.1: 488 | resolution: {integrity: sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==} 489 | engines: {node: '>= 0.12'} 490 | 491 | fs-extra@10.1.0: 492 | resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==} 493 | engines: {node: '>=12'} 494 | 495 | fs-extra@11.2.0: 496 | resolution: {integrity: sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==} 497 | engines: {node: '>=14.14'} 498 | 499 | fsevents@2.3.3: 500 | resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} 501 | engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} 502 | os: [darwin] 503 | 504 | get-func-name@2.0.2: 505 | resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} 506 | 507 | get-stream@8.0.1: 508 | resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} 509 | engines: {node: '>=16'} 510 | 511 | graceful-fs@4.2.11: 512 | resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} 513 | 514 | htmlrewriter@0.0.7: 515 | resolution: {integrity: sha512-OvSdqGI04ZZm+zzWv+JXRiqn61sFY3ei9sY3HjNCJL7g6LXQH23CENO68hTTxM5xan0P2ENQ8+GTRQwHbPpyvg==} 516 | 517 | http-proxy-agent@7.0.2: 518 | resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==} 519 | engines: {node: '>= 14'} 520 | 521 | https-proxy-agent@7.0.5: 522 | resolution: {integrity: sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==} 523 | engines: {node: '>= 14'} 524 | 525 | human-signals@5.0.0: 526 | resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} 527 | engines: {node: '>=16.17.0'} 528 | 529 | is-stream@3.0.0: 530 | resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} 531 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 532 | 533 | isexe@2.0.0: 534 | resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} 535 | 536 | jsonfile@6.1.0: 537 | resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} 538 | 539 | loupe@3.1.1: 540 | resolution: {integrity: sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==} 541 | 542 | magic-string@0.30.10: 543 | resolution: {integrity: sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==} 544 | 545 | merge-stream@2.0.0: 546 | resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} 547 | 548 | mime-db@1.52.0: 549 | resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} 550 | engines: {node: '>= 0.6'} 551 | 552 | mime-types@2.1.35: 553 | resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} 554 | engines: {node: '>= 0.6'} 555 | 556 | mimic-fn@4.0.0: 557 | resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} 558 | engines: {node: '>=12'} 559 | 560 | minimatch@3.1.2: 561 | resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} 562 | 563 | minimatch@5.1.6: 564 | resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} 565 | engines: {node: '>=10'} 566 | 567 | ms@2.1.2: 568 | resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} 569 | 570 | nanoid@3.3.7: 571 | resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} 572 | engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} 573 | hasBin: true 574 | 575 | node-fetch@2.7.0: 576 | resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} 577 | engines: {node: 4.x || >=6.0.0} 578 | peerDependencies: 579 | encoding: ^0.1.0 580 | peerDependenciesMeta: 581 | encoding: 582 | optional: true 583 | 584 | npm-run-path@5.3.0: 585 | resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} 586 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 587 | 588 | onetime@6.0.0: 589 | resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} 590 | engines: {node: '>=12'} 591 | 592 | path-key@3.1.1: 593 | resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} 594 | engines: {node: '>=8'} 595 | 596 | path-key@4.0.0: 597 | resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} 598 | engines: {node: '>=12'} 599 | 600 | pathe@1.1.2: 601 | resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} 602 | 603 | pathval@2.0.0: 604 | resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} 605 | engines: {node: '>= 14.16'} 606 | 607 | picocolors@1.0.1: 608 | resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} 609 | 610 | postcss@8.4.40: 611 | resolution: {integrity: sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q==} 612 | engines: {node: ^10 || ^12 || >=14} 613 | 614 | prettier@2.8.8: 615 | resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} 616 | engines: {node: '>=10.13.0'} 617 | hasBin: true 618 | 619 | rollup@4.19.0: 620 | resolution: {integrity: sha512-5r7EYSQIowHsK4eTZ0Y81qpZuJz+MUuYeqmmYmRMl1nwhdmbiYqt5jwzf6u7wyOzJgYqtCRMtVRKOtHANBz7rA==} 621 | engines: {node: '>=18.0.0', npm: '>=8.0.0'} 622 | hasBin: true 623 | 624 | sax@1.4.1: 625 | resolution: {integrity: sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==} 626 | 627 | semver@6.3.1: 628 | resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} 629 | hasBin: true 630 | 631 | shebang-command@2.0.0: 632 | resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} 633 | engines: {node: '>=8'} 634 | 635 | shebang-regex@3.0.0: 636 | resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} 637 | engines: {node: '>=8'} 638 | 639 | siginfo@2.0.0: 640 | resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} 641 | 642 | signal-exit@4.1.0: 643 | resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} 644 | engines: {node: '>=14'} 645 | 646 | source-map-js@1.2.0: 647 | resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} 648 | engines: {node: '>=0.10.0'} 649 | 650 | stackback@0.0.2: 651 | resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} 652 | 653 | std-env@3.7.0: 654 | resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} 655 | 656 | strip-final-newline@3.0.0: 657 | resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} 658 | engines: {node: '>=12'} 659 | 660 | strnum@1.0.5: 661 | resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==} 662 | 663 | temp-dir@2.0.0: 664 | resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==} 665 | engines: {node: '>=8'} 666 | 667 | tempfile@4.0.0: 668 | resolution: {integrity: sha512-dNH6UWyI8kijDmLVb0IJvCG4JZ5uOmy40CLoi/dVySL49v0f0Y+jIN2rE6Hj85y8mIIya1vwpKZlL9jASs5ktg==} 669 | engines: {node: '>=12.20'} 670 | 671 | tinybench@2.8.0: 672 | resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} 673 | 674 | tinypool@1.0.0: 675 | resolution: {integrity: sha512-KIKExllK7jp3uvrNtvRBYBWBOAXSX8ZvoaD8T+7KB/QHIuoJW3Pmr60zucywjAlMb5TeXUkcs/MWeWLu0qvuAQ==} 676 | engines: {node: ^18.0.0 || >=20.0.0} 677 | 678 | tinyrainbow@1.2.0: 679 | resolution: {integrity: sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==} 680 | engines: {node: '>=14.0.0'} 681 | 682 | tinyspy@3.0.0: 683 | resolution: {integrity: sha512-q5nmENpTHgiPVd1cJDDc9cVoYN5x4vCvwT3FMilvKPKneCBZAxn2YWQjDF0UMcE9k0Cay1gBiDfTMU0g+mPMQA==} 684 | engines: {node: '>=14.0.0'} 685 | 686 | tr46@0.0.3: 687 | resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} 688 | 689 | tslib@1.14.1: 690 | resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} 691 | 692 | tslib@2.6.3: 693 | resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} 694 | 695 | tunnel@0.0.6: 696 | resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} 697 | engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} 698 | 699 | undici-types@5.26.5: 700 | resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} 701 | 702 | undici@5.28.4: 703 | resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} 704 | engines: {node: '>=14.0'} 705 | 706 | universalify@2.0.1: 707 | resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} 708 | engines: {node: '>= 10.0.0'} 709 | 710 | uuid@3.4.0: 711 | resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} 712 | deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. 713 | hasBin: true 714 | 715 | uuid@8.3.2: 716 | resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} 717 | hasBin: true 718 | 719 | vite-node@2.0.4: 720 | resolution: {integrity: sha512-ZpJVkxcakYtig5iakNeL7N3trufe3M6vGuzYAr4GsbCTwobDeyPJpE4cjDhhPluv8OvQCFzu2LWp6GkoKRITXA==} 721 | engines: {node: ^18.0.0 || >=20.0.0} 722 | hasBin: true 723 | 724 | vite@5.3.5: 725 | resolution: {integrity: sha512-MdjglKR6AQXQb9JGiS7Rc2wC6uMjcm7Go/NHNO63EwiJXfuk9PgqiP/n5IDJCziMkfw9n4Ubp7lttNwz+8ZVKA==} 726 | engines: {node: ^18.0.0 || >=20.0.0} 727 | hasBin: true 728 | peerDependencies: 729 | '@types/node': ^18.0.0 || >=20.0.0 730 | less: '*' 731 | lightningcss: ^1.21.0 732 | sass: '*' 733 | stylus: '*' 734 | sugarss: '*' 735 | terser: ^5.4.0 736 | peerDependenciesMeta: 737 | '@types/node': 738 | optional: true 739 | less: 740 | optional: true 741 | lightningcss: 742 | optional: true 743 | sass: 744 | optional: true 745 | stylus: 746 | optional: true 747 | sugarss: 748 | optional: true 749 | terser: 750 | optional: true 751 | 752 | vitest@2.0.4: 753 | resolution: {integrity: sha512-luNLDpfsnxw5QSW4bISPe6tkxVvv5wn2BBs/PuDRkhXZ319doZyLOBr1sjfB5yCEpTiU7xCAdViM8TNVGPwoog==} 754 | engines: {node: ^18.0.0 || >=20.0.0} 755 | hasBin: true 756 | peerDependencies: 757 | '@edge-runtime/vm': '*' 758 | '@types/node': ^18.0.0 || >=20.0.0 759 | '@vitest/browser': 2.0.4 760 | '@vitest/ui': 2.0.4 761 | happy-dom: '*' 762 | jsdom: '*' 763 | peerDependenciesMeta: 764 | '@edge-runtime/vm': 765 | optional: true 766 | '@types/node': 767 | optional: true 768 | '@vitest/browser': 769 | optional: true 770 | '@vitest/ui': 771 | optional: true 772 | happy-dom: 773 | optional: true 774 | jsdom: 775 | optional: true 776 | 777 | webidl-conversions@3.0.1: 778 | resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} 779 | 780 | whatwg-url@5.0.0: 781 | resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} 782 | 783 | which@2.0.2: 784 | resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} 785 | engines: {node: '>= 8'} 786 | hasBin: true 787 | 788 | why-is-node-running@2.3.0: 789 | resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} 790 | engines: {node: '>=8'} 791 | hasBin: true 792 | 793 | xml2js@0.5.0: 794 | resolution: {integrity: sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==} 795 | engines: {node: '>=4.0.0'} 796 | 797 | xmlbuilder@11.0.1: 798 | resolution: {integrity: sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==} 799 | engines: {node: '>=4.0'} 800 | 801 | snapshots: 802 | 803 | '@actions/cache@3.2.4': 804 | dependencies: 805 | '@actions/core': 1.10.1 806 | '@actions/exec': 1.1.1 807 | '@actions/glob': 0.1.2 808 | '@actions/http-client': 2.2.1 809 | '@actions/io': 1.1.3 810 | '@azure/abort-controller': 1.1.0 811 | '@azure/ms-rest-js': 2.7.0 812 | '@azure/storage-blob': 12.24.0 813 | semver: 6.3.1 814 | uuid: 3.4.0 815 | transitivePeerDependencies: 816 | - encoding 817 | - supports-color 818 | 819 | '@actions/core@1.10.1': 820 | dependencies: 821 | '@actions/http-client': 2.2.1 822 | uuid: 8.3.2 823 | 824 | '@actions/exec@1.1.1': 825 | dependencies: 826 | '@actions/io': 1.1.3 827 | 828 | '@actions/glob@0.1.2': 829 | dependencies: 830 | '@actions/core': 1.10.1 831 | minimatch: 3.1.2 832 | 833 | '@actions/http-client@2.2.1': 834 | dependencies: 835 | tunnel: 0.0.6 836 | undici: 5.28.4 837 | 838 | '@actions/io@1.1.3': {} 839 | 840 | '@ampproject/remapping@2.3.0': 841 | dependencies: 842 | '@jridgewell/gen-mapping': 0.3.5 843 | '@jridgewell/trace-mapping': 0.3.25 844 | 845 | '@azure/abort-controller@1.1.0': 846 | dependencies: 847 | tslib: 2.6.3 848 | 849 | '@azure/abort-controller@2.1.2': 850 | dependencies: 851 | tslib: 2.6.3 852 | 853 | '@azure/core-auth@1.7.2': 854 | dependencies: 855 | '@azure/abort-controller': 2.1.2 856 | '@azure/core-util': 1.9.1 857 | tslib: 2.6.3 858 | 859 | '@azure/core-client@1.9.2': 860 | dependencies: 861 | '@azure/abort-controller': 2.1.2 862 | '@azure/core-auth': 1.7.2 863 | '@azure/core-rest-pipeline': 1.16.2 864 | '@azure/core-tracing': 1.1.2 865 | '@azure/core-util': 1.9.1 866 | '@azure/logger': 1.1.3 867 | tslib: 2.6.3 868 | transitivePeerDependencies: 869 | - supports-color 870 | 871 | '@azure/core-http-compat@2.1.2': 872 | dependencies: 873 | '@azure/abort-controller': 2.1.2 874 | '@azure/core-client': 1.9.2 875 | '@azure/core-rest-pipeline': 1.16.2 876 | transitivePeerDependencies: 877 | - supports-color 878 | 879 | '@azure/core-lro@2.7.2': 880 | dependencies: 881 | '@azure/abort-controller': 2.1.2 882 | '@azure/core-util': 1.9.1 883 | '@azure/logger': 1.1.3 884 | tslib: 2.6.3 885 | 886 | '@azure/core-paging@1.6.2': 887 | dependencies: 888 | tslib: 2.6.3 889 | 890 | '@azure/core-rest-pipeline@1.16.2': 891 | dependencies: 892 | '@azure/abort-controller': 2.1.2 893 | '@azure/core-auth': 1.7.2 894 | '@azure/core-tracing': 1.1.2 895 | '@azure/core-util': 1.9.1 896 | '@azure/logger': 1.1.3 897 | http-proxy-agent: 7.0.2 898 | https-proxy-agent: 7.0.5 899 | tslib: 2.6.3 900 | transitivePeerDependencies: 901 | - supports-color 902 | 903 | '@azure/core-tracing@1.1.2': 904 | dependencies: 905 | tslib: 2.6.3 906 | 907 | '@azure/core-util@1.9.1': 908 | dependencies: 909 | '@azure/abort-controller': 2.1.2 910 | tslib: 2.6.3 911 | 912 | '@azure/core-xml@1.4.2': 913 | dependencies: 914 | fast-xml-parser: 4.4.0 915 | tslib: 2.6.3 916 | 917 | '@azure/logger@1.1.3': 918 | dependencies: 919 | tslib: 2.6.3 920 | 921 | '@azure/ms-rest-js@2.7.0': 922 | dependencies: 923 | '@azure/core-auth': 1.7.2 924 | abort-controller: 3.0.0 925 | form-data: 2.5.1 926 | node-fetch: 2.7.0 927 | tslib: 1.14.1 928 | tunnel: 0.0.6 929 | uuid: 8.3.2 930 | xml2js: 0.5.0 931 | transitivePeerDependencies: 932 | - encoding 933 | 934 | '@azure/storage-blob@12.24.0': 935 | dependencies: 936 | '@azure/abort-controller': 1.1.0 937 | '@azure/core-auth': 1.7.2 938 | '@azure/core-client': 1.9.2 939 | '@azure/core-http-compat': 2.1.2 940 | '@azure/core-lro': 2.7.2 941 | '@azure/core-paging': 1.6.2 942 | '@azure/core-rest-pipeline': 1.16.2 943 | '@azure/core-tracing': 1.1.2 944 | '@azure/core-util': 1.9.1 945 | '@azure/core-xml': 1.4.2 946 | '@azure/logger': 1.1.3 947 | events: 3.3.0 948 | tslib: 2.6.3 949 | transitivePeerDependencies: 950 | - supports-color 951 | 952 | '@esbuild/aix-ppc64@0.21.5': 953 | optional: true 954 | 955 | '@esbuild/android-arm64@0.21.5': 956 | optional: true 957 | 958 | '@esbuild/android-arm@0.21.5': 959 | optional: true 960 | 961 | '@esbuild/android-x64@0.21.5': 962 | optional: true 963 | 964 | '@esbuild/darwin-arm64@0.21.5': 965 | optional: true 966 | 967 | '@esbuild/darwin-x64@0.21.5': 968 | optional: true 969 | 970 | '@esbuild/freebsd-arm64@0.21.5': 971 | optional: true 972 | 973 | '@esbuild/freebsd-x64@0.21.5': 974 | optional: true 975 | 976 | '@esbuild/linux-arm64@0.21.5': 977 | optional: true 978 | 979 | '@esbuild/linux-arm@0.21.5': 980 | optional: true 981 | 982 | '@esbuild/linux-ia32@0.21.5': 983 | optional: true 984 | 985 | '@esbuild/linux-loong64@0.21.5': 986 | optional: true 987 | 988 | '@esbuild/linux-mips64el@0.21.5': 989 | optional: true 990 | 991 | '@esbuild/linux-ppc64@0.21.5': 992 | optional: true 993 | 994 | '@esbuild/linux-riscv64@0.21.5': 995 | optional: true 996 | 997 | '@esbuild/linux-s390x@0.21.5': 998 | optional: true 999 | 1000 | '@esbuild/linux-x64@0.21.5': 1001 | optional: true 1002 | 1003 | '@esbuild/netbsd-x64@0.21.5': 1004 | optional: true 1005 | 1006 | '@esbuild/openbsd-x64@0.21.5': 1007 | optional: true 1008 | 1009 | '@esbuild/sunos-x64@0.21.5': 1010 | optional: true 1011 | 1012 | '@esbuild/win32-arm64@0.21.5': 1013 | optional: true 1014 | 1015 | '@esbuild/win32-ia32@0.21.5': 1016 | optional: true 1017 | 1018 | '@esbuild/win32-x64@0.21.5': 1019 | optional: true 1020 | 1021 | '@fastify/busboy@2.1.1': {} 1022 | 1023 | '@iarna/toml@2.2.5': {} 1024 | 1025 | '@jridgewell/gen-mapping@0.3.5': 1026 | dependencies: 1027 | '@jridgewell/set-array': 1.2.1 1028 | '@jridgewell/sourcemap-codec': 1.5.0 1029 | '@jridgewell/trace-mapping': 0.3.25 1030 | 1031 | '@jridgewell/resolve-uri@3.1.2': {} 1032 | 1033 | '@jridgewell/set-array@1.2.1': {} 1034 | 1035 | '@jridgewell/sourcemap-codec@1.5.0': {} 1036 | 1037 | '@jridgewell/trace-mapping@0.3.25': 1038 | dependencies: 1039 | '@jridgewell/resolve-uri': 3.1.2 1040 | '@jridgewell/sourcemap-codec': 1.5.0 1041 | 1042 | '@rollup/rollup-android-arm-eabi@4.19.0': 1043 | optional: true 1044 | 1045 | '@rollup/rollup-android-arm64@4.19.0': 1046 | optional: true 1047 | 1048 | '@rollup/rollup-darwin-arm64@4.19.0': 1049 | optional: true 1050 | 1051 | '@rollup/rollup-darwin-x64@4.19.0': 1052 | optional: true 1053 | 1054 | '@rollup/rollup-linux-arm-gnueabihf@4.19.0': 1055 | optional: true 1056 | 1057 | '@rollup/rollup-linux-arm-musleabihf@4.19.0': 1058 | optional: true 1059 | 1060 | '@rollup/rollup-linux-arm64-gnu@4.19.0': 1061 | optional: true 1062 | 1063 | '@rollup/rollup-linux-arm64-musl@4.19.0': 1064 | optional: true 1065 | 1066 | '@rollup/rollup-linux-powerpc64le-gnu@4.19.0': 1067 | optional: true 1068 | 1069 | '@rollup/rollup-linux-riscv64-gnu@4.19.0': 1070 | optional: true 1071 | 1072 | '@rollup/rollup-linux-s390x-gnu@4.19.0': 1073 | optional: true 1074 | 1075 | '@rollup/rollup-linux-x64-gnu@4.19.0': 1076 | optional: true 1077 | 1078 | '@rollup/rollup-linux-x64-musl@4.19.0': 1079 | optional: true 1080 | 1081 | '@rollup/rollup-win32-arm64-msvc@4.19.0': 1082 | optional: true 1083 | 1084 | '@rollup/rollup-win32-ia32-msvc@4.19.0': 1085 | optional: true 1086 | 1087 | '@rollup/rollup-win32-x64-msvc@4.19.0': 1088 | optional: true 1089 | 1090 | '@types/estree@1.0.5': {} 1091 | 1092 | '@types/folder-hash@4.0.4': {} 1093 | 1094 | '@types/fs-extra@11.0.4': 1095 | dependencies: 1096 | '@types/jsonfile': 6.1.4 1097 | '@types/node': 20.14.12 1098 | 1099 | '@types/jsonfile@6.1.4': 1100 | dependencies: 1101 | '@types/node': 20.14.12 1102 | 1103 | '@types/node@20.14.12': 1104 | dependencies: 1105 | undici-types: 5.26.5 1106 | 1107 | '@vitest/expect@2.0.4': 1108 | dependencies: 1109 | '@vitest/spy': 2.0.4 1110 | '@vitest/utils': 2.0.4 1111 | chai: 5.1.1 1112 | tinyrainbow: 1.2.0 1113 | 1114 | '@vitest/pretty-format@2.0.4': 1115 | dependencies: 1116 | tinyrainbow: 1.2.0 1117 | 1118 | '@vitest/runner@2.0.4': 1119 | dependencies: 1120 | '@vitest/utils': 2.0.4 1121 | pathe: 1.1.2 1122 | 1123 | '@vitest/snapshot@2.0.4': 1124 | dependencies: 1125 | '@vitest/pretty-format': 2.0.4 1126 | magic-string: 0.30.10 1127 | pathe: 1.1.2 1128 | 1129 | '@vitest/spy@2.0.4': 1130 | dependencies: 1131 | tinyspy: 3.0.0 1132 | 1133 | '@vitest/utils@2.0.4': 1134 | dependencies: 1135 | '@vitest/pretty-format': 2.0.4 1136 | estree-walker: 3.0.3 1137 | loupe: 3.1.1 1138 | tinyrainbow: 1.2.0 1139 | 1140 | '@xmorse/deployment-utils@0.1.10': 1141 | dependencies: 1142 | '@actions/cache': 3.2.4 1143 | '@iarna/toml': 2.2.5 1144 | '@types/folder-hash': 4.0.4 1145 | async-sema: 3.1.1 1146 | folder-hash: 4.0.4 1147 | fs-extra: 10.1.0 1148 | picocolors: 1.0.1 1149 | tempfile: 4.0.0 1150 | transitivePeerDependencies: 1151 | - encoding 1152 | - supports-color 1153 | 1154 | abort-controller@3.0.0: 1155 | dependencies: 1156 | event-target-shim: 5.0.1 1157 | 1158 | agent-base@7.1.1: 1159 | dependencies: 1160 | debug: 4.3.5 1161 | transitivePeerDependencies: 1162 | - supports-color 1163 | 1164 | assertion-error@2.0.1: {} 1165 | 1166 | async-sema@3.1.1: {} 1167 | 1168 | asynckit@0.4.0: {} 1169 | 1170 | balanced-match@1.0.2: {} 1171 | 1172 | brace-expansion@1.1.11: 1173 | dependencies: 1174 | balanced-match: 1.0.2 1175 | concat-map: 0.0.1 1176 | 1177 | brace-expansion@2.0.1: 1178 | dependencies: 1179 | balanced-match: 1.0.2 1180 | 1181 | cac@6.7.14: {} 1182 | 1183 | chai@5.1.1: 1184 | dependencies: 1185 | assertion-error: 2.0.1 1186 | check-error: 2.1.1 1187 | deep-eql: 5.0.2 1188 | loupe: 3.1.1 1189 | pathval: 2.0.0 1190 | 1191 | check-error@2.1.1: {} 1192 | 1193 | combined-stream@1.0.8: 1194 | dependencies: 1195 | delayed-stream: 1.0.0 1196 | 1197 | concat-map@0.0.1: {} 1198 | 1199 | cross-spawn@7.0.3: 1200 | dependencies: 1201 | path-key: 3.1.1 1202 | shebang-command: 2.0.0 1203 | which: 2.0.2 1204 | 1205 | debug@4.3.5: 1206 | dependencies: 1207 | ms: 2.1.2 1208 | 1209 | deep-eql@5.0.2: {} 1210 | 1211 | delayed-stream@1.0.0: {} 1212 | 1213 | esbuild@0.21.5: 1214 | optionalDependencies: 1215 | '@esbuild/aix-ppc64': 0.21.5 1216 | '@esbuild/android-arm': 0.21.5 1217 | '@esbuild/android-arm64': 0.21.5 1218 | '@esbuild/android-x64': 0.21.5 1219 | '@esbuild/darwin-arm64': 0.21.5 1220 | '@esbuild/darwin-x64': 0.21.5 1221 | '@esbuild/freebsd-arm64': 0.21.5 1222 | '@esbuild/freebsd-x64': 0.21.5 1223 | '@esbuild/linux-arm': 0.21.5 1224 | '@esbuild/linux-arm64': 0.21.5 1225 | '@esbuild/linux-ia32': 0.21.5 1226 | '@esbuild/linux-loong64': 0.21.5 1227 | '@esbuild/linux-mips64el': 0.21.5 1228 | '@esbuild/linux-ppc64': 0.21.5 1229 | '@esbuild/linux-riscv64': 0.21.5 1230 | '@esbuild/linux-s390x': 0.21.5 1231 | '@esbuild/linux-x64': 0.21.5 1232 | '@esbuild/netbsd-x64': 0.21.5 1233 | '@esbuild/openbsd-x64': 0.21.5 1234 | '@esbuild/sunos-x64': 0.21.5 1235 | '@esbuild/win32-arm64': 0.21.5 1236 | '@esbuild/win32-ia32': 0.21.5 1237 | '@esbuild/win32-x64': 0.21.5 1238 | 1239 | estree-walker@3.0.3: 1240 | dependencies: 1241 | '@types/estree': 1.0.5 1242 | 1243 | event-target-shim@5.0.1: {} 1244 | 1245 | events@3.3.0: {} 1246 | 1247 | execa@8.0.1: 1248 | dependencies: 1249 | cross-spawn: 7.0.3 1250 | get-stream: 8.0.1 1251 | human-signals: 5.0.0 1252 | is-stream: 3.0.0 1253 | merge-stream: 2.0.0 1254 | npm-run-path: 5.3.0 1255 | onetime: 6.0.0 1256 | signal-exit: 4.1.0 1257 | strip-final-newline: 3.0.0 1258 | 1259 | fast-xml-parser@4.4.0: 1260 | dependencies: 1261 | strnum: 1.0.5 1262 | 1263 | folder-hash@4.0.4: 1264 | dependencies: 1265 | debug: 4.3.5 1266 | minimatch: 5.1.6 1267 | transitivePeerDependencies: 1268 | - supports-color 1269 | 1270 | form-data@2.5.1: 1271 | dependencies: 1272 | asynckit: 0.4.0 1273 | combined-stream: 1.0.8 1274 | mime-types: 2.1.35 1275 | 1276 | fs-extra@10.1.0: 1277 | dependencies: 1278 | graceful-fs: 4.2.11 1279 | jsonfile: 6.1.0 1280 | universalify: 2.0.1 1281 | 1282 | fs-extra@11.2.0: 1283 | dependencies: 1284 | graceful-fs: 4.2.11 1285 | jsonfile: 6.1.0 1286 | universalify: 2.0.1 1287 | 1288 | fsevents@2.3.3: 1289 | optional: true 1290 | 1291 | get-func-name@2.0.2: {} 1292 | 1293 | get-stream@8.0.1: {} 1294 | 1295 | graceful-fs@4.2.11: {} 1296 | 1297 | htmlrewriter@0.0.7: {} 1298 | 1299 | http-proxy-agent@7.0.2: 1300 | dependencies: 1301 | agent-base: 7.1.1 1302 | debug: 4.3.5 1303 | transitivePeerDependencies: 1304 | - supports-color 1305 | 1306 | https-proxy-agent@7.0.5: 1307 | dependencies: 1308 | agent-base: 7.1.1 1309 | debug: 4.3.5 1310 | transitivePeerDependencies: 1311 | - supports-color 1312 | 1313 | human-signals@5.0.0: {} 1314 | 1315 | is-stream@3.0.0: {} 1316 | 1317 | isexe@2.0.0: {} 1318 | 1319 | jsonfile@6.1.0: 1320 | dependencies: 1321 | universalify: 2.0.1 1322 | optionalDependencies: 1323 | graceful-fs: 4.2.11 1324 | 1325 | loupe@3.1.1: 1326 | dependencies: 1327 | get-func-name: 2.0.2 1328 | 1329 | magic-string@0.30.10: 1330 | dependencies: 1331 | '@jridgewell/sourcemap-codec': 1.5.0 1332 | 1333 | merge-stream@2.0.0: {} 1334 | 1335 | mime-db@1.52.0: {} 1336 | 1337 | mime-types@2.1.35: 1338 | dependencies: 1339 | mime-db: 1.52.0 1340 | 1341 | mimic-fn@4.0.0: {} 1342 | 1343 | minimatch@3.1.2: 1344 | dependencies: 1345 | brace-expansion: 1.1.11 1346 | 1347 | minimatch@5.1.6: 1348 | dependencies: 1349 | brace-expansion: 2.0.1 1350 | 1351 | ms@2.1.2: {} 1352 | 1353 | nanoid@3.3.7: {} 1354 | 1355 | node-fetch@2.7.0: 1356 | dependencies: 1357 | whatwg-url: 5.0.0 1358 | 1359 | npm-run-path@5.3.0: 1360 | dependencies: 1361 | path-key: 4.0.0 1362 | 1363 | onetime@6.0.0: 1364 | dependencies: 1365 | mimic-fn: 4.0.0 1366 | 1367 | path-key@3.1.1: {} 1368 | 1369 | path-key@4.0.0: {} 1370 | 1371 | pathe@1.1.2: {} 1372 | 1373 | pathval@2.0.0: {} 1374 | 1375 | picocolors@1.0.1: {} 1376 | 1377 | postcss@8.4.40: 1378 | dependencies: 1379 | nanoid: 3.3.7 1380 | picocolors: 1.0.1 1381 | source-map-js: 1.2.0 1382 | 1383 | prettier@2.8.8: {} 1384 | 1385 | rollup@4.19.0: 1386 | dependencies: 1387 | '@types/estree': 1.0.5 1388 | optionalDependencies: 1389 | '@rollup/rollup-android-arm-eabi': 4.19.0 1390 | '@rollup/rollup-android-arm64': 4.19.0 1391 | '@rollup/rollup-darwin-arm64': 4.19.0 1392 | '@rollup/rollup-darwin-x64': 4.19.0 1393 | '@rollup/rollup-linux-arm-gnueabihf': 4.19.0 1394 | '@rollup/rollup-linux-arm-musleabihf': 4.19.0 1395 | '@rollup/rollup-linux-arm64-gnu': 4.19.0 1396 | '@rollup/rollup-linux-arm64-musl': 4.19.0 1397 | '@rollup/rollup-linux-powerpc64le-gnu': 4.19.0 1398 | '@rollup/rollup-linux-riscv64-gnu': 4.19.0 1399 | '@rollup/rollup-linux-s390x-gnu': 4.19.0 1400 | '@rollup/rollup-linux-x64-gnu': 4.19.0 1401 | '@rollup/rollup-linux-x64-musl': 4.19.0 1402 | '@rollup/rollup-win32-arm64-msvc': 4.19.0 1403 | '@rollup/rollup-win32-ia32-msvc': 4.19.0 1404 | '@rollup/rollup-win32-x64-msvc': 4.19.0 1405 | fsevents: 2.3.3 1406 | 1407 | sax@1.4.1: {} 1408 | 1409 | semver@6.3.1: {} 1410 | 1411 | shebang-command@2.0.0: 1412 | dependencies: 1413 | shebang-regex: 3.0.0 1414 | 1415 | shebang-regex@3.0.0: {} 1416 | 1417 | siginfo@2.0.0: {} 1418 | 1419 | signal-exit@4.1.0: {} 1420 | 1421 | source-map-js@1.2.0: {} 1422 | 1423 | stackback@0.0.2: {} 1424 | 1425 | std-env@3.7.0: {} 1426 | 1427 | strip-final-newline@3.0.0: {} 1428 | 1429 | strnum@1.0.5: {} 1430 | 1431 | temp-dir@2.0.0: {} 1432 | 1433 | tempfile@4.0.0: 1434 | dependencies: 1435 | temp-dir: 2.0.0 1436 | uuid: 8.3.2 1437 | 1438 | tinybench@2.8.0: {} 1439 | 1440 | tinypool@1.0.0: {} 1441 | 1442 | tinyrainbow@1.2.0: {} 1443 | 1444 | tinyspy@3.0.0: {} 1445 | 1446 | tr46@0.0.3: {} 1447 | 1448 | tslib@1.14.1: {} 1449 | 1450 | tslib@2.6.3: {} 1451 | 1452 | tunnel@0.0.6: {} 1453 | 1454 | undici-types@5.26.5: {} 1455 | 1456 | undici@5.28.4: 1457 | dependencies: 1458 | '@fastify/busboy': 2.1.1 1459 | 1460 | universalify@2.0.1: {} 1461 | 1462 | uuid@3.4.0: {} 1463 | 1464 | uuid@8.3.2: {} 1465 | 1466 | vite-node@2.0.4(@types/node@20.14.12): 1467 | dependencies: 1468 | cac: 6.7.14 1469 | debug: 4.3.5 1470 | pathe: 1.1.2 1471 | tinyrainbow: 1.2.0 1472 | vite: 5.3.5(@types/node@20.14.12) 1473 | transitivePeerDependencies: 1474 | - '@types/node' 1475 | - less 1476 | - lightningcss 1477 | - sass 1478 | - stylus 1479 | - sugarss 1480 | - supports-color 1481 | - terser 1482 | 1483 | vite@5.3.5(@types/node@20.14.12): 1484 | dependencies: 1485 | esbuild: 0.21.5 1486 | postcss: 8.4.40 1487 | rollup: 4.19.0 1488 | optionalDependencies: 1489 | '@types/node': 20.14.12 1490 | fsevents: 2.3.3 1491 | 1492 | vitest@2.0.4(@types/node@20.14.12): 1493 | dependencies: 1494 | '@ampproject/remapping': 2.3.0 1495 | '@vitest/expect': 2.0.4 1496 | '@vitest/pretty-format': 2.0.4 1497 | '@vitest/runner': 2.0.4 1498 | '@vitest/snapshot': 2.0.4 1499 | '@vitest/spy': 2.0.4 1500 | '@vitest/utils': 2.0.4 1501 | chai: 5.1.1 1502 | debug: 4.3.5 1503 | execa: 8.0.1 1504 | magic-string: 0.30.10 1505 | pathe: 1.1.2 1506 | std-env: 3.7.0 1507 | tinybench: 2.8.0 1508 | tinypool: 1.0.0 1509 | tinyrainbow: 1.2.0 1510 | vite: 5.3.5(@types/node@20.14.12) 1511 | vite-node: 2.0.4(@types/node@20.14.12) 1512 | why-is-node-running: 2.3.0 1513 | optionalDependencies: 1514 | '@types/node': 20.14.12 1515 | transitivePeerDependencies: 1516 | - less 1517 | - lightningcss 1518 | - sass 1519 | - stylus 1520 | - sugarss 1521 | - supports-color 1522 | - terser 1523 | 1524 | webidl-conversions@3.0.1: {} 1525 | 1526 | whatwg-url@5.0.0: 1527 | dependencies: 1528 | tr46: 0.0.3 1529 | webidl-conversions: 3.0.1 1530 | 1531 | which@2.0.2: 1532 | dependencies: 1533 | isexe: 2.0.0 1534 | 1535 | why-is-node-running@2.3.0: 1536 | dependencies: 1537 | siginfo: 2.0.0 1538 | stackback: 0.0.2 1539 | 1540 | xml2js@0.5.0: 1541 | dependencies: 1542 | sax: 1.4.1 1543 | xmlbuilder: 11.0.1 1544 | 1545 | xmlbuilder@11.0.1: {} 1546 | -------------------------------------------------------------------------------- /scripts/build.ts: -------------------------------------------------------------------------------- 1 | import { callMain, shell } from '@xmorse/deployment-utils' 2 | import path from 'path' 3 | import fs from 'fs-extra' 4 | 5 | async function main() { 6 | await fs.rm(`dist`, { recursive: true, force: true }) 7 | await shell(`wasm-pack build --target web`) 8 | // await shell(`wasm-pack build --target nodejs --out-dir node`) 9 | await fs.mkdirSync(`dist`, { recursive: true }) 10 | await fs.copy(`pkg`, `dist`, { 11 | filter(p) { 12 | return ( 13 | !p.endsWith('package.json') && 14 | !p.endsWith('gitignore') && 15 | !p.endsWith('README.md') 16 | ) 17 | }, 18 | }) 19 | await fs.copy(`src`, `dist`, { 20 | filter(p) { 21 | // console.log(p) 22 | return !path.extname(p) || p.endsWith('.d.ts') 23 | }, 24 | }) 25 | await shell(`pnpm tsc `) 26 | await fs.copy(`src/asyncify.js`, `dist/asyncify.js`, {}) 27 | 28 | // createa a file base64.js that exports the wasm as a base64 string 29 | // await fs.writeFile( 30 | // `dist/base64.wasm.js`, 31 | // `export default "${await fs.readFile( 32 | // `dist/html_rewriter_bg.wasm`, 33 | // { 34 | // encoding: 'base64', 35 | // }, 36 | // )}"`, 37 | // ) 38 | } 39 | 40 | main() 41 | -------------------------------------------------------------------------------- /scripts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /scripts/try.js: -------------------------------------------------------------------------------- 1 | import { HTMLRewriter } from 'htmlrewriter' 2 | 3 | const rewriter = new HTMLRewriter() 4 | 5 | async function main() { 6 | rewriter.on('a', { 7 | element(element) { 8 | element.setAttribute('href', 'https://www.baidu.com') 9 | }, 10 | }) 11 | const res = await rewriter.transform( 12 | new Response('google'), 13 | ) 14 | console.log(await res.text()) 15 | } 16 | 17 | main() 18 | -------------------------------------------------------------------------------- /src/asyncify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef {object} WasmExports 3 | * @property {WebAssembly.Memory} memory 4 | * @property {function} asyncify_get_state 5 | * @property {function} asyncify_start_unwind 6 | * @property {function} asyncify_stop_unwind 7 | * @property {function} asyncify_start_rewind 8 | * @property {function} asyncify_stop_rewind 9 | */ 10 | 11 | /** 12 | * @type {WasmExports} 13 | */ 14 | let wasm 15 | 16 | /** 17 | * @param {WasmExports} wasmExports 18 | */ 19 | function setWasmExports(wasmExports) { 20 | wasm = wasmExports 21 | } 22 | 23 | /** 24 | * @type {Int32Array} 25 | */ 26 | let cachedInt32Memory = null 27 | 28 | /** 29 | * @returns {Int32Array} 30 | */ 31 | function getInt32Memory() { 32 | if ( 33 | cachedInt32Memory === null || 34 | cachedInt32Memory.buffer !== wasm.memory.buffer 35 | ) { 36 | cachedInt32Memory = new Int32Array(wasm.memory.buffer) 37 | } 38 | return cachedInt32Memory 39 | } 40 | 41 | // https://github.com/WebAssembly/binaryen/blob/fb9de9d391a7272548dcc41cd8229076189d7398/src/passes/Asyncify.cpp#L99 42 | const State = { 43 | NONE: 0, 44 | UNWINDING: 1, 45 | REWINDING: 2, 46 | } 47 | 48 | function assertStrictEqual(actual, expected) { 49 | if (actual !== expected) { 50 | throw new Error(`Expected ${actual} to equal ${expected}`) 51 | } 52 | } 53 | 54 | function assert(condition) { 55 | if (!condition) { 56 | throw new Error('Assertion failed') 57 | } 58 | } 59 | 60 | function assertNoneState() { 61 | assertStrictEqual(wasm.asyncify_get_state(), State.NONE) 62 | } 63 | 64 | /** 65 | * Maps `HTMLRewriter`s (their `asyncifyStackPtr`s) to `Promise`s. 66 | * `asyncifyStackPtr` acts as unique reference to `HTMLRewriter`. 67 | * Each rewriter MUST have AT MOST ONE pending promise at any time. 68 | * @type {Map} 69 | */ 70 | const promises = new Map() 71 | 72 | /** 73 | * @param {number} stackPtr 74 | * @param {Promise} promise 75 | */ 76 | function awaitPromise(stackPtr, promise) { 77 | if (wasm.asyncify_get_state() === State.REWINDING) { 78 | wasm.asyncify_stop_rewind() 79 | return 80 | } 81 | 82 | assertNoneState() 83 | 84 | // https://github.com/WebAssembly/binaryen/blob/fb9de9d391a7272548dcc41cd8229076189d7398/src/passes/Asyncify.cpp#L106 85 | assertStrictEqual(stackPtr % 4, 0) 86 | getInt32Memory().set([stackPtr + 8, stackPtr + 1024], stackPtr / 4) 87 | 88 | wasm.asyncify_start_unwind(stackPtr) 89 | 90 | assert(!promises.has(stackPtr)) 91 | promises.set(stackPtr, promise) 92 | } 93 | 94 | /** 95 | * @param {HTMLRewriter} rewriter 96 | * @param {Function} fn 97 | * @param args 98 | */ 99 | async function wrap(rewriter, fn, ...args) { 100 | const stackPtr = rewriter.asyncifyStackPtr 101 | 102 | assertNoneState() 103 | let result = fn(...args) 104 | 105 | while (wasm.asyncify_get_state() === State.UNWINDING) { 106 | wasm.asyncify_stop_unwind() 107 | 108 | assertNoneState() 109 | assert(promises.has(stackPtr)) 110 | await promises.get(stackPtr) 111 | promises.delete(stackPtr) 112 | 113 | assertNoneState() 114 | wasm.asyncify_start_rewind(stackPtr) 115 | result = fn() 116 | } 117 | 118 | assertNoneState() 119 | return result 120 | } 121 | 122 | export { awaitPromise, setWasmExports, wrap } 123 | -------------------------------------------------------------------------------- /src/comment.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use lol_html::html_content::Comment as NativeComment; 3 | 4 | #[wasm_bindgen] 5 | pub struct Comment(NativeRefWrap>); 6 | 7 | impl_from_native!(NativeComment --> Comment); 8 | impl_mutations!(Comment); 9 | 10 | #[wasm_bindgen] 11 | impl Comment { 12 | #[wasm_bindgen(method, getter=text)] 13 | pub fn text(&self) -> JsResult { 14 | self.0.get().map(|c| c.text().into()) 15 | } 16 | 17 | #[wasm_bindgen(method, setter=text)] 18 | pub fn set_text(&mut self, text: &str) -> JsResult<()> { 19 | self.0.get_mut()?.set_text(text).into_js_result() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/doctype.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use lol_html::html_content::Doctype as NativeDoctype; 3 | 4 | #[wasm_bindgen] 5 | pub struct Doctype(NativeRefWrap>); 6 | 7 | impl_from_native!(NativeDoctype --> Doctype); 8 | 9 | #[wasm_bindgen] 10 | impl Doctype { 11 | #[wasm_bindgen(method, getter)] 12 | pub fn name(&self) -> JsResult { 13 | self.0 14 | .get() 15 | .map(|d| d.name().map(JsValue::from).unwrap_or(JsValue::null())) 16 | } 17 | 18 | #[wasm_bindgen(method, getter=publicId)] 19 | pub fn public_id(&self) -> JsResult { 20 | self.0 21 | .get() 22 | .map(|d| d.public_id().map(JsValue::from).unwrap_or(JsValue::null())) 23 | } 24 | 25 | #[wasm_bindgen(method, getter=systemId)] 26 | pub fn system_id(&self) -> JsResult { 27 | self.0 28 | .get() 29 | .map(|d| d.system_id().map(JsValue::from).unwrap_or(JsValue::null())) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/document_end.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use lol_html::html_content::DocumentEnd as NativeDocumentEnd; 3 | 4 | #[wasm_bindgen] 5 | pub struct DocumentEnd(NativeRefWrap>); 6 | 7 | impl_from_native!(NativeDocumentEnd --> DocumentEnd); 8 | 9 | #[wasm_bindgen] 10 | impl DocumentEnd { 11 | pub fn append( 12 | &mut self, 13 | content: &str, 14 | content_type: Option, 15 | ) -> Result<(), JsValue> { 16 | self.0 17 | .get_mut() 18 | .map(|e| e.append(content, content_type.into_native())) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/element.rs: -------------------------------------------------------------------------------- 1 | use super::end_tag::EndTag; 2 | use super::handlers::{await_promise, make_handler, HandlerJsErrorWrap}; 3 | use super::*; 4 | use js_sys::{Function as JsFunction, Promise as JsPromise}; 5 | use lol_html::html_content::Element as NativeElement; 6 | use serde_wasm_bindgen::to_value as to_js_value; 7 | use wasm_bindgen::JsCast; 8 | 9 | #[wasm_bindgen] 10 | pub struct Element(NativeRefWrap>); 11 | 12 | impl_from_native!(NativeElement --> Element); 13 | impl_mutations!(Element); 14 | 15 | #[wasm_bindgen] 16 | impl Element { 17 | #[wasm_bindgen(method, getter=tagName)] 18 | pub fn tag_name(&self) -> JsResult { 19 | self.0.get().map(|e| e.tag_name()) 20 | } 21 | 22 | #[wasm_bindgen(method, setter=tagName)] 23 | pub fn set_tag_name(&mut self, name: &str) -> JsResult<()> { 24 | self.0.get_mut()?.set_tag_name(name).into_js_result() 25 | } 26 | 27 | #[wasm_bindgen(method, getter=namespaceURI)] 28 | pub fn namespace_uri(&self) -> JsResult { 29 | self.0.get().map(|e| e.namespace_uri().into()) 30 | } 31 | 32 | #[wasm_bindgen(method, getter)] 33 | pub fn attributes(&self) -> JsResult { 34 | self.0 35 | .get() 36 | .map(|e| { 37 | e.attributes() 38 | .iter() 39 | .map(|a| vec![a.name(), a.value()]) 40 | .collect::>() 41 | }) 42 | .and_then(|a| to_js_value(&a).into_js_result()) 43 | } 44 | 45 | #[wasm_bindgen(method, js_name=getAttribute)] 46 | pub fn get_attribute(&self, name: &str) -> JsResult { 47 | self.0.get().map(|e| { 48 | e.get_attribute(name) 49 | .map(JsValue::from) 50 | .unwrap_or(JsValue::null()) 51 | }) 52 | } 53 | 54 | #[wasm_bindgen(method, js_name=hasAttribute)] 55 | pub fn has_attribute(&self, name: &str) -> JsResult { 56 | self.0.get().map(|e| e.has_attribute(name)) 57 | } 58 | 59 | #[wasm_bindgen(method, js_name=setAttribute)] 60 | pub fn set_attribute(&mut self, name: &str, value: &str) -> JsResult<()> { 61 | self.0 62 | .get_mut()? 63 | .set_attribute(name, value) 64 | .into_js_result() 65 | } 66 | 67 | #[wasm_bindgen(method, js_name=removeAttribute)] 68 | pub fn remove_attribute(&mut self, name: &str) -> JsResult<()> { 69 | self.0.get_mut().map(|e| e.remove_attribute(name)) 70 | } 71 | 72 | pub fn prepend( 73 | &mut self, 74 | content: &str, 75 | content_type: Option, 76 | ) -> Result<(), JsValue> { 77 | self.0 78 | .get_mut() 79 | .map(|e| e.prepend(content, content_type.into_native())) 80 | } 81 | 82 | pub fn append( 83 | &mut self, 84 | content: &str, 85 | content_type: Option, 86 | ) -> Result<(), JsValue> { 87 | self.0 88 | .get_mut() 89 | .map(|e| e.append(content, content_type.into_native())) 90 | } 91 | 92 | #[wasm_bindgen(method, js_name=setInnerContent)] 93 | pub fn set_inner_content( 94 | &mut self, 95 | content: &str, 96 | content_type: Option, 97 | ) -> Result<(), JsValue> { 98 | self.0 99 | .get_mut() 100 | .map(|e| e.set_inner_content(content, content_type.into_native())) 101 | } 102 | 103 | #[wasm_bindgen(method, js_name=removeAndKeepContent)] 104 | pub fn remove_and_keep_content(&mut self) -> Result<(), JsValue> { 105 | self.0.get_mut().map(|e| e.remove_and_keep_content()) 106 | } 107 | 108 | #[wasm_bindgen(method, js_name=onEndTag)] 109 | pub fn on_end_tag(&mut self, handler: JsFunction) -> Result<(), JsValue> { 110 | let this = JsValue::NULL; 111 | let stack_ptr = self.0.stack_ptr; 112 | self.0 113 | .get_mut()? 114 | .on_end_tag(make_handler!(handler, EndTag, this, stack_ptr)) 115 | .into_js_result() 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/end_tag.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use lol_html::html_content::EndTag as NativeEndTag; 3 | 4 | #[wasm_bindgen] 5 | pub struct EndTag(NativeRefWrap>); 6 | 7 | impl_from_native!(NativeEndTag --> EndTag); 8 | 9 | #[wasm_bindgen] 10 | impl EndTag { 11 | #[wasm_bindgen(method, getter=name)] 12 | pub fn name(&self) -> JsResult { 13 | self.0.get().map(|e| e.name()) 14 | } 15 | 16 | #[wasm_bindgen(method, setter=name)] 17 | pub fn set_name(&mut self, name: &str) -> JsResult<()> { 18 | self.0.get_mut().map(|e| e.set_name_str(String::from(name))) 19 | } 20 | 21 | pub fn before( 22 | &mut self, 23 | content: &str, 24 | content_type: Option, 25 | ) -> JsResult<()> { 26 | self.0 27 | .get_mut() 28 | .map(|e| e.before(content, content_type.into_native())) 29 | } 30 | 31 | pub fn after( 32 | &mut self, 33 | content: &str, 34 | content_type: Option, 35 | ) -> JsResult<()> { 36 | self.0 37 | .get_mut() 38 | .map(|e| e.after(content, content_type.into_native())) 39 | } 40 | 41 | pub fn remove(&mut self) -> JsResult<()> { 42 | self.0.get_mut().map(|e| e.remove()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/errors.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, it, test } from 'vitest' 2 | import { HTMLRewriter } from 'htmlrewriter' 3 | 4 | test( 5 | 'errors', 6 | async () => { 7 | const abortController = new AbortController() 8 | const res = await fetch('https://framer.com/marketplace', { 9 | signal: abortController.signal, 10 | }) 11 | 12 | const transform = new HTMLRewriter() 13 | .on('a', { 14 | element(element) { 15 | throw new Error('aborted') 16 | }, 17 | }) 18 | .transform(res) 19 | const err = await transform.text().catch((e) => e) 20 | expect(err).toBeInstanceOf(Error) 21 | expect(err.message).toContain('aborted') 22 | }, 23 | 1000 * 10, 24 | ) 25 | test( 26 | 'abort', 27 | async () => { 28 | const abortController = new AbortController() 29 | const res = await fetch('https://framer.com/marketplace', { 30 | signal: abortController.signal, 31 | }) 32 | 33 | const err = await new HTMLRewriter() 34 | .on('a', { 35 | element(e) { 36 | const href = e.getAttribute('href') 37 | // console.log('href', href) 38 | if (href && href.includes('/template/')) { 39 | abortController.abort() 40 | } 41 | }, 42 | }) 43 | .transform(res) 44 | .text() 45 | .catch((e) => e) 46 | 47 | // expect(err).toBeInstanceOf(Error) 48 | // expect(err.message).toContain('aborted') 49 | // console.log(err) 50 | // console.log(err) 51 | }, 52 | 1000 * 10, 53 | ) 54 | test( 55 | 'works', 56 | async () => { 57 | const res = await fetch('https://framer.com', { 58 | headers: { 59 | accept: 'text/html', 60 | }, 61 | }) 62 | 63 | const transform = new HTMLRewriter() 64 | .on('a', { 65 | element(element) { 66 | element.remove() 67 | }, 68 | }) 69 | .transform(res) 70 | const text = await transform.text() 71 | expect(text).toContain(' { 79 | const res = await fetch('https://json.schemastore.org/fly.json', { 80 | headers: { 81 | // accept: 'text/html', 82 | }, 83 | }) 84 | 85 | let resClone = res.clone() 86 | const transform = new HTMLRewriter() 87 | .on('a', { 88 | element(element) {}, 89 | }) 90 | .transform(res) 91 | const text = await transform.text() 92 | // console.log(text) 93 | expect(text).toEqual(await resClone.text()) 94 | }, 95 | 1000 * 10, 96 | ) 97 | 98 | function sleep(ms: number) { 99 | return new Promise((resolve) => setTimeout(resolve, ms)) 100 | } 101 | -------------------------------------------------------------------------------- /src/handlers.rs: -------------------------------------------------------------------------------- 1 | use super::comment::Comment; 2 | use super::doctype::Doctype; 3 | use super::document_end::DocumentEnd; 4 | use super::element::Element; 5 | use super::text_chunk::TextChunk; 6 | use super::*; 7 | use js_sys::{Function as JsFunction, Promise as JsPromise}; 8 | use lol_html::{ 9 | DocumentContentHandlers as NativeDocumentContentHandlers, 10 | ElementContentHandlers as NativeElementContentHandlers, 11 | }; 12 | use std::mem; 13 | use std::rc::Rc; 14 | use thiserror::Error; 15 | use wasm_bindgen::JsCast; 16 | 17 | // NOTE: Display is noop, because we'll unwrap JSValue error when it will be propagated to 18 | // `write()` or `end()`. 19 | #[derive(Error, Debug)] 20 | #[error("JS handler error")] 21 | pub struct HandlerJsErrorWrap(pub JsValue); 22 | // Probably horribly unsafe, but it works™ 23 | unsafe impl Send for HandlerJsErrorWrap {} 24 | unsafe impl Sync for HandlerJsErrorWrap {} 25 | 26 | #[wasm_bindgen(raw_module = "./asyncify.js")] 27 | extern "C" { 28 | #[wasm_bindgen(js_name = awaitPromise)] 29 | pub(crate) fn await_promise(stack_ptr: *mut u8, promise: &JsPromise); 30 | } 31 | 32 | macro_rules! make_handler { 33 | ($handler:ident, $JsArgType:ident, $this:ident, $stack_ptr:ident) => { 34 | move |arg: &mut _| { 35 | let (js_arg, anchor) = $JsArgType::from_native(arg, $stack_ptr); 36 | let js_arg = JsValue::from(js_arg); 37 | 38 | let res = match $handler.call1(&$this, &js_arg) { 39 | Ok(res) => { 40 | if let Some(promise) = res.dyn_ref::() { 41 | await_promise($stack_ptr, promise); 42 | } 43 | Ok(()) 44 | } 45 | Err(e) => Err(HandlerJsErrorWrap(e).into()), 46 | }; 47 | 48 | mem::drop(anchor); 49 | 50 | res 51 | } 52 | }; 53 | } 54 | pub(crate) use make_handler; 55 | 56 | pub trait IntoNativeHandlers { 57 | fn into_native(self, stack_ptr: *mut u8) -> T; 58 | } 59 | 60 | #[wasm_bindgen] 61 | extern "C" { 62 | pub type ElementContentHandlers; 63 | 64 | #[wasm_bindgen(method, getter)] 65 | fn element(this: &ElementContentHandlers) -> Option; 66 | 67 | #[wasm_bindgen(method, getter)] 68 | fn comments(this: &ElementContentHandlers) -> Option; 69 | 70 | #[wasm_bindgen(method, getter)] 71 | fn text(this: &ElementContentHandlers) -> Option; 72 | } 73 | 74 | impl IntoNativeHandlers> for ElementContentHandlers { 75 | fn into_native(self, stack_ptr: *mut u8) -> NativeElementContentHandlers<'static> { 76 | let handlers: Rc = Rc::new((&self).into()); 77 | let mut native = NativeElementContentHandlers::default(); 78 | 79 | if let Some(handler) = self.element() { 80 | let this = Rc::clone(&handlers); 81 | native = native.element(make_handler!(handler, Element, this, stack_ptr)); 82 | } 83 | 84 | if let Some(handler) = self.comments() { 85 | let this = Rc::clone(&handlers); 86 | native = native.comments(make_handler!(handler, Comment, this, stack_ptr)); 87 | } 88 | 89 | if let Some(handler) = self.text() { 90 | let this = Rc::clone(&handlers); 91 | native = native.text(make_handler!(handler, TextChunk, this, stack_ptr)); 92 | } 93 | 94 | native 95 | } 96 | } 97 | 98 | #[wasm_bindgen] 99 | extern "C" { 100 | pub type DocumentContentHandlers; 101 | 102 | #[wasm_bindgen(method, getter)] 103 | fn doctype(this: &DocumentContentHandlers) -> Option; 104 | 105 | #[wasm_bindgen(method, getter)] 106 | fn comments(this: &DocumentContentHandlers) -> Option; 107 | 108 | #[wasm_bindgen(method, getter)] 109 | fn text(this: &DocumentContentHandlers) -> Option; 110 | 111 | #[wasm_bindgen(method, getter)] 112 | fn end(this: &DocumentContentHandlers) -> Option; 113 | } 114 | 115 | impl IntoNativeHandlers> for DocumentContentHandlers { 116 | fn into_native(self, stack_ptr: *mut u8) -> NativeDocumentContentHandlers<'static> { 117 | let handlers: Rc = Rc::new((&self).into()); 118 | let mut native = NativeDocumentContentHandlers::default(); 119 | 120 | if let Some(handler) = self.doctype() { 121 | let this = Rc::clone(&handlers); 122 | native = native.doctype(make_handler!(handler, Doctype, this, stack_ptr)); 123 | } 124 | 125 | if let Some(handler) = self.comments() { 126 | let this = Rc::clone(&handlers); 127 | native = native.comments(make_handler!(handler, Comment, this, stack_ptr)); 128 | } 129 | 130 | if let Some(handler) = self.text() { 131 | let this = Rc::clone(&handlers); 132 | native = native.text(make_handler!(handler, TextChunk, this, stack_ptr)); 133 | } 134 | 135 | if let Some(handler) = self.end() { 136 | let this = Rc::clone(&handlers); 137 | native = native.end(make_handler!(handler, DocumentEnd, this, stack_ptr)); 138 | } 139 | 140 | native 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /src/html_rewriter.rs: -------------------------------------------------------------------------------- 1 | use super::handlers::{ 2 | DocumentContentHandlers, ElementContentHandlers, HandlerJsErrorWrap, IntoNativeHandlers, 3 | }; 4 | use super::*; 5 | use js_sys::{Function as JsFunction, Uint8Array}; 6 | use lol_html::errors::RewritingError; 7 | use lol_html::{ 8 | DocumentContentHandlers as NativeDocumentContentHandlers, 9 | ElementContentHandlers as NativeElementContentHandlers, HtmlRewriter as NativeHTMLRewriter, 10 | OutputSink, Selector, Settings, 11 | }; 12 | use std::borrow::Cow; 13 | 14 | struct JsOutputSink(JsFunction); 15 | 16 | impl JsOutputSink { 17 | fn new(func: &JsFunction) -> Self { 18 | JsOutputSink(func.clone()) 19 | } 20 | } 21 | 22 | impl OutputSink for JsOutputSink { 23 | #[inline] 24 | fn handle_chunk(&mut self, chunk: &[u8]) { 25 | let this = JsValue::NULL; 26 | let chunk = Uint8Array::from(chunk); 27 | 28 | // NOTE: the error is handled in the JS wrapper. 29 | self.0.call1(&this, &chunk).unwrap(); 30 | } 31 | } 32 | 33 | //noinspection RsTypeCheck 34 | fn rewriting_error_to_js(err: RewritingError) -> JsValue { 35 | match err { 36 | RewritingError::ContentHandlerError(err) => err.downcast::().unwrap().0, 37 | _ => JsValue::from(err.to_string()), 38 | } 39 | } 40 | 41 | #[wasm_bindgen] 42 | #[derive(Default)] 43 | pub struct HTMLRewriter { 44 | selectors: Vec, 45 | element_content_handlers: Vec>, 46 | document_content_handlers: Vec>, 47 | output_sink: Option, 48 | inner: Option>, 49 | inner_constructed: bool, 50 | asyncify_stack: Vec, 51 | enable_esi_tags: bool, 52 | } 53 | 54 | #[wasm_bindgen] 55 | extern "C" { 56 | pub type HTMLRewriterOptions; 57 | 58 | #[wasm_bindgen(structural, method, getter, js_name = enableEsiTags)] 59 | pub fn enable_esi_tags(this: &HTMLRewriterOptions) -> Option; 60 | } 61 | 62 | #[wasm_bindgen] 63 | impl HTMLRewriter { 64 | #[wasm_bindgen(constructor)] 65 | pub fn new(output_sink: &JsFunction, options: Option) -> Self { 66 | HTMLRewriter { 67 | output_sink: Some(JsOutputSink::new(output_sink)), 68 | asyncify_stack: vec![0; 1024], 69 | enable_esi_tags: options.and_then(|o| o.enable_esi_tags()).unwrap_or(false), 70 | ..Self::default() 71 | } 72 | } 73 | 74 | fn assert_not_fully_constructed(&self) -> JsResult<()> { 75 | if self.inner_constructed { 76 | Err("Handlers can't be added after write.".into()) 77 | } else { 78 | Ok(()) 79 | } 80 | } 81 | 82 | fn inner_mut(&mut self) -> JsResult<&mut NativeHTMLRewriter<'static, JsOutputSink>> { 83 | Ok(match self.inner { 84 | Some(ref mut inner) => inner, 85 | None => { 86 | let output_sink = self.output_sink.take().unwrap(); 87 | 88 | let settings = Settings { 89 | element_content_handlers: self 90 | .selectors 91 | .drain(..) 92 | .zip(self.element_content_handlers.drain(..)) 93 | .map(|(selector, h)| (Cow::Owned(selector), h)) 94 | .collect(), 95 | 96 | document_content_handlers: self.document_content_handlers.drain(..).collect(), 97 | enable_esi_tags: self.enable_esi_tags, 98 | ..Settings::default() 99 | }; 100 | 101 | let rewriter = NativeHTMLRewriter::new(settings, output_sink); 102 | 103 | self.inner = Some(rewriter); 104 | self.inner_constructed = true; 105 | 106 | self.inner.as_mut().unwrap() 107 | } 108 | }) 109 | } 110 | 111 | pub fn on(&mut self, selector: &str, handlers: ElementContentHandlers) -> JsResult<()> { 112 | self.assert_not_fully_constructed()?; 113 | 114 | let selector = selector.parse::().into_js_result()?; 115 | 116 | self.selectors.push(selector); 117 | let stack_ptr = self.asyncify_stack_ptr(); 118 | self.element_content_handlers 119 | .push(handlers.into_native(stack_ptr)); 120 | 121 | Ok(()) 122 | } 123 | 124 | #[wasm_bindgen(method, js_name=onDocument)] 125 | pub fn on_document(&mut self, handlers: DocumentContentHandlers) -> JsResult<()> { 126 | self.assert_not_fully_constructed()?; 127 | let stack_ptr = self.asyncify_stack_ptr(); 128 | self.document_content_handlers 129 | .push(handlers.into_native(stack_ptr)); 130 | 131 | Ok(()) 132 | } 133 | 134 | pub fn write(&mut self, chunk: &[u8]) -> JsResult<()> { 135 | self.inner_mut()? 136 | .write(chunk) 137 | .map_err(rewriting_error_to_js) 138 | } 139 | 140 | pub fn end(&mut self) -> JsResult<()> { 141 | self.inner_mut()?; 142 | // Rewriter must be constructed by self.inner_mut() 143 | self.inner 144 | .take() 145 | .unwrap() 146 | .end() 147 | .map_err(rewriting_error_to_js) 148 | } 149 | 150 | #[wasm_bindgen(method, getter=asyncifyStackPtr)] 151 | pub fn asyncify_stack_ptr(&mut self) -> *mut u8 { 152 | self.asyncify_stack.as_mut_ptr() 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/html_rewriter_wrapper.ts: -------------------------------------------------------------------------------- 1 | import init, { HTMLRewriter as RawHTMLRewriter } from '../dist/html_rewriter.js' 2 | 3 | import { DocumentHandlers, ElementHandlers } from './types' 4 | const encoder = new TextEncoder() 5 | const decoder = new TextDecoder() 6 | 7 | // console.log(wasm) 8 | 9 | class HTMLRewriter { 10 | static initPromise?: Promise 11 | 12 | constructor(options: any = {}) {} 13 | 14 | elementHandlers: [selector: string, handlers: ElementHandlers][] = [] 15 | documentHandlers: DocumentHandlers[] = [] 16 | 17 | on(selector: string, handlers: ElementHandlers): this { 18 | this.elementHandlers.push([selector, handlers]) 19 | return this 20 | } 21 | 22 | onDocument(handlers: DocumentHandlers): this { 23 | this.documentHandlers.push(handlers) 24 | return this 25 | } 26 | transform(response: Response): Response { 27 | const body = response.body as ReadableStream | null 28 | // HTMLRewriter doesn't run the end handler if the body is null, so it's 29 | // pointless to setup the readable stream. 30 | if (body === null) return new Response(body, response) 31 | 32 | if (response instanceof Response) { 33 | // Make sure we validate chunks are BufferSources and convert them to 34 | // Uint8Arrays as required by the Rust glue code. 35 | response = new Response(response.body, response) 36 | } 37 | 38 | let rewriter: RawHTMLRewriter 39 | const readable = new ReadableStream({ 40 | start: async (controller) => { 41 | // Create a rewriter instance for this transformation that writes its 42 | // output to the transformed response's stream. Note that each 43 | // BaseHTMLRewriter can only be used once. 44 | await HTMLRewriter.initPromise 45 | // console.log('creating rewriter') 46 | rewriter = new RawHTMLRewriter( 47 | (chunk: any) => { 48 | // enqueue will throw on empty chunks 49 | if (chunk.length !== 0) controller.enqueue(chunk) 50 | }, 51 | { enableEsiTags: false }, 52 | ) 53 | // Add all registered handlers 54 | for (const [selector, handlers] of this.elementHandlers) { 55 | rewriter.on(selector, handlers) 56 | } 57 | for (const handlers of this.documentHandlers) { 58 | rewriter.onDocument(handlers) 59 | } 60 | 61 | // Pipe the response body to the rewriter 62 | const reader = body.getReader() 63 | try { 64 | while (true) { 65 | // console.log('reading') 66 | const { done, value } = await reader.read() 67 | if (done) break 68 | rewriter.write(value) 69 | } 70 | 71 | rewriter.end() 72 | } catch (error) { 73 | // rewriter.end() 74 | controller.error(error) 75 | } finally { 76 | rewriter.free() 77 | reader.releaseLock() 78 | controller.close() 79 | } 80 | }, 81 | }) 82 | 83 | // Return a response with the transformed body, copying over headers, etc 84 | const res = new Response(readable, response) 85 | // If Content-Length is set, it's probably going to be wrong, since we're 86 | // rewriting content, so remove it 87 | res.headers.delete('Content-Length') 88 | return res 89 | } 90 | } 91 | 92 | export function HTMLRewriterWrapper(initPromise: Promise) { 93 | HTMLRewriter.initPromise = initPromise 94 | return HTMLRewriter 95 | } 96 | -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | import { HTMLRewriterWrapper } from './html_rewriter_wrapper' 2 | 3 | export const HTMLRewriter: ReturnType 4 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | use js_sys::TypeError; 2 | use lol_html::html_content::ContentType as NativeContentType; 3 | use std::cell::Cell; 4 | use std::convert::Into; 5 | use std::marker::PhantomData; 6 | use std::mem; 7 | use std::ops::Drop; 8 | use std::rc::Rc; 9 | use wasm_bindgen::prelude::*; 10 | 11 | type JsResult = Result; 12 | 13 | struct Anchor<'r> { 14 | poisoned: Rc>, 15 | lifetime: PhantomData<&'r mut ()>, 16 | } 17 | 18 | impl<'r> Anchor<'r> { 19 | pub fn new(poisoned: Rc>) -> Self { 20 | Anchor { 21 | poisoned, 22 | lifetime: PhantomData, 23 | } 24 | } 25 | } 26 | 27 | impl Drop for Anchor<'_> { 28 | fn drop(&mut self) { 29 | self.poisoned.replace(true); 30 | } 31 | } 32 | 33 | // NOTE: wasm_bindgen doesn't allow structures with lifetimes. To workaround that 34 | // we create a wrapper that erases all the lifetime information from the inner reference 35 | // and provides an anchor object that keeps track of the lifetime in the runtime. 36 | // 37 | // When anchor goes out of scope, wrapper becomes poisoned and any attempt to get inner 38 | // object results in exception. 39 | #[derive(Clone)] 40 | struct NativeRefWrap { 41 | inner_ptr: *mut R, 42 | poisoned: Rc>, 43 | stack_ptr: *mut u8, 44 | } 45 | 46 | impl NativeRefWrap { 47 | pub fn wrap(inner: &mut I, stack_ptr: *mut u8) -> (Self, Anchor) { 48 | let wrap = NativeRefWrap { 49 | inner_ptr: unsafe { mem::transmute(inner) }, 50 | poisoned: Rc::new(Cell::new(false)), 51 | stack_ptr, 52 | }; 53 | 54 | let anchor = Anchor::new(Rc::clone(&wrap.poisoned)); 55 | 56 | (wrap, anchor) 57 | } 58 | 59 | fn assert_not_poisoned(&self) -> JsResult<()> { 60 | if self.poisoned.get() { 61 | Err(TypeError::new( 62 | "This content token is no longer valid. Content tokens are only valid during the execution of the relevant content handler.", 63 | ).into()) 64 | } else { 65 | Ok(()) 66 | } 67 | } 68 | 69 | pub fn get(&self) -> JsResult<&R> { 70 | self.assert_not_poisoned()?; 71 | 72 | Ok(unsafe { self.inner_ptr.as_ref() }.unwrap()) 73 | } 74 | 75 | pub fn get_mut(&mut self) -> JsResult<&mut R> { 76 | self.assert_not_poisoned()?; 77 | 78 | Ok(unsafe { self.inner_ptr.as_mut() }.unwrap()) 79 | } 80 | } 81 | 82 | trait IntoJsResult { 83 | fn into_js_result(self) -> JsResult; 84 | } 85 | 86 | impl IntoJsResult for Result { 87 | #[inline] 88 | fn into_js_result(self) -> JsResult { 89 | self.map_err(|e| { 90 | let mut msg = String::from("Parser error: "); 91 | msg.push_str(&e.to_string()); 92 | TypeError::new(&msg).into() 93 | }) 94 | } 95 | } 96 | 97 | trait IntoNative { 98 | fn into_native(self) -> T; 99 | } 100 | 101 | #[wasm_bindgen] 102 | extern "C" { 103 | pub type ContentTypeOptions; 104 | 105 | #[wasm_bindgen(method, getter)] 106 | fn html(this: &ContentTypeOptions) -> Option; 107 | } 108 | 109 | impl IntoNative for Option { 110 | fn into_native(self) -> NativeContentType { 111 | match self { 112 | Some(opts) => match opts.html() { 113 | Some(true) => NativeContentType::Html, 114 | Some(false) => NativeContentType::Text, 115 | None => NativeContentType::Text, 116 | }, 117 | None => NativeContentType::Text, 118 | } 119 | } 120 | } 121 | 122 | macro_rules! impl_mutations { 123 | ($Ty:ident) => { 124 | #[wasm_bindgen] 125 | impl $Ty { 126 | pub fn before( 127 | &mut self, 128 | content: &str, 129 | content_type: Option, 130 | ) -> Result<(), JsValue> { 131 | self.0 132 | .get_mut() 133 | .map(|o| o.before(content, content_type.into_native())) 134 | } 135 | 136 | pub fn after( 137 | &mut self, 138 | content: &str, 139 | content_type: Option, 140 | ) -> Result<(), JsValue> { 141 | self.0 142 | .get_mut() 143 | .map(|o| o.after(content, content_type.into_native())) 144 | } 145 | 146 | pub fn replace( 147 | &mut self, 148 | content: &str, 149 | content_type: Option, 150 | ) -> Result<(), JsValue> { 151 | self.0 152 | .get_mut() 153 | .map(|o| o.replace(content, content_type.into_native())) 154 | } 155 | 156 | pub fn remove(&mut self) -> Result<(), JsValue> { 157 | self.0.get_mut().map(|o| o.remove()) 158 | } 159 | 160 | #[wasm_bindgen(method, getter)] 161 | pub fn removed(&self) -> JsResult { 162 | self.0.get().map(|o| o.removed()) 163 | } 164 | } 165 | }; 166 | } 167 | 168 | macro_rules! impl_from_native { 169 | ($Ty:ident --> $JsTy:ident) => { 170 | impl $JsTy { 171 | pub(crate) fn from_native<'r>( 172 | inner: &'r mut $Ty, 173 | stack_ptr: *mut u8, 174 | ) -> (Self, Anchor<'r>) { 175 | let (ref_wrap, anchor) = NativeRefWrap::wrap(inner, stack_ptr); 176 | 177 | ($JsTy(ref_wrap), anchor) 178 | } 179 | } 180 | }; 181 | } 182 | 183 | mod comment; 184 | mod doctype; 185 | mod document_end; 186 | mod element; 187 | mod end_tag; 188 | mod handlers; 189 | mod html_rewriter; 190 | mod text_chunk; 191 | -------------------------------------------------------------------------------- /src/text_chunk.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use lol_html::html_content::TextChunk as NativeTextChunk; 3 | 4 | #[wasm_bindgen] 5 | pub struct TextChunk(NativeRefWrap>); 6 | 7 | impl_from_native!(NativeTextChunk --> TextChunk); 8 | impl_mutations!(TextChunk); 9 | 10 | #[wasm_bindgen] 11 | impl TextChunk { 12 | #[wasm_bindgen(method, getter)] 13 | pub fn text(&self) -> JsResult { 14 | self.0.get().map(|c| c.as_str().into()) 15 | } 16 | 17 | #[wasm_bindgen(method, getter=lastInTextNode)] 18 | pub fn last_in_text_node(&self) -> JsResult { 19 | self.0.get().map(|c| c.last_in_text_node()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/types.d.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/cloudflare/html-rewriter-wasm/blob/de05e01f225e6d4c316b19b9aae8b9aa68db9524/src/html_rewriter.d.ts#L67 2 | 3 | export interface ContentTypeOptions { 4 | html?: boolean 5 | } 6 | 7 | export class Element { 8 | before(content: string, options?: ContentTypeOptions): this 9 | after(content: string, options?: ContentTypeOptions): this 10 | replace(content: string, options?: ContentTypeOptions): this 11 | remove(): this 12 | getAttribute(name: string): string | null 13 | hasAttribute(name: string): boolean 14 | setAttribute(name: string, value: string): this 15 | removeAttribute(name: string): this 16 | prepend(content: string, options?: ContentTypeOptions): this 17 | append(content: string, options?: ContentTypeOptions): this 18 | setInnerContent(content: string, options?: ContentTypeOptions): this 19 | removeAndKeepContent(): this 20 | readonly attributes: IterableIterator<[string, string]> 21 | readonly namespaceURI: string 22 | readonly removed: boolean 23 | tagName: string 24 | onEndTag( 25 | handler: (this: this, endTag: EndTag) => void | Promise, 26 | ): void 27 | } 28 | 29 | export class EndTag { 30 | before(content: string, options?: ContentTypeOptions): this 31 | after(content: string, options?: ContentTypeOptions): this 32 | remove(): this 33 | name: string 34 | } 35 | 36 | export class Comment { 37 | before(content: string, options?: ContentTypeOptions): this 38 | after(content: string, options?: ContentTypeOptions): this 39 | replace(content: string, options?: ContentTypeOptions): this 40 | remove(): this 41 | readonly removed: boolean 42 | text: string 43 | } 44 | 45 | export class TextChunk { 46 | before(content: string, options?: ContentTypeOptions): this 47 | after(content: string, options?: ContentTypeOptions): this 48 | replace(content: string, options?: ContentTypeOptions): this 49 | remove(): this 50 | readonly lastInTextNode: boolean 51 | readonly removed: boolean 52 | readonly text: string 53 | } 54 | 55 | export class Doctype { 56 | readonly name: string | null 57 | readonly publicId: string | null 58 | readonly systemId: string | null 59 | } 60 | 61 | export class DocumentEnd { 62 | append(content: string, options?: ContentTypeOptions): this 63 | } 64 | 65 | export interface ElementHandlers { 66 | element?(element: Element): void | Promise 67 | comments?(comment: Comment): void | Promise 68 | text?(text: TextChunk): void | Promise 69 | } 70 | 71 | export interface DocumentHandlers { 72 | doctype?(doctype: Doctype): void | Promise 73 | comments?(comment: Comment): void | Promise 74 | text?(text: TextChunk): void | Promise 75 | end?(end: DocumentEnd): void | Promise 76 | } 77 | 78 | export interface HTMLRewriterOptions { 79 | enableEsiTags?: boolean 80 | } 81 | 82 | export class HTMLRewriter { 83 | constructor( 84 | outputSink: (chunk: Uint8Array) => void, 85 | options?: HTMLRewriterOptions, 86 | ) 87 | on(selector: string, handlers: ElementHandlers): this 88 | onDocument(handlers: DocumentHandlers): this 89 | write(chunk: Uint8Array): Promise 90 | end(): Promise 91 | free(): void 92 | } 93 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ES2020", 4 | "target": "es2018", 5 | "lib": ["es2018", "dom"], 6 | "strict": true, 7 | "rootDir": "src", 8 | "moduleResolution": "Node", 9 | "esModuleInterop": true, 10 | "allowJs": false, 11 | "types": ["node"], 12 | "noImplicitAny": false, 13 | "skipLibCheck": true, 14 | "outDir": "dist", 15 | "declaration": true, 16 | 17 | "sourceMap": true 18 | }, 19 | "include": ["src"], 20 | "exclude": ["node_modules", "scripts", "play.ts", "src/*.test.ts"] 21 | } 22 | -------------------------------------------------------------------------------- /vercel.js: -------------------------------------------------------------------------------- 1 | import init from './dist/html_rewriter' 2 | 3 | import wasm from './dist/html_rewriter_bg.wasm?module' 4 | import { HTMLRewriterWrapper } from './dist/html_rewriter_wrapper' 5 | 6 | // console.log('using vercel wasm') 7 | 8 | export const HTMLRewriter = HTMLRewriterWrapper(init(wasm)) 9 | --------------------------------------------------------------------------------