{"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":"http://registry-npm.ywwl.com/@mrbbot/parsed-html-rewriter/download/@mrbbot/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"}],"size":80596,"noattachment":false,"key":"/@mrbbot/parsed-html-rewriter/-/@mrbbot/parsed-html-rewriter-0.1.7.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.7_1625324201818_0.5199709579958591"},"_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":1625324201922,"_cnpm_publish_time":1625324201922,"dist-tags":{"latest":"0.1.8"}}