@liquid-js/qr-code-styling 1.10.1 → 1.10.3

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.
@@ -750,6 +750,48 @@ const dotMask = [
750
750
  [0, 0, 0, 0, 0, 0, 0],
751
751
  [0, 0, 0, 0, 0, 0, 0]
752
752
  ];
753
+ const dataCount = {
754
+ "1": 104,
755
+ "2": 176,
756
+ "3": 272,
757
+ "4": 384,
758
+ "5": 496,
759
+ "6": 608,
760
+ "7": 704,
761
+ "8": 880,
762
+ "9": 1056,
763
+ "10": 1232,
764
+ "11": 1440,
765
+ "12": 1648,
766
+ "13": 1952,
767
+ "14": 2088,
768
+ "15": 2360,
769
+ "16": 2600,
770
+ "17": 2936,
771
+ "18": 3176,
772
+ "19": 3560,
773
+ "20": 3880,
774
+ "21": 4096,
775
+ "22": 4544,
776
+ "23": 4912,
777
+ "24": 5312,
778
+ "25": 5744,
779
+ "26": 6032,
780
+ "27": 6464,
781
+ "28": 6968,
782
+ "29": 7288,
783
+ "30": 7880,
784
+ "31": 8264,
785
+ "32": 8920,
786
+ "33": 9368,
787
+ "34": 9848,
788
+ "35": 10288,
789
+ "36": 10832,
790
+ "37": 11408,
791
+ "38": 12016,
792
+ "39": 12656,
793
+ "40": 13328
794
+ };
753
795
  class QRSVG {
754
796
  //TODO don't pass all options to this class
755
797
  constructor(options) {
@@ -774,6 +816,7 @@ class QRSVG {
774
816
  }
775
817
  async drawQR(qr) {
776
818
  const count = qr.getModuleCount();
819
+ const typeNumber = ((count - 17) / 4).toFixed(0);
777
820
  const dotSize = this._options.dotsOptions.size;
778
821
  let drawImageSize = {
779
822
  hideXDots: 0,
@@ -787,7 +830,7 @@ class QRSVG {
787
830
  const size = await this._imageTools.getSize(this._options);
788
831
  const { imageOptions, qrOptions } = this._options;
789
832
  const coverLevel = imageOptions.imageSize * ErrorCorrectionPercents[qrOptions.errorCorrectionLevel];
790
- const maxHiddenDots = Math.floor(coverLevel * count * count);
833
+ const maxHiddenDots = Math.floor(coverLevel * dataCount[typeNumber]);
791
834
  drawImageSize = calculateImageSize({
792
835
  originalWidth: size.width,
793
836
  originalHeight: size.height,
@@ -1249,7 +1292,7 @@ class QRCodeStyling extends QRCodeStyling$1 {
1249
1292
  constructor(options) {
1250
1293
  const dom = new xmldom.DOMImplementation().createDocument(null, null);
1251
1294
  const imageCache = new Map();
1252
- const loadImage = async (url) => {
1295
+ const loadImage = async function (url) {
1253
1296
  if (typeof url == "string") {
1254
1297
  let pr = imageCache.get(url);
1255
1298
  if (pr)
@@ -1280,7 +1323,7 @@ class QRCodeStyling extends QRCodeStyling$1 {
1280
1323
  document: options.document || dom,
1281
1324
  imageTools: options.imageTools || {
1282
1325
  toDataURL: (url) => loadImage(url).then(({ contentType, data }) => `data:${contentType?.replace("application/xml", "image/svg+xml")};base64,${data.toString("base64")}`),
1283
- getSize: async (options) => {
1326
+ getSize: async function (options) {
1284
1327
  if (!options.image) {
1285
1328
  throw new Error("Image is not defined");
1286
1329
  }