Skip to content

Commit

Permalink
fix(qrcode): namespace_cache (#99)
Browse files Browse the repository at this point in the history
Co-authored-by: Raphaël Balet <raphael@megaphone.info>
  • Loading branch information
rbalet and Raphaël Balet authored Jun 12, 2024
1 parent 3ad7fa0 commit 65da1d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/demo",
"preserveSymlinks": true,
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions projects/ngx-kjua/src/lib/kjua/lib/qrcode.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
const RE_CODE_LENGTH_OVERFLOW = /code length overflow/i;

import * as qr_gen from "qrcode-generator";
(qr_gen as any).stringToBytes = qr_gen.stringToBytesFuncs["UTF-8"];
import qrcode from "qrcode-generator";
qrcode.stringToBytes = qrcode.stringToBytesFuncs["UTF-8"];

const min_qrcode = (text: any, level: any, min_ver: number = 1) => {
min_ver = Math.max(1, min_ver);
const min_qrcode = (
text: string,
level: ErrorCorrectionLevel,
min_ver: TypeNumber = 1
) => {
min_ver = Math.max(1, min_ver) as TypeNumber;

for (let version = min_ver; version <= 40; version += 1) {
try {
const qr = (qr_gen as any)(version, level);
const qr = qrcode(version, level);
qr.addData(text);
qr.make();
const module_count = qr.getModuleCount();
Expand All @@ -33,8 +37,8 @@ const min_qrcode = (text: any, level: any, min_ver: number = 1) => {

export const quiet_qrcode = (
text = "",
level = "L",
min_ver = 1,
level: ErrorCorrectionLevel = "L",
min_ver: TypeNumber = 1,
quiet = 0
) => {
const qr = min_qrcode(text, level, min_ver);
Expand Down

0 comments on commit 65da1d7

Please sign in to comment.