{"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":"http://registry-npm.ywwl.com/@mrbbot/parsed-html-rewriter/download/@mrbbot/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"}],"size":80624,"noattachment":false,"key":"/@mrbbot/parsed-html-rewriter/-/@mrbbot/parsed-html-rewriter-0.1.6.tgz"},"_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","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","publish_time":1625266770518,"_cnpm_publish_time":1625266770518,"dist-tags":{"latest":"0.1.8"}}