Socket
Socket
Sign inDemoInstall

react-qrcode-logo

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-qrcode-logo - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

13

dist/index.d.ts
import * as React from 'react';
declare enum ErrorCorrectionLevel {
'L' = 1,
'M' = 0,
'Q' = 3,
'H' = 2
}
export interface IProps {
value?: string;
ecLevel?: keyof typeof ErrorCorrectionLevel;
ecLevel?: 'L' | 'M' | 'Q' | 'H';
size?: number;

@@ -19,3 +13,3 @@ padding?: number;

logoOpacity?: number;
style?: Object;
style?: object;
}

@@ -40,6 +34,5 @@ export declare class QRCode extends React.Component<IProps, {}> {

background: string;
} & Object;
};
ref: React.RefObject<HTMLCanvasElement>;
}, HTMLCanvasElement>;
}
export {};

@@ -15,14 +15,18 @@ "use strict";

})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var isEqual = require("lodash.isequal");
var qrcode = require("qrcode-generator");
var React = require("react");
var ReactDOM = require("react-dom");
var QRCodeImpl = require("qr.js/lib/QRCode");
var isEqual = require("lodash.isequal");
var ErrorCorrectionLevel;
(function (ErrorCorrectionLevel) {
ErrorCorrectionLevel[ErrorCorrectionLevel["L"] = 1] = "L";
ErrorCorrectionLevel[ErrorCorrectionLevel["M"] = 0] = "M";
ErrorCorrectionLevel[ErrorCorrectionLevel["Q"] = 3] = "Q";
ErrorCorrectionLevel[ErrorCorrectionLevel["H"] = 2] = "H";
})(ErrorCorrectionLevel || (ErrorCorrectionLevel = {}));
var QRCode = /** @class */ (function (_super) {

@@ -65,23 +69,21 @@ __extends(QRCode, _super);

QRCode.prototype.update = function () {
var _this = this;
var _a = this.props, value = _a.value, ecLevel = _a.ecLevel, size = _a.size, bgColor = _a.bgColor, fgColor = _a.fgColor, logoImage = _a.logoImage, logoWidth = _a.logoWidth, logoHeight = _a.logoHeight, logoOpacity = _a.logoOpacity;
var qrcode = new QRCodeImpl(-1, ErrorCorrectionLevel[ecLevel]);
qrcode.addData(QRCode.utf16to8(value));
qrcode.make();
var myqrcode = qrcode(0, ecLevel);
myqrcode.addData(QRCode.utf16to8(value));
myqrcode.make();
var canvas = ReactDOM.findDOMNode(this.canvas.current);
var ctx = canvas.getContext('2d');
var cells = qrcode.modules;
var tileW = size / cells.length;
var tileH = size / cells.length;
var tileW = size / myqrcode.getModuleCount();
var tileH = size / myqrcode.getModuleCount();
var scale = (window.devicePixelRatio || 1);
canvas.height = canvas.width = size * scale;
ctx.scale(scale, scale);
cells.forEach(function (row, rdx) {
row.forEach(function (cell, cdx) {
ctx.fillStyle = cell ? fgColor : bgColor;
var w = (Math.ceil((cdx + 1) * tileW) - Math.floor(cdx * tileW));
var h = (Math.ceil((rdx + 1) * tileH) - Math.floor(rdx * tileH));
ctx.fillRect(Math.round(cdx * tileW), Math.round(rdx * tileH), w, h);
}, _this);
}, this);
for (var i = 0; i < (myqrcode.getModuleCount()); i++) {
for (var j = 0; j < (myqrcode.getModuleCount()); j++) {
ctx.fillStyle = myqrcode.isDark(i, j) ? fgColor : bgColor;
var w = (Math.ceil((j + 1) * tileW) - Math.floor(j * tileW));
var h = (Math.ceil((i + 1) * tileH) - Math.floor(i * tileH));
ctx.fillRect(Math.round(j * tileW), Math.round(i * tileH), w, h);
}
}
if (logoImage) {

@@ -109,6 +111,3 @@ var image_1 = new Image();

width: this.props.size,
style: Object.assign({
height: this.props.size + 'px', width: this.props.size + 'px',
padding: (100 * this.props.padding) / this.props.size + '%', background: this.props.bgColor
}, this.props.style),
style: __assign({ height: this.props.size + 'px', width: this.props.size + 'px', padding: (100 * this.props.padding) / this.props.size + '%', background: this.props.bgColor }, this.props.style),
ref: this.canvas

@@ -115,0 +114,0 @@ });

{
"name": "react-qrcode-logo",
"version": "1.1.0",
"version": "2.0.0",
"description": "React component to generate a QR Code customizable with logo and more properties",

@@ -39,4 +39,4 @@ "main": "dist/index.js",

"lodash.isequal": "^4.5.0",
"qr.js": "0.0.0"
"qrcode-generator": "^1.4.1"
}
}

@@ -21,3 +21,3 @@ # react-qrcode-logo

## Avaiable Props
## Available Props
| Prop | Type | Default value | Description |

@@ -24,0 +24,0 @@ | ------------|---------------------------------------| ---------------------|-----|

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc