@liquid-js/qr-code-styling 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/core/QROptions.d.ts
CHANGED
|
@@ -183,7 +183,8 @@ const defaultOptions = {
|
|
|
183
183
|
},
|
|
184
184
|
dotsOptions: {
|
|
185
185
|
type: exports.DotType.square,
|
|
186
|
-
color: "#000"
|
|
186
|
+
color: "#000",
|
|
187
|
+
size: 10
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
190
|
|
|
@@ -773,9 +774,7 @@ class QRSVG {
|
|
|
773
774
|
}
|
|
774
775
|
async drawQR(qr) {
|
|
775
776
|
const count = qr.getModuleCount();
|
|
776
|
-
const
|
|
777
|
-
const realQRSize = this._options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
|
|
778
|
-
const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
|
|
777
|
+
const dotSize = this._options.dotsOptions.size;
|
|
779
778
|
let drawImageSize = {
|
|
780
779
|
hideXDots: 0,
|
|
781
780
|
hideYDots: 0,
|
|
@@ -860,8 +859,7 @@ class QRSVG {
|
|
|
860
859
|
throw "The canvas is too small.";
|
|
861
860
|
}
|
|
862
861
|
const minSize = Math.min(options.width, options.height);
|
|
863
|
-
const
|
|
864
|
-
const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
|
|
862
|
+
const dotSize = this._options.dotsOptions.size;
|
|
865
863
|
const xBeginning = Math.floor((options.width - count * dotSize) / 2);
|
|
866
864
|
const yBeginning = Math.floor((options.height - count * dotSize) / 2);
|
|
867
865
|
const dot = new QRDot({ svg: this._element, type: options.dotsOptions.type, document: this._document });
|
|
@@ -949,9 +947,7 @@ class QRSVG {
|
|
|
949
947
|
throw "Element code is not defined";
|
|
950
948
|
}
|
|
951
949
|
const count = this._qr.getModuleCount();
|
|
952
|
-
const
|
|
953
|
-
const realQRSize = options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
|
|
954
|
-
const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
|
|
950
|
+
const dotSize = this._options.dotsOptions.size;
|
|
955
951
|
const cornersSquareSize = dotSize * 7;
|
|
956
952
|
const cornersDotSize = dotSize * 3;
|
|
957
953
|
const xBeginning = Math.floor((options.width - count * dotSize) / 2);
|
|
@@ -1177,8 +1173,13 @@ let QRCodeStyling$1 = class QRCodeStyling {
|
|
|
1177
1173
|
if (!this._qr) {
|
|
1178
1174
|
return;
|
|
1179
1175
|
}
|
|
1180
|
-
|
|
1181
|
-
const
|
|
1176
|
+
const count = Math.ceil((this._options.shape == exports.ShapeType.circle ? Math.sqrt(2) : 1) * this._qr.getModuleCount());
|
|
1177
|
+
const size = this._options.dotsOptions.size * (count + 2 * this._options.margin);
|
|
1178
|
+
const qrSVG = new QRSVG({
|
|
1179
|
+
...this._options,
|
|
1180
|
+
width: size,
|
|
1181
|
+
height: size
|
|
1182
|
+
});
|
|
1182
1183
|
this._svg = qrSVG.getElement();
|
|
1183
1184
|
this._svgDrawingPromise = qrSVG.drawQR(this._qr).then(() => {
|
|
1184
1185
|
if (!this._svg)
|
|
@@ -1248,7 +1249,7 @@ class QRCodeStyling extends QRCodeStyling$1 {
|
|
|
1248
1249
|
constructor(options) {
|
|
1249
1250
|
const dom = new xmldom.DOMImplementation().createDocument(null, null);
|
|
1250
1251
|
const imageCache = new Map();
|
|
1251
|
-
const loadImage = async (url)
|
|
1252
|
+
const loadImage = async function (url) {
|
|
1252
1253
|
if (typeof url == "string") {
|
|
1253
1254
|
let pr = imageCache.get(url);
|
|
1254
1255
|
if (pr)
|
|
@@ -1279,7 +1280,7 @@ class QRCodeStyling extends QRCodeStyling$1 {
|
|
|
1279
1280
|
document: options.document || dom,
|
|
1280
1281
|
imageTools: options.imageTools || {
|
|
1281
1282
|
toDataURL: (url) => loadImage(url).then(({ contentType, data }) => `data:${contentType?.replace("application/xml", "image/svg+xml")};base64,${data.toString("base64")}`),
|
|
1282
|
-
getSize: async (options)
|
|
1283
|
+
getSize: async function (options) {
|
|
1283
1284
|
if (!options.image) {
|
|
1284
1285
|
throw new Error("Image is not defined");
|
|
1285
1286
|
}
|