@digipair/skill-qrcode 0.134.0 → 0.135.2
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/dist/index.esm.js +71 -64
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -13072,10 +13072,10 @@ regex.testAlphanumeric = function testAlphanumeric(str) {
|
|
|
13072
13072
|
|
|
13073
13073
|
var formatInfo = {};
|
|
13074
13074
|
|
|
13075
|
-
var Utils$
|
|
13075
|
+
var Utils$2 = utils$1;
|
|
13076
13076
|
var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
|
|
13077
13077
|
var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
|
|
13078
|
-
var G15_BCH = Utils$
|
|
13078
|
+
var G15_BCH = Utils$2.getBCHDigit(G15);
|
|
13079
13079
|
/**
|
|
13080
13080
|
* Returns format information with relative error correction bits
|
|
13081
13081
|
*
|
|
@@ -13088,8 +13088,8 @@ var G15_BCH = Utils$3.getBCHDigit(G15);
|
|
|
13088
13088
|
*/ formatInfo.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
13089
13089
|
var data = errorCorrectionLevel.bit << 3 | mask;
|
|
13090
13090
|
var d = data << 10;
|
|
13091
|
-
while(Utils$
|
|
13092
|
-
d ^= G15 << Utils$
|
|
13091
|
+
while(Utils$2.getBCHDigit(d) - G15_BCH >= 0){
|
|
13092
|
+
d ^= G15 << Utils$2.getBCHDigit(d) - G15_BCH;
|
|
13093
13093
|
}
|
|
13094
13094
|
// xor final data with mask pattern in order to ensure that
|
|
13095
13095
|
// no combination of Error Correction Level and data mask pattern
|
|
@@ -13248,7 +13248,7 @@ ByteData.prototype.write = function(bitBuffer) {
|
|
|
13248
13248
|
var byteData = ByteData;
|
|
13249
13249
|
|
|
13250
13250
|
var Mode$1 = mode;
|
|
13251
|
-
var Utils$
|
|
13251
|
+
var Utils$1 = utils$1;
|
|
13252
13252
|
function KanjiData(data) {
|
|
13253
13253
|
this.mode = Mode$1.KANJI;
|
|
13254
13254
|
this.data = data;
|
|
@@ -13268,7 +13268,7 @@ KanjiData.prototype.write = function(bitBuffer) {
|
|
|
13268
13268
|
// These byte values are shifted from the JIS X 0208 values.
|
|
13269
13269
|
// JIS X 0208 gives details of the shift coded representation.
|
|
13270
13270
|
for(i = 0; i < this.data.length; i++){
|
|
13271
|
-
var value = Utils$
|
|
13271
|
+
var value = Utils$1.toSJIS(this.data[i]);
|
|
13272
13272
|
// For characters with Shift JIS values from 0x8140 to 0x9FFC:
|
|
13273
13273
|
if (value >= 0x8140 && value <= 0x9FFC) {
|
|
13274
13274
|
// Subtract 0x8140 from Shift JIS value
|
|
@@ -13744,7 +13744,7 @@ var dijkstraExports = dijkstra.exports;
|
|
|
13744
13744
|
};
|
|
13745
13745
|
} (segments));
|
|
13746
13746
|
|
|
13747
|
-
var Utils
|
|
13747
|
+
var Utils = utils$1;
|
|
13748
13748
|
var ECLevel = errorCorrectionLevel;
|
|
13749
13749
|
var BitBuffer = bitBuffer;
|
|
13750
13750
|
var BitMatrix = bitMatrix;
|
|
@@ -13953,7 +13953,7 @@ var Segments = segments;
|
|
|
13953
13953
|
data.write(buffer);
|
|
13954
13954
|
});
|
|
13955
13955
|
// Calculate required number of bits
|
|
13956
|
-
var totalCodewords = Utils
|
|
13956
|
+
var totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
13957
13957
|
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
13958
13958
|
var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
13959
13959
|
// Add a terminator.
|
|
@@ -13991,7 +13991,7 @@ var Segments = segments;
|
|
|
13991
13991
|
* @return {Uint8Array} Buffer containing encoded codewords
|
|
13992
13992
|
*/ function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
13993
13993
|
// Total codewords for this QR code version (Data + Error correction)
|
|
13994
|
-
var totalCodewords = Utils
|
|
13994
|
+
var totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
13995
13995
|
// Total number of error correction codewords
|
|
13996
13996
|
var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
13997
13997
|
// Total number of data codewords
|
|
@@ -14084,7 +14084,7 @@ var Segments = segments;
|
|
|
14084
14084
|
}
|
|
14085
14085
|
var dataBits = createData(version, errorCorrectionLevel, segments);
|
|
14086
14086
|
// Allocate matrix buffer
|
|
14087
|
-
var moduleCount = Utils
|
|
14087
|
+
var moduleCount = Utils.getSymbolSize(version);
|
|
14088
14088
|
var modules = new BitMatrix(moduleCount);
|
|
14089
14089
|
// Add function modules
|
|
14090
14090
|
setupFinderPattern(modules, version);
|
|
@@ -14137,7 +14137,7 @@ var Segments = segments;
|
|
|
14137
14137
|
version = Version.from(options.version);
|
|
14138
14138
|
mask = MaskPattern.from(options.maskPattern);
|
|
14139
14139
|
if (options.toSJISFunc) {
|
|
14140
|
-
Utils
|
|
14140
|
+
Utils.setToSJISFunction(options.toSJISFunc);
|
|
14141
14141
|
}
|
|
14142
14142
|
}
|
|
14143
14143
|
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
@@ -16592,61 +16592,68 @@ var svg = {};
|
|
|
16592
16592
|
|
|
16593
16593
|
var svgTag = {};
|
|
16594
16594
|
|
|
16595
|
-
var
|
|
16596
|
-
|
|
16597
|
-
|
|
16598
|
-
|
|
16599
|
-
|
|
16600
|
-
|
|
16601
|
-
function
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
}
|
|
16606
|
-
function
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
|
|
16610
|
-
|
|
16611
|
-
|
|
16612
|
-
|
|
16613
|
-
|
|
16614
|
-
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16629
|
-
|
|
16630
|
-
|
|
16595
|
+
var hasRequiredSvgTag;
|
|
16596
|
+
|
|
16597
|
+
function requireSvgTag () {
|
|
16598
|
+
if (hasRequiredSvgTag) return svgTag;
|
|
16599
|
+
hasRequiredSvgTag = 1;
|
|
16600
|
+
var Utils = utils;
|
|
16601
|
+
function getColorAttrib(color, attrib) {
|
|
16602
|
+
var alpha = color.a / 255;
|
|
16603
|
+
var str = attrib + '="' + color.hex + '"';
|
|
16604
|
+
return alpha < 1 ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str;
|
|
16605
|
+
}
|
|
16606
|
+
function svgCmd(cmd, x, y) {
|
|
16607
|
+
var str = cmd + x;
|
|
16608
|
+
if (typeof y !== 'undefined') str += ' ' + y;
|
|
16609
|
+
return str;
|
|
16610
|
+
}
|
|
16611
|
+
function qrToPath(data, size, margin) {
|
|
16612
|
+
var path = '';
|
|
16613
|
+
var moveBy = 0;
|
|
16614
|
+
var newRow = false;
|
|
16615
|
+
var lineLength = 0;
|
|
16616
|
+
for(var i = 0; i < data.length; i++){
|
|
16617
|
+
var col = Math.floor(i % size);
|
|
16618
|
+
var row = Math.floor(i / size);
|
|
16619
|
+
if (!col && !newRow) newRow = true;
|
|
16620
|
+
if (data[i]) {
|
|
16621
|
+
lineLength++;
|
|
16622
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
16623
|
+
path += newRow ? svgCmd('M', col + margin, 0.5 + row + margin) : svgCmd('m', moveBy, 0);
|
|
16624
|
+
moveBy = 0;
|
|
16625
|
+
newRow = false;
|
|
16626
|
+
}
|
|
16627
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
16628
|
+
path += svgCmd('h', lineLength);
|
|
16629
|
+
lineLength = 0;
|
|
16630
|
+
}
|
|
16631
|
+
} else {
|
|
16632
|
+
moveBy++;
|
|
16633
|
+
}
|
|
16634
|
+
}
|
|
16635
|
+
return path;
|
|
16636
|
+
}
|
|
16637
|
+
svgTag.render = function render(qrData, options, cb) {
|
|
16638
|
+
var opts = Utils.getOptions(options);
|
|
16639
|
+
var size = qrData.modules.size;
|
|
16640
|
+
var data = qrData.modules.data;
|
|
16641
|
+
var qrcodesize = size + opts.margin * 2;
|
|
16642
|
+
var bg = !opts.color.light.a ? '' : '<path ' + getColorAttrib(opts.color.light, 'fill') + ' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>';
|
|
16643
|
+
var path = '<path ' + getColorAttrib(opts.color.dark, 'stroke') + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
16644
|
+
var viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"';
|
|
16645
|
+
var width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
16646
|
+
var svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n';
|
|
16647
|
+
if (typeof cb === 'function') {
|
|
16648
|
+
cb(null, svgTag);
|
|
16649
|
+
}
|
|
16650
|
+
return svgTag;
|
|
16651
|
+
};
|
|
16652
|
+
return svgTag;
|
|
16631
16653
|
}
|
|
16632
|
-
svgTag.render = function render(qrData, options, cb) {
|
|
16633
|
-
var opts = Utils.getOptions(options);
|
|
16634
|
-
var size = qrData.modules.size;
|
|
16635
|
-
var data = qrData.modules.data;
|
|
16636
|
-
var qrcodesize = size + opts.margin * 2;
|
|
16637
|
-
var bg = !opts.color.light.a ? '' : '<path ' + getColorAttrib(opts.color.light, 'fill') + ' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>';
|
|
16638
|
-
var path = '<path ' + getColorAttrib(opts.color.dark, 'stroke') + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
16639
|
-
var viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"';
|
|
16640
|
-
var width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
16641
|
-
var svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n';
|
|
16642
|
-
if (typeof cb === 'function') {
|
|
16643
|
-
cb(null, svgTag);
|
|
16644
|
-
}
|
|
16645
|
-
return svgTag;
|
|
16646
|
-
};
|
|
16647
16654
|
|
|
16648
16655
|
(function (exports) {
|
|
16649
|
-
var svgTagRenderer =
|
|
16656
|
+
var svgTagRenderer = requireSvgTag();
|
|
16650
16657
|
exports.render = svgTagRenderer.render;
|
|
16651
16658
|
exports.renderToFile = function renderToFile(path, qrData, options, cb) {
|
|
16652
16659
|
if (typeof cb === 'undefined') {
|
|
@@ -16729,7 +16736,7 @@ function requireBrowser () {
|
|
|
16729
16736
|
var canPromise = canPromise$1;
|
|
16730
16737
|
var QRCode = qrcode;
|
|
16731
16738
|
var CanvasRenderer = requireCanvas();
|
|
16732
|
-
var SvgRenderer =
|
|
16739
|
+
var SvgRenderer = requireSvgTag();
|
|
16733
16740
|
function renderCanvas(renderFunc, canvas, text, opts, cb) {
|
|
16734
16741
|
var args = [].slice.call(arguments, 1);
|
|
16735
16742
|
var argsNum = args.length;
|