@liquid-js/qr-code-styling 2.2.2 → 2.3.0
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/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Denys Kozak
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Denys Kozak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -34,7 +34,7 @@ export declare class QRCodeStyling {
|
|
|
34
34
|
* const extension = (svg, options) => {
|
|
35
35
|
* const { width, height } = options;
|
|
36
36
|
* const size = Math.min(width, height);
|
|
37
|
-
* const border = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
37
|
+
* const border = options.document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
38
38
|
* const borderAttributes = {
|
|
39
39
|
* fill: "none",
|
|
40
40
|
* x: (width - size + 40) / 2,
|
|
@@ -62,6 +62,7 @@ var Mode;
|
|
|
62
62
|
Mode["alphanumeric"] = "Alphanumeric";
|
|
63
63
|
Mode["byte"] = "Byte";
|
|
64
64
|
Mode["kanji"] = "Kanji";
|
|
65
|
+
Mode["unicode"] = "Unicode";
|
|
65
66
|
})(Mode || (Mode = {}));
|
|
66
67
|
var FileExtension;
|
|
67
68
|
(function (FileExtension) {
|
|
@@ -84,6 +85,9 @@ function getMode(data) {
|
|
|
84
85
|
return Mode.numeric;
|
|
85
86
|
case /^[0-9A-Z $%*+\-./:]*$/.test(data):
|
|
86
87
|
return Mode.alphanumeric;
|
|
88
|
+
// eslint-disable-next-line no-control-regex
|
|
89
|
+
case /[^\u0000-\u00ff]/.test(data):
|
|
90
|
+
return Mode.unicode;
|
|
87
91
|
default:
|
|
88
92
|
return Mode.byte;
|
|
89
93
|
}
|
|
@@ -398,7 +402,7 @@ class QRCornerDot {
|
|
|
398
402
|
this._rotateFigure({
|
|
399
403
|
...args,
|
|
400
404
|
draw: () => {
|
|
401
|
-
this._element =
|
|
405
|
+
this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
402
406
|
this._element.setAttribute("x", String(x));
|
|
403
407
|
this._element.setAttribute("y", String(y));
|
|
404
408
|
this._element.setAttribute("width", String(size));
|
|
@@ -414,7 +418,7 @@ class QRCornerDot {
|
|
|
414
418
|
this._rotateFigure({
|
|
415
419
|
...args,
|
|
416
420
|
draw: () => {
|
|
417
|
-
this._element =
|
|
421
|
+
this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
418
422
|
this._element.setAttribute("clip-rule", "evenodd");
|
|
419
423
|
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
420
424
|
`v ${2 * dotSize}` +
|
|
@@ -434,7 +438,7 @@ class QRCornerDot {
|
|
|
434
438
|
this._rotateFigure({
|
|
435
439
|
...args,
|
|
436
440
|
draw: () => {
|
|
437
|
-
this._element =
|
|
441
|
+
this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
438
442
|
this._element.setAttribute("clip-rule", "evenodd");
|
|
439
443
|
this._element.setAttribute("d", `M ${x} ${y + dotSize / 2}` +
|
|
440
444
|
`v ${dotSize / 4}` +
|
|
@@ -588,7 +592,7 @@ class QRCornerSquare {
|
|
|
588
592
|
this._rotateFigure({
|
|
589
593
|
...args,
|
|
590
594
|
draw: () => {
|
|
591
|
-
this._element =
|
|
595
|
+
this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
592
596
|
this._element.setAttribute("clip-rule", "evenodd");
|
|
593
597
|
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
594
598
|
`v ${2 * dotSize}` +
|
|
@@ -616,7 +620,7 @@ class QRCornerSquare {
|
|
|
616
620
|
this._rotateFigure({
|
|
617
621
|
...args,
|
|
618
622
|
draw: () => {
|
|
619
|
-
this._element =
|
|
623
|
+
this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
620
624
|
this._element.setAttribute("clip-rule", "evenodd");
|
|
621
625
|
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
622
626
|
`v ${2 * dotSize}` +
|
|
@@ -1609,7 +1613,15 @@ let QRCodeStyling$1 = class QRCodeStyling {
|
|
|
1609
1613
|
return;
|
|
1610
1614
|
}
|
|
1611
1615
|
this._qr = qrcode(this._options.qrOptions.typeNumber, this._options.qrOptions.errorCorrectionLevel);
|
|
1612
|
-
|
|
1616
|
+
let mode = this._options.qrOptions.mode || getMode(this._options.data);
|
|
1617
|
+
if (mode == Mode.unicode) {
|
|
1618
|
+
qrcode.stringToBytes = qrcode.stringToBytesFuncs["UTF-8"];
|
|
1619
|
+
mode = Mode.byte;
|
|
1620
|
+
}
|
|
1621
|
+
else {
|
|
1622
|
+
qrcode.stringToBytes = qrcode.stringToBytesFuncs["default"];
|
|
1623
|
+
}
|
|
1624
|
+
this._qr.addData(this._options.data, mode);
|
|
1613
1625
|
this._qr.make();
|
|
1614
1626
|
this._setupSvg();
|
|
1615
1627
|
this.append(this._container);
|
|
@@ -1636,7 +1648,7 @@ let QRCodeStyling$1 = class QRCodeStyling {
|
|
|
1636
1648
|
* const extension = (svg, options) => {
|
|
1637
1649
|
* const { width, height } = options;
|
|
1638
1650
|
* const size = Math.min(width, height);
|
|
1639
|
-
* const border = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1651
|
+
* const border = options.document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1640
1652
|
* const borderAttributes = {
|
|
1641
1653
|
* fill: "none",
|
|
1642
1654
|
* x: (width - size + 40) / 2,
|