{"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":"http://registry-npm.ywwl.com/@mrbbot/parsed-html-rewriter/download/@mrbbot/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"}],"size":80699,"noattachment":false,"key":"/@mrbbot/parsed-html-rewriter/-/@mrbbot/parsed-html-rewriter-0.1.8.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.8_1625916520640_0.6724794232292155"},"_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":1625916520805,"_cnpm_publish_time":1625916520805,"dist-tags":{"latest":"0.1.8"}}