@kdcloudjs/kdesign 1.7.50 → 1.7.52
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/CHANGELOG.md +51 -0
- package/dist/kdesign.css +1 -1
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +1641 -837
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +1 -1
- package/dist/kdesign.min.js +15 -10
- package/dist/kdesign.min.js.map +1 -1
- package/es/grid/row.js +2 -2
- package/es/qr-code/qr-code.js +1 -1
- package/lib/grid/row.js +2 -2
- package/lib/qr-code/qr-code.js +1 -1
- package/package.json +2 -2
package/dist/kdesign.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* @kdcloudjs/kdesign v1.7.
|
|
3
|
+
* @kdcloudjs/kdesign v1.7.51
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2020-present, Kingdee, Inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -20088,10 +20088,10 @@ var Row = function Row(props) {
|
|
|
20088
20088
|
}
|
|
20089
20089
|
}
|
|
20090
20090
|
var rowStyle = {
|
|
20091
|
-
|
|
20091
|
+
rowGap: "".concat(gap.v, "px"),
|
|
20092
20092
|
margin: "0 ".concat(-1 * gap.h / 2, "px")
|
|
20093
20093
|
};
|
|
20094
|
-
if (gap.v && isSogouOrIe) rowStyle
|
|
20094
|
+
if (gap.v && isSogouOrIe) rowStyle.marginBottom = "".concat(-1 * gap.v, "px");
|
|
20095
20095
|
var toalign = {
|
|
20096
20096
|
top: 'flex-start',
|
|
20097
20097
|
middle: 'center',
|
|
@@ -27941,7 +27941,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
27941
27941
|
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_9__);
|
|
27942
27942
|
/* harmony import */ var _config_provider_ConfigContext__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../config-provider/ConfigContext */ "./components/config-provider/ConfigContext.tsx");
|
|
27943
27943
|
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../_utils */ "./components/_utils/index.ts");
|
|
27944
|
-
/* harmony import */ var
|
|
27944
|
+
/* harmony import */ var qrcode_react_ie__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! qrcode.react-ie */ "./node_modules/qrcode.react-ie/lib/esm/index.js");
|
|
27945
27945
|
/* harmony import */ var _spin__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../spin */ "./components/spin/index.tsx");
|
|
27946
27946
|
/* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../button */ "./components/button/index.tsx");
|
|
27947
27947
|
/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../icon */ "./components/icon/index.tsx");
|
|
@@ -28031,7 +28031,7 @@ var QRCode = function QRCode(props) {
|
|
|
28031
28031
|
type: "text",
|
|
28032
28032
|
onClick: onRefresh,
|
|
28033
28033
|
size: "middle"
|
|
28034
|
-
}, "\u70B9\u51FB\u5237\u65B0"))), type === 'canvas' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement(
|
|
28034
|
+
}, "\u70B9\u51FB\u5237\u65B0"))), type === 'canvas' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement(qrcode_react_ie__WEBPACK_IMPORTED_MODULE_12__["QRCodeCanvas"], codeProps) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement(qrcode_react_ie__WEBPACK_IMPORTED_MODULE_12__["QRCodeSVG"], codeProps));
|
|
28035
28035
|
};
|
|
28036
28036
|
QRCode.displayName = 'QRCode';
|
|
28037
28037
|
/* harmony default export */ __webpack_exports__["default"] = (QRCode);
|
|
@@ -140898,883 +140898,1687 @@ module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
|
140898
140898
|
|
|
140899
140899
|
/***/ }),
|
|
140900
140900
|
|
|
140901
|
-
/***/ "./node_modules/qrcode.react/lib/esm/index.js":
|
|
140902
|
-
|
|
140903
|
-
!*** ./node_modules/qrcode.react/lib/esm/index.js ***!
|
|
140904
|
-
|
|
140905
|
-
/*! exports provided: QRCodeCanvas, QRCodeSVG
|
|
140901
|
+
/***/ "./node_modules/qrcode.react-ie/lib/esm/index.js":
|
|
140902
|
+
/*!*******************************************************!*\
|
|
140903
|
+
!*** ./node_modules/qrcode.react-ie/lib/esm/index.js ***!
|
|
140904
|
+
\*******************************************************/
|
|
140905
|
+
/*! exports provided: QRCodeCanvas, QRCodeSVG */
|
|
140906
140906
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
140907
140907
|
|
|
140908
140908
|
"use strict";
|
|
140909
140909
|
__webpack_require__.r(__webpack_exports__);
|
|
140910
140910
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QRCodeCanvas", function() { return QRCodeCanvas; });
|
|
140911
140911
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QRCodeSVG", function() { return QRCodeSVG; });
|
|
140912
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return QRCode; });
|
|
140913
140912
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
140914
140913
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
140915
|
-
var __defProp = Object.defineProperty;
|
|
140916
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
140917
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
140918
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
140919
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
140920
|
-
var __spreadValues = (a, b) => {
|
|
140921
|
-
for (var prop in b || (b = {}))
|
|
140922
|
-
if (__hasOwnProp.call(b, prop))
|
|
140923
|
-
__defNormalProp(a, prop, b[prop]);
|
|
140924
|
-
if (__getOwnPropSymbols)
|
|
140925
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
140926
|
-
if (__propIsEnum.call(b, prop))
|
|
140927
|
-
__defNormalProp(a, prop, b[prop]);
|
|
140928
|
-
}
|
|
140929
|
-
return a;
|
|
140930
|
-
};
|
|
140931
|
-
var __objRest = (source, exclude) => {
|
|
140932
|
-
var target = {};
|
|
140933
|
-
for (var prop in source)
|
|
140934
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
140935
|
-
target[prop] = source[prop];
|
|
140936
|
-
if (source != null && __getOwnPropSymbols)
|
|
140937
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
140938
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
140939
|
-
target[prop] = source[prop];
|
|
140940
|
-
}
|
|
140941
|
-
return target;
|
|
140942
|
-
};
|
|
140943
|
-
|
|
140944
140914
|
// src/index.tsx
|
|
140945
|
-
|
|
140946
|
-
|
|
140947
|
-
|
|
140948
|
-
|
|
140949
|
-
|
|
140950
|
-
|
|
140951
|
-
|
|
140952
|
-
|
|
140953
|
-
|
|
140954
|
-
((
|
|
140955
|
-
|
|
140956
|
-
constructor(version, errorCorrectionLevel, dataCodewords, msk) {
|
|
140957
|
-
this.version = version;
|
|
140958
|
-
this.errorCorrectionLevel = errorCorrectionLevel;
|
|
140959
|
-
this.modules = [];
|
|
140960
|
-
this.isFunction = [];
|
|
140961
|
-
if (version < _QrCode.MIN_VERSION || version > _QrCode.MAX_VERSION)
|
|
140962
|
-
throw new RangeError("Version value out of range");
|
|
140963
|
-
if (msk < -1 || msk > 7)
|
|
140964
|
-
throw new RangeError("Mask value out of range");
|
|
140965
|
-
this.size = version * 4 + 17;
|
|
140966
|
-
let row = [];
|
|
140967
|
-
for (let i = 0; i < this.size; i++)
|
|
140968
|
-
row.push(false);
|
|
140969
|
-
for (let i = 0; i < this.size; i++) {
|
|
140970
|
-
this.modules.push(row.slice());
|
|
140971
|
-
this.isFunction.push(row.slice());
|
|
140972
|
-
}
|
|
140973
|
-
this.drawFunctionPatterns();
|
|
140974
|
-
const allCodewords = this.addEccAndInterleave(dataCodewords);
|
|
140975
|
-
this.drawCodewords(allCodewords);
|
|
140976
|
-
if (msk == -1) {
|
|
140977
|
-
let minPenalty = 1e9;
|
|
140978
|
-
for (let i = 0; i < 8; i++) {
|
|
140979
|
-
this.applyMask(i);
|
|
140980
|
-
this.drawFormatBits(i);
|
|
140981
|
-
const penalty = this.getPenaltyScore();
|
|
140982
|
-
if (penalty < minPenalty) {
|
|
140983
|
-
msk = i;
|
|
140984
|
-
minPenalty = penalty;
|
|
140985
|
-
}
|
|
140986
|
-
this.applyMask(i);
|
|
140987
|
-
}
|
|
140988
|
-
}
|
|
140989
|
-
assert(0 <= msk && msk <= 7);
|
|
140990
|
-
this.mask = msk;
|
|
140991
|
-
this.applyMask(msk);
|
|
140992
|
-
this.drawFormatBits(msk);
|
|
140993
|
-
this.isFunction = [];
|
|
140994
|
-
}
|
|
140995
|
-
static encodeText(text, ecl) {
|
|
140996
|
-
const segs = qrcodegen2.QrSegment.makeSegments(text);
|
|
140997
|
-
return _QrCode.encodeSegments(segs, ecl);
|
|
140998
|
-
}
|
|
140999
|
-
static encodeBinary(data, ecl) {
|
|
141000
|
-
const seg = qrcodegen2.QrSegment.makeBytes(data);
|
|
141001
|
-
return _QrCode.encodeSegments([seg], ecl);
|
|
141002
|
-
}
|
|
141003
|
-
static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
|
|
141004
|
-
if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7)
|
|
141005
|
-
throw new RangeError("Invalid value");
|
|
141006
|
-
let version;
|
|
141007
|
-
let dataUsedBits;
|
|
141008
|
-
for (version = minVersion; ; version++) {
|
|
141009
|
-
const dataCapacityBits2 = _QrCode.getNumDataCodewords(version, ecl) * 8;
|
|
141010
|
-
const usedBits = QrSegment.getTotalBits(segs, version);
|
|
141011
|
-
if (usedBits <= dataCapacityBits2) {
|
|
141012
|
-
dataUsedBits = usedBits;
|
|
141013
|
-
break;
|
|
141014
|
-
}
|
|
141015
|
-
if (version >= maxVersion)
|
|
141016
|
-
throw new RangeError("Data too long");
|
|
141017
|
-
}
|
|
141018
|
-
for (const newEcl of [_QrCode.Ecc.MEDIUM, _QrCode.Ecc.QUARTILE, _QrCode.Ecc.HIGH]) {
|
|
141019
|
-
if (boostEcl && dataUsedBits <= _QrCode.getNumDataCodewords(version, newEcl) * 8)
|
|
141020
|
-
ecl = newEcl;
|
|
141021
|
-
}
|
|
141022
|
-
let bb = [];
|
|
141023
|
-
for (const seg of segs) {
|
|
141024
|
-
appendBits(seg.mode.modeBits, 4, bb);
|
|
141025
|
-
appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);
|
|
141026
|
-
for (const b of seg.getData())
|
|
141027
|
-
bb.push(b);
|
|
141028
|
-
}
|
|
141029
|
-
assert(bb.length == dataUsedBits);
|
|
141030
|
-
const dataCapacityBits = _QrCode.getNumDataCodewords(version, ecl) * 8;
|
|
141031
|
-
assert(bb.length <= dataCapacityBits);
|
|
141032
|
-
appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
|
|
141033
|
-
appendBits(0, (8 - bb.length % 8) % 8, bb);
|
|
141034
|
-
assert(bb.length % 8 == 0);
|
|
141035
|
-
for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)
|
|
141036
|
-
appendBits(padByte, 8, bb);
|
|
141037
|
-
let dataCodewords = [];
|
|
141038
|
-
while (dataCodewords.length * 8 < bb.length)
|
|
141039
|
-
dataCodewords.push(0);
|
|
141040
|
-
bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
|
|
141041
|
-
return new _QrCode(version, ecl, dataCodewords, mask);
|
|
141042
|
-
}
|
|
141043
|
-
getModule(x, y) {
|
|
141044
|
-
return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
|
|
141045
|
-
}
|
|
141046
|
-
getModules() {
|
|
141047
|
-
return this.modules;
|
|
141048
|
-
}
|
|
141049
|
-
drawFunctionPatterns() {
|
|
141050
|
-
for (let i = 0; i < this.size; i++) {
|
|
141051
|
-
this.setFunctionModule(6, i, i % 2 == 0);
|
|
141052
|
-
this.setFunctionModule(i, 6, i % 2 == 0);
|
|
141053
|
-
}
|
|
141054
|
-
this.drawFinderPattern(3, 3);
|
|
141055
|
-
this.drawFinderPattern(this.size - 4, 3);
|
|
141056
|
-
this.drawFinderPattern(3, this.size - 4);
|
|
141057
|
-
const alignPatPos = this.getAlignmentPatternPositions();
|
|
141058
|
-
const numAlign = alignPatPos.length;
|
|
141059
|
-
for (let i = 0; i < numAlign; i++) {
|
|
141060
|
-
for (let j = 0; j < numAlign; j++) {
|
|
141061
|
-
if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0))
|
|
141062
|
-
this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
|
|
141063
|
-
}
|
|
141064
|
-
}
|
|
141065
|
-
this.drawFormatBits(0);
|
|
141066
|
-
this.drawVersion();
|
|
141067
|
-
}
|
|
141068
|
-
drawFormatBits(mask) {
|
|
141069
|
-
const data = this.errorCorrectionLevel.formatBits << 3 | mask;
|
|
141070
|
-
let rem = data;
|
|
141071
|
-
for (let i = 0; i < 10; i++)
|
|
141072
|
-
rem = rem << 1 ^ (rem >>> 9) * 1335;
|
|
141073
|
-
const bits = (data << 10 | rem) ^ 21522;
|
|
141074
|
-
assert(bits >>> 15 == 0);
|
|
141075
|
-
for (let i = 0; i <= 5; i++)
|
|
141076
|
-
this.setFunctionModule(8, i, getBit(bits, i));
|
|
141077
|
-
this.setFunctionModule(8, 7, getBit(bits, 6));
|
|
141078
|
-
this.setFunctionModule(8, 8, getBit(bits, 7));
|
|
141079
|
-
this.setFunctionModule(7, 8, getBit(bits, 8));
|
|
141080
|
-
for (let i = 9; i < 15; i++)
|
|
141081
|
-
this.setFunctionModule(14 - i, 8, getBit(bits, i));
|
|
141082
|
-
for (let i = 0; i < 8; i++)
|
|
141083
|
-
this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
|
|
141084
|
-
for (let i = 8; i < 15; i++)
|
|
141085
|
-
this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
|
|
141086
|
-
this.setFunctionModule(8, this.size - 8, true);
|
|
141087
|
-
}
|
|
141088
|
-
drawVersion() {
|
|
141089
|
-
if (this.version < 7)
|
|
141090
|
-
return;
|
|
141091
|
-
let rem = this.version;
|
|
141092
|
-
for (let i = 0; i < 12; i++)
|
|
141093
|
-
rem = rem << 1 ^ (rem >>> 11) * 7973;
|
|
141094
|
-
const bits = this.version << 12 | rem;
|
|
141095
|
-
assert(bits >>> 18 == 0);
|
|
141096
|
-
for (let i = 0; i < 18; i++) {
|
|
141097
|
-
const color = getBit(bits, i);
|
|
141098
|
-
const a = this.size - 11 + i % 3;
|
|
141099
|
-
const b = Math.floor(i / 3);
|
|
141100
|
-
this.setFunctionModule(a, b, color);
|
|
141101
|
-
this.setFunctionModule(b, a, color);
|
|
141102
|
-
}
|
|
141103
|
-
}
|
|
141104
|
-
drawFinderPattern(x, y) {
|
|
141105
|
-
for (let dy = -4; dy <= 4; dy++) {
|
|
141106
|
-
for (let dx = -4; dx <= 4; dx++) {
|
|
141107
|
-
const dist = Math.max(Math.abs(dx), Math.abs(dy));
|
|
141108
|
-
const xx = x + dx;
|
|
141109
|
-
const yy = y + dy;
|
|
141110
|
-
if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)
|
|
141111
|
-
this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
|
141112
|
-
}
|
|
141113
|
-
}
|
|
141114
|
-
}
|
|
141115
|
-
drawAlignmentPattern(x, y) {
|
|
141116
|
-
for (let dy = -2; dy <= 2; dy++) {
|
|
141117
|
-
for (let dx = -2; dx <= 2; dx++)
|
|
141118
|
-
this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
|
|
141119
|
-
}
|
|
141120
|
-
}
|
|
141121
|
-
setFunctionModule(x, y, isDark) {
|
|
141122
|
-
this.modules[y][x] = isDark;
|
|
141123
|
-
this.isFunction[y][x] = true;
|
|
141124
|
-
}
|
|
141125
|
-
addEccAndInterleave(data) {
|
|
141126
|
-
const ver = this.version;
|
|
141127
|
-
const ecl = this.errorCorrectionLevel;
|
|
141128
|
-
if (data.length != _QrCode.getNumDataCodewords(ver, ecl))
|
|
141129
|
-
throw new RangeError("Invalid argument");
|
|
141130
|
-
const numBlocks = _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
141131
|
-
const blockEccLen = _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
|
|
141132
|
-
const rawCodewords = Math.floor(_QrCode.getNumRawDataModules(ver) / 8);
|
|
141133
|
-
const numShortBlocks = numBlocks - rawCodewords % numBlocks;
|
|
141134
|
-
const shortBlockLen = Math.floor(rawCodewords / numBlocks);
|
|
141135
|
-
let blocks = [];
|
|
141136
|
-
const rsDiv = _QrCode.reedSolomonComputeDivisor(blockEccLen);
|
|
141137
|
-
for (let i = 0, k = 0; i < numBlocks; i++) {
|
|
141138
|
-
let dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
|
|
141139
|
-
k += dat.length;
|
|
141140
|
-
const ecc = _QrCode.reedSolomonComputeRemainder(dat, rsDiv);
|
|
141141
|
-
if (i < numShortBlocks)
|
|
141142
|
-
dat.push(0);
|
|
141143
|
-
blocks.push(dat.concat(ecc));
|
|
141144
|
-
}
|
|
141145
|
-
let result = [];
|
|
141146
|
-
for (let i = 0; i < blocks[0].length; i++) {
|
|
141147
|
-
blocks.forEach((block, j) => {
|
|
141148
|
-
if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)
|
|
141149
|
-
result.push(block[i]);
|
|
141150
|
-
});
|
|
141151
|
-
}
|
|
141152
|
-
assert(result.length == rawCodewords);
|
|
141153
|
-
return result;
|
|
140915
|
+
function _array_like_to_array(arr, len) {
|
|
140916
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
140917
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
140918
|
+
return arr2;
|
|
140919
|
+
}
|
|
140920
|
+
function _array_with_holes(arr) {
|
|
140921
|
+
if (Array.isArray(arr)) return arr;
|
|
140922
|
+
}
|
|
140923
|
+
function _class_call_check(instance, Constructor) {
|
|
140924
|
+
if (!(instance instanceof Constructor)) {
|
|
140925
|
+
throw new TypeError("Cannot call a class as a function");
|
|
141154
140926
|
}
|
|
141155
|
-
|
|
141156
|
-
|
|
141157
|
-
|
|
141158
|
-
|
|
141159
|
-
|
|
141160
|
-
|
|
141161
|
-
|
|
141162
|
-
|
|
141163
|
-
for (let j = 0; j < 2; j++) {
|
|
141164
|
-
const x = right - j;
|
|
141165
|
-
const upward = (right + 1 & 2) == 0;
|
|
141166
|
-
const y = upward ? this.size - 1 - vert : vert;
|
|
141167
|
-
if (!this.isFunction[y][x] && i < data.length * 8) {
|
|
141168
|
-
this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
|
|
141169
|
-
i++;
|
|
141170
|
-
}
|
|
141171
|
-
}
|
|
141172
|
-
}
|
|
141173
|
-
}
|
|
141174
|
-
assert(i == data.length * 8);
|
|
140927
|
+
}
|
|
140928
|
+
function _defineProperties(target, props) {
|
|
140929
|
+
for(var i = 0; i < props.length; i++){
|
|
140930
|
+
var descriptor = props[i];
|
|
140931
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
140932
|
+
descriptor.configurable = true;
|
|
140933
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
140934
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
141175
140935
|
}
|
|
141176
|
-
|
|
141177
|
-
|
|
141178
|
-
|
|
141179
|
-
|
|
141180
|
-
|
|
141181
|
-
|
|
141182
|
-
|
|
141183
|
-
|
|
141184
|
-
|
|
141185
|
-
|
|
141186
|
-
|
|
141187
|
-
|
|
141188
|
-
|
|
141189
|
-
|
|
141190
|
-
|
|
141191
|
-
|
|
141192
|
-
|
|
141193
|
-
|
|
141194
|
-
|
|
141195
|
-
|
|
141196
|
-
|
|
141197
|
-
|
|
141198
|
-
|
|
141199
|
-
|
|
141200
|
-
|
|
141201
|
-
|
|
141202
|
-
|
|
141203
|
-
|
|
141204
|
-
|
|
141205
|
-
|
|
141206
|
-
break;
|
|
141207
|
-
default:
|
|
141208
|
-
throw new Error("Unreachable");
|
|
141209
|
-
}
|
|
141210
|
-
if (!this.isFunction[y][x] && invert)
|
|
141211
|
-
this.modules[y][x] = !this.modules[y][x];
|
|
141212
|
-
}
|
|
141213
|
-
}
|
|
141214
|
-
}
|
|
141215
|
-
getPenaltyScore() {
|
|
141216
|
-
let result = 0;
|
|
141217
|
-
for (let y = 0; y < this.size; y++) {
|
|
141218
|
-
let runColor = false;
|
|
141219
|
-
let runX = 0;
|
|
141220
|
-
let runHistory = [0, 0, 0, 0, 0, 0, 0];
|
|
141221
|
-
for (let x = 0; x < this.size; x++) {
|
|
141222
|
-
if (this.modules[y][x] == runColor) {
|
|
141223
|
-
runX++;
|
|
141224
|
-
if (runX == 5)
|
|
141225
|
-
result += _QrCode.PENALTY_N1;
|
|
141226
|
-
else if (runX > 5)
|
|
141227
|
-
result++;
|
|
141228
|
-
} else {
|
|
141229
|
-
this.finderPenaltyAddHistory(runX, runHistory);
|
|
141230
|
-
if (!runColor)
|
|
141231
|
-
result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;
|
|
141232
|
-
runColor = this.modules[y][x];
|
|
141233
|
-
runX = 1;
|
|
141234
|
-
}
|
|
141235
|
-
}
|
|
141236
|
-
result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode.PENALTY_N3;
|
|
141237
|
-
}
|
|
141238
|
-
for (let x = 0; x < this.size; x++) {
|
|
141239
|
-
let runColor = false;
|
|
141240
|
-
let runY = 0;
|
|
141241
|
-
let runHistory = [0, 0, 0, 0, 0, 0, 0];
|
|
141242
|
-
for (let y = 0; y < this.size; y++) {
|
|
141243
|
-
if (this.modules[y][x] == runColor) {
|
|
141244
|
-
runY++;
|
|
141245
|
-
if (runY == 5)
|
|
141246
|
-
result += _QrCode.PENALTY_N1;
|
|
141247
|
-
else if (runY > 5)
|
|
141248
|
-
result++;
|
|
141249
|
-
} else {
|
|
141250
|
-
this.finderPenaltyAddHistory(runY, runHistory);
|
|
141251
|
-
if (!runColor)
|
|
141252
|
-
result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;
|
|
141253
|
-
runColor = this.modules[y][x];
|
|
141254
|
-
runY = 1;
|
|
141255
|
-
}
|
|
140936
|
+
}
|
|
140937
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
140938
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
140939
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
140940
|
+
return Constructor;
|
|
140941
|
+
}
|
|
140942
|
+
function _define_property(obj, key, value) {
|
|
140943
|
+
if (key in obj) {
|
|
140944
|
+
Object.defineProperty(obj, key, {
|
|
140945
|
+
value: value,
|
|
140946
|
+
enumerable: true,
|
|
140947
|
+
configurable: true,
|
|
140948
|
+
writable: true
|
|
140949
|
+
});
|
|
140950
|
+
} else {
|
|
140951
|
+
obj[key] = value;
|
|
140952
|
+
}
|
|
140953
|
+
return obj;
|
|
140954
|
+
}
|
|
140955
|
+
function _iterable_to_array_limit(arr, i) {
|
|
140956
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
140957
|
+
if (_i == null) return;
|
|
140958
|
+
var _arr = [];
|
|
140959
|
+
var _n = true;
|
|
140960
|
+
var _d = false;
|
|
140961
|
+
var _s, _e;
|
|
140962
|
+
try {
|
|
140963
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
140964
|
+
_arr.push(_s.value);
|
|
140965
|
+
if (i && _arr.length === i) break;
|
|
141256
140966
|
}
|
|
141257
|
-
|
|
141258
|
-
|
|
141259
|
-
|
|
141260
|
-
|
|
141261
|
-
|
|
141262
|
-
|
|
141263
|
-
|
|
140967
|
+
} catch (err) {
|
|
140968
|
+
_d = true;
|
|
140969
|
+
_e = err;
|
|
140970
|
+
} finally{
|
|
140971
|
+
try {
|
|
140972
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
140973
|
+
} finally{
|
|
140974
|
+
if (_d) throw _e;
|
|
141264
140975
|
}
|
|
141265
|
-
}
|
|
141266
|
-
let dark = 0;
|
|
141267
|
-
for (const row of this.modules)
|
|
141268
|
-
dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
|
|
141269
|
-
const total = this.size * this.size;
|
|
141270
|
-
const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
|
|
141271
|
-
assert(0 <= k && k <= 9);
|
|
141272
|
-
result += k * _QrCode.PENALTY_N4;
|
|
141273
|
-
assert(0 <= result && result <= 2568888);
|
|
141274
|
-
return result;
|
|
141275
140976
|
}
|
|
141276
|
-
|
|
141277
|
-
|
|
141278
|
-
|
|
141279
|
-
|
|
141280
|
-
|
|
141281
|
-
|
|
141282
|
-
|
|
141283
|
-
|
|
141284
|
-
|
|
141285
|
-
|
|
141286
|
-
|
|
141287
|
-
|
|
141288
|
-
|
|
141289
|
-
|
|
141290
|
-
|
|
141291
|
-
|
|
141292
|
-
|
|
141293
|
-
const numAlign = Math.floor(ver / 7) + 2;
|
|
141294
|
-
result -= (25 * numAlign - 10) * numAlign - 55;
|
|
141295
|
-
if (ver >= 7)
|
|
141296
|
-
result -= 36;
|
|
141297
|
-
}
|
|
141298
|
-
assert(208 <= result && result <= 29648);
|
|
141299
|
-
return result;
|
|
141300
|
-
}
|
|
141301
|
-
static getNumDataCodewords(ver, ecl) {
|
|
141302
|
-
return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
141303
|
-
}
|
|
141304
|
-
static reedSolomonComputeDivisor(degree) {
|
|
141305
|
-
if (degree < 1 || degree > 255)
|
|
141306
|
-
throw new RangeError("Degree out of range");
|
|
141307
|
-
let result = [];
|
|
141308
|
-
for (let i = 0; i < degree - 1; i++)
|
|
141309
|
-
result.push(0);
|
|
141310
|
-
result.push(1);
|
|
141311
|
-
let root = 1;
|
|
141312
|
-
for (let i = 0; i < degree; i++) {
|
|
141313
|
-
for (let j = 0; j < result.length; j++) {
|
|
141314
|
-
result[j] = _QrCode.reedSolomonMultiply(result[j], root);
|
|
141315
|
-
if (j + 1 < result.length)
|
|
141316
|
-
result[j] ^= result[j + 1];
|
|
141317
|
-
}
|
|
141318
|
-
root = _QrCode.reedSolomonMultiply(root, 2);
|
|
141319
|
-
}
|
|
141320
|
-
return result;
|
|
141321
|
-
}
|
|
141322
|
-
static reedSolomonComputeRemainder(data, divisor) {
|
|
141323
|
-
let result = divisor.map((_) => 0);
|
|
141324
|
-
for (const b of data) {
|
|
141325
|
-
const factor = b ^ result.shift();
|
|
141326
|
-
result.push(0);
|
|
141327
|
-
divisor.forEach((coef, i) => result[i] ^= _QrCode.reedSolomonMultiply(coef, factor));
|
|
141328
|
-
}
|
|
141329
|
-
return result;
|
|
141330
|
-
}
|
|
141331
|
-
static reedSolomonMultiply(x, y) {
|
|
141332
|
-
if (x >>> 8 != 0 || y >>> 8 != 0)
|
|
141333
|
-
throw new RangeError("Byte out of range");
|
|
141334
|
-
let z = 0;
|
|
141335
|
-
for (let i = 7; i >= 0; i--) {
|
|
141336
|
-
z = z << 1 ^ (z >>> 7) * 285;
|
|
141337
|
-
z ^= (y >>> i & 1) * x;
|
|
141338
|
-
}
|
|
141339
|
-
assert(z >>> 8 == 0);
|
|
141340
|
-
return z;
|
|
141341
|
-
}
|
|
141342
|
-
finderPenaltyCountPatterns(runHistory) {
|
|
141343
|
-
const n = runHistory[1];
|
|
141344
|
-
assert(n <= this.size * 3);
|
|
141345
|
-
const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;
|
|
141346
|
-
return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
|
|
141347
|
-
}
|
|
141348
|
-
finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
|
|
141349
|
-
if (currentRunColor) {
|
|
141350
|
-
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
141351
|
-
currentRunLength = 0;
|
|
141352
|
-
}
|
|
141353
|
-
currentRunLength += this.size;
|
|
141354
|
-
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
141355
|
-
return this.finderPenaltyCountPatterns(runHistory);
|
|
141356
|
-
}
|
|
141357
|
-
finderPenaltyAddHistory(currentRunLength, runHistory) {
|
|
141358
|
-
if (runHistory[0] == 0)
|
|
141359
|
-
currentRunLength += this.size;
|
|
141360
|
-
runHistory.pop();
|
|
141361
|
-
runHistory.unshift(currentRunLength);
|
|
141362
|
-
}
|
|
141363
|
-
};
|
|
141364
|
-
let QrCode = _QrCode;
|
|
141365
|
-
QrCode.MIN_VERSION = 1;
|
|
141366
|
-
QrCode.MAX_VERSION = 40;
|
|
141367
|
-
QrCode.PENALTY_N1 = 3;
|
|
141368
|
-
QrCode.PENALTY_N2 = 3;
|
|
141369
|
-
QrCode.PENALTY_N3 = 40;
|
|
141370
|
-
QrCode.PENALTY_N4 = 10;
|
|
141371
|
-
QrCode.ECC_CODEWORDS_PER_BLOCK = [
|
|
141372
|
-
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
141373
|
-
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
|
141374
|
-
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
141375
|
-
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
|
141376
|
-
];
|
|
141377
|
-
QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
|
|
141378
|
-
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
141379
|
-
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
141380
|
-
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
|
141381
|
-
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
|
|
141382
|
-
];
|
|
141383
|
-
qrcodegen2.QrCode = QrCode;
|
|
141384
|
-
function appendBits(val, len, bb) {
|
|
141385
|
-
if (len < 0 || len > 31 || val >>> len != 0)
|
|
141386
|
-
throw new RangeError("Value out of range");
|
|
141387
|
-
for (let i = len - 1; i >= 0; i--)
|
|
141388
|
-
bb.push(val >>> i & 1);
|
|
141389
|
-
}
|
|
141390
|
-
function getBit(x, i) {
|
|
141391
|
-
return (x >>> i & 1) != 0;
|
|
141392
|
-
}
|
|
141393
|
-
function assert(cond) {
|
|
141394
|
-
if (!cond)
|
|
141395
|
-
throw new Error("Assertion error");
|
|
141396
|
-
}
|
|
141397
|
-
const _QrSegment = class {
|
|
141398
|
-
constructor(mode, numChars, bitData) {
|
|
141399
|
-
this.mode = mode;
|
|
141400
|
-
this.numChars = numChars;
|
|
141401
|
-
this.bitData = bitData;
|
|
141402
|
-
if (numChars < 0)
|
|
141403
|
-
throw new RangeError("Invalid argument");
|
|
141404
|
-
this.bitData = bitData.slice();
|
|
141405
|
-
}
|
|
141406
|
-
static makeBytes(data) {
|
|
141407
|
-
let bb = [];
|
|
141408
|
-
for (const b of data)
|
|
141409
|
-
appendBits(b, 8, bb);
|
|
141410
|
-
return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb);
|
|
141411
|
-
}
|
|
141412
|
-
static makeNumeric(digits) {
|
|
141413
|
-
if (!_QrSegment.isNumeric(digits))
|
|
141414
|
-
throw new RangeError("String contains non-numeric characters");
|
|
141415
|
-
let bb = [];
|
|
141416
|
-
for (let i = 0; i < digits.length; ) {
|
|
141417
|
-
const n = Math.min(digits.length - i, 3);
|
|
141418
|
-
appendBits(parseInt(digits.substr(i, n), 10), n * 3 + 1, bb);
|
|
141419
|
-
i += n;
|
|
141420
|
-
}
|
|
141421
|
-
return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb);
|
|
141422
|
-
}
|
|
141423
|
-
static makeAlphanumeric(text) {
|
|
141424
|
-
if (!_QrSegment.isAlphanumeric(text))
|
|
141425
|
-
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
141426
|
-
let bb = [];
|
|
141427
|
-
let i;
|
|
141428
|
-
for (i = 0; i + 2 <= text.length; i += 2) {
|
|
141429
|
-
let temp = _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
|
|
141430
|
-
temp += _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
|
|
141431
|
-
appendBits(temp, 11, bb);
|
|
141432
|
-
}
|
|
141433
|
-
if (i < text.length)
|
|
141434
|
-
appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
|
|
141435
|
-
return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text.length, bb);
|
|
141436
|
-
}
|
|
141437
|
-
static makeSegments(text) {
|
|
141438
|
-
if (text == "")
|
|
141439
|
-
return [];
|
|
141440
|
-
else if (_QrSegment.isNumeric(text))
|
|
141441
|
-
return [_QrSegment.makeNumeric(text)];
|
|
141442
|
-
else if (_QrSegment.isAlphanumeric(text))
|
|
141443
|
-
return [_QrSegment.makeAlphanumeric(text)];
|
|
141444
|
-
else
|
|
141445
|
-
return [_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text))];
|
|
141446
|
-
}
|
|
141447
|
-
static makeEci(assignVal) {
|
|
141448
|
-
let bb = [];
|
|
141449
|
-
if (assignVal < 0)
|
|
141450
|
-
throw new RangeError("ECI assignment value out of range");
|
|
141451
|
-
else if (assignVal < 1 << 7)
|
|
141452
|
-
appendBits(assignVal, 8, bb);
|
|
141453
|
-
else if (assignVal < 1 << 14) {
|
|
141454
|
-
appendBits(2, 2, bb);
|
|
141455
|
-
appendBits(assignVal, 14, bb);
|
|
141456
|
-
} else if (assignVal < 1e6) {
|
|
141457
|
-
appendBits(6, 3, bb);
|
|
141458
|
-
appendBits(assignVal, 21, bb);
|
|
141459
|
-
} else
|
|
141460
|
-
throw new RangeError("ECI assignment value out of range");
|
|
141461
|
-
return new _QrSegment(_QrSegment.Mode.ECI, 0, bb);
|
|
141462
|
-
}
|
|
141463
|
-
static isNumeric(text) {
|
|
141464
|
-
return _QrSegment.NUMERIC_REGEX.test(text);
|
|
141465
|
-
}
|
|
141466
|
-
static isAlphanumeric(text) {
|
|
141467
|
-
return _QrSegment.ALPHANUMERIC_REGEX.test(text);
|
|
141468
|
-
}
|
|
141469
|
-
getData() {
|
|
141470
|
-
return this.bitData.slice();
|
|
141471
|
-
}
|
|
141472
|
-
static getTotalBits(segs, version) {
|
|
141473
|
-
let result = 0;
|
|
141474
|
-
for (const seg of segs) {
|
|
141475
|
-
const ccbits = seg.mode.numCharCountBits(version);
|
|
141476
|
-
if (seg.numChars >= 1 << ccbits)
|
|
141477
|
-
return Infinity;
|
|
141478
|
-
result += 4 + ccbits + seg.bitData.length;
|
|
141479
|
-
}
|
|
141480
|
-
return result;
|
|
140977
|
+
return _arr;
|
|
140978
|
+
}
|
|
140979
|
+
function _non_iterable_rest() {
|
|
140980
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
140981
|
+
}
|
|
140982
|
+
function _object_spread(target) {
|
|
140983
|
+
for(var i = 1; i < arguments.length; i++){
|
|
140984
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
140985
|
+
var ownKeys = Object.keys(source);
|
|
140986
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
140987
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
140988
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
140989
|
+
}));
|
|
140990
|
+
}
|
|
140991
|
+
ownKeys.forEach(function(key) {
|
|
140992
|
+
_define_property(target, key, source[key]);
|
|
140993
|
+
});
|
|
141481
140994
|
}
|
|
141482
|
-
|
|
141483
|
-
|
|
141484
|
-
|
|
141485
|
-
|
|
141486
|
-
|
|
141487
|
-
|
|
141488
|
-
|
|
141489
|
-
|
|
141490
|
-
|
|
140995
|
+
return target;
|
|
140996
|
+
}
|
|
140997
|
+
function _object_without_properties(source, excluded) {
|
|
140998
|
+
if (source == null) return {};
|
|
140999
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
141000
|
+
var key, i;
|
|
141001
|
+
if (Object.getOwnPropertySymbols) {
|
|
141002
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
141003
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
141004
|
+
key = sourceSymbolKeys[i];
|
|
141005
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
141006
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
141007
|
+
target[key] = source[key];
|
|
141491
141008
|
}
|
|
141492
|
-
}
|
|
141493
|
-
return result;
|
|
141494
141009
|
}
|
|
141495
|
-
|
|
141496
|
-
|
|
141497
|
-
|
|
141498
|
-
|
|
141499
|
-
|
|
141500
|
-
|
|
141010
|
+
return target;
|
|
141011
|
+
}
|
|
141012
|
+
function _object_without_properties_loose(source, excluded) {
|
|
141013
|
+
if (source == null) return {};
|
|
141014
|
+
var target = {};
|
|
141015
|
+
var sourceKeys = Object.keys(source);
|
|
141016
|
+
var key, i;
|
|
141017
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
141018
|
+
key = sourceKeys[i];
|
|
141019
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
141020
|
+
target[key] = source[key];
|
|
141021
|
+
}
|
|
141022
|
+
return target;
|
|
141023
|
+
}
|
|
141024
|
+
function _sliced_to_array(arr, i) {
|
|
141025
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
141026
|
+
}
|
|
141027
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
141028
|
+
if (!o) return;
|
|
141029
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
141030
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
141031
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
141032
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
141033
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
141034
|
+
}
|
|
141035
|
+
|
|
141036
|
+
// src/third-party/qrcodegen/index.ts
|
|
141037
|
+
/**
|
|
141038
|
+
* @license QR Code generator library (TypeScript)
|
|
141039
|
+
* Copyright (c) Project Nayuki.
|
|
141040
|
+
* SPDX-License-Identifier: MIT
|
|
141041
|
+
*/ var qrcodegen;
|
|
141042
|
+
(function(qrcodegen2) {
|
|
141043
|
+
var appendBits = function appendBits(val, len, bb) {
|
|
141044
|
+
if (len < 0 || len > 31 || val >>> len != 0) throw new RangeError("Value out of range");
|
|
141045
|
+
for(var i = len - 1; i >= 0; i--)bb.push(val >>> i & 1);
|
|
141046
|
+
};
|
|
141047
|
+
var getBit = function getBit(x, i) {
|
|
141048
|
+
return (x >>> i & 1) != 0;
|
|
141049
|
+
};
|
|
141050
|
+
var assert = function assert(cond) {
|
|
141051
|
+
if (!cond) throw new Error("Assertion error");
|
|
141052
|
+
};
|
|
141053
|
+
var _QrCode = /*#__PURE__*/ function() {
|
|
141054
|
+
"use strict";
|
|
141055
|
+
function _QrCode(version, errorCorrectionLevel, dataCodewords, msk) {
|
|
141056
|
+
_class_call_check(this, _QrCode);
|
|
141057
|
+
this.version = version;
|
|
141058
|
+
this.errorCorrectionLevel = errorCorrectionLevel;
|
|
141059
|
+
// The modules of this QR Code (false = light, true = dark).
|
|
141060
|
+
// Immutable after constructor finishes. Accessed through getModule().
|
|
141061
|
+
this.modules = [];
|
|
141062
|
+
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
|
|
141063
|
+
this.isFunction = [];
|
|
141064
|
+
if (version < _QrCode.MIN_VERSION || version > _QrCode.MAX_VERSION) throw new RangeError("Version value out of range");
|
|
141065
|
+
if (msk < -1 || msk > 7) throw new RangeError("Mask value out of range");
|
|
141066
|
+
this.size = version * 4 + 17;
|
|
141067
|
+
var row = [];
|
|
141068
|
+
for(var i = 0; i < this.size; i++)row.push(false);
|
|
141069
|
+
for(var i1 = 0; i1 < this.size; i1++){
|
|
141070
|
+
this.modules.push(row.slice());
|
|
141071
|
+
this.isFunction.push(row.slice());
|
|
141072
|
+
}
|
|
141073
|
+
this.drawFunctionPatterns();
|
|
141074
|
+
var allCodewords = this.addEccAndInterleave(dataCodewords);
|
|
141075
|
+
this.drawCodewords(allCodewords);
|
|
141076
|
+
if (msk == -1) {
|
|
141077
|
+
var minPenalty = 1e9;
|
|
141078
|
+
for(var i2 = 0; i2 < 8; i2++){
|
|
141079
|
+
this.applyMask(i2);
|
|
141080
|
+
this.drawFormatBits(i2);
|
|
141081
|
+
var penalty = this.getPenaltyScore();
|
|
141082
|
+
if (penalty < minPenalty) {
|
|
141083
|
+
msk = i2;
|
|
141084
|
+
minPenalty = penalty;
|
|
141085
|
+
}
|
|
141086
|
+
this.applyMask(i2);
|
|
141087
|
+
}
|
|
141088
|
+
}
|
|
141089
|
+
assert(0 <= msk && msk <= 7);
|
|
141090
|
+
this.mask = msk;
|
|
141091
|
+
this.applyMask(msk);
|
|
141092
|
+
this.drawFormatBits(msk);
|
|
141093
|
+
this.isFunction = [];
|
|
141094
|
+
}
|
|
141095
|
+
_create_class(_QrCode, [
|
|
141096
|
+
{
|
|
141097
|
+
/*-- Accessor methods --*/ // Returns the color of the module (pixel) at the given coordinates, which is false
|
|
141098
|
+
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
|
141099
|
+
// If the given coordinates are out of bounds, then false (light) is returned.
|
|
141100
|
+
key: "getModule",
|
|
141101
|
+
value: function getModule(x, y) {
|
|
141102
|
+
return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
|
|
141103
|
+
}
|
|
141104
|
+
},
|
|
141105
|
+
{
|
|
141106
|
+
// Modified to expose modules for easy access
|
|
141107
|
+
key: "getModules",
|
|
141108
|
+
value: function getModules() {
|
|
141109
|
+
return this.modules;
|
|
141110
|
+
}
|
|
141111
|
+
},
|
|
141112
|
+
{
|
|
141113
|
+
/*-- Private helper methods for constructor: Drawing function modules --*/ // Reads this object's version field, and draws and marks all function modules.
|
|
141114
|
+
key: "drawFunctionPatterns",
|
|
141115
|
+
value: function drawFunctionPatterns() {
|
|
141116
|
+
for(var i = 0; i < this.size; i++){
|
|
141117
|
+
this.setFunctionModule(6, i, i % 2 == 0);
|
|
141118
|
+
this.setFunctionModule(i, 6, i % 2 == 0);
|
|
141119
|
+
}
|
|
141120
|
+
this.drawFinderPattern(3, 3);
|
|
141121
|
+
this.drawFinderPattern(this.size - 4, 3);
|
|
141122
|
+
this.drawFinderPattern(3, this.size - 4);
|
|
141123
|
+
var alignPatPos = this.getAlignmentPatternPositions();
|
|
141124
|
+
var numAlign = alignPatPos.length;
|
|
141125
|
+
for(var i1 = 0; i1 < numAlign; i1++){
|
|
141126
|
+
for(var j = 0; j < numAlign; j++){
|
|
141127
|
+
if (!(i1 == 0 && j == 0 || i1 == 0 && j == numAlign - 1 || i1 == numAlign - 1 && j == 0)) this.drawAlignmentPattern(alignPatPos[i1], alignPatPos[j]);
|
|
141128
|
+
}
|
|
141129
|
+
}
|
|
141130
|
+
this.drawFormatBits(0);
|
|
141131
|
+
this.drawVersion();
|
|
141132
|
+
}
|
|
141133
|
+
},
|
|
141134
|
+
{
|
|
141135
|
+
// Draws two copies of the format bits (with its own error correction code)
|
|
141136
|
+
// based on the given mask and this object's error correction level field.
|
|
141137
|
+
key: "drawFormatBits",
|
|
141138
|
+
value: function drawFormatBits(mask) {
|
|
141139
|
+
var data = this.errorCorrectionLevel.formatBits << 3 | mask;
|
|
141140
|
+
var rem = data;
|
|
141141
|
+
for(var i = 0; i < 10; i++)rem = rem << 1 ^ (rem >>> 9) * 1335;
|
|
141142
|
+
var bits = (data << 10 | rem) ^ 21522;
|
|
141143
|
+
assert(bits >>> 15 == 0);
|
|
141144
|
+
for(var i1 = 0; i1 <= 5; i1++)this.setFunctionModule(8, i1, getBit(bits, i1));
|
|
141145
|
+
this.setFunctionModule(8, 7, getBit(bits, 6));
|
|
141146
|
+
this.setFunctionModule(8, 8, getBit(bits, 7));
|
|
141147
|
+
this.setFunctionModule(7, 8, getBit(bits, 8));
|
|
141148
|
+
for(var i2 = 9; i2 < 15; i2++)this.setFunctionModule(14 - i2, 8, getBit(bits, i2));
|
|
141149
|
+
for(var i3 = 0; i3 < 8; i3++)this.setFunctionModule(this.size - 1 - i3, 8, getBit(bits, i3));
|
|
141150
|
+
for(var i4 = 8; i4 < 15; i4++)this.setFunctionModule(8, this.size - 15 + i4, getBit(bits, i4));
|
|
141151
|
+
this.setFunctionModule(8, this.size - 8, true);
|
|
141152
|
+
}
|
|
141153
|
+
},
|
|
141154
|
+
{
|
|
141155
|
+
// Draws two copies of the version bits (with its own error correction code),
|
|
141156
|
+
// based on this object's version field, iff 7 <= version <= 40.
|
|
141157
|
+
key: "drawVersion",
|
|
141158
|
+
value: function drawVersion() {
|
|
141159
|
+
if (this.version < 7) return;
|
|
141160
|
+
var rem = this.version;
|
|
141161
|
+
for(var i = 0; i < 12; i++)rem = rem << 1 ^ (rem >>> 11) * 7973;
|
|
141162
|
+
var bits = this.version << 12 | rem;
|
|
141163
|
+
assert(bits >>> 18 == 0);
|
|
141164
|
+
for(var i1 = 0; i1 < 18; i1++){
|
|
141165
|
+
var color = getBit(bits, i1);
|
|
141166
|
+
var a = this.size - 11 + i1 % 3;
|
|
141167
|
+
var b = Math.floor(i1 / 3);
|
|
141168
|
+
this.setFunctionModule(a, b, color);
|
|
141169
|
+
this.setFunctionModule(b, a, color);
|
|
141170
|
+
}
|
|
141171
|
+
}
|
|
141172
|
+
},
|
|
141173
|
+
{
|
|
141174
|
+
// Draws a 9*9 finder pattern including the border separator,
|
|
141175
|
+
// with the center module at (x, y). Modules can be out of bounds.
|
|
141176
|
+
key: "drawFinderPattern",
|
|
141177
|
+
value: function drawFinderPattern(x, y) {
|
|
141178
|
+
for(var dy = -4; dy <= 4; dy++){
|
|
141179
|
+
for(var dx = -4; dx <= 4; dx++){
|
|
141180
|
+
var dist = Math.max(Math.abs(dx), Math.abs(dy));
|
|
141181
|
+
var xx = x + dx;
|
|
141182
|
+
var yy = y + dy;
|
|
141183
|
+
if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size) this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
|
141184
|
+
}
|
|
141185
|
+
}
|
|
141186
|
+
}
|
|
141187
|
+
},
|
|
141188
|
+
{
|
|
141189
|
+
// Draws a 5*5 alignment pattern, with the center module
|
|
141190
|
+
// at (x, y). All modules must be in bounds.
|
|
141191
|
+
key: "drawAlignmentPattern",
|
|
141192
|
+
value: function drawAlignmentPattern(x, y) {
|
|
141193
|
+
for(var dy = -2; dy <= 2; dy++){
|
|
141194
|
+
for(var dx = -2; dx <= 2; dx++)this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
|
|
141195
|
+
}
|
|
141196
|
+
}
|
|
141197
|
+
},
|
|
141198
|
+
{
|
|
141199
|
+
// Sets the color of a module and marks it as a function module.
|
|
141200
|
+
// Only used by the constructor. Coordinates must be in bounds.
|
|
141201
|
+
key: "setFunctionModule",
|
|
141202
|
+
value: function setFunctionModule(x, y, isDark) {
|
|
141203
|
+
this.modules[y][x] = isDark;
|
|
141204
|
+
this.isFunction[y][x] = true;
|
|
141205
|
+
}
|
|
141206
|
+
},
|
|
141207
|
+
{
|
|
141208
|
+
/*-- Private helper methods for constructor: Codewords and masking --*/ // Returns a new byte string representing the given data with the appropriate error correction
|
|
141209
|
+
// codewords appended to it, based on this object's version and error correction level.
|
|
141210
|
+
key: "addEccAndInterleave",
|
|
141211
|
+
value: function addEccAndInterleave(data) {
|
|
141212
|
+
var _loop = function(i1) {
|
|
141213
|
+
blocks.forEach(function(block, j) {
|
|
141214
|
+
if (i1 != shortBlockLen - blockEccLen || j >= numShortBlocks) result.push(block[i1]);
|
|
141215
|
+
});
|
|
141216
|
+
};
|
|
141217
|
+
var ver = this.version;
|
|
141218
|
+
var ecl = this.errorCorrectionLevel;
|
|
141219
|
+
if (data.length != _QrCode.getNumDataCodewords(ver, ecl)) throw new RangeError("Invalid argument");
|
|
141220
|
+
var numBlocks = _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
141221
|
+
var blockEccLen = _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
|
|
141222
|
+
var rawCodewords = Math.floor(_QrCode.getNumRawDataModules(ver) / 8);
|
|
141223
|
+
var numShortBlocks = numBlocks - rawCodewords % numBlocks;
|
|
141224
|
+
var shortBlockLen = Math.floor(rawCodewords / numBlocks);
|
|
141225
|
+
var blocks = [];
|
|
141226
|
+
var rsDiv = _QrCode.reedSolomonComputeDivisor(blockEccLen);
|
|
141227
|
+
for(var i = 0, k = 0; i < numBlocks; i++){
|
|
141228
|
+
var dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
|
|
141229
|
+
k += dat.length;
|
|
141230
|
+
var ecc = _QrCode.reedSolomonComputeRemainder(dat, rsDiv);
|
|
141231
|
+
if (i < numShortBlocks) dat.push(0);
|
|
141232
|
+
blocks.push(dat.concat(ecc));
|
|
141233
|
+
}
|
|
141234
|
+
var result = [];
|
|
141235
|
+
for(var i1 = 0; i1 < blocks[0].length; i1++)_loop(i1);
|
|
141236
|
+
assert(result.length == rawCodewords);
|
|
141237
|
+
return result;
|
|
141238
|
+
}
|
|
141239
|
+
},
|
|
141240
|
+
{
|
|
141241
|
+
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
|
141242
|
+
// data area of this QR Code. Function modules need to be marked off before this is called.
|
|
141243
|
+
key: "drawCodewords",
|
|
141244
|
+
value: function drawCodewords(data) {
|
|
141245
|
+
if (data.length != Math.floor(_QrCode.getNumRawDataModules(this.version) / 8)) throw new RangeError("Invalid argument");
|
|
141246
|
+
var i = 0;
|
|
141247
|
+
for(var right = this.size - 1; right >= 1; right -= 2){
|
|
141248
|
+
if (right == 6) right = 5;
|
|
141249
|
+
for(var vert = 0; vert < this.size; vert++){
|
|
141250
|
+
for(var j = 0; j < 2; j++){
|
|
141251
|
+
var x = right - j;
|
|
141252
|
+
var upward = (right + 1 & 2) == 0;
|
|
141253
|
+
var y = upward ? this.size - 1 - vert : vert;
|
|
141254
|
+
if (!this.isFunction[y][x] && i < data.length * 8) {
|
|
141255
|
+
this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
|
|
141256
|
+
i++;
|
|
141257
|
+
}
|
|
141258
|
+
}
|
|
141259
|
+
}
|
|
141260
|
+
}
|
|
141261
|
+
assert(i == data.length * 8);
|
|
141262
|
+
}
|
|
141263
|
+
},
|
|
141264
|
+
{
|
|
141265
|
+
// XORs the codeword modules in this QR Code with the given mask pattern.
|
|
141266
|
+
// The function modules must be marked and the codeword bits must be drawn
|
|
141267
|
+
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
|
141268
|
+
// the same mask value a second time will undo the mask. A final well-formed
|
|
141269
|
+
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
|
141270
|
+
key: "applyMask",
|
|
141271
|
+
value: function applyMask(mask) {
|
|
141272
|
+
if (mask < 0 || mask > 7) throw new RangeError("Mask value out of range");
|
|
141273
|
+
for(var y = 0; y < this.size; y++){
|
|
141274
|
+
for(var x = 0; x < this.size; x++){
|
|
141275
|
+
var invert = void 0;
|
|
141276
|
+
switch(mask){
|
|
141277
|
+
case 0:
|
|
141278
|
+
invert = (x + y) % 2 == 0;
|
|
141279
|
+
break;
|
|
141280
|
+
case 1:
|
|
141281
|
+
invert = y % 2 == 0;
|
|
141282
|
+
break;
|
|
141283
|
+
case 2:
|
|
141284
|
+
invert = x % 3 == 0;
|
|
141285
|
+
break;
|
|
141286
|
+
case 3:
|
|
141287
|
+
invert = (x + y) % 3 == 0;
|
|
141288
|
+
break;
|
|
141289
|
+
case 4:
|
|
141290
|
+
invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0;
|
|
141291
|
+
break;
|
|
141292
|
+
case 5:
|
|
141293
|
+
invert = x * y % 2 + x * y % 3 == 0;
|
|
141294
|
+
break;
|
|
141295
|
+
case 6:
|
|
141296
|
+
invert = (x * y % 2 + x * y % 3) % 2 == 0;
|
|
141297
|
+
break;
|
|
141298
|
+
case 7:
|
|
141299
|
+
invert = ((x + y) % 2 + x * y % 3) % 2 == 0;
|
|
141300
|
+
break;
|
|
141301
|
+
default:
|
|
141302
|
+
throw new Error("Unreachable");
|
|
141303
|
+
}
|
|
141304
|
+
if (!this.isFunction[y][x] && invert) this.modules[y][x] = !this.modules[y][x];
|
|
141305
|
+
}
|
|
141306
|
+
}
|
|
141307
|
+
}
|
|
141308
|
+
},
|
|
141309
|
+
{
|
|
141310
|
+
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
|
141311
|
+
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
|
141312
|
+
key: "getPenaltyScore",
|
|
141313
|
+
value: function getPenaltyScore() {
|
|
141314
|
+
var result = 0;
|
|
141315
|
+
for(var y = 0; y < this.size; y++){
|
|
141316
|
+
var runColor = false;
|
|
141317
|
+
var runX = 0;
|
|
141318
|
+
var runHistory = [
|
|
141319
|
+
0,
|
|
141320
|
+
0,
|
|
141321
|
+
0,
|
|
141322
|
+
0,
|
|
141323
|
+
0,
|
|
141324
|
+
0,
|
|
141325
|
+
0
|
|
141326
|
+
];
|
|
141327
|
+
for(var x = 0; x < this.size; x++){
|
|
141328
|
+
if (this.modules[y][x] == runColor) {
|
|
141329
|
+
runX++;
|
|
141330
|
+
if (runX == 5) result += _QrCode.PENALTY_N1;
|
|
141331
|
+
else if (runX > 5) result++;
|
|
141332
|
+
} else {
|
|
141333
|
+
this.finderPenaltyAddHistory(runX, runHistory);
|
|
141334
|
+
if (!runColor) result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;
|
|
141335
|
+
runColor = this.modules[y][x];
|
|
141336
|
+
runX = 1;
|
|
141337
|
+
}
|
|
141338
|
+
}
|
|
141339
|
+
result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode.PENALTY_N3;
|
|
141340
|
+
}
|
|
141341
|
+
for(var x1 = 0; x1 < this.size; x1++){
|
|
141342
|
+
var runColor1 = false;
|
|
141343
|
+
var runY = 0;
|
|
141344
|
+
var runHistory1 = [
|
|
141345
|
+
0,
|
|
141346
|
+
0,
|
|
141347
|
+
0,
|
|
141348
|
+
0,
|
|
141349
|
+
0,
|
|
141350
|
+
0,
|
|
141351
|
+
0
|
|
141352
|
+
];
|
|
141353
|
+
for(var y1 = 0; y1 < this.size; y1++){
|
|
141354
|
+
if (this.modules[y1][x1] == runColor1) {
|
|
141355
|
+
runY++;
|
|
141356
|
+
if (runY == 5) result += _QrCode.PENALTY_N1;
|
|
141357
|
+
else if (runY > 5) result++;
|
|
141358
|
+
} else {
|
|
141359
|
+
this.finderPenaltyAddHistory(runY, runHistory1);
|
|
141360
|
+
if (!runColor1) result += this.finderPenaltyCountPatterns(runHistory1) * _QrCode.PENALTY_N3;
|
|
141361
|
+
runColor1 = this.modules[y1][x1];
|
|
141362
|
+
runY = 1;
|
|
141363
|
+
}
|
|
141364
|
+
}
|
|
141365
|
+
result += this.finderPenaltyTerminateAndCount(runColor1, runY, runHistory1) * _QrCode.PENALTY_N3;
|
|
141366
|
+
}
|
|
141367
|
+
for(var y2 = 0; y2 < this.size - 1; y2++){
|
|
141368
|
+
for(var x2 = 0; x2 < this.size - 1; x2++){
|
|
141369
|
+
var color = this.modules[y2][x2];
|
|
141370
|
+
if (color == this.modules[y2][x2 + 1] && color == this.modules[y2 + 1][x2] && color == this.modules[y2 + 1][x2 + 1]) result += _QrCode.PENALTY_N2;
|
|
141371
|
+
}
|
|
141372
|
+
}
|
|
141373
|
+
var dark = 0;
|
|
141374
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
141375
|
+
try {
|
|
141376
|
+
for(var _iterator = this.modules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
141377
|
+
var row = _step.value;
|
|
141378
|
+
dark = row.reduce(function(sum, color) {
|
|
141379
|
+
return sum + (color ? 1 : 0);
|
|
141380
|
+
}, dark);
|
|
141381
|
+
}
|
|
141382
|
+
} catch (err) {
|
|
141383
|
+
_didIteratorError = true;
|
|
141384
|
+
_iteratorError = err;
|
|
141385
|
+
} finally{
|
|
141386
|
+
try {
|
|
141387
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
141388
|
+
_iterator.return();
|
|
141389
|
+
}
|
|
141390
|
+
} finally{
|
|
141391
|
+
if (_didIteratorError) {
|
|
141392
|
+
throw _iteratorError;
|
|
141393
|
+
}
|
|
141394
|
+
}
|
|
141395
|
+
}
|
|
141396
|
+
var total = this.size * this.size;
|
|
141397
|
+
var k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
|
|
141398
|
+
assert(0 <= k && k <= 9);
|
|
141399
|
+
result += k * _QrCode.PENALTY_N4;
|
|
141400
|
+
assert(0 <= result && result <= 2568888);
|
|
141401
|
+
return result;
|
|
141402
|
+
}
|
|
141403
|
+
},
|
|
141404
|
+
{
|
|
141405
|
+
/*-- Private helper functions --*/ // Returns an ascending list of positions of alignment patterns for this version number.
|
|
141406
|
+
// Each position is in the range [0,177), and are used on both the x and y axes.
|
|
141407
|
+
// This could be implemented as lookup table of 40 variable-length lists of integers.
|
|
141408
|
+
key: "getAlignmentPatternPositions",
|
|
141409
|
+
value: function getAlignmentPatternPositions() {
|
|
141410
|
+
if (this.version == 1) return [];
|
|
141411
|
+
else {
|
|
141412
|
+
var numAlign = Math.floor(this.version / 7) + 2;
|
|
141413
|
+
var step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
|
|
141414
|
+
var result = [
|
|
141415
|
+
6
|
|
141416
|
+
];
|
|
141417
|
+
for(var pos = this.size - 7; result.length < numAlign; pos -= step)result.splice(1, 0, pos);
|
|
141418
|
+
return result;
|
|
141419
|
+
}
|
|
141420
|
+
}
|
|
141421
|
+
},
|
|
141422
|
+
{
|
|
141423
|
+
// Can only be called immediately after a light run is added, and
|
|
141424
|
+
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
|
141425
|
+
key: "finderPenaltyCountPatterns",
|
|
141426
|
+
value: function finderPenaltyCountPatterns(runHistory) {
|
|
141427
|
+
var n = runHistory[1];
|
|
141428
|
+
assert(n <= this.size * 3);
|
|
141429
|
+
var core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;
|
|
141430
|
+
return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
|
|
141431
|
+
}
|
|
141432
|
+
},
|
|
141433
|
+
{
|
|
141434
|
+
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
|
141435
|
+
key: "finderPenaltyTerminateAndCount",
|
|
141436
|
+
value: function finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
|
|
141437
|
+
if (currentRunColor) {
|
|
141438
|
+
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
141439
|
+
currentRunLength = 0;
|
|
141440
|
+
}
|
|
141441
|
+
currentRunLength += this.size;
|
|
141442
|
+
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
141443
|
+
return this.finderPenaltyCountPatterns(runHistory);
|
|
141444
|
+
}
|
|
141445
|
+
},
|
|
141446
|
+
{
|
|
141447
|
+
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
|
141448
|
+
key: "finderPenaltyAddHistory",
|
|
141449
|
+
value: function finderPenaltyAddHistory(currentRunLength, runHistory) {
|
|
141450
|
+
if (runHistory[0] == 0) currentRunLength += this.size;
|
|
141451
|
+
runHistory.pop();
|
|
141452
|
+
runHistory.unshift(currentRunLength);
|
|
141453
|
+
}
|
|
141454
|
+
}
|
|
141455
|
+
], [
|
|
141456
|
+
{
|
|
141457
|
+
key: "encodeText",
|
|
141458
|
+
value: /*-- Static factory functions (high level) --*/ // Returns a QR Code representing the given Unicode text string at the given error correction level.
|
|
141459
|
+
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
|
|
141460
|
+
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
|
|
141461
|
+
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
|
141462
|
+
// ecl argument if it can be done without increasing the version.
|
|
141463
|
+
function encodeText(text, ecl) {
|
|
141464
|
+
var segs = qrcodegen2.QrSegment.makeSegments(text);
|
|
141465
|
+
return _QrCode.encodeSegments(segs, ecl);
|
|
141466
|
+
}
|
|
141467
|
+
},
|
|
141468
|
+
{
|
|
141469
|
+
key: "encodeBinary",
|
|
141470
|
+
value: // Returns a QR Code representing the given binary data at the given error correction level.
|
|
141471
|
+
// This function always encodes using the binary segment mode, not any text mode. The maximum number of
|
|
141472
|
+
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
|
141473
|
+
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
|
141474
|
+
function encodeBinary(data, ecl) {
|
|
141475
|
+
var seg = qrcodegen2.QrSegment.makeBytes(data);
|
|
141476
|
+
return _QrCode.encodeSegments([
|
|
141477
|
+
seg
|
|
141478
|
+
], ecl);
|
|
141479
|
+
}
|
|
141480
|
+
},
|
|
141481
|
+
{
|
|
141482
|
+
key: "encodeSegments",
|
|
141483
|
+
value: /*-- Static factory functions (mid level) --*/ // Returns a QR Code representing the given segments with the given encoding parameters.
|
|
141484
|
+
// The smallest possible QR Code version within the given range is automatically
|
|
141485
|
+
// chosen for the output. Iff boostEcl is true, then the ECC level of the result
|
|
141486
|
+
// may be higher than the ecl argument if it can be done without increasing the
|
|
141487
|
+
// version. The mask number is either between 0 to 7 (inclusive) to force that
|
|
141488
|
+
// mask, or -1 to automatically choose an appropriate mask (which may be slow).
|
|
141489
|
+
// This function allows the user to create a custom sequence of segments that switches
|
|
141490
|
+
// between modes (such as alphanumeric and byte) to encode text in less space.
|
|
141491
|
+
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
|
141492
|
+
function encodeSegments(segs, ecl) {
|
|
141493
|
+
var minVersion = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1, maxVersion = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 40, mask = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1, boostEcl = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : true;
|
|
141494
|
+
if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7) throw new RangeError("Invalid value");
|
|
141495
|
+
var version;
|
|
141496
|
+
var dataUsedBits;
|
|
141497
|
+
for(version = minVersion;; version++){
|
|
141498
|
+
var dataCapacityBits2 = _QrCode.getNumDataCodewords(version, ecl) * 8;
|
|
141499
|
+
var usedBits = QrSegment.getTotalBits(segs, version);
|
|
141500
|
+
if (usedBits <= dataCapacityBits2) {
|
|
141501
|
+
dataUsedBits = usedBits;
|
|
141502
|
+
break;
|
|
141503
|
+
}
|
|
141504
|
+
if (version >= maxVersion) throw new RangeError("Data too long");
|
|
141505
|
+
}
|
|
141506
|
+
for(var _i = 0, _iter = [
|
|
141507
|
+
_QrCode.Ecc.MEDIUM,
|
|
141508
|
+
_QrCode.Ecc.QUARTILE,
|
|
141509
|
+
_QrCode.Ecc.HIGH
|
|
141510
|
+
]; _i < _iter.length; _i++){
|
|
141511
|
+
var newEcl = _iter[_i];
|
|
141512
|
+
if (boostEcl && dataUsedBits <= _QrCode.getNumDataCodewords(version, newEcl) * 8) ecl = newEcl;
|
|
141513
|
+
}
|
|
141514
|
+
var bb = [];
|
|
141515
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
141516
|
+
try {
|
|
141517
|
+
for(var _iterator = segs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
141518
|
+
var seg = _step.value;
|
|
141519
|
+
appendBits(seg.mode.modeBits, 4, bb);
|
|
141520
|
+
appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);
|
|
141521
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
141522
|
+
try {
|
|
141523
|
+
for(var _iterator1 = seg.getData()[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
141524
|
+
var b = _step1.value;
|
|
141525
|
+
bb.push(b);
|
|
141526
|
+
}
|
|
141527
|
+
} catch (err) {
|
|
141528
|
+
_didIteratorError1 = true;
|
|
141529
|
+
_iteratorError1 = err;
|
|
141530
|
+
} finally{
|
|
141531
|
+
try {
|
|
141532
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
141533
|
+
_iterator1.return();
|
|
141534
|
+
}
|
|
141535
|
+
} finally{
|
|
141536
|
+
if (_didIteratorError1) {
|
|
141537
|
+
throw _iteratorError1;
|
|
141538
|
+
}
|
|
141539
|
+
}
|
|
141540
|
+
}
|
|
141541
|
+
}
|
|
141542
|
+
} catch (err) {
|
|
141543
|
+
_didIteratorError = true;
|
|
141544
|
+
_iteratorError = err;
|
|
141545
|
+
} finally{
|
|
141546
|
+
try {
|
|
141547
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
141548
|
+
_iterator.return();
|
|
141549
|
+
}
|
|
141550
|
+
} finally{
|
|
141551
|
+
if (_didIteratorError) {
|
|
141552
|
+
throw _iteratorError;
|
|
141553
|
+
}
|
|
141554
|
+
}
|
|
141555
|
+
}
|
|
141556
|
+
assert(bb.length == dataUsedBits);
|
|
141557
|
+
var dataCapacityBits = _QrCode.getNumDataCodewords(version, ecl) * 8;
|
|
141558
|
+
assert(bb.length <= dataCapacityBits);
|
|
141559
|
+
appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
|
|
141560
|
+
appendBits(0, (8 - bb.length % 8) % 8, bb);
|
|
141561
|
+
assert(bb.length % 8 == 0);
|
|
141562
|
+
for(var padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)appendBits(padByte, 8, bb);
|
|
141563
|
+
var dataCodewords = [];
|
|
141564
|
+
while(dataCodewords.length * 8 < bb.length)dataCodewords.push(0);
|
|
141565
|
+
bb.forEach(function(b, i) {
|
|
141566
|
+
return dataCodewords[i >>> 3] |= b << 7 - (i & 7);
|
|
141567
|
+
});
|
|
141568
|
+
return new _QrCode(version, ecl, dataCodewords, mask);
|
|
141569
|
+
}
|
|
141570
|
+
},
|
|
141571
|
+
{
|
|
141572
|
+
key: "getNumRawDataModules",
|
|
141573
|
+
value: // Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
|
141574
|
+
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
|
141575
|
+
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
|
141576
|
+
function getNumRawDataModules(ver) {
|
|
141577
|
+
if (ver < _QrCode.MIN_VERSION || ver > _QrCode.MAX_VERSION) throw new RangeError("Version number out of range");
|
|
141578
|
+
var result = (16 * ver + 128) * ver + 64;
|
|
141579
|
+
if (ver >= 2) {
|
|
141580
|
+
var numAlign = Math.floor(ver / 7) + 2;
|
|
141581
|
+
result -= (25 * numAlign - 10) * numAlign - 55;
|
|
141582
|
+
if (ver >= 7) result -= 36;
|
|
141583
|
+
}
|
|
141584
|
+
assert(208 <= result && result <= 29648);
|
|
141585
|
+
return result;
|
|
141586
|
+
}
|
|
141587
|
+
},
|
|
141588
|
+
{
|
|
141589
|
+
key: "getNumDataCodewords",
|
|
141590
|
+
value: // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
|
141591
|
+
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
|
141592
|
+
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
|
|
141593
|
+
function getNumDataCodewords(ver, ecl) {
|
|
141594
|
+
return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
141595
|
+
}
|
|
141596
|
+
},
|
|
141597
|
+
{
|
|
141598
|
+
key: "reedSolomonComputeDivisor",
|
|
141599
|
+
value: // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
|
|
141600
|
+
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
|
|
141601
|
+
function reedSolomonComputeDivisor(degree) {
|
|
141602
|
+
if (degree < 1 || degree > 255) throw new RangeError("Degree out of range");
|
|
141603
|
+
var result = [];
|
|
141604
|
+
for(var i = 0; i < degree - 1; i++)result.push(0);
|
|
141605
|
+
result.push(1);
|
|
141606
|
+
var root = 1;
|
|
141607
|
+
for(var i1 = 0; i1 < degree; i1++){
|
|
141608
|
+
for(var j = 0; j < result.length; j++){
|
|
141609
|
+
result[j] = _QrCode.reedSolomonMultiply(result[j], root);
|
|
141610
|
+
if (j + 1 < result.length) result[j] ^= result[j + 1];
|
|
141611
|
+
}
|
|
141612
|
+
root = _QrCode.reedSolomonMultiply(root, 2);
|
|
141613
|
+
}
|
|
141614
|
+
return result;
|
|
141615
|
+
}
|
|
141616
|
+
},
|
|
141617
|
+
{
|
|
141618
|
+
key: "reedSolomonComputeRemainder",
|
|
141619
|
+
value: // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
|
141620
|
+
function reedSolomonComputeRemainder(data, divisor) {
|
|
141621
|
+
var result = divisor.map(function(_) {
|
|
141622
|
+
return 0;
|
|
141623
|
+
});
|
|
141624
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
141625
|
+
try {
|
|
141626
|
+
var _loop = function() {
|
|
141627
|
+
var b = _step.value;
|
|
141628
|
+
var factor = b ^ result.shift();
|
|
141629
|
+
result.push(0);
|
|
141630
|
+
divisor.forEach(function(coef, i) {
|
|
141631
|
+
return result[i] ^= _QrCode.reedSolomonMultiply(coef, factor);
|
|
141632
|
+
});
|
|
141633
|
+
};
|
|
141634
|
+
for(var _iterator = data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
141635
|
+
} catch (err) {
|
|
141636
|
+
_didIteratorError = true;
|
|
141637
|
+
_iteratorError = err;
|
|
141638
|
+
} finally{
|
|
141639
|
+
try {
|
|
141640
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
141641
|
+
_iterator.return();
|
|
141642
|
+
}
|
|
141643
|
+
} finally{
|
|
141644
|
+
if (_didIteratorError) {
|
|
141645
|
+
throw _iteratorError;
|
|
141646
|
+
}
|
|
141647
|
+
}
|
|
141648
|
+
}
|
|
141649
|
+
return result;
|
|
141650
|
+
}
|
|
141651
|
+
},
|
|
141652
|
+
{
|
|
141653
|
+
key: "reedSolomonMultiply",
|
|
141654
|
+
value: // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
|
|
141655
|
+
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
|
|
141656
|
+
function reedSolomonMultiply(x, y) {
|
|
141657
|
+
if (x >>> 8 != 0 || y >>> 8 != 0) throw new RangeError("Byte out of range");
|
|
141658
|
+
var z = 0;
|
|
141659
|
+
for(var i = 7; i >= 0; i--){
|
|
141660
|
+
z = z << 1 ^ (z >>> 7) * 285;
|
|
141661
|
+
z ^= (y >>> i & 1) * x;
|
|
141662
|
+
}
|
|
141663
|
+
assert(z >>> 8 == 0);
|
|
141664
|
+
return z;
|
|
141665
|
+
}
|
|
141666
|
+
}
|
|
141667
|
+
]);
|
|
141668
|
+
return _QrCode;
|
|
141669
|
+
}();
|
|
141670
|
+
/*-- Constants and tables --*/ // The minimum version number supported in the QR Code Model 2 standard.
|
|
141671
|
+
_QrCode.MIN_VERSION = 1;
|
|
141672
|
+
// The maximum version number supported in the QR Code Model 2 standard.
|
|
141673
|
+
_QrCode.MAX_VERSION = 40;
|
|
141674
|
+
// For use in getPenaltyScore(), when evaluating which mask is best.
|
|
141675
|
+
_QrCode.PENALTY_N1 = 3;
|
|
141676
|
+
_QrCode.PENALTY_N2 = 3;
|
|
141677
|
+
_QrCode.PENALTY_N3 = 40;
|
|
141678
|
+
_QrCode.PENALTY_N4 = 10;
|
|
141679
|
+
_QrCode.ECC_CODEWORDS_PER_BLOCK = [
|
|
141680
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
141681
|
+
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
141682
|
+
[
|
|
141683
|
+
-1,
|
|
141684
|
+
7,
|
|
141685
|
+
10,
|
|
141686
|
+
15,
|
|
141687
|
+
20,
|
|
141688
|
+
26,
|
|
141689
|
+
18,
|
|
141690
|
+
20,
|
|
141691
|
+
24,
|
|
141692
|
+
30,
|
|
141693
|
+
18,
|
|
141694
|
+
20,
|
|
141695
|
+
24,
|
|
141696
|
+
26,
|
|
141697
|
+
30,
|
|
141698
|
+
22,
|
|
141699
|
+
24,
|
|
141700
|
+
28,
|
|
141701
|
+
30,
|
|
141702
|
+
28,
|
|
141703
|
+
28,
|
|
141704
|
+
28,
|
|
141705
|
+
28,
|
|
141706
|
+
30,
|
|
141707
|
+
30,
|
|
141708
|
+
26,
|
|
141709
|
+
28,
|
|
141710
|
+
30,
|
|
141711
|
+
30,
|
|
141712
|
+
30,
|
|
141713
|
+
30,
|
|
141714
|
+
30,
|
|
141715
|
+
30,
|
|
141716
|
+
30,
|
|
141717
|
+
30,
|
|
141718
|
+
30,
|
|
141719
|
+
30,
|
|
141720
|
+
30,
|
|
141721
|
+
30,
|
|
141722
|
+
30,
|
|
141723
|
+
30
|
|
141724
|
+
],
|
|
141725
|
+
// Low
|
|
141726
|
+
[
|
|
141727
|
+
-1,
|
|
141728
|
+
10,
|
|
141729
|
+
16,
|
|
141730
|
+
26,
|
|
141731
|
+
18,
|
|
141732
|
+
24,
|
|
141733
|
+
16,
|
|
141734
|
+
18,
|
|
141735
|
+
22,
|
|
141736
|
+
22,
|
|
141737
|
+
26,
|
|
141738
|
+
30,
|
|
141739
|
+
22,
|
|
141740
|
+
22,
|
|
141741
|
+
24,
|
|
141742
|
+
24,
|
|
141743
|
+
28,
|
|
141744
|
+
28,
|
|
141745
|
+
26,
|
|
141746
|
+
26,
|
|
141747
|
+
26,
|
|
141748
|
+
26,
|
|
141749
|
+
28,
|
|
141750
|
+
28,
|
|
141751
|
+
28,
|
|
141752
|
+
28,
|
|
141753
|
+
28,
|
|
141754
|
+
28,
|
|
141755
|
+
28,
|
|
141756
|
+
28,
|
|
141757
|
+
28,
|
|
141758
|
+
28,
|
|
141759
|
+
28,
|
|
141760
|
+
28,
|
|
141761
|
+
28,
|
|
141762
|
+
28,
|
|
141763
|
+
28,
|
|
141764
|
+
28,
|
|
141765
|
+
28,
|
|
141766
|
+
28,
|
|
141767
|
+
28
|
|
141768
|
+
],
|
|
141769
|
+
// Medium
|
|
141770
|
+
[
|
|
141771
|
+
-1,
|
|
141772
|
+
13,
|
|
141773
|
+
22,
|
|
141774
|
+
18,
|
|
141775
|
+
26,
|
|
141776
|
+
18,
|
|
141777
|
+
24,
|
|
141778
|
+
18,
|
|
141779
|
+
22,
|
|
141780
|
+
20,
|
|
141781
|
+
24,
|
|
141782
|
+
28,
|
|
141783
|
+
26,
|
|
141784
|
+
24,
|
|
141785
|
+
20,
|
|
141786
|
+
30,
|
|
141787
|
+
24,
|
|
141788
|
+
28,
|
|
141789
|
+
28,
|
|
141790
|
+
26,
|
|
141791
|
+
30,
|
|
141792
|
+
28,
|
|
141793
|
+
30,
|
|
141794
|
+
30,
|
|
141795
|
+
30,
|
|
141796
|
+
30,
|
|
141797
|
+
28,
|
|
141798
|
+
30,
|
|
141799
|
+
30,
|
|
141800
|
+
30,
|
|
141801
|
+
30,
|
|
141802
|
+
30,
|
|
141803
|
+
30,
|
|
141804
|
+
30,
|
|
141805
|
+
30,
|
|
141806
|
+
30,
|
|
141807
|
+
30,
|
|
141808
|
+
30,
|
|
141809
|
+
30,
|
|
141810
|
+
30,
|
|
141811
|
+
30
|
|
141812
|
+
],
|
|
141813
|
+
// Quartile
|
|
141814
|
+
[
|
|
141815
|
+
-1,
|
|
141816
|
+
17,
|
|
141817
|
+
28,
|
|
141818
|
+
22,
|
|
141819
|
+
16,
|
|
141820
|
+
22,
|
|
141821
|
+
28,
|
|
141822
|
+
26,
|
|
141823
|
+
26,
|
|
141824
|
+
24,
|
|
141825
|
+
28,
|
|
141826
|
+
24,
|
|
141827
|
+
28,
|
|
141828
|
+
22,
|
|
141829
|
+
24,
|
|
141830
|
+
24,
|
|
141831
|
+
30,
|
|
141832
|
+
28,
|
|
141833
|
+
28,
|
|
141834
|
+
26,
|
|
141835
|
+
28,
|
|
141836
|
+
30,
|
|
141837
|
+
24,
|
|
141838
|
+
30,
|
|
141839
|
+
30,
|
|
141840
|
+
30,
|
|
141841
|
+
30,
|
|
141842
|
+
30,
|
|
141843
|
+
30,
|
|
141844
|
+
30,
|
|
141845
|
+
30,
|
|
141846
|
+
30,
|
|
141847
|
+
30,
|
|
141848
|
+
30,
|
|
141849
|
+
30,
|
|
141850
|
+
30,
|
|
141851
|
+
30,
|
|
141852
|
+
30,
|
|
141853
|
+
30,
|
|
141854
|
+
30,
|
|
141855
|
+
30
|
|
141856
|
+
]
|
|
141857
|
+
];
|
|
141858
|
+
_QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
|
|
141859
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
141860
|
+
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
141861
|
+
[
|
|
141862
|
+
-1,
|
|
141863
|
+
1,
|
|
141864
|
+
1,
|
|
141865
|
+
1,
|
|
141866
|
+
1,
|
|
141867
|
+
1,
|
|
141868
|
+
2,
|
|
141869
|
+
2,
|
|
141870
|
+
2,
|
|
141871
|
+
2,
|
|
141872
|
+
4,
|
|
141873
|
+
4,
|
|
141874
|
+
4,
|
|
141875
|
+
4,
|
|
141876
|
+
4,
|
|
141877
|
+
6,
|
|
141878
|
+
6,
|
|
141879
|
+
6,
|
|
141880
|
+
6,
|
|
141881
|
+
7,
|
|
141882
|
+
8,
|
|
141883
|
+
8,
|
|
141884
|
+
9,
|
|
141885
|
+
9,
|
|
141886
|
+
10,
|
|
141887
|
+
12,
|
|
141888
|
+
12,
|
|
141889
|
+
12,
|
|
141890
|
+
13,
|
|
141891
|
+
14,
|
|
141892
|
+
15,
|
|
141893
|
+
16,
|
|
141894
|
+
17,
|
|
141895
|
+
18,
|
|
141896
|
+
19,
|
|
141897
|
+
19,
|
|
141898
|
+
20,
|
|
141899
|
+
21,
|
|
141900
|
+
22,
|
|
141901
|
+
24,
|
|
141902
|
+
25
|
|
141903
|
+
],
|
|
141904
|
+
// Low
|
|
141905
|
+
[
|
|
141906
|
+
-1,
|
|
141907
|
+
1,
|
|
141908
|
+
1,
|
|
141909
|
+
1,
|
|
141910
|
+
2,
|
|
141911
|
+
2,
|
|
141912
|
+
4,
|
|
141913
|
+
4,
|
|
141914
|
+
4,
|
|
141915
|
+
5,
|
|
141916
|
+
5,
|
|
141917
|
+
5,
|
|
141918
|
+
8,
|
|
141919
|
+
9,
|
|
141920
|
+
9,
|
|
141921
|
+
10,
|
|
141922
|
+
10,
|
|
141923
|
+
11,
|
|
141924
|
+
13,
|
|
141925
|
+
14,
|
|
141926
|
+
16,
|
|
141927
|
+
17,
|
|
141928
|
+
17,
|
|
141929
|
+
18,
|
|
141930
|
+
20,
|
|
141931
|
+
21,
|
|
141932
|
+
23,
|
|
141933
|
+
25,
|
|
141934
|
+
26,
|
|
141935
|
+
28,
|
|
141936
|
+
29,
|
|
141937
|
+
31,
|
|
141938
|
+
33,
|
|
141939
|
+
35,
|
|
141940
|
+
37,
|
|
141941
|
+
38,
|
|
141942
|
+
40,
|
|
141943
|
+
43,
|
|
141944
|
+
45,
|
|
141945
|
+
47,
|
|
141946
|
+
49
|
|
141947
|
+
],
|
|
141948
|
+
// Medium
|
|
141949
|
+
[
|
|
141950
|
+
-1,
|
|
141951
|
+
1,
|
|
141952
|
+
1,
|
|
141953
|
+
2,
|
|
141954
|
+
2,
|
|
141955
|
+
4,
|
|
141956
|
+
4,
|
|
141957
|
+
6,
|
|
141958
|
+
6,
|
|
141959
|
+
8,
|
|
141960
|
+
8,
|
|
141961
|
+
8,
|
|
141962
|
+
10,
|
|
141963
|
+
12,
|
|
141964
|
+
16,
|
|
141965
|
+
12,
|
|
141966
|
+
17,
|
|
141967
|
+
16,
|
|
141968
|
+
18,
|
|
141969
|
+
21,
|
|
141970
|
+
20,
|
|
141971
|
+
23,
|
|
141972
|
+
23,
|
|
141973
|
+
25,
|
|
141974
|
+
27,
|
|
141975
|
+
29,
|
|
141976
|
+
34,
|
|
141977
|
+
34,
|
|
141978
|
+
35,
|
|
141979
|
+
38,
|
|
141980
|
+
40,
|
|
141981
|
+
43,
|
|
141982
|
+
45,
|
|
141983
|
+
48,
|
|
141984
|
+
51,
|
|
141985
|
+
53,
|
|
141986
|
+
56,
|
|
141987
|
+
59,
|
|
141988
|
+
62,
|
|
141989
|
+
65,
|
|
141990
|
+
68
|
|
141991
|
+
],
|
|
141992
|
+
// Quartile
|
|
141993
|
+
[
|
|
141994
|
+
-1,
|
|
141995
|
+
1,
|
|
141996
|
+
1,
|
|
141997
|
+
2,
|
|
141998
|
+
4,
|
|
141999
|
+
4,
|
|
142000
|
+
4,
|
|
142001
|
+
5,
|
|
142002
|
+
6,
|
|
142003
|
+
8,
|
|
142004
|
+
8,
|
|
142005
|
+
11,
|
|
142006
|
+
11,
|
|
142007
|
+
16,
|
|
142008
|
+
16,
|
|
142009
|
+
18,
|
|
142010
|
+
16,
|
|
142011
|
+
19,
|
|
142012
|
+
21,
|
|
142013
|
+
25,
|
|
142014
|
+
25,
|
|
142015
|
+
25,
|
|
142016
|
+
34,
|
|
142017
|
+
30,
|
|
142018
|
+
32,
|
|
142019
|
+
35,
|
|
142020
|
+
37,
|
|
142021
|
+
40,
|
|
142022
|
+
42,
|
|
142023
|
+
45,
|
|
142024
|
+
48,
|
|
142025
|
+
51,
|
|
142026
|
+
54,
|
|
142027
|
+
57,
|
|
142028
|
+
60,
|
|
142029
|
+
63,
|
|
142030
|
+
66,
|
|
142031
|
+
70,
|
|
142032
|
+
74,
|
|
142033
|
+
77,
|
|
142034
|
+
81
|
|
142035
|
+
]
|
|
142036
|
+
];
|
|
142037
|
+
var QrCode = _QrCode;
|
|
142038
|
+
qrcodegen2.QrCode = _QrCode;
|
|
142039
|
+
var _QrSegment = /*#__PURE__*/ function() {
|
|
142040
|
+
"use strict";
|
|
142041
|
+
function _QrSegment(mode, numChars, bitData) {
|
|
142042
|
+
_class_call_check(this, _QrSegment);
|
|
142043
|
+
this.mode = mode;
|
|
142044
|
+
this.numChars = numChars;
|
|
142045
|
+
this.bitData = bitData;
|
|
142046
|
+
if (numChars < 0) throw new RangeError("Invalid argument");
|
|
142047
|
+
this.bitData = bitData.slice();
|
|
142048
|
+
}
|
|
142049
|
+
_create_class(_QrSegment, [
|
|
142050
|
+
{
|
|
142051
|
+
/*-- Methods --*/ // Returns a new copy of the data bits of this segment.
|
|
142052
|
+
key: "getData",
|
|
142053
|
+
value: function getData() {
|
|
142054
|
+
return this.bitData.slice();
|
|
142055
|
+
}
|
|
142056
|
+
}
|
|
142057
|
+
], [
|
|
142058
|
+
{
|
|
142059
|
+
key: "makeBytes",
|
|
142060
|
+
value: /*-- Static factory functions (mid level) --*/ // Returns a segment representing the given binary data encoded in
|
|
142061
|
+
// byte mode. All input byte arrays are acceptable. Any text string
|
|
142062
|
+
// can be converted to UTF-8 bytes and encoded as a byte mode segment.
|
|
142063
|
+
function makeBytes(data) {
|
|
142064
|
+
var bb = [];
|
|
142065
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
142066
|
+
try {
|
|
142067
|
+
for(var _iterator = data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
142068
|
+
var b = _step.value;
|
|
142069
|
+
appendBits(b, 8, bb);
|
|
142070
|
+
}
|
|
142071
|
+
} catch (err) {
|
|
142072
|
+
_didIteratorError = true;
|
|
142073
|
+
_iteratorError = err;
|
|
142074
|
+
} finally{
|
|
142075
|
+
try {
|
|
142076
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
142077
|
+
_iterator.return();
|
|
142078
|
+
}
|
|
142079
|
+
} finally{
|
|
142080
|
+
if (_didIteratorError) {
|
|
142081
|
+
throw _iteratorError;
|
|
142082
|
+
}
|
|
142083
|
+
}
|
|
142084
|
+
}
|
|
142085
|
+
return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb);
|
|
142086
|
+
}
|
|
142087
|
+
},
|
|
142088
|
+
{
|
|
142089
|
+
key: "makeNumeric",
|
|
142090
|
+
value: // Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
|
142091
|
+
function makeNumeric(digits) {
|
|
142092
|
+
if (!_QrSegment.isNumeric(digits)) throw new RangeError("String contains non-numeric characters");
|
|
142093
|
+
var bb = [];
|
|
142094
|
+
for(var i = 0; i < digits.length;){
|
|
142095
|
+
var n = Math.min(digits.length - i, 3);
|
|
142096
|
+
appendBits(parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);
|
|
142097
|
+
i += n;
|
|
142098
|
+
}
|
|
142099
|
+
return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb);
|
|
142100
|
+
}
|
|
142101
|
+
},
|
|
142102
|
+
{
|
|
142103
|
+
key: "makeAlphanumeric",
|
|
142104
|
+
value: // Returns a segment representing the given text string encoded in alphanumeric mode.
|
|
142105
|
+
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
|
142106
|
+
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
142107
|
+
function makeAlphanumeric(text) {
|
|
142108
|
+
if (!_QrSegment.isAlphanumeric(text)) throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
142109
|
+
var bb = [];
|
|
142110
|
+
var i;
|
|
142111
|
+
for(i = 0; i + 2 <= text.length; i += 2){
|
|
142112
|
+
var temp = _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
|
|
142113
|
+
temp += _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
|
|
142114
|
+
appendBits(temp, 11, bb);
|
|
142115
|
+
}
|
|
142116
|
+
if (i < text.length) appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
|
|
142117
|
+
return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text.length, bb);
|
|
142118
|
+
}
|
|
142119
|
+
},
|
|
142120
|
+
{
|
|
142121
|
+
key: "makeSegments",
|
|
142122
|
+
value: // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
|
142123
|
+
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
|
142124
|
+
function makeSegments(text) {
|
|
142125
|
+
if (text == "") return [];
|
|
142126
|
+
else if (_QrSegment.isNumeric(text)) return [
|
|
142127
|
+
_QrSegment.makeNumeric(text)
|
|
142128
|
+
];
|
|
142129
|
+
else if (_QrSegment.isAlphanumeric(text)) return [
|
|
142130
|
+
_QrSegment.makeAlphanumeric(text)
|
|
142131
|
+
];
|
|
142132
|
+
else return [
|
|
142133
|
+
_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text))
|
|
142134
|
+
];
|
|
142135
|
+
}
|
|
142136
|
+
},
|
|
142137
|
+
{
|
|
142138
|
+
key: "makeEci",
|
|
142139
|
+
value: // Returns a segment representing an Extended Channel Interpretation
|
|
142140
|
+
// (ECI) designator with the given assignment value.
|
|
142141
|
+
function makeEci(assignVal) {
|
|
142142
|
+
var bb = [];
|
|
142143
|
+
if (assignVal < 0) throw new RangeError("ECI assignment value out of range");
|
|
142144
|
+
else if (assignVal < 1 << 7) appendBits(assignVal, 8, bb);
|
|
142145
|
+
else if (assignVal < 1 << 14) {
|
|
142146
|
+
appendBits(2, 2, bb);
|
|
142147
|
+
appendBits(assignVal, 14, bb);
|
|
142148
|
+
} else if (assignVal < 1e6) {
|
|
142149
|
+
appendBits(6, 3, bb);
|
|
142150
|
+
appendBits(assignVal, 21, bb);
|
|
142151
|
+
} else throw new RangeError("ECI assignment value out of range");
|
|
142152
|
+
return new _QrSegment(_QrSegment.Mode.ECI, 0, bb);
|
|
142153
|
+
}
|
|
142154
|
+
},
|
|
142155
|
+
{
|
|
142156
|
+
key: "isNumeric",
|
|
142157
|
+
value: // Tests whether the given string can be encoded as a segment in numeric mode.
|
|
142158
|
+
// A string is encodable iff each character is in the range 0 to 9.
|
|
142159
|
+
function isNumeric(text) {
|
|
142160
|
+
return _QrSegment.NUMERIC_REGEX.test(text);
|
|
142161
|
+
}
|
|
142162
|
+
},
|
|
142163
|
+
{
|
|
142164
|
+
key: "isAlphanumeric",
|
|
142165
|
+
value: // Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
|
142166
|
+
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
|
142167
|
+
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
142168
|
+
function isAlphanumeric(text) {
|
|
142169
|
+
return _QrSegment.ALPHANUMERIC_REGEX.test(text);
|
|
142170
|
+
}
|
|
142171
|
+
},
|
|
142172
|
+
{
|
|
142173
|
+
key: "getTotalBits",
|
|
142174
|
+
value: // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
|
|
142175
|
+
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
|
142176
|
+
function getTotalBits(segs, version) {
|
|
142177
|
+
var result = 0;
|
|
142178
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
142179
|
+
try {
|
|
142180
|
+
for(var _iterator = segs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
142181
|
+
var seg = _step.value;
|
|
142182
|
+
var ccbits = seg.mode.numCharCountBits(version);
|
|
142183
|
+
if (seg.numChars >= 1 << ccbits) return Infinity;
|
|
142184
|
+
result += 4 + ccbits + seg.bitData.length;
|
|
142185
|
+
}
|
|
142186
|
+
} catch (err) {
|
|
142187
|
+
_didIteratorError = true;
|
|
142188
|
+
_iteratorError = err;
|
|
142189
|
+
} finally{
|
|
142190
|
+
try {
|
|
142191
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
142192
|
+
_iterator.return();
|
|
142193
|
+
}
|
|
142194
|
+
} finally{
|
|
142195
|
+
if (_didIteratorError) {
|
|
142196
|
+
throw _iteratorError;
|
|
142197
|
+
}
|
|
142198
|
+
}
|
|
142199
|
+
}
|
|
142200
|
+
return result;
|
|
142201
|
+
}
|
|
142202
|
+
},
|
|
142203
|
+
{
|
|
142204
|
+
key: "toUtf8ByteArray",
|
|
142205
|
+
value: // Returns a new array of bytes representing the given string encoded in UTF-8.
|
|
142206
|
+
function toUtf8ByteArray(str) {
|
|
142207
|
+
str = encodeURI(str);
|
|
142208
|
+
var result = [];
|
|
142209
|
+
for(var i = 0; i < str.length; i++){
|
|
142210
|
+
if (str.charAt(i) != "%") result.push(str.charCodeAt(i));
|
|
142211
|
+
else {
|
|
142212
|
+
result.push(parseInt(str.substring(i + 1, i + 3), 16));
|
|
142213
|
+
i += 2;
|
|
142214
|
+
}
|
|
142215
|
+
}
|
|
142216
|
+
return result;
|
|
142217
|
+
}
|
|
142218
|
+
}
|
|
142219
|
+
]);
|
|
142220
|
+
return _QrSegment;
|
|
142221
|
+
}();
|
|
142222
|
+
/*-- Constants --*/ // Describes precisely all strings that are encodable in numeric mode.
|
|
142223
|
+
_QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
|
|
142224
|
+
// Describes precisely all strings that are encodable in alphanumeric mode.
|
|
142225
|
+
_QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
|
|
142226
|
+
// The set of all legal characters in alphanumeric mode,
|
|
142227
|
+
// where each character value maps to the index in the string.
|
|
142228
|
+
_QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
142229
|
+
var QrSegment = _QrSegment;
|
|
142230
|
+
qrcodegen2.QrSegment = _QrSegment;
|
|
141501
142231
|
})(qrcodegen || (qrcodegen = {}));
|
|
141502
|
-
((qrcodegen2)
|
|
141503
|
-
|
|
141504
|
-
|
|
141505
|
-
|
|
141506
|
-
|
|
141507
|
-
|
|
141508
|
-
|
|
141509
|
-
|
|
141510
|
-
|
|
141511
|
-
|
|
141512
|
-
|
|
141513
|
-
|
|
141514
|
-
|
|
141515
|
-
|
|
141516
|
-
|
|
141517
|
-
|
|
142232
|
+
(function(qrcodegen2) {
|
|
142233
|
+
var QrCode;
|
|
142234
|
+
(function(QrCode2) {
|
|
142235
|
+
var _Ecc = function _Ecc(ordinal, formatBits) {
|
|
142236
|
+
"use strict";
|
|
142237
|
+
_class_call_check(this, _Ecc);
|
|
142238
|
+
this.ordinal = ordinal;
|
|
142239
|
+
this.formatBits = formatBits;
|
|
142240
|
+
};
|
|
142241
|
+
/*-- Constants --*/ _Ecc.LOW = new _Ecc(0, 1);
|
|
142242
|
+
// The QR Code can tolerate about 7% erroneous codewords
|
|
142243
|
+
_Ecc.MEDIUM = new _Ecc(1, 0);
|
|
142244
|
+
// The QR Code can tolerate about 15% erroneous codewords
|
|
142245
|
+
_Ecc.QUARTILE = new _Ecc(2, 3);
|
|
142246
|
+
// The QR Code can tolerate about 25% erroneous codewords
|
|
142247
|
+
_Ecc.HIGH = new _Ecc(3, 2);
|
|
142248
|
+
var Ecc = _Ecc;
|
|
142249
|
+
QrCode2.Ecc = _Ecc;
|
|
142250
|
+
})(QrCode = qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
|
|
141518
142251
|
})(qrcodegen || (qrcodegen = {}));
|
|
141519
|
-
((qrcodegen2)
|
|
141520
|
-
|
|
141521
|
-
|
|
141522
|
-
|
|
141523
|
-
|
|
141524
|
-
|
|
141525
|
-
|
|
141526
|
-
|
|
141527
|
-
|
|
141528
|
-
|
|
141529
|
-
|
|
141530
|
-
|
|
141531
|
-
|
|
141532
|
-
|
|
141533
|
-
|
|
141534
|
-
|
|
141535
|
-
|
|
141536
|
-
|
|
141537
|
-
|
|
141538
|
-
|
|
142252
|
+
(function(qrcodegen2) {
|
|
142253
|
+
var QrSegment;
|
|
142254
|
+
(function(QrSegment2) {
|
|
142255
|
+
var _Mode = /*#__PURE__*/ function() {
|
|
142256
|
+
"use strict";
|
|
142257
|
+
function _Mode(modeBits, numBitsCharCount) {
|
|
142258
|
+
_class_call_check(this, _Mode);
|
|
142259
|
+
this.modeBits = modeBits;
|
|
142260
|
+
this.numBitsCharCount = numBitsCharCount;
|
|
142261
|
+
}
|
|
142262
|
+
_create_class(_Mode, [
|
|
142263
|
+
{
|
|
142264
|
+
/*-- Method --*/ // (Package-private) Returns the bit width of the character count field for a segment in
|
|
142265
|
+
// this mode in a QR Code at the given version number. The result is in the range [0, 16].
|
|
142266
|
+
key: "numCharCountBits",
|
|
142267
|
+
value: function numCharCountBits(ver) {
|
|
142268
|
+
return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
|
|
142269
|
+
}
|
|
142270
|
+
}
|
|
142271
|
+
]);
|
|
142272
|
+
return _Mode;
|
|
142273
|
+
}();
|
|
142274
|
+
/*-- Constants --*/ _Mode.NUMERIC = new _Mode(1, [
|
|
142275
|
+
10,
|
|
142276
|
+
12,
|
|
142277
|
+
14
|
|
142278
|
+
]);
|
|
142279
|
+
_Mode.ALPHANUMERIC = new _Mode(2, [
|
|
142280
|
+
9,
|
|
142281
|
+
11,
|
|
142282
|
+
13
|
|
142283
|
+
]);
|
|
142284
|
+
_Mode.BYTE = new _Mode(4, [
|
|
142285
|
+
8,
|
|
142286
|
+
16,
|
|
142287
|
+
16
|
|
142288
|
+
]);
|
|
142289
|
+
_Mode.KANJI = new _Mode(8, [
|
|
142290
|
+
8,
|
|
142291
|
+
10,
|
|
142292
|
+
12
|
|
142293
|
+
]);
|
|
142294
|
+
_Mode.ECI = new _Mode(7, [
|
|
142295
|
+
0,
|
|
142296
|
+
0,
|
|
142297
|
+
0
|
|
142298
|
+
]);
|
|
142299
|
+
var Mode = _Mode;
|
|
142300
|
+
QrSegment2.Mode = _Mode;
|
|
142301
|
+
})(QrSegment = qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
|
|
141539
142302
|
})(qrcodegen || (qrcodegen = {}));
|
|
141540
142303
|
var qrcodegen_default = qrcodegen;
|
|
141541
|
-
|
|
141542
142304
|
// src/index.tsx
|
|
141543
142305
|
/**
|
|
141544
142306
|
* @license qrcode.react
|
|
141545
142307
|
* Copyright (c) Paul O'Shannessy
|
|
141546
142308
|
* SPDX-License-Identifier: ISC
|
|
141547
|
-
*/
|
|
141548
|
-
|
|
141549
|
-
|
|
141550
|
-
|
|
141551
|
-
|
|
141552
|
-
H: qrcodegen_default.QrCode.Ecc.HIGH
|
|
142309
|
+
*/ var ERROR_LEVEL_MAP = {
|
|
142310
|
+
L: qrcodegen_default.QrCode.Ecc.LOW,
|
|
142311
|
+
M: qrcodegen_default.QrCode.Ecc.MEDIUM,
|
|
142312
|
+
Q: qrcodegen_default.QrCode.Ecc.QUARTILE,
|
|
142313
|
+
H: qrcodegen_default.QrCode.Ecc.HIGH
|
|
141553
142314
|
};
|
|
141554
142315
|
var DEFAULT_SIZE = 128;
|
|
141555
142316
|
var DEFAULT_LEVEL = "L";
|
|
141556
142317
|
var DEFAULT_BGCOLOR = "#FFFFFF";
|
|
141557
142318
|
var DEFAULT_FGCOLOR = "#000000";
|
|
141558
142319
|
var DEFAULT_INCLUDEMARGIN = false;
|
|
141559
|
-
var
|
|
142320
|
+
var DEFAULT_MINVERSION = 1;
|
|
142321
|
+
var SPEC_MARGIN_SIZE = 4;
|
|
142322
|
+
var DEFAULT_MARGIN_SIZE = 0;
|
|
141560
142323
|
var DEFAULT_IMG_SCALE = 0.1;
|
|
141561
|
-
function generatePath(modules
|
|
141562
|
-
|
|
141563
|
-
|
|
141564
|
-
|
|
141565
|
-
|
|
141566
|
-
|
|
141567
|
-
|
|
141568
|
-
|
|
141569
|
-
|
|
141570
|
-
|
|
141571
|
-
|
|
141572
|
-
|
|
141573
|
-
|
|
141574
|
-
|
|
141575
|
-
|
|
141576
|
-
|
|
141577
|
-
|
|
141578
|
-
|
|
141579
|
-
|
|
141580
|
-
|
|
141581
|
-
|
|
141582
|
-
|
|
141583
|
-
|
|
141584
|
-
|
|
142324
|
+
function generatePath(modules) {
|
|
142325
|
+
var margin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
142326
|
+
var ops = [];
|
|
142327
|
+
modules.forEach(function(row, y) {
|
|
142328
|
+
var start = null;
|
|
142329
|
+
row.forEach(function(cell, x) {
|
|
142330
|
+
if (!cell && start !== null) {
|
|
142331
|
+
ops.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
|
|
142332
|
+
start = null;
|
|
142333
|
+
return;
|
|
142334
|
+
}
|
|
142335
|
+
if (x === row.length - 1) {
|
|
142336
|
+
if (!cell) {
|
|
142337
|
+
return;
|
|
142338
|
+
}
|
|
142339
|
+
if (start === null) {
|
|
142340
|
+
ops.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
|
|
142341
|
+
} else {
|
|
142342
|
+
ops.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
|
|
142343
|
+
}
|
|
142344
|
+
return;
|
|
142345
|
+
}
|
|
142346
|
+
if (cell && start === null) {
|
|
142347
|
+
start = x;
|
|
142348
|
+
}
|
|
142349
|
+
});
|
|
141585
142350
|
});
|
|
141586
|
-
|
|
141587
|
-
return ops.join("");
|
|
142351
|
+
return ops.join("");
|
|
141588
142352
|
}
|
|
141589
142353
|
function excavateModules(modules, excavation) {
|
|
141590
|
-
|
|
141591
|
-
|
|
141592
|
-
|
|
141593
|
-
|
|
141594
|
-
|
|
141595
|
-
|
|
141596
|
-
|
|
141597
|
-
|
|
141598
|
-
|
|
142354
|
+
return modules.slice().map(function(row, y) {
|
|
142355
|
+
if (y < excavation.y || y >= excavation.y + excavation.h) {
|
|
142356
|
+
return row;
|
|
142357
|
+
}
|
|
142358
|
+
return row.map(function(cell, x) {
|
|
142359
|
+
if (x < excavation.x || x >= excavation.x + excavation.w) {
|
|
142360
|
+
return cell;
|
|
142361
|
+
}
|
|
142362
|
+
return false;
|
|
142363
|
+
});
|
|
141599
142364
|
});
|
|
141600
|
-
});
|
|
141601
142365
|
}
|
|
141602
|
-
function getImageSettings(cells, size,
|
|
141603
|
-
|
|
141604
|
-
|
|
141605
|
-
|
|
141606
|
-
|
|
141607
|
-
|
|
141608
|
-
|
|
141609
|
-
|
|
141610
|
-
|
|
141611
|
-
|
|
141612
|
-
|
|
141613
|
-
|
|
141614
|
-
|
|
141615
|
-
|
|
141616
|
-
|
|
141617
|
-
|
|
141618
|
-
|
|
141619
|
-
|
|
141620
|
-
|
|
141621
|
-
|
|
141622
|
-
|
|
142366
|
+
function getImageSettings(cells, size, margin, imageSettings) {
|
|
142367
|
+
if (imageSettings == null) {
|
|
142368
|
+
return null;
|
|
142369
|
+
}
|
|
142370
|
+
var numCells = cells.length + margin * 2;
|
|
142371
|
+
var defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);
|
|
142372
|
+
var scale = numCells / size;
|
|
142373
|
+
var w = (imageSettings.width || defaultSize) * scale;
|
|
142374
|
+
var h = (imageSettings.height || defaultSize) * scale;
|
|
142375
|
+
var x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;
|
|
142376
|
+
var y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;
|
|
142377
|
+
var opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;
|
|
142378
|
+
var excavation = null;
|
|
142379
|
+
if (imageSettings.excavate) {
|
|
142380
|
+
var floorX = Math.floor(x);
|
|
142381
|
+
var floorY = Math.floor(y);
|
|
142382
|
+
var ceilW = Math.ceil(w + x - floorX);
|
|
142383
|
+
var ceilH = Math.ceil(h + y - floorY);
|
|
142384
|
+
excavation = {
|
|
142385
|
+
x: floorX,
|
|
142386
|
+
y: floorY,
|
|
142387
|
+
w: ceilW,
|
|
142388
|
+
h: ceilH
|
|
142389
|
+
};
|
|
142390
|
+
}
|
|
142391
|
+
return {
|
|
142392
|
+
x: x,
|
|
142393
|
+
y: y,
|
|
142394
|
+
h: h,
|
|
142395
|
+
w: w,
|
|
142396
|
+
excavation: excavation,
|
|
142397
|
+
opacity: opacity
|
|
142398
|
+
};
|
|
142399
|
+
}
|
|
142400
|
+
function getMarginSize(includeMargin, marginSize) {
|
|
142401
|
+
if (marginSize != null) {
|
|
142402
|
+
return Math.floor(marginSize);
|
|
142403
|
+
}
|
|
142404
|
+
return includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
|
|
142405
|
+
}
|
|
142406
|
+
function makeQRCode(param) {
|
|
142407
|
+
var value = param.value, level = param.level, minVersion = param.minVersion;
|
|
142408
|
+
var segments = qrcodegen_default.QrSegment.makeSegments(value);
|
|
142409
|
+
return qrcodegen_default.QrCode.encodeSegments(segments, ERROR_LEVEL_MAP[level], minVersion);
|
|
141623
142410
|
}
|
|
141624
142411
|
var SUPPORTS_PATH2D = function() {
|
|
141625
|
-
|
|
141626
|
-
|
|
141627
|
-
|
|
141628
|
-
|
|
141629
|
-
|
|
141630
|
-
|
|
142412
|
+
try {
|
|
142413
|
+
new Path2D().addPath(new Path2D());
|
|
142414
|
+
} catch (e) {
|
|
142415
|
+
return false;
|
|
142416
|
+
}
|
|
142417
|
+
return true;
|
|
141631
142418
|
}();
|
|
141632
|
-
|
|
141633
|
-
|
|
141634
|
-
|
|
141635
|
-
|
|
141636
|
-
|
|
141637
|
-
|
|
141638
|
-
|
|
141639
|
-
|
|
141640
|
-
|
|
141641
|
-
|
|
141642
|
-
|
|
141643
|
-
|
|
141644
|
-
|
|
141645
|
-
|
|
141646
|
-
"
|
|
141647
|
-
"
|
|
141648
|
-
"
|
|
141649
|
-
|
|
141650
|
-
|
|
141651
|
-
|
|
141652
|
-
|
|
141653
|
-
|
|
141654
|
-
|
|
141655
|
-
|
|
141656
|
-
|
|
141657
|
-
|
|
141658
|
-
|
|
141659
|
-
|
|
141660
|
-
|
|
141661
|
-
|
|
141662
|
-
|
|
141663
|
-
|
|
141664
|
-
|
|
141665
|
-
const numCells = cells.length + margin * 2;
|
|
141666
|
-
const calculatedImageSettings = getImageSettings(cells, size, includeMargin, imageSettings);
|
|
141667
|
-
const image = _image.current;
|
|
141668
|
-
const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
|
|
141669
|
-
if (haveImageToRender) {
|
|
141670
|
-
if (calculatedImageSettings.excavation != null) {
|
|
141671
|
-
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
141672
|
-
}
|
|
141673
|
-
}
|
|
141674
|
-
const pixelRatio = window.devicePixelRatio || 1;
|
|
141675
|
-
canvas.height = canvas.width = size * pixelRatio;
|
|
141676
|
-
const scale = size / numCells * pixelRatio;
|
|
141677
|
-
ctx.scale(scale, scale);
|
|
141678
|
-
ctx.fillStyle = bgColor;
|
|
141679
|
-
ctx.fillRect(0, 0, numCells, numCells);
|
|
141680
|
-
ctx.fillStyle = fgColor;
|
|
141681
|
-
if (SUPPORTS_PATH2D) {
|
|
141682
|
-
ctx.fill(new Path2D(generatePath(cells, margin)));
|
|
141683
|
-
} else {
|
|
141684
|
-
cells.forEach(function(row, rdx) {
|
|
141685
|
-
row.forEach(function(cell, cdx) {
|
|
141686
|
-
if (cell) {
|
|
141687
|
-
ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
|
|
142419
|
+
var QRCodeCanvas = react__WEBPACK_IMPORTED_MODULE_0___default.a.forwardRef(function QRCodeCanvas2(props, forwardedRef) {
|
|
142420
|
+
var value = props.value, _props_size = props.size, size = _props_size === void 0 ? DEFAULT_SIZE : _props_size, _props_level = props.level, level = _props_level === void 0 ? DEFAULT_LEVEL : _props_level, _props_bgColor = props.bgColor, bgColor = _props_bgColor === void 0 ? DEFAULT_BGCOLOR : _props_bgColor, _props_fgColor = props.fgColor, fgColor = _props_fgColor === void 0 ? DEFAULT_FGCOLOR : _props_fgColor, _props_includeMargin = props.includeMargin, includeMargin = _props_includeMargin === void 0 ? DEFAULT_INCLUDEMARGIN : _props_includeMargin, _props_minVersion = props.minVersion, minVersion = _props_minVersion === void 0 ? DEFAULT_MINVERSION : _props_minVersion, marginSize = props.marginSize, style = props.style, imageSettings = props.imageSettings, otherProps = _object_without_properties(props, [
|
|
142421
|
+
"value",
|
|
142422
|
+
"size",
|
|
142423
|
+
"level",
|
|
142424
|
+
"bgColor",
|
|
142425
|
+
"fgColor",
|
|
142426
|
+
"includeMargin",
|
|
142427
|
+
"minVersion",
|
|
142428
|
+
"marginSize",
|
|
142429
|
+
"style",
|
|
142430
|
+
"imageSettings"
|
|
142431
|
+
]);
|
|
142432
|
+
var imgSrc = imageSettings === null || imageSettings === void 0 ? void 0 : imageSettings.src;
|
|
142433
|
+
var _canvas = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(null);
|
|
142434
|
+
var _image = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(null);
|
|
142435
|
+
var setCanvasRef = Object(react__WEBPACK_IMPORTED_MODULE_0__["useCallback"])(function(node) {
|
|
142436
|
+
_canvas.current = node;
|
|
142437
|
+
if (typeof forwardedRef === "function") {
|
|
142438
|
+
forwardedRef(node);
|
|
142439
|
+
} else if (forwardedRef) {
|
|
142440
|
+
forwardedRef.current = node;
|
|
142441
|
+
}
|
|
142442
|
+
}, [
|
|
142443
|
+
forwardedRef
|
|
142444
|
+
]);
|
|
142445
|
+
var _useState = _sliced_to_array(Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])(false), 2), isImgLoaded = _useState[0], setIsImageLoaded = _useState[1];
|
|
142446
|
+
Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function() {
|
|
142447
|
+
if (_canvas.current != null) {
|
|
142448
|
+
var canvas = _canvas.current;
|
|
142449
|
+
var ctx = canvas.getContext("2d");
|
|
142450
|
+
if (!ctx) {
|
|
142451
|
+
return;
|
|
141688
142452
|
}
|
|
141689
|
-
|
|
142453
|
+
var qrcode = makeQRCode({
|
|
142454
|
+
value: value,
|
|
142455
|
+
level: level,
|
|
142456
|
+
minVersion: minVersion
|
|
142457
|
+
});
|
|
142458
|
+
var cells = qrcode.getModules();
|
|
142459
|
+
var margin = getMarginSize(includeMargin, marginSize);
|
|
142460
|
+
var numCells = cells.length + margin * 2;
|
|
142461
|
+
var calculatedImageSettings = getImageSettings(cells, size, margin, imageSettings);
|
|
142462
|
+
var image = _image.current;
|
|
142463
|
+
var haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
|
|
142464
|
+
if (haveImageToRender) {
|
|
142465
|
+
if (calculatedImageSettings.excavation != null) {
|
|
142466
|
+
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
142467
|
+
}
|
|
142468
|
+
}
|
|
142469
|
+
var pixelRatio = window.devicePixelRatio || 1;
|
|
142470
|
+
canvas.height = canvas.width = size * pixelRatio;
|
|
142471
|
+
var scale = size / numCells * pixelRatio;
|
|
142472
|
+
ctx.scale(scale, scale);
|
|
142473
|
+
ctx.fillStyle = bgColor;
|
|
142474
|
+
ctx.fillRect(0, 0, numCells, numCells);
|
|
142475
|
+
ctx.fillStyle = fgColor;
|
|
142476
|
+
if (SUPPORTS_PATH2D) {
|
|
142477
|
+
ctx.fill(new Path2D(generatePath(cells, margin)));
|
|
142478
|
+
} else {
|
|
142479
|
+
cells.forEach(function(row, rdx) {
|
|
142480
|
+
row.forEach(function(cell, cdx) {
|
|
142481
|
+
if (cell) {
|
|
142482
|
+
ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
|
|
142483
|
+
}
|
|
142484
|
+
});
|
|
142485
|
+
});
|
|
142486
|
+
}
|
|
142487
|
+
if (calculatedImageSettings) {
|
|
142488
|
+
ctx.globalAlpha = calculatedImageSettings.opacity;
|
|
142489
|
+
}
|
|
142490
|
+
if (haveImageToRender) {
|
|
142491
|
+
ctx.drawImage(image, calculatedImageSettings.x + margin, calculatedImageSettings.y + margin, calculatedImageSettings.w, calculatedImageSettings.h);
|
|
142492
|
+
}
|
|
142493
|
+
}
|
|
142494
|
+
});
|
|
142495
|
+
Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function() {
|
|
142496
|
+
setIsImageLoaded(false);
|
|
142497
|
+
}, [
|
|
142498
|
+
imgSrc
|
|
142499
|
+
]);
|
|
142500
|
+
var canvasStyle = _object_spread({
|
|
142501
|
+
height: size,
|
|
142502
|
+
width: size
|
|
142503
|
+
}, style);
|
|
142504
|
+
var img = null;
|
|
142505
|
+
if (imgSrc != null) {
|
|
142506
|
+
img = /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("img", {
|
|
142507
|
+
src: imgSrc,
|
|
142508
|
+
key: imgSrc,
|
|
142509
|
+
style: {
|
|
142510
|
+
display: "none"
|
|
142511
|
+
},
|
|
142512
|
+
onLoad: function() {
|
|
142513
|
+
setIsImageLoaded(true);
|
|
142514
|
+
},
|
|
142515
|
+
ref: _image
|
|
141690
142516
|
});
|
|
141691
|
-
}
|
|
141692
|
-
if (haveImageToRender) {
|
|
141693
|
-
ctx.drawImage(image, calculatedImageSettings.x + margin, calculatedImageSettings.y + margin, calculatedImageSettings.w, calculatedImageSettings.h);
|
|
141694
|
-
}
|
|
141695
142517
|
}
|
|
141696
|
-
|
|
141697
|
-
|
|
141698
|
-
|
|
141699
|
-
|
|
141700
|
-
|
|
141701
|
-
|
|
141702
|
-
|
|
141703
|
-
|
|
141704
|
-
|
|
141705
|
-
|
|
141706
|
-
|
|
141707
|
-
|
|
141708
|
-
|
|
141709
|
-
|
|
141710
|
-
|
|
141711
|
-
|
|
141712
|
-
|
|
141713
|
-
|
|
141714
|
-
|
|
141715
|
-
|
|
141716
|
-
|
|
141717
|
-
|
|
141718
|
-
|
|
141719
|
-
|
|
141720
|
-
|
|
141721
|
-
|
|
141722
|
-
value,
|
|
141723
|
-
size = DEFAULT_SIZE,
|
|
141724
|
-
level = DEFAULT_LEVEL,
|
|
141725
|
-
bgColor = DEFAULT_BGCOLOR,
|
|
141726
|
-
fgColor = DEFAULT_FGCOLOR,
|
|
141727
|
-
includeMargin = DEFAULT_INCLUDEMARGIN,
|
|
141728
|
-
imageSettings
|
|
141729
|
-
} = _a, otherProps = __objRest(_a, [
|
|
141730
|
-
"value",
|
|
141731
|
-
"size",
|
|
141732
|
-
"level",
|
|
141733
|
-
"bgColor",
|
|
141734
|
-
"fgColor",
|
|
141735
|
-
"includeMargin",
|
|
141736
|
-
"imageSettings"
|
|
141737
|
-
]);
|
|
141738
|
-
let cells = qrcodegen_default.QrCode.encodeText(value, ERROR_LEVEL_MAP[level]).getModules();
|
|
141739
|
-
const margin = includeMargin ? MARGIN_SIZE : 0;
|
|
141740
|
-
const numCells = cells.length + margin * 2;
|
|
141741
|
-
const calculatedImageSettings = getImageSettings(cells, size, includeMargin, imageSettings);
|
|
141742
|
-
let image = null;
|
|
141743
|
-
if (imageSettings != null && calculatedImageSettings != null) {
|
|
141744
|
-
if (calculatedImageSettings.excavation != null) {
|
|
141745
|
-
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
141746
|
-
}
|
|
141747
|
-
image = /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("image", {
|
|
141748
|
-
xlinkHref: imageSettings.src,
|
|
141749
|
-
height: calculatedImageSettings.h,
|
|
141750
|
-
width: calculatedImageSettings.w,
|
|
141751
|
-
x: calculatedImageSettings.x + margin,
|
|
141752
|
-
y: calculatedImageSettings.y + margin,
|
|
141753
|
-
preserveAspectRatio: "none"
|
|
142518
|
+
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("canvas", _object_spread({
|
|
142519
|
+
style: canvasStyle,
|
|
142520
|
+
height: size,
|
|
142521
|
+
width: size,
|
|
142522
|
+
ref: setCanvasRef,
|
|
142523
|
+
role: "img"
|
|
142524
|
+
}, otherProps)), img);
|
|
142525
|
+
});
|
|
142526
|
+
QRCodeCanvas.displayName = "QRCodeCanvas";
|
|
142527
|
+
var QRCodeSVG = react__WEBPACK_IMPORTED_MODULE_0___default.a.forwardRef(function QRCodeSVG2(props, forwardedRef) {
|
|
142528
|
+
var value = props.value, _props_size = props.size, size = _props_size === void 0 ? DEFAULT_SIZE : _props_size, _props_level = props.level, level = _props_level === void 0 ? DEFAULT_LEVEL : _props_level, _props_bgColor = props.bgColor, bgColor = _props_bgColor === void 0 ? DEFAULT_BGCOLOR : _props_bgColor, _props_fgColor = props.fgColor, fgColor = _props_fgColor === void 0 ? DEFAULT_FGCOLOR : _props_fgColor, _props_includeMargin = props.includeMargin, includeMargin = _props_includeMargin === void 0 ? DEFAULT_INCLUDEMARGIN : _props_includeMargin, _props_minVersion = props.minVersion, minVersion = _props_minVersion === void 0 ? DEFAULT_MINVERSION : _props_minVersion, title = props.title, marginSize = props.marginSize, imageSettings = props.imageSettings, otherProps = _object_without_properties(props, [
|
|
142529
|
+
"value",
|
|
142530
|
+
"size",
|
|
142531
|
+
"level",
|
|
142532
|
+
"bgColor",
|
|
142533
|
+
"fgColor",
|
|
142534
|
+
"includeMargin",
|
|
142535
|
+
"minVersion",
|
|
142536
|
+
"title",
|
|
142537
|
+
"marginSize",
|
|
142538
|
+
"imageSettings"
|
|
142539
|
+
]);
|
|
142540
|
+
var qrcode = makeQRCode({
|
|
142541
|
+
value: value,
|
|
142542
|
+
level: level,
|
|
142543
|
+
minVersion: minVersion
|
|
141754
142544
|
});
|
|
141755
|
-
|
|
141756
|
-
|
|
141757
|
-
|
|
141758
|
-
|
|
141759
|
-
|
|
141760
|
-
|
|
141761
|
-
|
|
141762
|
-
|
|
141763
|
-
|
|
141764
|
-
|
|
141765
|
-
|
|
141766
|
-
|
|
141767
|
-
|
|
141768
|
-
|
|
141769
|
-
|
|
141770
|
-
|
|
141771
|
-
|
|
141772
|
-
|
|
141773
|
-
|
|
141774
|
-
|
|
141775
|
-
|
|
141776
|
-
|
|
141777
|
-
|
|
142545
|
+
var cells = qrcode.getModules();
|
|
142546
|
+
var margin = getMarginSize(includeMargin, marginSize);
|
|
142547
|
+
var numCells = cells.length + margin * 2;
|
|
142548
|
+
var calculatedImageSettings = getImageSettings(cells, size, margin, imageSettings);
|
|
142549
|
+
var image = null;
|
|
142550
|
+
if (imageSettings != null && calculatedImageSettings != null) {
|
|
142551
|
+
if (calculatedImageSettings.excavation != null) {
|
|
142552
|
+
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
142553
|
+
}
|
|
142554
|
+
image = /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("image", {
|
|
142555
|
+
xlinkHref: imageSettings.src,
|
|
142556
|
+
height: calculatedImageSettings.h,
|
|
142557
|
+
width: calculatedImageSettings.w,
|
|
142558
|
+
x: calculatedImageSettings.x + margin,
|
|
142559
|
+
y: calculatedImageSettings.y + margin,
|
|
142560
|
+
preserveAspectRatio: "none",
|
|
142561
|
+
opacity: calculatedImageSettings.opacity
|
|
142562
|
+
});
|
|
142563
|
+
}
|
|
142564
|
+
var fgPath = generatePath(cells, margin);
|
|
142565
|
+
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("svg", _object_spread({
|
|
142566
|
+
height: size,
|
|
142567
|
+
width: size,
|
|
142568
|
+
viewBox: "0 0 ".concat(numCells, " ").concat(numCells),
|
|
142569
|
+
ref: forwardedRef,
|
|
142570
|
+
role: "img"
|
|
142571
|
+
}, otherProps), !!title && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("title", null, title), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("path", {
|
|
142572
|
+
fill: bgColor,
|
|
142573
|
+
d: "M0,0 h".concat(numCells, "v").concat(numCells, "H0z"),
|
|
142574
|
+
shapeRendering: "crispEdges"
|
|
142575
|
+
}), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("path", {
|
|
142576
|
+
fill: fgColor,
|
|
142577
|
+
d: fgPath,
|
|
142578
|
+
shapeRendering: "crispEdges"
|
|
142579
|
+
}), image);
|
|
142580
|
+
});
|
|
142581
|
+
QRCodeSVG.displayName = "QRCodeSVG";
|
|
141778
142582
|
|
|
141779
142583
|
|
|
141780
142584
|
|