{"_id":"@berryv/g2-ssr-node","_rev":"8-e2f4866a48f0e519c60891c58cd22eb8","name":"@berryv/g2-ssr-node","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@berryv/g2-ssr-node","version":"0.1.0","author":{"url":"https://github.com/pearmini","name":"pearmini"},"license":"ISC","_id":"@berryv/g2-ssr-node@0.1.0","maintainers":[{"name":"pearmini","email":"subairui@icloud.com"}],"homepage":"https://github.com/pearmini/g2-ssr-node#readme","bugs":{"url":"https://github.com/pearmini/g2-ssr-node/issues"},"bin":{"g2-ssr-node":"bin/g2-ssr-node.js"},"dist":{"shasum":"a8a34e7f39a595275cb1bea8da43a5d3907ec7e4","tarball":"https://registry.npmjs.org/@berryv/g2-ssr-node/-/g2-ssr-node-0.1.0.tgz","fileCount":12,"integrity":"sha512-Vd7FZj0bekHH2mu0+y0QU0G5TgdVbvo/BY4NOtmlewtWqZ1JujZVpRWUHLN2AugO3K0hpkC6FxnNGxY3UfrSxQ==","signatures":[{"sig":"MEUCIQD1YvCHuQGqR9tOgywBbiSPezLcIfQ8cyIKnycG845kiAIgUg7npPNn623oE/Oxo0gdGfP2Dk/h1IY3CBT8iJ2VbEk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1228227},"main":"src/index.js","gitHead":"93d9eca29c919994b74fdcaa195fadebab6385b7","scripts":{"test":"npm run test:lint && npm run test:format && npm run test:node","build":"rm -rf dist && rollup -c","test:png":"g2-ssr-node g2png -i ./test/plots/bar.json -o ./test/output/bar.png","test:lint":"eslint src test","test:node":"vitest","test:format":"prettier --check src test bin"},"_npmUser":{"name":"pearmini","email":"subairui@icloud.com"},"repository":{"url":"git+https://github.com/pearmini/g2-ssr-node.git","type":"git"},"_npmVersion":"6.14.15","description":"The tool for G2 spec's SSR(Server-Side Rendering) in Node.js.","directories":{},"_nodeVersion":"14.18.3","dependencies":{"canvas":"^2.11.2","@antv/g":"^5.18.21","@antv/g2":"^5.1.8","commander":"^11.1.0","node-fetch":"^2.7.0","@antv/g-canvas":"^1.11.24"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.53.0","rollup":"^3.0.0","vitest":"^0.32.0","prettier":"^3.1.0","@rollup/plugin-json":"^6.0.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-node-resolve":"^15.2.3"},"_npmOperationalInternal":{"tmp":"tmp/g2-ssr-node_0.1.0_1700731543422_0.9947617605074845","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@berryv/g2-ssr-node","version":"0.2.0","author":{"url":"https://github.com/pearmini","name":"pearmini"},"license":"ISC","_id":"@berryv/g2-ssr-node@0.2.0","maintainers":[{"name":"pearmini","email":"subairui@icloud.com"}],"homepage":"https://github.com/pearmini/g2-ssr-node#readme","bugs":{"url":"https://github.com/pearmini/g2-ssr-node/issues"},"bin":{"g2-ssr-node":"bin/g2-ssr-node.js"},"dist":{"shasum":"12bc1f4bdae0683997111cfc472926b55c029b69","tarball":"https://registry.npmjs.org/@berryv/g2-ssr-node/-/g2-ssr-node-0.2.0.tgz","fileCount":17,"integrity":"sha512-pWZlLuaEn8H5e4R90jIyfCAySr5yHwbHpR9AwExFi8Qd+iSCdwF7ExyeJcME+BpT//lkaRg+1cqjRdtsxTPAIw==","signatures":[{"sig":"MEYCIQC1nExsTnczuuVSDSmR+IKMkt6PmM+tTGT3OJyT/ELgfwIhANlGx+AaTG5DUSkiaN2X1wD4FrmkVCs6vUyMXQyUaNxz","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1232177},"main":"src/index.js","gitHead":"c07a5b82a4109f30533aaabf35490cf1290816c0","scripts":{"test":"npm run test:lint && npm run test:format && npm run test:node","build":"rm -rf dist && rollup -c","test:cli":"npm run test:png && npm run test:pdf && npm run test:jpeg","test:pdf":"rm -rf ./test/output/bar.pdf && g2-ssr-node g2pdf -i ./test/plots/bar.json -o ./test/output/bar.pdf","test:png":"rm -rf ./test/output/bar.png && g2-ssr-node g2png -i ./test/plots/bar.json -o ./test/output/bar.png","test:jpeg":"rm -rf ./test/output/bar.jpeg && g2-ssr-node g2jpeg -i ./test/plots/bar.json -o ./test/output/bar.jpeg","test:lint":"eslint src test","test:node":"vitest","test:format":"prettier --check src test bin"},"_npmUser":{"name":"pearmini","email":"subairui@icloud.com"},"repository":{"url":"git+https://github.com/pearmini/g2-ssr-node.git","type":"git"},"_npmVersion":"6.14.15","description":"The tool for G2 spec's SSR(Server-Side Rendering) in Node.js.","directories":{},"_nodeVersion":"14.18.3","dependencies":{"canvas":"^2.11.2","@antv/g":"^5.18.21","@antv/g2":"^5.1.8","commander":"^11.1.0","node-fetch":"^2.7.0","@antv/g-canvas":"^1.11.24"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.53.0","rollup":"^3.0.0","vitest":"^0.32.0","prettier":"^3.1.0","@rollup/plugin-json":"^6.0.1","@rollup/plugin-terser":"^0.4.4","eslint-config-prettier":"^9.0.0","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-node-resolve":"^15.2.3"},"_npmOperationalInternal":{"tmp":"tmp/g2-ssr-node_0.2.0_1700809765091_0.09018203224504595","host":"s3://npm-registry-packages"}},"0.2.1":{"name":"@berryv/g2-ssr-node","version":"0.2.1","description":"The tool for G2 spec's SSR(Server-Side Rendering) in Node.js.","author":{"name":"pearmini","url":"https://github.com/pearmini"},"license":"ISC","bin":{"g2-ssr-node":"bin/g2-ssr-node.js"},"main":"src/index.js","repository":{"type":"git","url":"git+https://github.com/pearmini/g2-ssr-node.git"},"scripts":{"test":"npm run test:lint && npm run test:format && npm run test:node","test:cli":"npm run test:png && npm run test:pdf && npm run test:jpeg","test:png":"rm -rf ./test/output/bar.png && g2-ssr-node g2png -i ./test/plots/bar.json -o ./test/output/bar.png","test:canvas":"rm -rf ./test/output/cloud.png && g2-ssr-node g2png -i ./test/plots/cloud.json -o ./test/output/cloud.png","test:pdf":"rm -rf ./test/output/bar.pdf && g2-ssr-node g2pdf -i ./test/plots/bar.json -o ./test/output/bar.pdf","test:jpeg":"rm -rf ./test/output/bar.jpeg && g2-ssr-node g2jpeg -i ./test/plots/bar.json -o ./test/output/bar.jpeg","test:node":"vitest","test:lint":"eslint src test","test:format":"prettier --check src test bin","build":"rm -rf dist && rollup -c","prepublishOnly":"npm run build"},"dependencies":{"@antv/g":"^6.0.0","@antv/g-canvas":"^2.0.0","@antv/g2":"^5.1.8","canvas":"^2.11.2","commander":"^11.1.0","node-fetch":"^2.7.0"},"devDependencies":{"@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.1","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-terser":"^0.4.4","eslint":"^8.53.0","eslint-config-prettier":"^9.0.0","prettier":"^3.1.0","rollup":"^3.0.0","vitest":"^0.32.0"},"gitHead":"e84f11ee90fe9b566770801911bfa6f04e5186c3","bugs":{"url":"https://github.com/pearmini/g2-ssr-node/issues"},"homepage":"https://github.com/pearmini/g2-ssr-node#readme","_id":"@berryv/g2-ssr-node@0.2.1","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-wTqAlJBIoMGrKgVyahA8+LqexrtwBHS/RkeeL0VFPEooqSwndGYNYgWjLOrtJS0upZSp9Ac3TeBkV/ACTxD8sg==","shasum":"69ce3cf68ba03846a28d38290c30e03b54095456","tarball":"https://registry.npmjs.org/@berryv/g2-ssr-node/-/g2-ssr-node-0.2.1.tgz","fileCount":14,"unpackedSize":996308,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCvRNZvKNcuoGV05M2nRzczG6rYYd2u299jjUzIvhRZ3QIhAN3yQoOICCHtz1dZLqPQytiIadO9ABwR4RSwGAfYn9HR"}]},"_npmUser":{"name":"pearmini","email":"subairui@icloud.com"},"directories":{},"maintainers":[{"name":"pearmini","email":"subairui@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/g2-ssr-node_0.2.1_1720702369853_0.2496216465169787"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-23T09:25:43.299Z","modified":"2024-07-11T12:52:50.220Z","0.0.1":"2023-11-23T09:13:09.820Z","0.0.2":"2023-11-23T09:21:35.506Z","0.1.0":"2023-11-23T09:25:43.645Z","0.2.0":"2023-11-24T07:09:25.297Z","0.2.1":"2024-07-11T12:52:50.047Z"},"bugs":{"url":"https://github.com/pearmini/g2-ssr-node/issues"},"author":{"name":"pearmini","url":"https://github.com/pearmini"},"license":"ISC","homepage":"https://github.com/pearmini/g2-ssr-node#readme","repository":{"type":"git","url":"git+https://github.com/pearmini/g2-ssr-node.git"},"description":"The tool for G2 spec's SSR(Server-Side Rendering) in Node.js.","maintainers":[{"name":"pearmini","email":"subairui@icloud.com"}],"readme":"# @berryv/g2-ssr-node\n\nThe tool for G2 spec's SSR(Server-Side Rendering) in Node.js.\n\n## Installing\n\nInstall via a package manager such as Yarn or NPM.\n\n```bash\n$ npm install @berryv/g2-ssr-node\n```\n\nUse CLI to convert a G2 specification file named in `bar.json` into a png file named `bar.png`.\n\n```bash\n$ g2-ssr-node g2png -i ./bar.json -o bar.png\n```\n\nIn Node, use `render` to convert a G2 specification into a png file named `bar.png`.\n\n```js\nconst fs = require(\"fs\");\nconst { render } = require(\"@berry/g2-ssr-node\");\n\nconst spec = {\n  type: \"interval\",\n  data: [\n    { genre: \"Sports\", sold: 275 },\n    { genre: \"Strategy\", sold: 115 },\n    { genre: \"Action\", sold: 120 },\n    { genre: \"Shooter\", sold: 350 },\n    { genre: \"Other\", sold: 150 },\n  ],\n  encode: { x: \"genre\", y: \"sold\", color: \"genre\" },\n};\n\nrender(spec).then((canvas) => {\n  const out = fs.createWriteStream(\"./bar.png\");\n  const stream = canvas.createJPEGStream();\n  stream.pipe(out);\n  stream.on(\"finish\", () => console.log(\"Convert successfully!\"));\n});\n```\n\n## Development\n\n```bash\n$ npm i\n$ npm link\n$ npm run build\n$ npm run test:png\n```\n\n## API Reference\n\n- [CLI](#cli) - Convert spec in command line.\n- [Node](#node) - Convert spec in Node.js.\n\n### CLI\n\n<a name=\"cli-g2png\" href=\"#cli-g2png\">#</a> subcommand.**g2png**\n\n```txt\nUsage: g2-ssr-node g2png [options]\n\nConvert a G2 spec to an PNG image\n\nOptions:\n  -i, --input <filename>   filename for the input spec\n  -o, --output <filename>  filename for the output image\n  -h, --help               display help for command\n```\n\nFor example, convert a G2 specification file named in `bar.json` into a png file named `bar.png`:\n\n```bash\n$ g2-ssr-node g2png -i ./bar.json -o bar.png\n```\n\n<a name=\"cli-g2jpeg\" href=\"#cli-g2jpeg\">#</a> subcommand.**g2jpeg**\n\n```txt\nUsage: g2-ssr-node g2pdf [options]\n\nConvert a G2 spec to a PDF\n\nOptions:\n  -i, --input <filename>   filename for the input spec\n  -o, --output <filename>  filename for the output pdf\n  -h, --help               display help for command\n```\n\nFor example, convert a G2 specification file named in `bar.json` into a png file named `bar.jpeg`:\n\n```bash\n$ g2-ssr-node g2jpeg -i ./bar.json -o bar.jpeg\n```\n\n<a name=\"cli-g2pdf\" href=\"#cli-g2pdf\">#</a> subcommand.**g2pdf**\n\n```txt\nUsage: g2-ssr-node g2jpeg [options]\n\nConvert a G2 spec to an JPEG image\n\nOptions:\n  -i, --input <filename>   filename for the input spec\n  -o, --output <filename>  filename for the output image\n  -h, --help               display help for command\n```\n\nFor example, convert a G2 specification file named in `bar.json` into a png file named `bar.pdf`:\n\n```bash\n$ g2-ssr-node g2pdf -i ./bar.json -o bar.pdf\n```\n\n### Node\n\n<a name=\"node-renderImage\" href=\"#node-renderImage\">#</a> node.**renderImage(_options_)**\n\nRenders a G2 specification into a image canvas in [node-canvas](https://github.com/Automattic/node-canvas) resolved by a promise. Then creates a stream from the returned canvas and write into a file, supporting the following stream types:\n\n- [canvas.createPNGStream](https://github.com/Automattic/node-canvas#canvascreatepngstream)\n- [canvas.createJPEGStream](https://github.com/Automattic/node-canvas#canvascreatejpegstream)\n\nFor example, convert a G2 specification into a png file named `bar.png`.\n\n```js\nconst fs = require(\"fs\");\nconst { render } = require(\"@berry/g2-ssr-node\");\n\nconst spec = {\n  type: \"interval\",\n  data: [\n    { genre: \"Sports\", sold: 275 },\n    { genre: \"Strategy\", sold: 115 },\n    { genre: \"Action\", sold: 120 },\n    { genre: \"Shooter\", sold: 350 },\n    { genre: \"Other\", sold: 150 },\n  ],\n  encode: { x: \"genre\", y: \"sold\", color: \"genre\" },\n};\n\nrenderImage(spec).then((canvas) => {\n  const out = fs.createWriteStream(\"./bar.png\");\n  const stream = canvas.createJPEGStream();\n  stream.pipe(out);\n  stream.on(\"finish\", () => console.log(\"Convert successfully!\"));\n});\n```\n\n<a name=\"node-renderPDF\" href=\"#node-renderPDF\">#</a> node.**renderPDF(_options_)**\n\nRenders a G2 specification into a pdf canvas in [node-canvas](https://github.com/Automattic/node-canvas) resolved by a promise. Then creates a pdf stream from the returned canvas and write into a file:\n\n- [canvas.createPDFStream](https://github.com/Automattic/node-canvas#canvascreatepdfstream)\n\nFor example, convert a G2 specification into a png file named `bar.png`.\n\n```js\nconst fs = require(\"fs\");\nconst { render } = require(\"@berry/g2-ssr-node\");\n\nconst spec = {\n  type: \"interval\",\n  data: [\n    { genre: \"Sports\", sold: 275 },\n    { genre: \"Strategy\", sold: 115 },\n    { genre: \"Action\", sold: 120 },\n    { genre: \"Shooter\", sold: 350 },\n    { genre: \"Other\", sold: 150 },\n  ],\n  encode: { x: \"genre\", y: \"sold\", color: \"genre\" },\n};\n\nrenderPDF(spec).then((canvas) => {\n  const out = fs.createWriteStream(\"./bar.png\");\n  const stream = canvas.createPDFStream();\n  stream.pipe(out);\n  stream.on(\"finish\", () => console.log(\"Convert successfully!\"));\n});\n```\n","readmeFilename":"README.md"}