{"_rev":"8-fc4da416c05bd1d6d95c8c34da33c0d3","time":{"created":"2022-08-16T21:25:15.057Z","1.6.0-rc.2":"2022-08-16T21:01:19.938Z","modified":"2022-08-16T21:25:15.464Z","1.6.0-rc.3":"2022-08-16T21:21:30.537Z","1.6.0-rc.4":"2022-08-16T21:25:15.321Z"},"_id":"@buza_me/qr-code-styling","name":"@buza_me/qr-code-styling","dist-tags":{"latest":"1.6.0-rc.4"},"versions":{"1.6.0-rc.4":{"name":"@buza_me/qr-code-styling","version":"1.6.0-rc.4","description":"Add a style and an image to your QR code","main":"lib/qr-code-styling.js","types":"lib/index.d.ts","dependencies":{"qrcode-generator":"^1.4.3"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","canvas":"^2.8.0","clean-webpack-plugin":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-loader":"^4.0.2","eslint-plugin-jest":"^24.1.3","eslint-plugin-prettier":"^3.3.1","html-webpack-plugin":"^4.5.1","jest":"^26.6.3","jest-environment-jsdom-fifteen":"^1.0.0","prettier":"^2.2.1","ts-jest":"^26.4.4","ts-loader":"^8.0.14","typescript":"^4.1.3","webpack":"^5.12.3","webpack-cli":"^4.3.1","webpack-dev-server":"^3.11.1","webpack-merge":"^5.7.3"},"scripts":{"build":"webpack --mode=production --config webpack.config.build.js","build:dev":"webpack --mode=development --config webpack.config.build.js","test":"jest","start":"webpack serve --open --config webpack.config.dev-server.js","lint-fix":"eslint --cache --fix \"src/**/*.{ts,tsx}\""},"repository":{"type":"git","url":"git+https://github.com/buza-me/qr-code-styling.git"},"keywords":["qr","qrcode","qr-code","js","qrjs","qrstyling","styling","qrbranding","branding","qrimage","image","qrlogo","logo","design"],"author":{"name":"Denys Kozak","email":"kozak.denys.dev@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/kozakdenys/qr-code-styling/issues"},"homepage":"https://qr-code-styling.com","gitHead":"0eee55c3d842953de9946c6d3bc3f4265e2fded1","_id":"@buza_me/qr-code-styling@1.6.0-rc.4","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-qsIavwSfebOA/yAQ37iYc7XQ7EzaCMOGIx2mcwcGPIkebHKBb65TAdZUP8tTI/Rl9aEkXEU/KQqt8FrrxRXP2g==","shasum":"ab3dc47bad3516881b8e14ca7f1b98ba30ce375e","tarball":"https://registry.npmjs.org/@buza_me/qr-code-styling/-/qr-code-styling-1.6.0-rc.4.tgz","fileCount":30,"unpackedSize":264891,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBGJjhcUeqK5jcC8cqaBrWj1mHUxaQkB5Ik1X3bJrQ1HAiEAhJ5klve7iStuz/dAQ9t8/8rvItMd4ruXjzcueDSnQqM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi/As7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrdNw//Y36BEsgBtZ7maB1LWUU27soONreUlUxItGxZSKJB0uDXJMJQ\r\n+CUjW0dLtQGJ3FkMQxGIZVWxatP8twQVxp+DEPOd/jpiReTdTIlkTgK6J2UC\r\nAQ14BKPaD0vKxJoRqI5b6TP9tEbSFhWum+4r1JhOE/kgnVdUt11WQ7rVeSYW\r\nbdwtG69WsFluvNPO6Lm8qrQiQC5r4+U3u315lu0htUx2sJao2w+s9wJkDzHB\r\ncW/hXvy5uavc41JeyV1ONqA9YYr1LnaG6XEM/okxYqNxe6aoQ8JLsb5mcB8q\r\nE/Tkek56ins0QXNPb7RuBzaMARfPUAjwfQHaXMqEe1XfCwD1/QIVnb+o+Wih\r\nWcoYkifcYV4E1FZXqGLFjUqxgH1ORiBC+LF3waZvZrxE1aEytTH7t8Qr7P/u\r\n8mZMiOYjHuIoDT3Y6sKyTyI+peoSKOveFikL3T3X+z/XQFznNbYjuaNvYrI4\r\nKcZmyYsxN4tSkTDth9SfPT8P3gTUf+ZZ+8uphkpO/BxsCQTjXZNpaSrDlWhY\r\nME4nahLXvWmZjQNaFBUK79JPZ+vFpVfgAqUiakd+f6CzU6L5OgoEb8d1IFxr\r\nszgdUETf6azdaquMwAvpQWO0NLnk7YBq1Om8CYFRLPpPCei2mSfhuWZdnSDn\r\nPjxXJWKFoChtRv827FSvKF771A582ygbHYg=\r\n=afrF\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"buza_me","email":"buza.work@gmail.com"},"directories":{},"maintainers":[{"name":"buza_me","email":"buza.work@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/qr-code-styling_1.6.0-rc.4_1660685115103_0.870499161577885"},"_hasShrinkwrap":false}},"maintainers":[{"name":"buza_me","email":"buza.work@gmail.com"}],"description":"Add a style and an image to your QR code","homepage":"https://qr-code-styling.com","keywords":["qr","qrcode","qr-code","js","qrjs","qrstyling","styling","qrbranding","branding","qrimage","image","qrlogo","logo","design"],"repository":{"type":"git","url":"git+https://github.com/buza-me/qr-code-styling.git"},"author":{"name":"Denys Kozak","email":"kozak.denys.dev@gmail.com"},"bugs":{"url":"https://github.com/kozakdenys/qr-code-styling/issues"},"license":"MIT","readme":"# QR Code Styling\r\n[![Version](https://img.shields.io/npm/v/qr-code-styling.svg)](https://www.npmjs.org/package/qr-code-styling)\r\n\r\nJavaScript library for generating QR codes with a logo and styling.\r\n\r\nTry it here https://qr-code-styling.com\r\n\r\nIf you have issues / suggestions / notes / questions, please open an issue or contact me. Let's create a cool library together.\r\n### Examples\r\n<p float=\"left\">\r\n<img style=\"display:inline-block\" src=\"https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/facebook_example_new.png\" width=\"240\" />\r\n<img style=\"display:inline-block\" src=\"https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/qr_code_example.png\" width=\"240\" />\r\n<img style=\"display:inline-block\" src=\"https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/telegram_example_new.png\" width=\"240\" />\r\n</p>\r\n\r\n### Installation\r\n\r\n```\r\nnpm install qr-code-styling\r\n```\r\n\r\n### Usage\r\n\r\n```HTML\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>QR Code Styling</title>\r\n    <script type=\"text/javascript\" src=\"https://unpkg.com/qr-code-styling@1.5.0/lib/qr-code-styling.js\"></script>\r\n</head>\r\n<body>\r\n<div id=\"canvas\"></div>\r\n<script type=\"text/javascript\">\r\n\r\n    const qrCode = new QRCodeStyling({\r\n        width: 300,\r\n        height: 300,\r\n        type: \"svg\",\r\n        data: \"https://www.facebook.com/\",\r\n        image: \"https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg\",\r\n        dotsOptions: {\r\n            color: \"#4267b2\",\r\n            type: \"rounded\"\r\n        },\r\n        backgroundOptions: {\r\n            color: \"#e9ebee\",\r\n        },\r\n        imageOptions: {\r\n            crossOrigin: \"anonymous\",\r\n            margin: 20\r\n        }\r\n    });\r\n\r\n    qrCode.append(document.getElementById(\"canvas\"));\r\n    qrCode.download({ name: \"qr\", extension: \"svg\" });\r\n</script>\r\n</body>\r\n</html>\r\n```\r\n---\r\n\r\n[**React example (Codesandbox)**](https://codesandbox.io/s/qr-code-styling-react-example-l8rwl?file=/src/App.js)\r\n\r\n[**Angular example (Codesandbox)**](https://codesandbox.io/s/agitated-panini-tpgb2?file=/src/app/app.component.ts)\r\n\r\n---\r\n\r\n[**React example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/react)\r\n\r\n[**Angular example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/angular)\r\n\r\n[**Vue example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/vue)\r\n\r\n---\r\n\r\n### API Documentation\r\n\r\n#### QRCodeStyling instance\r\n`new QRCodeStyling(options) => QRCodeStyling`\r\n\r\nParam  |Type  |Description\r\n-------|------|------------\r\noptions|object|Init object\r\n\r\n`options` structure\r\n\r\nProperty               |Type                     |Default Value|Description\r\n-----------------------|-------------------------|-------------|-----------------------------------------------------\r\nwidth                  |number                   |`300`        |Size of canvas\r\nheight                 |number                   |`300`        |Size of canvas\r\ntype                   |string (`'canvas' 'svg'`)|`canvas`     |The type of the element that will be rendered\r\ndata                   |string                   |             |The date will be encoded to the QR code\r\nimage                  |string                   |             |The image will be copied to the center of the QR code\r\nmargin                 |number                   |`0`          |Margin around canvas\r\nqrOptions              |object                   |             |Options will be passed to `qrcode-generator` lib\r\nimageOptions           |object                   |             |Specific image options, details see below\r\ndotsOptions            |object                   |             |Dots styling options\r\ncornersSquareOptions   |object                   |             |Square in the corners styling options\r\ncornersDotOptionsHelper|object                   |             |Dots in the corners styling options\r\nbackgroundOptions      |object                   |             |QR background styling options\r\n\r\n`options.qrOptions` structure\r\n\r\nProperty              |Type                                              |Default Value\r\n----------------------|--------------------------------------------------|-------------\r\ntypeNumber            |number (`0 - 40`)                                 |`0`\r\nmode                  |string (`'Numeric' 'Alphanumeric' 'Byte' 'Kanji'`)|\r\nerrorCorrectionLevel  |string (`'L' 'M' 'Q' 'H'`)                        |`'Q'`\r\nbyteModeStringEncoding|string (`'default' 'UTF-8' 'SJIS'`)               |`'default'`\r\n\r\n`options.imageOptions` structure\r\n\r\nProperty          |Type                                   |Default Value|Description\r\n------------------|---------------------------------------|-------------|------------------------------------------------------------------------------\r\nhideBackgroundDots|boolean                                |`true`       |Hide all dots covered by the image\r\nimageSize         |number                                 |`0.4`        |Coefficient of the image size. Not recommended to use ove 0.5. Lower is better\r\nmargin            |number                                 |`0`          |Margin of the image in px\r\ncrossOrigin       |string(`'anonymous' 'use-credentials'`)|             |Set \"anonymous\" if you want to download QR code from other origins.\r\n\r\n`options.dotsOptions` structure\r\n\r\nProperty|Type                                                                          |Default Value|Description\r\n--------|------------------------------------------------------------------------------|-------------|-------------------\r\ncolor   |string                                                                        |`'#000'`     |Color of QR dots\r\ngradient|object                                                                        |             |Gradient of QR dots\r\ntype    |string (`'rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded'`)|`'square'`   |Style of QR dots\r\n\r\n`options.backgroundOptions` structure\r\n\r\nProperty|Type  |Default Value\r\n--------|------|-------------\r\ncolor   |string|`'#fff'`\r\ngradient|object|\r\n\r\n`options.cornersSquareOptions` structure\r\n\r\nProperty|Type                                     |Default Value|Description\r\n--------|-----------------------------------------|-------------|-----------------\r\ncolor   |string                                   |             |Color of Corners Square\r\ngradient|object                                   |             |Gradient of Corners Square\r\ntype    |string (`'dot' 'square' 'extra-rounded'`)|             |Style of Corners Square\r\n\r\n`options.cornersDotOptions` structure\r\n\r\nProperty|Type                     |Default Value|Description\r\n--------|-------------------------|-------------|-----------------\r\ncolor   |string                   |             |Color of Corners Dot\r\ngradient|object                   |             |Gradient of Corners Dot\r\ntype    |string (`'dot' 'square'`)|             |Style of Corners Dot\r\n\r\nGradient structure\r\n\r\n`options.dotsOptions.gradient`\r\n\r\n`options.backgroundOptions.gradient`\r\n\r\n`options.cornersSquareOptions.gradient`\r\n\r\n`options.cornersDotOptions.gradient`\r\n\r\nProperty  |Type                        |Default Value|Description\r\n----------|----------------------------|-------------|---------------------------------------------------------\r\ntype      |string (`'linear' 'radial'`)|\"linear\"     |Type of gradient spread\r\nrotation  |number                      |0            |Rotation of gradient in radians (Math.PI === 180 degrees)\r\ncolorStops|array of objects            |             |Gradient colors. Example `[{ offset: 0, color: 'blue' }, {  offset: 1, color: 'red' }]`\r\n\r\nGradient colorStops structure\r\n\r\n`options.dotsOptions.gradient.colorStops[]`\r\n\r\n`options.backgroundOptions.gradient.colorStops[]`\r\n\r\n`options.cornersSquareOptions.gradient.colorStops[]`\r\n\r\n`options.cornersDotOptions.gradient.colorStops[]`\r\n\r\nProperty|Type            |Default Value|Description\r\n--------|----------------|-------------|-----------------------------------\r\noffset  |number (`0 - 1`)|             |Position of color in gradient range\r\ncolor   |string          |             |Color of stop in gradient range\r\n\r\n#### QRCodeStyling methods\r\n`QRCodeStyling.append(container) => void`\r\n\r\nParam    |Type       |Description\r\n---------|-----------|-----------\r\ncontainer|DOM element|This container will be used for appending of the QR code\r\n\r\n`QRCodeStyling.getRawData(extension) => Promise<Blob>`\r\n\r\nParam    |Type                                |Default Value|Description\r\n---------|------------------------------------|-------------|------------\r\nextension|string (`'png' 'jpeg' 'webp' 'svg'`)|`'png'`      |Blob type\r\n\r\n`QRCodeStyling.update(options) => void`\r\n\r\nParam  |Type  |Description\r\n-------|------|--------------------------------------\r\noptions|object|The same options as for initialization\r\n\r\n`QRCodeStyling.applyExtension(extension) => void`\r\n\r\nParam    |Type                  |Description\r\n---------|----------------------|------------------------------------------------------------------------------------------\r\nextension|(svg, options) => void|Extension is a function that takes svg and previously applied options and modifies an svg\r\n\r\n`applyExtension` example\r\n\r\n```JS\r\nconst extension = (svg, options) => {\r\n    const { width, height } = options;\r\n    const size = Math.min(width, height);\r\n    const border = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\r\n    const borderAttributes = {\r\n        \"fill\": \"none\",\r\n        \"x\": (width - size + 40) / 2,\r\n        \"y\": (height - size + 40) / 2,\r\n        \"width\": size - 40,\r\n        \"height\": size - 40,\r\n        \"stroke\": 'black',\r\n        \"stroke-width\": 40,\r\n        \"rx\": 100,\r\n    };\r\n    Object.keys(borderAttributes).forEach(attribute => {\r\n      border.setAttribute(attribute, borderAttributes[attribute]);\r\n    });\r\n    svg.appendChild(border);\r\n};\r\n```\r\n\r\n`QRCodeStyling.deleteExtension() => void`\r\n\r\n`QRCodeStyling.download(downloadOptions) => Promise<void>`\r\n\r\nParam          |Type  |Description\r\n---------------|------|------------\r\ndownloadOptions|object|Options with extension and name of file (not required)\r\n\r\n`downloadOptions` structure\r\n\r\nProperty |Type                                |Default Value|Description\r\n---------|------------------------------------|-------------|-----------------------------------------------------\r\nname     |string                              |`'qr'`       |Name of the downloaded file\r\nextension|string (`'png' 'jpeg' 'webp' 'svg'`)|`'png'`      |File extension\r\n\r\n\r\n### License\r\n\r\n[MIT License](https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/LICENSE). Copyright (c) 2021 Denys Kozak\r\n\r\n","readmeFilename":"README.md"}