aruZeta / QRgen

A QR code generation library.
https://aruzeta.github.io/QRgen/
MIT License
103 stars 8 forks source link

Compile to JS #20

Closed enthus1ast closed 2 years ago

enthus1ast commented 2 years ago

It would be nice to generate QRcodes on the JS backend in the browser. Currently it fails with:

import QRgen
let urlQR = newQR("https://my-url.domain")
echo urlQR.printSvg
nim js -r "qrgent.nim"
Hint: used config file 'C:\Users\david\.choosenim\toolchains\nim-1.6.6\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\david\.choosenim\toolchains\nim-1.6.6\config\config.nims' [Conf]
............................................................................
C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\pure\encodings.nim(470, 20) Error: undeclared identifier: 'EILSEQ'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (3, 9): 'DirSep' [const declared in C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\pure\includes\osseps.nim(27, 3)]
 (3, 9): 'ExtSep' [const declared in C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\pure\includes\osseps.nim(89, 3)]
 (3, 9): 'File' [type declared in C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\system\io.nim(21, 3)]
 (3, 9): 'false' [enumField declared in C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\system\basic_types.nim(16, 5)]
 (3, 9): 'newSeq' [proc declared in C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\system.nim(643, 6)]
 (3, 9): 'newSeq' [proc declared in C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\system.nim(662, 6)]
 (3, 9): 'seq' [type declared in C:\Users\david\.choosenim\toolchains\nim-1.6.6\lib\system.nim(299, 3)]
aruZeta commented 2 years ago

Seems like it's an issue related to encodings, which will most likely be removed in #18, so let's see if it works after that.

enthus1ast commented 2 years ago

with disabled encoding ( #18 ) and some small changes it works nicely on the js backend: https://github.com/enthus1ast/QRgen/tree/js

aruZeta commented 2 years ago

Nice! Will commit the fix to 18 when I get home in some hours, or if possible you could make a PR to develop :)

aruZeta commented 2 years ago

The last commit fixed the issue.

(The only issue I see is that there is no stdout in JS)