{"_id":"@mrbbot/parsed-html-rewriter","_rev":"4-d25ade512e9dd29959fde5b32e690f1b","name":"@mrbbot/parsed-html-rewriter","dist-tags":{"latest":"0.1.8"},"versions":{"0.1.6":{"name":"@mrbbot/parsed-html-rewriter","version":"0.1.6","description":"A DOM-based implementation of Cloudflare Worker's HTMLRewriter.","type":"module","main":"cjs/index.cjs","module":"index.js","types":"index.d.ts","exports":{".":{"import":"./index.js","require":"./cjs/index.cjs"},"./polyfill":{"import":"./polyfill.js","require":"./cjs/polyfill.cjs"}},"publishConfig":{"access":"public"},"scripts":{"postinstall":"shx ls index.js >> /dev/null 2>&1 || npm run build","clean":"shx rm -rf cjs *.d.ts *.js *.js.map *.d.ts.map *.tgz","test":"npm run build:mjs && node test/test.js","build":"npm run build:mjs & npm run build:cjs & npm run build:dist & wait","build:mjs":"tsc -p tsconfig.json","build:cjs":"tsc -p tsconfig.cjs.json && npm run sed && npm run mv","build:dist":"esbuild src/index.ts --bundle --format=esm --target=es2020 --outfile=dist/index.js --tsconfig=tsconfig.json","sed":"shx sed -i 's/\\.(.*)\\.js/\\.$1\\.cjs/g' cjs/*.js > /dev/null ","mv":"for f in cjs/*.js; do shx mv \"$f\" \"${f%.js}.cjs\"; done","prepack":"npm run clean && npm run build"},"author":{"name":"Florian Klampfer","email":"mail@qwtel.com","url":"https://qwtel.com/"},"license":"MIT","dependencies":{"@cloudflare/workers-types":"^2.2.1","linkedom":"^0.9.7","tslib":"^2.2.0","whatwg-stream-to-async-iter":"^0.3.2"},"devDependencies":{"esbuild":"^0.11.11","node-fetch-polyfill":"^2.0.6","node-web-streams":"^0.2.2","shx":"^0.3.3","typed-array-utils":"^0.2.2","typescript":"^4.2.4","web-streams-polyfill":"^1.3.2"},"repository":{"type":"git","url":"git+https://github.com/mrbbot/parsed-html-rewriter.git"},"bugs":{"url":"https://github.com/mrbbot/parsed-html-rewriter/issues"},"homepage":"https://github.com/mrbbot/parsed-html-rewriter#readme","keywords":["polyfill","html","dom","cloudflare-workers","html-rewriter"],"gitHead":"d6a435cd690ccbb9bcc9278ef7457caa2a70c16b","_id":"@mrbbot/parsed-html-rewriter@0.1.6","_nodeVersion":"14.17.1","_npmVersion":"7.19.0","dist":{"integrity":"sha512-uL2z9ZN9kZWZXNeZfcKugol5nkE1ZkxT1ZUjTu1uOkOHB7TafkOrp1mTHPhweF2/7yltwJMAJkQr2G0LVYY4kA==","shasum":"e76d4029d0fd1fd83aaddba3fd9ea94e29bc288f","tarball":"https://registry.npmjs.org/@mrbbot/parsed-html-rewriter/-/parsed-html-rewriter-0.1.6.tgz","fileCount":25,"unpackedSize":403464,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg35pSCRA9TVsSAnZWagAAx2oP/3hzFCp6qJDXZE+3c91T\necUw7Ta4vlopKq5e5GkFHneA8mPoproSECUlwAcSC8PgOdAgM762NM8EU58O\nUvDV5ptIauiW9nWD1gWhq3k3mj0642J/t5La92yujWwyk6VV0xiZwAPt9HbN\nRW1Tap2HueJseZoW4JkhHoWCmkE31m9mWWDqctwhHMg3POl+3enQ/egeJu4+\nlVc33jzaYBtH5N63YhNXJL0ggPdQ1K0nwLQ/PYPQfYSCTN1MRpASGyT+bnaO\nphMyjdZIyfsMQOLqMeTT67P7NgkTbXIDBuQZhzXucnX9zKgR9yvO1nWxORtl\nzHZHVoydGmwHH6mjQAGmc2oe21TPMGKiw7FdFjjEXMAmluA0U9Wl662lDdRB\nSakEieJolAj6htc7N8e44uaoVYRjpV0wco9WRULECEC8J88rZVxn9qdqVow4\nBtz01EtFIpniyGwoKadcxUbBlRkNXanTxFG8D7mnLxzL3PEyF/Z9IDnf2vOZ\neKObzaCsHuoLAi5o3zUufp7nMdVhX45h73KXuq4CdXQYUV9nYe20dFwSW3TC\nkNm+Y6ibs+RLOCgAzba9QHZkbDvTshJSQrelVpMSlXe2LO6paj5L1ibrl3vc\nDL/ZiZs10hsMyH9outl1+lTo3tu/Prn9FyvXaXr75ueHnXeXUWdHV+kAfxor\npg/s\r\n=Kmoy\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDhB1GW9/Tsbngvj2TCWTMuChVcQM5vcdgH6ELebc42yQIhAJZfFfwFchWf6NnETIAFu8cBHUkdbL6uUIynuyDohJXs"}]},"_npmUser":{"name":"mrbbot","email":"mrbbot@gmail.com"},"directories":{},"maintainers":[{"name":"mrbbot","email":"mrbbot@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parsed-html-rewriter_0.1.6_1625266770123_0.8273315652036093"},"_hasShrinkwrap":false,"deprecated":"use \"html-rewriter-wasm\" instead"},"0.1.7":{"name":"@mrbbot/parsed-html-rewriter","version":"0.1.7","description":"A DOM-based implementation of Cloudflare Worker's HTMLRewriter.","type":"module","main":"cjs/index.cjs","module":"index.js","types":"index.d.ts","exports":{".":{"import":"./index.js","require":"./cjs/index.cjs"},"./polyfill":{"import":"./polyfill.js","require":"./cjs/polyfill.cjs"}},"publishConfig":{"access":"public"},"scripts":{"clean":"shx rm -rf cjs *.d.ts *.js *.js.map *.d.ts.map *.tgz","test":"npm run build:mjs && node test/test.js","build":"npm run build:mjs & npm run build:cjs & npm run build:dist & wait","build:mjs":"tsc -p tsconfig.json","build:cjs":"tsc -p tsconfig.cjs.json && npm run sed && npm run mv","build:dist":"esbuild src/index.ts --bundle --format=esm --target=es2020 --outfile=dist/index.js --tsconfig=tsconfig.json","sed":"shx sed -i 's/\\.(.*)\\.js/\\.$1\\.cjs/g' cjs/*.js > /dev/null ","mv":"for f in cjs/*.js; do shx mv \"$f\" \"${f%.js}.cjs\"; done","prepack":"npm run clean && npm run build"},"author":{"name":"Florian Klampfer","email":"mail@qwtel.com","url":"https://qwtel.com/"},"license":"MIT","dependencies":{"@cloudflare/workers-types":"^2.2.1","linkedom":"^0.9.7","tslib":"^2.2.0","whatwg-stream-to-async-iter":"^0.3.2"},"devDependencies":{"esbuild":"^0.11.11","node-fetch-polyfill":"^2.0.6","node-web-streams":"^0.2.2","shx":"^0.3.3","typed-array-utils":"^0.2.2","typescript":"^4.2.4","web-streams-polyfill":"^1.3.2"},"repository":{"type":"git","url":"git+https://github.com/mrbbot/parsed-html-rewriter.git"},"bugs":{"url":"https://github.com/mrbbot/parsed-html-rewriter/issues"},"homepage":"https://github.com/mrbbot/parsed-html-rewriter#readme","keywords":["polyfill","html","dom","cloudflare-workers","html-rewriter"],"gitHead":"d6a435cd690ccbb9bcc9278ef7457caa2a70c16b","_id":"@mrbbot/parsed-html-rewriter@0.1.7","_nodeVersion":"14.17.1","_npmVersion":"7.19.0","dist":{"integrity":"sha512-SV3di3OmVmScR1tnb/0fZULgvDklI5gtFwI9pYoLuxe3JkUOkZCICisOCy3KY6mslJovQkzDAiJfBVIctO3DKw==","shasum":"9f4c7eab3e69e226d33cd6d2b2552df22bef3563","tarball":"https://registry.npmjs.org/@mrbbot/parsed-html-rewriter/-/parsed-html-rewriter-0.1.7.tgz","fileCount":25,"unpackedSize":403391,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4HqqCRA9TVsSAnZWagAAkxgQAIVZo0oe5tScybPZ/wjA\naUZwzEKeaP8X6VaTBdqXSXsXfGgjpvlx3EaG3Zn9f304yfOCNqBRwFm9MBPG\nPOaSYUHM0yzIhh6dBYI50Fa/bgGFksIsXURg346DO0I0BdXhMdfNzDjrtxDQ\nlafBD7ZmSJ7uAHh2l8c2ZQJ+6lfDjnlGIXYwZW3VrWNtWBp87m0MA63HfknX\nidK0rfVkhPklLb5wOEvFHqAxNfXSCBlGblnjWmOPfrEWFthc503JGwlsvDs4\nvHtNtW7lfwRtkTvWYn+mxs4v2RVDwHLf2W/0HrZ6eXBFUnX8K0uFmxw6EaYz\n6jt+/bUuOkmipybTrpbBirnzEmtNs9l16afJg4xrrBSAoxHQFe9HlIJksKap\nWxR/97OIQvyxjoIdIHkeDvo91O6cfOLO5qwvASbNI/g3O79N70fRoJHrOUmZ\nmrH8OVQXDnfcPG4rAt1WLrukFoUc3dSGS4maBWj9pOWQomAmcIIpeMhQw/l4\nM3hM459miycLJpwOceNs4CzNNyjttWvbntwFd4IJbIFHfbx5Jbnx4xp2SDEl\ngV9MG+ScJE2vA9KFTu8r5QwTg9PGFm7grZj40xsnpHPyAq7jyVZCFB8n0KoO\nRNuAmWlAtcqhQN+PpOfu8zenp2GT4dFmZkVpBoI2wf6mg2+fWv9IKaG2MA1u\nzekG\r\n=clAh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDkIOmzJpYDwAo/RIxcUAevS/T1b1ejcXL0jOwxqWG48QIhAIKNSVNjAuTfnYUuTb8VzX8BtiSTsnwWBDkiPR+6Sh6x"}]},"_npmUser":{"name":"mrbbot","email":"mrbbot@gmail.com"},"directories":{},"maintainers":[{"name":"mrbbot","email":"mrbbot@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parsed-html-rewriter_0.1.7_1625324201818_0.5199709579958591"},"_hasShrinkwrap":false,"deprecated":"use \"html-rewriter-wasm\" instead"},"0.1.8":{"name":"@mrbbot/parsed-html-rewriter","version":"0.1.8","description":"A DOM-based implementation of Cloudflare Worker's HTMLRewriter.","type":"module","main":"cjs/index.cjs","module":"index.js","types":"index.d.ts","exports":{".":{"import":"./index.js","require":"./cjs/index.cjs"},"./polyfill":{"import":"./polyfill.js","require":"./cjs/polyfill.cjs"}},"publishConfig":{"access":"public"},"scripts":{"clean":"shx rm -rf cjs *.d.ts *.js *.js.map *.d.ts.map *.tgz","test":"npm run build:mjs && node test/test.js","build":"npm run build:mjs & npm run build:cjs & npm run build:dist & wait","build:mjs":"tsc -p tsconfig.json","build:cjs":"tsc -p tsconfig.cjs.json && npm run sed && npm run mv","build:dist":"esbuild src/index.ts --bundle --format=esm --target=es2020 --outfile=dist/index.js --tsconfig=tsconfig.json","sed":"shx sed -i 's/\\.(.*)\\.js/\\.$1\\.cjs/g' cjs/*.js > /dev/null ","mv":"for f in cjs/*.js; do shx mv \"$f\" \"${f%.js}.cjs\"; done","prepack":"npm run clean && npm run build"},"author":{"name":"Florian Klampfer","email":"mail@qwtel.com","url":"https://qwtel.com/"},"license":"MIT","dependencies":{"@cloudflare/workers-types":"^2.2.1","linkedom":"^0.9.7","tslib":"^2.2.0"},"devDependencies":{"esbuild":"^0.11.11","node-fetch-polyfill":"^2.0.6","shx":"^0.3.3","typed-array-utils":"^0.2.2","typescript":"^4.2.4","web-streams-polyfill":"^3.0.3"},"repository":{"type":"git","url":"git+https://github.com/mrbbot/parsed-html-rewriter.git"},"bugs":{"url":"https://github.com/mrbbot/parsed-html-rewriter/issues"},"homepage":"https://github.com/mrbbot/parsed-html-rewriter#readme","keywords":["polyfill","html","dom","cloudflare-workers","html-rewriter"],"gitHead":"d6a435cd690ccbb9bcc9278ef7457caa2a70c16b","_id":"@mrbbot/parsed-html-rewriter@0.1.8","_nodeVersion":"14.17.1","_npmVersion":"7.19.0","dist":{"integrity":"sha512-fNO8RKaJk+/CTlVXTZEhkHUAeJbClx4oHKM1MraG78NUGwcZmFAUcGSbaFKZXx5hoNf+AHKF67+7RzlVnqy4LA==","shasum":"ccde2f141822da8ce43dbdc1e051a023396a59e7","tarball":"https://registry.npmjs.org/@mrbbot/parsed-html-rewriter/-/parsed-html-rewriter-0.1.8.tgz","fileCount":25,"unpackedSize":405089,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg6YRpCRA9TVsSAnZWagAAtLAP/jxtavWoM/HO6bQi1SLO\nW3FcvVncFZwQDTbDVYKyxGRizC/y4MWMvRbbQtGf920F/bBfFczFQ1sgA91u\nuhjHq7n6z49PkgVsGRlQfPHIzV8HqMLDhznGJzwo9sBl4JCnQFDqhzPhmJWR\nMKcWEeQySYirn8k/QPmnhD1xt2/nJJkWrmYtg3PNCn6ic9f/xHjpn8s5qgHI\nlLl20Yuukqu07Rg2bmcs7gBPob7Usf4tSrte/FhjKHQpngGcRql/3ofZi7pm\nZxmMu3oDgKkdJGtBSQ5RBeo4YtYjoBL41BVpmyhsKzEmOkrwXWY5J4Uu12aw\nVprOoICddlHRGKLbEHglV9q3nPzCUaGlSQsEZ1l9r8LE/dWJjGnxKX0Deul6\nhoRGF2Y/7N1xOv/+dhMfnAyqc+0LeugwpdkPl3m5yko99x2Z41Kev00U6Y38\nOeXL83/pl58lU/ZPTUgkyhFNQ03BDk9CCMSdntcSYmUPUfL2F5iy3dUFiw2H\nnLV8hW8K3xrG91yW25zBhMvwaYIF/fqY6hBNwmgVRrAT/X6jX/uj6q3dgwWS\nnf+vnHAZsqWWR2Hta5436fbPDMTpZlZ9iFNqitWnUMJDWWzGFCfF1tN4PeVk\nEMfQm3fOS/oPoswNMno7DG5QB5VX5XN6fK7ddUJ+hPKT/E+x8MPYzhb/GOzg\n+XFs\r\n=FNVe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsN33cCxvI+Eo/WIqBMmHHLKWhLIi7uyyOWqiksYFAYAIhAJXYAyCU7RbldZqsq58fB/54VwxRkW71/JjOL6jpeljt"}]},"_npmUser":{"name":"mrbbot","email":"mrbbot@gmail.com"},"directories":{},"maintainers":[{"name":"mrbbot","email":"mrbbot@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parsed-html-rewriter_0.1.8_1625916520640_0.6724794232292155"},"_hasShrinkwrap":false,"deprecated":"use \"html-rewriter-wasm\" instead"}},"time":{"created":"2021-07-02T22:59:30.074Z","0.1.6":"2021-07-02T22:59:30.518Z","modified":"2022-04-06T06:45:34.558Z","0.1.7":"2021-07-03T14:56:41.922Z","0.1.8":"2021-07-10T11:28:40.805Z"},"maintainers":[{"name":"mrbbot","email":"mrbbot@gmail.com"}],"description":"A DOM-based implementation of Cloudflare Worker's HTMLRewriter.","homepage":"https://github.com/mrbbot/parsed-html-rewriter#readme","keywords":["polyfill","html","dom","cloudflare-workers","html-rewriter"],"repository":{"type":"git","url":"git+https://github.com/mrbbot/parsed-html-rewriter.git"},"author":{"name":"Florian Klampfer","email":"mail@qwtel.com","url":"https://qwtel.com/"},"bugs":{"url":"https://github.com/mrbbot/parsed-html-rewriter/issues"},"license":"MIT","readme":"> This is a fork of [@worker-tools/parsed-html-rewriter](https://github.com/worker-tools/parsed-html-rewriter) that implements the `onDocument` handler and fixes installation on Windows.\n\n# Parsed HTML Rewriter\nA DOM-based implementation of [Cloudflare Worker's `HTMLRewriter`](https://developers.cloudflare.com/workers/runtime-apis/html-rewriter).\n\nUnlike the original, this implementation parses the entire DOM (provided by [`linkedom`](https://github.com/WebReflection/linkedom)),\nand runs selectors against this representation. As a result, it is slower, more memory intensive, and can't process streaming data.\n\nNote that this approach was chosen to quickly implement the functionality of `HTMLRewriter`, as there is currently no JS implementation available.\nA better implementation would replicate the streaming approach of [`lol-html`](https://github.com/cloudflare/lol-html), or even use a WebAssembly version of it.\n\nHowever, this implementation should run in most JS contexts (including Web Workers, Service Workers and Deno) without modification and handle many, if not most, use cases of `HTMLRewriter`. \nIt should be good enough for testing and offline Workers development.\n\n## Usage\nThis module can be used in two ways. \n\nAs a standalone module: \n\n```ts\nimport { ParsedHTMLRewriter } from '@mrbbot/parsed-html-rewriter'\n\nawait new ParsedHTMLRewriter()\n  .transform(new Response('<body></body>'))\n  .text();\n```\n\nOr as a polyfill:\n\n```ts\nimport '@mrbbot/parsed-html-rewriter/polyfill'\n\nawait new HTMLRewriter() // Will use the native version when running in a Worker\n  .transform(new Response('<body></body>'))\n  .text();\n```\n\n### innerHTML\nUnlike the current (March 2021) version on CF Workers, this implementation already supports the [proposed `innerHTML` handler](https://github.com/cloudflare/lol-html/issues/40#issuecomment-567126687). \nNote that this feature is unstable and will likely change as the real version materializes.\n\n```ts\nawait new HTMLRewriter()\n  .on('body', {\n    innerHTML(html) {\n      console.log(html) // => '<div id=\"foo\">bar</div>'\n    },\n  })\n  .transform(new Response('<body><div id=\"foo\">bar</div></body>'))\n  .text();\n```\n\n## Caveats\n- Because this version isn't based on streaming data, the order in which handlers are called can differ. Some measure have been taken to simulate the order, but differences may occur.\n- Texts never arrive in chunks. There is always just one chunk, followed by an empty one with `lastInTextNode` set to `true`.\n","readmeFilename":"README.md"}