{"_id":"@campfiredevs/pagedjs","_rev":"1-dcd60ab372a28b081489da6f90cbf806","name":"@campfiredevs/pagedjs","dist-tags":{"latest":"0.4.3"},"versions":{"0.5.1-beta.2":{"name":"@campfiredevs/pagedjs","version":"0.5.1-beta.2","author":{"url":"Original Author: Fred Chasen","name":"Cedric Delacombaz"},"license":"MIT","_id":"@campfiredevs/pagedjs@0.5.1-beta.2","maintainers":[{"name":"campfiredevs","email":"info@campfire.ch"}],"homepage":"https://pagedmedia.org","bugs":{"url":"https://github.com/campfire-ch/pagedjs/issues"},"dist":{"shasum":"edac93bc42e06e47f6b5af9ef73173e7a99cdbe7","tarball":"https://registry.npmjs.org/@campfiredevs/pagedjs/-/pagedjs-0.5.1-beta.2.tgz","fileCount":100,"integrity":"sha512-eReODunG2oCx0nsDGJJ95yZ+nIhXpXhWLf2FZlwpRDOGpJRmJQbx1NNb80K8yDwYCohNzSOvn9F/zoXRj1ccbQ==","signatures":[{"sig":"MEYCIQCjWH6Gdhr3VDFu4E7PxnaU8n06cRYtR3trI/Cw/TNcdAIhAMt36o+RJTj1VEa4nIt50F/kKuadr5P5c+jmeBVijyZ0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6227893},"main":"src/index.js","type":"module","browser":"dist/paged.js","exports":{"import":"./src/index.js","browser":"./dist/paged.js","default":"./src/index.js","require":"./lib/index.cjs","polyfill":"./dist/paged.polyfill.js"},"gitHead":"9a8f97905eeecc0cb4bf30add403a7ed618697f9","scripts":{"lint":"eslint -c .eslintrc.json src specs","test":"npm run lint && jest","build":"rollup -c","specs":"npm run pretest && jest --config=specs/jest.config.js","start":"rollup -w -c rollup.server.config.js","watch":"rollup -w -c","legacy":"babel dist/paged.js --out-file dist/paged.legacy.js && babel dist/paged.polyfill.js --out-file dist/paged.polyfill.legacy.js","compile":"babel src/ -d lib/ --out-file-extension .cjs","pretest":"npm run build && npm run compile","docker-test":"docker build -t pagedmedia/pagedjs . && docker run -it --rm --ipc=host --user pwuser --security-opt 'seccomp=seccomp.json' -v $(pwd)/specs:/home/pwuser/pagedjs/specs pagedmedia/pagedjs npm test","docker-build":"docker build -t pagedmedia/pagedjs .","docker-specs":"docker build -t pagedmedia/pagedjs . && docker run -it --rm --ipc=host -v $(pwd)/specs:/home/pwuser/pagedjs/specs pagedmedia/pagedjs npm run specs","prepublishOnly":"npm run build && npm run compile && npm run legacy","docker-update-specs":"docker build -t pagedmedia/pagedjs . && docker run -it --rm --ipc=host -v $(pwd)/specs:/home/pwuser/pagedjs/specs pagedmedia/pagedjs npm run specs -- -u"},"_npmUser":{"name":"campfiredevs","email":"info@campfire.ch"},"repository":{"url":"git+https://github.com/campfire-ch/pagedjs.git","type":"git"},"_npmVersion":"10.7.0","description":"Updated pagedjs fork to work in docker with puppeteer","directories":{},"_nodeVersion":"20.15.0","dependencies":{"css-tree":"^1.1.3","clear-cut":"^2.0.2","event-emitter":"^0.3.5","@babel/runtime":"^7.21.0","@babel/polyfill":"^7.10.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","chalk":"^5.2.0","eslint":"^8.38.0","rimraf":"^5.0.0","rollup":"^3.20.6","express":"^4.18.2","@babel/cli":"^7.21.0","@babel/core":"^7.21.4","playwright-core":"^1.32.3","@babel/preset-env":"^7.21.4","@rollup/plugin-json":"^6.0.0","jest-image-snapshot":"^6.1.0","rollup-plugin-serve":"^2.0.2","@rollup/plugin-terser":"^0.4.1","rollup-plugin-license":"^3.0.1","jest-environment-jsdom":"^29.5.0","@rollup/plugin-commonjs":"^24.1.0","rollup-plugin-livereload":"^2.0.5","@rollup/plugin-node-resolve":"^15.0.2","rollup-plugin-node-builtins":"^2.1.2","@babel/plugin-transform-runtime":"^7.21.4","babel-plugin-replace-import-extension":"^1.1.3","@babel/plugin-proposal-async-generator-functions":"^7.20.7"},"_npmOperationalInternal":{"tmp":"tmp/pagedjs_0.5.1-beta.2_1729082203079_0.00883372081440581","host":"s3://npm-registry-packages"}},"0.4.3":{"name":"@campfiredevs/pagedjs","version":"0.4.3","description":"Updated pagedjs fork to work in docker with puppeteer. Issue described here: https://github.com/pagedjs/pagedjs/issues/230#issuecomment-2303608178","author":{"name":"Cedric Delacombaz","url":"Original Author: Fred Chasen"},"repository":{"type":"git","url":"git+https://github.com/campfire-ch/pagedjs.git"},"license":"MIT","homepage":"https://pagedmedia.org","main":"src/index.js","browser":"dist/paged.js","type":"module","exports":{"import":"./src/index.js","require":"./lib/index.cjs","browser":"./dist/paged.js","polyfill":"./dist/paged.polyfill.js","default":"./src/index.js"},"dependencies":{"@babel/polyfill":"^7.10.1","@babel/runtime":"^7.21.0","clear-cut":"^2.0.2","css-tree":"^1.1.3","event-emitter":"^0.3.5"},"devDependencies":{"@babel/cli":"^7.21.0","@babel/core":"^7.21.4","@babel/plugin-proposal-async-generator-functions":"^7.20.7","@babel/plugin-transform-runtime":"^7.21.4","@babel/preset-env":"^7.21.4","@rollup/plugin-commonjs":"^24.1.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-terser":"^0.4.1","babel-plugin-replace-import-extension":"^1.1.3","chalk":"^5.2.0","eslint":"^8.38.0","express":"^4.18.2","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-image-snapshot":"^6.1.0","playwright-core":"^1.32.3","rimraf":"^5.0.0","rollup":"^3.20.6","rollup-plugin-license":"^3.0.1","rollup-plugin-livereload":"^2.0.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-serve":"^2.0.2"},"scripts":{"build":"rollup -c","start":"rollup -w -c rollup.server.config.js","test":"npm run lint && jest","specs":"npm run pretest && jest --config=specs/jest.config.js","compile":"babel src/ -d lib/ --out-file-extension .cjs","legacy":"babel dist/paged.js --out-file dist/paged.legacy.js && babel dist/paged.polyfill.js --out-file dist/paged.polyfill.legacy.js","pretest":"npm run build && npm run compile","prepublishOnly":"npm run build && npm run compile && npm run legacy","watch":"rollup -w -c","lint":"eslint -c .eslintrc.json src specs","docker-build":"docker build -t pagedmedia/pagedjs .","docker-test":"docker build -t pagedmedia/pagedjs . && docker run -it --rm --ipc=host --user pwuser --security-opt 'seccomp=seccomp.json' -v $(pwd)/specs:/home/pwuser/pagedjs/specs pagedmedia/pagedjs npm test","docker-specs":"docker build -t pagedmedia/pagedjs . && docker run -it --rm --ipc=host -v $(pwd)/specs:/home/pwuser/pagedjs/specs pagedmedia/pagedjs npm run specs","docker-update-specs":"docker build -t pagedmedia/pagedjs . && docker run -it --rm --ipc=host -v $(pwd)/specs:/home/pwuser/pagedjs/specs pagedmedia/pagedjs npm run specs -- -u"},"_id":"@campfiredevs/pagedjs@0.4.3","gitHead":"38bfda34e6954db2660e0e3c4ad0b2314ed7f173","bugs":{"url":"https://github.com/campfire-ch/pagedjs/issues"},"_nodeVersion":"20.15.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-8OomvhkK5kw9BT4A5PTAaZeWXnuU89pGb7Cv5ZJR2VxfkGwp1YMEDRGh/rT+SIVamgAXD4EQEgG03sxKk31uaA==","shasum":"caff3c5dae87c0cd60687cfa6a20ef9bf46c23a2","tarball":"https://registry.npmjs.org/@campfiredevs/pagedjs/-/pagedjs-0.4.3.tgz","fileCount":100,"unpackedSize":6227904,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjv5atHvU0CewTnhwXldKzxI7iHkzd85h9ri8RzHtCYgIhAMy/qn+BqHPZU1vrmOyWDaNh6bgj0ZkpZxXUiSkYorLL"}]},"_npmUser":{"name":"campfiredevs","email":"info@campfire.ch"},"directories":{},"maintainers":[{"name":"campfiredevs","email":"info@campfire.ch"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pagedjs_0.4.3_1733155923060_0.8503622534226187"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-16T12:36:42.977Z","modified":"2024-12-02T16:12:03.546Z","0.5.1-beta.2":"2024-10-16T12:36:43.281Z","0.4.3":"2024-12-02T16:12:03.342Z"},"bugs":{"url":"https://github.com/campfire-ch/pagedjs/issues"},"author":{"name":"Cedric Delacombaz","url":"Original Author: Fred Chasen"},"license":"MIT","homepage":"https://pagedmedia.org","repository":{"type":"git","url":"git+https://github.com/campfire-ch/pagedjs.git"},"description":"Updated pagedjs fork to work in docker with puppeteer. Issue described here: https://github.com/pagedjs/pagedjs/issues/230#issuecomment-2303608178","maintainers":[{"name":"campfiredevs","email":"info@campfire.ch"}],"readme":"<img style=\"display: block; margin: 5em 0 auto;\" src=\"assets/pagedjs.png\" alt=\"Paged.js logo - pagination in the browser\"/>\n\nPaged.js - Paged Media Tools\n===========\n\nPaged.js is an open-source library to display paginated content in the browser and to generate print books using web technology.\n\nIt contains a set of handlers for CSS transformations and fragmented layout which polyfill the [Paged Media](https://www.w3.org/TR/css-page-3/) and [Generated Content](https://www.w3.org/TR/css-gcpm-3/) CSS modules, along with hooks to create new handlers for custom properties.\n\nThe currently supported properties can be found on [the pagedjs website](https://pagedjs.org/documentation/cheatsheet/).\n\nA quick overview to getting started with Paged Media CSS and Paged.js is available on [pagedjs.org/documentation](https://pagedjs.org/documentation/).\n\n## NPM Module\n```sh\n$ npm install pagedjs\n```\n\n```js\nimport { Previewer } from 'pagedjs';\n\nlet paged = new Previewer();\nlet flow = paged.preview(DOMContent, [\"path/to/css/file.css\"], document.body).then((flow) => {\n\tconsole.log(\"Rendered\", flow.total, \"pages.\");\n})\n```\n\n## Polyfill\n\nAdd the the `paged.polyfill.js` script to replace all `@page` css and render the html page with the Paged Media styles applied:\n\n```html\n<script src=\"https://unpkg.com/pagedjs/dist/paged.polyfill.js\"></script>\n```\n\nTry the [polyfill with Aurorae](https://s3.amazonaws.com/pagedmedia/pagedjs/examples/polyfill.html).\n\nBy default the polyfill will run automatically as soon as the DOM is ready.\nHowever, you can add an async `before` function or return a Promise to delay the polyfill starting.\n\n```html\n<script>\n\twindow.PagedConfig = {\n\t\tbefore: () => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tsetTimeout(() => { resolve() }, 1000);\n\t\t\t})\n\t\t},\n\t\tafter: (flow) => { console.log(\"after\", flow) },\n\t};\n</script>\n```\n\nOtherwise you can disable `auto` running the previewer and call `window.PagedPolyfill.preview();`\nwhenever you want to start.\n\n```html\n<script>\n\twindow.PagedConfig = {\n\t\tauto: false,\n\t\tafter: (flow) => { console.log(\"after\", flow) },\n\t};\n\n\tsetTimeout(() => {\n\t\twindow.PagedPolyfill.preview();\n\t}, 1000);\n</script>\n```\n\n## Chunker\nChunks up a document into paged media flows and applies print classes.\n\nExamples:\n\n* Process the [first 50 pages of Moby Dick](https://s3.amazonaws.com/pagedmedia/pagedjs/examples/index.html).\n* Upload and [chunk an Epub using Epub.js](https://s3.amazonaws.com/pagedmedia/pagedjs/examples/epub.html).\n\n## Polisher\nConverts `@page` css to classes, and applies counters and content.\n\nExamples:\n\n* Test [styles for print](https://s3.amazonaws.com/pagedmedia/pagedjs/examples/polisher.html).\n\n### CLI\n\nCommand line interface to render out PDFs of HTML files using Puppeteer: [https://gitlab.pagedmedia.org/tools/pagedjs-cli](https://gitlab.pagedmedia.org/tools/pagedjs-cli).\n\n## Modules\n\nModules are groups of handlers for that apply the layout and styles of a CSS module, such as Generated Content.\n\nNew handlers can be registered from `import { registerHandlers } from 'pagedjs'` or by calling `Paged.registerHandlers` on an html page.\n\n```html\n<script src=\"https://unpkg.com/pagedjs/dist/paged.polyfill.js\"></script>\n<script>\n\tclass MyHandler extends Paged.Handler {\n\t\tconstructor(chunker, polisher, caller) {\n\t\t\tsuper(chunker, polisher, caller);\n\t\t}\n\n\t\tafterPageLayout(pageFragment, page) {\n\t\t\tconsole.log(pageFragment);\n\t\t}\n\t}\n\tPaged.registerHandlers(MyHandler);\n</script>\n```\n\nHandlers have methods that correspond to the hooks for the parsing, layout and rendering of the Chunker and Polisher. Returning a promise or `async` function from a method in a handler will complete that task before continuing with the other registered methods for that hook.\n\n```js\n// Previewer\nbeforePreview(content, renderTo)\nafterPreview(pages)\n\n// Chunker\nbeforeParsed(content)\nfilter(content)\nafterParsed(parsed)\nbeforePageLayout(page)\nonPageLayout(pageWrapper, breakToken, layout);\nafterPageLayout(pageElement, page, breakToken)\nfinalizePage(pageElement, page, breakToken)\nafterRendered(pages)\n\n// Polisher\nbeforeTreeParse(text, sheet)\nbeforeTreeWalk(ast)\nafterTreeWalk(ast, sheet)\nonUrl(urlNode)\nonAtPage(atPageNode)\nonRule(ruleNode)\nonDeclaration(declarationNode, ruleNode)\nonContent(contentNode, declarationNode, ruleNode)\n\n// Layout\nlayoutNode(node)\nrenderNode(node, sourceNode, layout)\nonOverflow(overflow, rendered, bounds)\nonBreakToken(breakToken, overflow, rendered)\nafterOverflowRemoved(removed, rendered)\nbeforeRenderResult(breakToken, pageWrapper)\n```\n\n## Setup\nInstall dependencies\n```sh\n$ npm install\n```\n\n## Development\nRun the local dev-server with livereload and autocompile on [http://localhost:9090/](http://localhost:9090/)\n```sh\n$ npm start\n```\n\n## Deployment\nBuild the `dist` output\n```sh\n$ npm run build\n```\n\nCompile the `lib` output\n```sh\n$ npm run compile\n```\n\nGenerate legacy builds with polyfills included\n```sh\n$ npm run legacy\n```\n\n## Testing\n\nTesting for Paged.js uses [Jest](https://facebook.github.io/jest/en/) but is split into Tests and Specs.\n\n### Tests\n\nUnit tests for Chunker and Polisher methods are run in node using JSDOM.\n\n```bash\nnpm test\n```\n\n### Specs\n\nSpecs run a html file in Chrome (using puppeteer) to test against CSS specifications.\n\nThey can also output a pdf and compare pages (one at a time) in that PDF with samples PDFs (saved as images).\n\nThe PDF comparison tests depend on the `ghostscript` and the `ghostscript4js` package.\n\nIt is recomend to run these in the Docker container below via:\n\n```bash\nnpm run docker-specs\n```\n\nHowever if you'd like to run the specs outside of Docker, you'll need to install a local version of Ghostscript for your system according to https://www.npmjs.com/package/ghostscript4js#prerequisites\n\nFor Mac you can install it with\n\n```bash\nbrew install ghostscript\n```\n\nFor Debian you can install it with\n\n```bash\nsudo apt-get install ghostscript\nsudo apt-get install libgs-dev\n```\n\nNow you can install the `ghostscript4js` library. For Linux you can optionally pass the location ghostscript was installed to in `GS4JS_HOME`.\n\n```bash\nGS4JS_HOME=\"/usr/lib/$(gcc -dumpmachine)\" npm install ghostscript4js\n```\n\nTo test the pdf output of specs, you'll need to build the library locally.\n\n```bash\nnpm run build\n```\n\nThen run the jest tests in puppeteer.\n\n```bash\nnpm run specs\n```\n\nTo debug the results of a test in a browser you can add `NODE_ENV=debug`\n\n```bash\nNODE_ENV=debug npm run specs\n```\n\nTo update the stored pdf images you can run\n\n```bash\nnpm run specs -- --updateSnapshot\n```\n\n### Docker\n\nA `pagedmedia/pagedjs` docker image contains all the dependencies needed to run the `pagedjs` development server, as well as the pdf comparison tests.\n\nTo build the image run\n\n```bash\ndocker build -t pagedmedia/pagedjs .\n```\n\nBy default the container will run the development server with `npm start`\n\n```bash\ndocker run -it -p 9090:9090 pagedmedia/pagedjs\n```\n\nThe tests and specs can be run within the container by passing a `seccomp` file for Chrome and running `npm test`\n\n```bash\ndocker run -it --security-opt 'seccomp=seccomp.json' pagedmedia/pagedjs npm test && npm run specs\n```\n\n## Sponsorship ✨\n\nThe Coko Foundation has two staff members dedicated part time to Paged.js.  The total cost is about 80k USD a year -- this isn't easily maintained by Coko as it is paid via the surplus from custom platform builds (all open source since Coko is a not-for-profit entity).\n\nJoin those sponsoring this project to support and maintain Paged.js.  If you benefit from the library, or are using it in a commercial product or service, contribute today so that we can continue to deliver a quality tool for web-based document pagination.  If you contribute at least $50 a month, create a pull request to add your name to the project sponsors listed below.\n\n[<img src=\"assets/donate.svg\" height=\"50\">](https://us.commitchange.com/nonprofits/5726/donate?offsite=t&=undefined&offsite=t&custom_amounts=5,10,25,50,100,200,1000&origin=https://pagedjs.org/)\n\n<a href=\"https://coko.foundation/\"><img src=\"assets/coko.svg\" height=\"100\" /></a>\n\n<a href=\"https://www.sparkfish.com/open-source/\"><img src=\"assets/sparkfish.svg\" height=\"25\" /></a>\n\n## Contributors\n\n### Core team\nThe core team behind paged.js includes [Adam Hyde](https://adamhyde.net), [Julie Blanc](http://julie-blanc.fr/), [Fred Chasen](http://fchasen.com/) & Julien Taquet.\n\n## Licence\n\nMIT License (MIT), which you can read [here](https://gitlab.pagedmedia.org/tools/pagedjs/blob/master/LICENSE.md)\n","readmeFilename":"README.md"}