icve-sso-vue3 0.0.17 → 0.0.19
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/icve-sso-vue3.common.js +3050 -684
- package/dist/icve-sso-vue3.common.js.map +1 -1
- package/dist/icve-sso-vue3.css +1 -1
- package/dist/icve-sso-vue3.umd.js +3050 -684
- package/dist/icve-sso-vue3.umd.js.map +1 -1
- package/dist/icve-sso-vue3.umd.min.js +3 -3
- package/dist/icve-sso-vue3.umd.min.js.map +1 -1
- package/package.json +2 -3
|
@@ -134,6 +134,682 @@ $({ target: 'Number', stat: true }, {
|
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
|
|
137
|
+
/***/ },
|
|
138
|
+
|
|
139
|
+
/***/ 157
|
|
140
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
141
|
+
|
|
142
|
+
const Utils = __webpack_require__(6886)
|
|
143
|
+
const ECLevel = __webpack_require__(9953)
|
|
144
|
+
const BitBuffer = __webpack_require__(9899)
|
|
145
|
+
const BitMatrix = __webpack_require__(8820)
|
|
146
|
+
const AlignmentPattern = __webpack_require__(6421)
|
|
147
|
+
const FinderPattern = __webpack_require__(7756)
|
|
148
|
+
const MaskPattern = __webpack_require__(1332)
|
|
149
|
+
const ECCode = __webpack_require__(7518)
|
|
150
|
+
const ReedSolomonEncoder = __webpack_require__(4764)
|
|
151
|
+
const Version = __webpack_require__(1427)
|
|
152
|
+
const FormatInfo = __webpack_require__(4565)
|
|
153
|
+
const Mode = __webpack_require__(208)
|
|
154
|
+
const Segments = __webpack_require__(9801)
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* QRCode for JavaScript
|
|
158
|
+
*
|
|
159
|
+
* modified by Ryan Day for nodejs support
|
|
160
|
+
* Copyright (c) 2011 Ryan Day
|
|
161
|
+
*
|
|
162
|
+
* Licensed under the MIT license:
|
|
163
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
164
|
+
*
|
|
165
|
+
//---------------------------------------------------------------------
|
|
166
|
+
// QRCode for JavaScript
|
|
167
|
+
//
|
|
168
|
+
// Copyright (c) 2009 Kazuhiko Arase
|
|
169
|
+
//
|
|
170
|
+
// URL: http://www.d-project.com/
|
|
171
|
+
//
|
|
172
|
+
// Licensed under the MIT license:
|
|
173
|
+
// http://www.opensource.org/licenses/mit-license.php
|
|
174
|
+
//
|
|
175
|
+
// The word "QR Code" is registered trademark of
|
|
176
|
+
// DENSO WAVE INCORPORATED
|
|
177
|
+
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
178
|
+
//
|
|
179
|
+
//---------------------------------------------------------------------
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Add finder patterns bits to matrix
|
|
184
|
+
*
|
|
185
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
186
|
+
* @param {Number} version QR Code version
|
|
187
|
+
*/
|
|
188
|
+
function setupFinderPattern (matrix, version) {
|
|
189
|
+
const size = matrix.size
|
|
190
|
+
const pos = FinderPattern.getPositions(version)
|
|
191
|
+
|
|
192
|
+
for (let i = 0; i < pos.length; i++) {
|
|
193
|
+
const row = pos[i][0]
|
|
194
|
+
const col = pos[i][1]
|
|
195
|
+
|
|
196
|
+
for (let r = -1; r <= 7; r++) {
|
|
197
|
+
if (row + r <= -1 || size <= row + r) continue
|
|
198
|
+
|
|
199
|
+
for (let c = -1; c <= 7; c++) {
|
|
200
|
+
if (col + c <= -1 || size <= col + c) continue
|
|
201
|
+
|
|
202
|
+
if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
|
|
203
|
+
(c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
|
|
204
|
+
(r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
|
|
205
|
+
matrix.set(row + r, col + c, true, true)
|
|
206
|
+
} else {
|
|
207
|
+
matrix.set(row + r, col + c, false, true)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Add timing pattern bits to matrix
|
|
216
|
+
*
|
|
217
|
+
* Note: this function must be called before {@link setupAlignmentPattern}
|
|
218
|
+
*
|
|
219
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
220
|
+
*/
|
|
221
|
+
function setupTimingPattern (matrix) {
|
|
222
|
+
const size = matrix.size
|
|
223
|
+
|
|
224
|
+
for (let r = 8; r < size - 8; r++) {
|
|
225
|
+
const value = r % 2 === 0
|
|
226
|
+
matrix.set(r, 6, value, true)
|
|
227
|
+
matrix.set(6, r, value, true)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Add alignment patterns bits to matrix
|
|
233
|
+
*
|
|
234
|
+
* Note: this function must be called after {@link setupTimingPattern}
|
|
235
|
+
*
|
|
236
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
237
|
+
* @param {Number} version QR Code version
|
|
238
|
+
*/
|
|
239
|
+
function setupAlignmentPattern (matrix, version) {
|
|
240
|
+
const pos = AlignmentPattern.getPositions(version)
|
|
241
|
+
|
|
242
|
+
for (let i = 0; i < pos.length; i++) {
|
|
243
|
+
const row = pos[i][0]
|
|
244
|
+
const col = pos[i][1]
|
|
245
|
+
|
|
246
|
+
for (let r = -2; r <= 2; r++) {
|
|
247
|
+
for (let c = -2; c <= 2; c++) {
|
|
248
|
+
if (r === -2 || r === 2 || c === -2 || c === 2 ||
|
|
249
|
+
(r === 0 && c === 0)) {
|
|
250
|
+
matrix.set(row + r, col + c, true, true)
|
|
251
|
+
} else {
|
|
252
|
+
matrix.set(row + r, col + c, false, true)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Add version info bits to matrix
|
|
261
|
+
*
|
|
262
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
263
|
+
* @param {Number} version QR Code version
|
|
264
|
+
*/
|
|
265
|
+
function setupVersionInfo (matrix, version) {
|
|
266
|
+
const size = matrix.size
|
|
267
|
+
const bits = Version.getEncodedBits(version)
|
|
268
|
+
let row, col, mod
|
|
269
|
+
|
|
270
|
+
for (let i = 0; i < 18; i++) {
|
|
271
|
+
row = Math.floor(i / 3)
|
|
272
|
+
col = i % 3 + size - 8 - 3
|
|
273
|
+
mod = ((bits >> i) & 1) === 1
|
|
274
|
+
|
|
275
|
+
matrix.set(row, col, mod, true)
|
|
276
|
+
matrix.set(col, row, mod, true)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Add format info bits to matrix
|
|
282
|
+
*
|
|
283
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
284
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
285
|
+
* @param {Number} maskPattern Mask pattern reference value
|
|
286
|
+
*/
|
|
287
|
+
function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
|
|
288
|
+
const size = matrix.size
|
|
289
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)
|
|
290
|
+
let i, mod
|
|
291
|
+
|
|
292
|
+
for (i = 0; i < 15; i++) {
|
|
293
|
+
mod = ((bits >> i) & 1) === 1
|
|
294
|
+
|
|
295
|
+
// vertical
|
|
296
|
+
if (i < 6) {
|
|
297
|
+
matrix.set(i, 8, mod, true)
|
|
298
|
+
} else if (i < 8) {
|
|
299
|
+
matrix.set(i + 1, 8, mod, true)
|
|
300
|
+
} else {
|
|
301
|
+
matrix.set(size - 15 + i, 8, mod, true)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// horizontal
|
|
305
|
+
if (i < 8) {
|
|
306
|
+
matrix.set(8, size - i - 1, mod, true)
|
|
307
|
+
} else if (i < 9) {
|
|
308
|
+
matrix.set(8, 15 - i - 1 + 1, mod, true)
|
|
309
|
+
} else {
|
|
310
|
+
matrix.set(8, 15 - i - 1, mod, true)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// fixed module
|
|
315
|
+
matrix.set(size - 8, 8, 1, true)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Add encoded data bits to matrix
|
|
320
|
+
*
|
|
321
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
322
|
+
* @param {Uint8Array} data Data codewords
|
|
323
|
+
*/
|
|
324
|
+
function setupData (matrix, data) {
|
|
325
|
+
const size = matrix.size
|
|
326
|
+
let inc = -1
|
|
327
|
+
let row = size - 1
|
|
328
|
+
let bitIndex = 7
|
|
329
|
+
let byteIndex = 0
|
|
330
|
+
|
|
331
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
332
|
+
if (col === 6) col--
|
|
333
|
+
|
|
334
|
+
while (true) {
|
|
335
|
+
for (let c = 0; c < 2; c++) {
|
|
336
|
+
if (!matrix.isReserved(row, col - c)) {
|
|
337
|
+
let dark = false
|
|
338
|
+
|
|
339
|
+
if (byteIndex < data.length) {
|
|
340
|
+
dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
matrix.set(row, col - c, dark)
|
|
344
|
+
bitIndex--
|
|
345
|
+
|
|
346
|
+
if (bitIndex === -1) {
|
|
347
|
+
byteIndex++
|
|
348
|
+
bitIndex = 7
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
row += inc
|
|
354
|
+
|
|
355
|
+
if (row < 0 || size <= row) {
|
|
356
|
+
row -= inc
|
|
357
|
+
inc = -inc
|
|
358
|
+
break
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Create encoded codewords from data input
|
|
366
|
+
*
|
|
367
|
+
* @param {Number} version QR Code version
|
|
368
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
369
|
+
* @param {ByteData} data Data input
|
|
370
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
371
|
+
*/
|
|
372
|
+
function createData (version, errorCorrectionLevel, segments) {
|
|
373
|
+
// Prepare data buffer
|
|
374
|
+
const buffer = new BitBuffer()
|
|
375
|
+
|
|
376
|
+
segments.forEach(function (data) {
|
|
377
|
+
// prefix data with mode indicator (4 bits)
|
|
378
|
+
buffer.put(data.mode.bit, 4)
|
|
379
|
+
|
|
380
|
+
// Prefix data with character count indicator.
|
|
381
|
+
// The character count indicator is a string of bits that represents the
|
|
382
|
+
// number of characters that are being encoded.
|
|
383
|
+
// The character count indicator must be placed after the mode indicator
|
|
384
|
+
// and must be a certain number of bits long, depending on the QR version
|
|
385
|
+
// and data mode
|
|
386
|
+
// @see {@link Mode.getCharCountIndicator}.
|
|
387
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))
|
|
388
|
+
|
|
389
|
+
// add binary data sequence to buffer
|
|
390
|
+
data.write(buffer)
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
// Calculate required number of bits
|
|
394
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version)
|
|
395
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
|
|
396
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
|
|
397
|
+
|
|
398
|
+
// Add a terminator.
|
|
399
|
+
// If the bit string is shorter than the total number of required bits,
|
|
400
|
+
// a terminator of up to four 0s must be added to the right side of the string.
|
|
401
|
+
// If the bit string is more than four bits shorter than the required number of bits,
|
|
402
|
+
// add four 0s to the end.
|
|
403
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
|
|
404
|
+
buffer.put(0, 4)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// If the bit string is fewer than four bits shorter, add only the number of 0s that
|
|
408
|
+
// are needed to reach the required number of bits.
|
|
409
|
+
|
|
410
|
+
// After adding the terminator, if the number of bits in the string is not a multiple of 8,
|
|
411
|
+
// pad the string on the right with 0s to make the string's length a multiple of 8.
|
|
412
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
413
|
+
buffer.putBit(0)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Add pad bytes if the string is still shorter than the total number of required bits.
|
|
417
|
+
// Extend the buffer to fill the data capacity of the symbol corresponding to
|
|
418
|
+
// the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
|
|
419
|
+
// and 00010001 (0x11) alternately.
|
|
420
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8
|
|
421
|
+
for (let i = 0; i < remainingByte; i++) {
|
|
422
|
+
buffer.put(i % 2 ? 0x11 : 0xEC, 8)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return createCodewords(buffer, version, errorCorrectionLevel)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Encode input data with Reed-Solomon and return codewords with
|
|
430
|
+
* relative error correction bits
|
|
431
|
+
*
|
|
432
|
+
* @param {BitBuffer} bitBuffer Data to encode
|
|
433
|
+
* @param {Number} version QR Code version
|
|
434
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
435
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
436
|
+
*/
|
|
437
|
+
function createCodewords (bitBuffer, version, errorCorrectionLevel) {
|
|
438
|
+
// Total codewords for this QR code version (Data + Error correction)
|
|
439
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version)
|
|
440
|
+
|
|
441
|
+
// Total number of error correction codewords
|
|
442
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
|
|
443
|
+
|
|
444
|
+
// Total number of data codewords
|
|
445
|
+
const dataTotalCodewords = totalCodewords - ecTotalCodewords
|
|
446
|
+
|
|
447
|
+
// Total number of blocks
|
|
448
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)
|
|
449
|
+
|
|
450
|
+
// Calculate how many blocks each group should contain
|
|
451
|
+
const blocksInGroup2 = totalCodewords % ecTotalBlocks
|
|
452
|
+
const blocksInGroup1 = ecTotalBlocks - blocksInGroup2
|
|
453
|
+
|
|
454
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)
|
|
455
|
+
|
|
456
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)
|
|
457
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1
|
|
458
|
+
|
|
459
|
+
// Number of EC codewords is the same for both groups
|
|
460
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1
|
|
461
|
+
|
|
462
|
+
// Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
|
|
463
|
+
const rs = new ReedSolomonEncoder(ecCount)
|
|
464
|
+
|
|
465
|
+
let offset = 0
|
|
466
|
+
const dcData = new Array(ecTotalBlocks)
|
|
467
|
+
const ecData = new Array(ecTotalBlocks)
|
|
468
|
+
let maxDataSize = 0
|
|
469
|
+
const buffer = new Uint8Array(bitBuffer.buffer)
|
|
470
|
+
|
|
471
|
+
// Divide the buffer into the required number of blocks
|
|
472
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
473
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2
|
|
474
|
+
|
|
475
|
+
// extract a block of data from buffer
|
|
476
|
+
dcData[b] = buffer.slice(offset, offset + dataSize)
|
|
477
|
+
|
|
478
|
+
// Calculate EC codewords for this data block
|
|
479
|
+
ecData[b] = rs.encode(dcData[b])
|
|
480
|
+
|
|
481
|
+
offset += dataSize
|
|
482
|
+
maxDataSize = Math.max(maxDataSize, dataSize)
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Create final data
|
|
486
|
+
// Interleave the data and error correction codewords from each block
|
|
487
|
+
const data = new Uint8Array(totalCodewords)
|
|
488
|
+
let index = 0
|
|
489
|
+
let i, r
|
|
490
|
+
|
|
491
|
+
// Add data codewords
|
|
492
|
+
for (i = 0; i < maxDataSize; i++) {
|
|
493
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
494
|
+
if (i < dcData[r].length) {
|
|
495
|
+
data[index++] = dcData[r][i]
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Apped EC codewords
|
|
501
|
+
for (i = 0; i < ecCount; i++) {
|
|
502
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
503
|
+
data[index++] = ecData[r][i]
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return data
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Build QR Code symbol
|
|
512
|
+
*
|
|
513
|
+
* @param {String} data Input string
|
|
514
|
+
* @param {Number} version QR Code version
|
|
515
|
+
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
|
|
516
|
+
* @param {MaskPattern} maskPattern Mask pattern
|
|
517
|
+
* @return {Object} Object containing symbol data
|
|
518
|
+
*/
|
|
519
|
+
function createSymbol (data, version, errorCorrectionLevel, maskPattern) {
|
|
520
|
+
let segments
|
|
521
|
+
|
|
522
|
+
if (Array.isArray(data)) {
|
|
523
|
+
segments = Segments.fromArray(data)
|
|
524
|
+
} else if (typeof data === 'string') {
|
|
525
|
+
let estimatedVersion = version
|
|
526
|
+
|
|
527
|
+
if (!estimatedVersion) {
|
|
528
|
+
const rawSegments = Segments.rawSplit(data)
|
|
529
|
+
|
|
530
|
+
// Estimate best version that can contain raw splitted segments
|
|
531
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Build optimized segments
|
|
535
|
+
// If estimated version is undefined, try with the highest version
|
|
536
|
+
segments = Segments.fromString(data, estimatedVersion || 40)
|
|
537
|
+
} else {
|
|
538
|
+
throw new Error('Invalid data')
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// Get the min version that can contain data
|
|
542
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel)
|
|
543
|
+
|
|
544
|
+
// If no version is found, data cannot be stored
|
|
545
|
+
if (!bestVersion) {
|
|
546
|
+
throw new Error('The amount of data is too big to be stored in a QR Code')
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// If not specified, use min version as default
|
|
550
|
+
if (!version) {
|
|
551
|
+
version = bestVersion
|
|
552
|
+
|
|
553
|
+
// Check if the specified version can contain the data
|
|
554
|
+
} else if (version < bestVersion) {
|
|
555
|
+
throw new Error('\n' +
|
|
556
|
+
'The chosen QR Code version cannot contain this amount of data.\n' +
|
|
557
|
+
'Minimum version required to store current data is: ' + bestVersion + '.\n'
|
|
558
|
+
)
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const dataBits = createData(version, errorCorrectionLevel, segments)
|
|
562
|
+
|
|
563
|
+
// Allocate matrix buffer
|
|
564
|
+
const moduleCount = Utils.getSymbolSize(version)
|
|
565
|
+
const modules = new BitMatrix(moduleCount)
|
|
566
|
+
|
|
567
|
+
// Add function modules
|
|
568
|
+
setupFinderPattern(modules, version)
|
|
569
|
+
setupTimingPattern(modules)
|
|
570
|
+
setupAlignmentPattern(modules, version)
|
|
571
|
+
|
|
572
|
+
// Add temporary dummy bits for format info just to set them as reserved.
|
|
573
|
+
// This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
|
|
574
|
+
// since the masking operation must be performed only on the encoding region.
|
|
575
|
+
// These blocks will be replaced with correct values later in code.
|
|
576
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0)
|
|
577
|
+
|
|
578
|
+
if (version >= 7) {
|
|
579
|
+
setupVersionInfo(modules, version)
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// Add data codewords
|
|
583
|
+
setupData(modules, dataBits)
|
|
584
|
+
|
|
585
|
+
if (isNaN(maskPattern)) {
|
|
586
|
+
// Find best mask pattern
|
|
587
|
+
maskPattern = MaskPattern.getBestMask(modules,
|
|
588
|
+
setupFormatInfo.bind(null, modules, errorCorrectionLevel))
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// Apply mask pattern
|
|
592
|
+
MaskPattern.applyMask(maskPattern, modules)
|
|
593
|
+
|
|
594
|
+
// Replace format info bits with correct values
|
|
595
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern)
|
|
596
|
+
|
|
597
|
+
return {
|
|
598
|
+
modules: modules,
|
|
599
|
+
version: version,
|
|
600
|
+
errorCorrectionLevel: errorCorrectionLevel,
|
|
601
|
+
maskPattern: maskPattern,
|
|
602
|
+
segments: segments
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* QR Code
|
|
608
|
+
*
|
|
609
|
+
* @param {String | Array} data Input data
|
|
610
|
+
* @param {Object} options Optional configurations
|
|
611
|
+
* @param {Number} options.version QR Code version
|
|
612
|
+
* @param {String} options.errorCorrectionLevel Error correction level
|
|
613
|
+
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
|
|
614
|
+
*/
|
|
615
|
+
exports.create = function create (data, options) {
|
|
616
|
+
if (typeof data === 'undefined' || data === '') {
|
|
617
|
+
throw new Error('No input text')
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
let errorCorrectionLevel = ECLevel.M
|
|
621
|
+
let version
|
|
622
|
+
let mask
|
|
623
|
+
|
|
624
|
+
if (typeof options !== 'undefined') {
|
|
625
|
+
// Use higher error correction level as default
|
|
626
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)
|
|
627
|
+
version = Version.from(options.version)
|
|
628
|
+
mask = MaskPattern.from(options.maskPattern)
|
|
629
|
+
|
|
630
|
+
if (options.toSJISFunc) {
|
|
631
|
+
Utils.setToSJISFunction(options.toSJISFunc)
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return createSymbol(data, version, errorCorrectionLevel, mask)
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
/***/ },
|
|
640
|
+
|
|
641
|
+
/***/ 208
|
|
642
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
643
|
+
|
|
644
|
+
const VersionCheck = __webpack_require__(1878)
|
|
645
|
+
const Regex = __webpack_require__(7044)
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Numeric mode encodes data from the decimal digit set (0 - 9)
|
|
649
|
+
* (byte values 30HEX to 39HEX).
|
|
650
|
+
* Normally, 3 data characters are represented by 10 bits.
|
|
651
|
+
*
|
|
652
|
+
* @type {Object}
|
|
653
|
+
*/
|
|
654
|
+
exports.NUMERIC = {
|
|
655
|
+
id: 'Numeric',
|
|
656
|
+
bit: 1 << 0,
|
|
657
|
+
ccBits: [10, 12, 14]
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Alphanumeric mode encodes data from a set of 45 characters,
|
|
662
|
+
* i.e. 10 numeric digits (0 - 9),
|
|
663
|
+
* 26 alphabetic characters (A - Z),
|
|
664
|
+
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
|
|
665
|
+
* Normally, two input characters are represented by 11 bits.
|
|
666
|
+
*
|
|
667
|
+
* @type {Object}
|
|
668
|
+
*/
|
|
669
|
+
exports.ALPHANUMERIC = {
|
|
670
|
+
id: 'Alphanumeric',
|
|
671
|
+
bit: 1 << 1,
|
|
672
|
+
ccBits: [9, 11, 13]
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* In byte mode, data is encoded at 8 bits per character.
|
|
677
|
+
*
|
|
678
|
+
* @type {Object}
|
|
679
|
+
*/
|
|
680
|
+
exports.BYTE = {
|
|
681
|
+
id: 'Byte',
|
|
682
|
+
bit: 1 << 2,
|
|
683
|
+
ccBits: [8, 16, 16]
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* The Kanji mode efficiently encodes Kanji characters in accordance with
|
|
688
|
+
* the Shift JIS system based on JIS X 0208.
|
|
689
|
+
* The Shift JIS values are shifted from the JIS X 0208 values.
|
|
690
|
+
* JIS X 0208 gives details of the shift coded representation.
|
|
691
|
+
* Each two-byte character value is compacted to a 13-bit binary codeword.
|
|
692
|
+
*
|
|
693
|
+
* @type {Object}
|
|
694
|
+
*/
|
|
695
|
+
exports.KANJI = {
|
|
696
|
+
id: 'Kanji',
|
|
697
|
+
bit: 1 << 3,
|
|
698
|
+
ccBits: [8, 10, 12]
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Mixed mode will contain a sequences of data in a combination of any of
|
|
703
|
+
* the modes described above
|
|
704
|
+
*
|
|
705
|
+
* @type {Object}
|
|
706
|
+
*/
|
|
707
|
+
exports.MIXED = {
|
|
708
|
+
bit: -1
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Returns the number of bits needed to store the data length
|
|
713
|
+
* according to QR Code specifications.
|
|
714
|
+
*
|
|
715
|
+
* @param {Mode} mode Data mode
|
|
716
|
+
* @param {Number} version QR Code version
|
|
717
|
+
* @return {Number} Number of bits
|
|
718
|
+
*/
|
|
719
|
+
exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
|
|
720
|
+
if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
|
|
721
|
+
|
|
722
|
+
if (!VersionCheck.isValid(version)) {
|
|
723
|
+
throw new Error('Invalid version: ' + version)
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (version >= 1 && version < 10) return mode.ccBits[0]
|
|
727
|
+
else if (version < 27) return mode.ccBits[1]
|
|
728
|
+
return mode.ccBits[2]
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Returns the most efficient mode to store the specified data
|
|
733
|
+
*
|
|
734
|
+
* @param {String} dataStr Input data string
|
|
735
|
+
* @return {Mode} Best mode
|
|
736
|
+
*/
|
|
737
|
+
exports.getBestModeForData = function getBestModeForData (dataStr) {
|
|
738
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC
|
|
739
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
|
|
740
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI
|
|
741
|
+
else return exports.BYTE
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Return mode name as string
|
|
746
|
+
*
|
|
747
|
+
* @param {Mode} mode Mode object
|
|
748
|
+
* @returns {String} Mode name
|
|
749
|
+
*/
|
|
750
|
+
exports.toString = function toString (mode) {
|
|
751
|
+
if (mode && mode.id) return mode.id
|
|
752
|
+
throw new Error('Invalid mode')
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Check if input param is a valid mode object
|
|
757
|
+
*
|
|
758
|
+
* @param {Mode} mode Mode object
|
|
759
|
+
* @returns {Boolean} True if valid mode, false otherwise
|
|
760
|
+
*/
|
|
761
|
+
exports.isValid = function isValid (mode) {
|
|
762
|
+
return mode && mode.bit && mode.ccBits
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Get mode object from its name
|
|
767
|
+
*
|
|
768
|
+
* @param {String} string Mode name
|
|
769
|
+
* @returns {Mode} Mode object
|
|
770
|
+
*/
|
|
771
|
+
function fromString (string) {
|
|
772
|
+
if (typeof string !== 'string') {
|
|
773
|
+
throw new Error('Param is not a string')
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const lcStr = string.toLowerCase()
|
|
777
|
+
|
|
778
|
+
switch (lcStr) {
|
|
779
|
+
case 'numeric':
|
|
780
|
+
return exports.NUMERIC
|
|
781
|
+
case 'alphanumeric':
|
|
782
|
+
return exports.ALPHANUMERIC
|
|
783
|
+
case 'kanji':
|
|
784
|
+
return exports.KANJI
|
|
785
|
+
case 'byte':
|
|
786
|
+
return exports.BYTE
|
|
787
|
+
default:
|
|
788
|
+
throw new Error('Unknown mode: ' + string)
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Returns mode from a value.
|
|
794
|
+
* If value is not a valid mode, returns defaultValue
|
|
795
|
+
*
|
|
796
|
+
* @param {Mode|String} value Encoding mode
|
|
797
|
+
* @param {Mode} defaultValue Fallback value
|
|
798
|
+
* @return {Mode} Encoding mode
|
|
799
|
+
*/
|
|
800
|
+
exports.from = function from (value, defaultValue) {
|
|
801
|
+
if (exports.isValid(value)) {
|
|
802
|
+
return value
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
try {
|
|
806
|
+
return fromString(value)
|
|
807
|
+
} catch (e) {
|
|
808
|
+
return defaultValue
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
|
|
137
813
|
/***/ },
|
|
138
814
|
|
|
139
815
|
/***/ 235
|
|
@@ -1640,6 +2316,261 @@ var NATIVE_SYMBOL = __webpack_require__(4495);
|
|
|
1640
2316
|
module.exports = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor;
|
|
1641
2317
|
|
|
1642
2318
|
|
|
2319
|
+
/***/ },
|
|
2320
|
+
|
|
2321
|
+
/***/ 1332
|
|
2322
|
+
(__unused_webpack_module, exports) {
|
|
2323
|
+
|
|
2324
|
+
/**
|
|
2325
|
+
* Data mask pattern reference
|
|
2326
|
+
* @type {Object}
|
|
2327
|
+
*/
|
|
2328
|
+
exports.Patterns = {
|
|
2329
|
+
PATTERN000: 0,
|
|
2330
|
+
PATTERN001: 1,
|
|
2331
|
+
PATTERN010: 2,
|
|
2332
|
+
PATTERN011: 3,
|
|
2333
|
+
PATTERN100: 4,
|
|
2334
|
+
PATTERN101: 5,
|
|
2335
|
+
PATTERN110: 6,
|
|
2336
|
+
PATTERN111: 7
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* Weighted penalty scores for the undesirable features
|
|
2341
|
+
* @type {Object}
|
|
2342
|
+
*/
|
|
2343
|
+
const PenaltyScores = {
|
|
2344
|
+
N1: 3,
|
|
2345
|
+
N2: 3,
|
|
2346
|
+
N3: 40,
|
|
2347
|
+
N4: 10
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* Check if mask pattern value is valid
|
|
2352
|
+
*
|
|
2353
|
+
* @param {Number} mask Mask pattern
|
|
2354
|
+
* @return {Boolean} true if valid, false otherwise
|
|
2355
|
+
*/
|
|
2356
|
+
exports.isValid = function isValid (mask) {
|
|
2357
|
+
return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
/**
|
|
2361
|
+
* Returns mask pattern from a value.
|
|
2362
|
+
* If value is not valid, returns undefined
|
|
2363
|
+
*
|
|
2364
|
+
* @param {Number|String} value Mask pattern value
|
|
2365
|
+
* @return {Number} Valid mask pattern or undefined
|
|
2366
|
+
*/
|
|
2367
|
+
exports.from = function from (value) {
|
|
2368
|
+
return exports.isValid(value) ? parseInt(value, 10) : undefined
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
/**
|
|
2372
|
+
* Find adjacent modules in row/column with the same color
|
|
2373
|
+
* and assign a penalty value.
|
|
2374
|
+
*
|
|
2375
|
+
* Points: N1 + i
|
|
2376
|
+
* i is the amount by which the number of adjacent modules of the same color exceeds 5
|
|
2377
|
+
*/
|
|
2378
|
+
exports.getPenaltyN1 = function getPenaltyN1 (data) {
|
|
2379
|
+
const size = data.size
|
|
2380
|
+
let points = 0
|
|
2381
|
+
let sameCountCol = 0
|
|
2382
|
+
let sameCountRow = 0
|
|
2383
|
+
let lastCol = null
|
|
2384
|
+
let lastRow = null
|
|
2385
|
+
|
|
2386
|
+
for (let row = 0; row < size; row++) {
|
|
2387
|
+
sameCountCol = sameCountRow = 0
|
|
2388
|
+
lastCol = lastRow = null
|
|
2389
|
+
|
|
2390
|
+
for (let col = 0; col < size; col++) {
|
|
2391
|
+
let module = data.get(row, col)
|
|
2392
|
+
if (module === lastCol) {
|
|
2393
|
+
sameCountCol++
|
|
2394
|
+
} else {
|
|
2395
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
|
|
2396
|
+
lastCol = module
|
|
2397
|
+
sameCountCol = 1
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
module = data.get(col, row)
|
|
2401
|
+
if (module === lastRow) {
|
|
2402
|
+
sameCountRow++
|
|
2403
|
+
} else {
|
|
2404
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
|
|
2405
|
+
lastRow = module
|
|
2406
|
+
sameCountRow = 1
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
|
|
2411
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
return points
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
/**
|
|
2418
|
+
* Find 2x2 blocks with the same color and assign a penalty value
|
|
2419
|
+
*
|
|
2420
|
+
* Points: N2 * (m - 1) * (n - 1)
|
|
2421
|
+
*/
|
|
2422
|
+
exports.getPenaltyN2 = function getPenaltyN2 (data) {
|
|
2423
|
+
const size = data.size
|
|
2424
|
+
let points = 0
|
|
2425
|
+
|
|
2426
|
+
for (let row = 0; row < size - 1; row++) {
|
|
2427
|
+
for (let col = 0; col < size - 1; col++) {
|
|
2428
|
+
const last = data.get(row, col) +
|
|
2429
|
+
data.get(row, col + 1) +
|
|
2430
|
+
data.get(row + 1, col) +
|
|
2431
|
+
data.get(row + 1, col + 1)
|
|
2432
|
+
|
|
2433
|
+
if (last === 4 || last === 0) points++
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
return points * PenaltyScores.N2
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
/**
|
|
2441
|
+
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
|
|
2442
|
+
* preceded or followed by light area 4 modules wide
|
|
2443
|
+
*
|
|
2444
|
+
* Points: N3 * number of pattern found
|
|
2445
|
+
*/
|
|
2446
|
+
exports.getPenaltyN3 = function getPenaltyN3 (data) {
|
|
2447
|
+
const size = data.size
|
|
2448
|
+
let points = 0
|
|
2449
|
+
let bitsCol = 0
|
|
2450
|
+
let bitsRow = 0
|
|
2451
|
+
|
|
2452
|
+
for (let row = 0; row < size; row++) {
|
|
2453
|
+
bitsCol = bitsRow = 0
|
|
2454
|
+
for (let col = 0; col < size; col++) {
|
|
2455
|
+
bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)
|
|
2456
|
+
if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++
|
|
2457
|
+
|
|
2458
|
+
bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)
|
|
2459
|
+
if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
return points * PenaltyScores.N3
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
/**
|
|
2467
|
+
* Calculate proportion of dark modules in entire symbol
|
|
2468
|
+
*
|
|
2469
|
+
* Points: N4 * k
|
|
2470
|
+
*
|
|
2471
|
+
* k is the rating of the deviation of the proportion of dark modules
|
|
2472
|
+
* in the symbol from 50% in steps of 5%
|
|
2473
|
+
*/
|
|
2474
|
+
exports.getPenaltyN4 = function getPenaltyN4 (data) {
|
|
2475
|
+
let darkCount = 0
|
|
2476
|
+
const modulesCount = data.data.length
|
|
2477
|
+
|
|
2478
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i]
|
|
2479
|
+
|
|
2480
|
+
const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)
|
|
2481
|
+
|
|
2482
|
+
return k * PenaltyScores.N4
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
/**
|
|
2486
|
+
* Return mask value at given position
|
|
2487
|
+
*
|
|
2488
|
+
* @param {Number} maskPattern Pattern reference value
|
|
2489
|
+
* @param {Number} i Row
|
|
2490
|
+
* @param {Number} j Column
|
|
2491
|
+
* @return {Boolean} Mask value
|
|
2492
|
+
*/
|
|
2493
|
+
function getMaskAt (maskPattern, i, j) {
|
|
2494
|
+
switch (maskPattern) {
|
|
2495
|
+
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
|
|
2496
|
+
case exports.Patterns.PATTERN001: return i % 2 === 0
|
|
2497
|
+
case exports.Patterns.PATTERN010: return j % 3 === 0
|
|
2498
|
+
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
|
|
2499
|
+
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
|
|
2500
|
+
case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
|
|
2501
|
+
case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
|
|
2502
|
+
case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
|
|
2503
|
+
|
|
2504
|
+
default: throw new Error('bad maskPattern:' + maskPattern)
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
/**
|
|
2509
|
+
* Apply a mask pattern to a BitMatrix
|
|
2510
|
+
*
|
|
2511
|
+
* @param {Number} pattern Pattern reference number
|
|
2512
|
+
* @param {BitMatrix} data BitMatrix data
|
|
2513
|
+
*/
|
|
2514
|
+
exports.applyMask = function applyMask (pattern, data) {
|
|
2515
|
+
const size = data.size
|
|
2516
|
+
|
|
2517
|
+
for (let col = 0; col < size; col++) {
|
|
2518
|
+
for (let row = 0; row < size; row++) {
|
|
2519
|
+
if (data.isReserved(row, col)) continue
|
|
2520
|
+
data.xor(row, col, getMaskAt(pattern, row, col))
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
/**
|
|
2526
|
+
* Returns the best mask pattern for data
|
|
2527
|
+
*
|
|
2528
|
+
* @param {BitMatrix} data
|
|
2529
|
+
* @return {Number} Mask pattern reference number
|
|
2530
|
+
*/
|
|
2531
|
+
exports.getBestMask = function getBestMask (data, setupFormatFunc) {
|
|
2532
|
+
const numPatterns = Object.keys(exports.Patterns).length
|
|
2533
|
+
let bestPattern = 0
|
|
2534
|
+
let lowerPenalty = Infinity
|
|
2535
|
+
|
|
2536
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
2537
|
+
setupFormatFunc(p)
|
|
2538
|
+
exports.applyMask(p, data)
|
|
2539
|
+
|
|
2540
|
+
// Calculate penalty
|
|
2541
|
+
const penalty =
|
|
2542
|
+
exports.getPenaltyN1(data) +
|
|
2543
|
+
exports.getPenaltyN2(data) +
|
|
2544
|
+
exports.getPenaltyN3(data) +
|
|
2545
|
+
exports.getPenaltyN4(data)
|
|
2546
|
+
|
|
2547
|
+
// Undo previously applied mask
|
|
2548
|
+
exports.applyMask(p, data)
|
|
2549
|
+
|
|
2550
|
+
if (penalty < lowerPenalty) {
|
|
2551
|
+
lowerPenalty = penalty
|
|
2552
|
+
bestPattern = p
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
return bestPattern
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
|
|
2560
|
+
/***/ },
|
|
2561
|
+
|
|
2562
|
+
/***/ 1333
|
|
2563
|
+
(module) {
|
|
2564
|
+
|
|
2565
|
+
// can-promise has a crash in some versions of react native that dont have
|
|
2566
|
+
// standard global objects
|
|
2567
|
+
// https://github.com/soldair/node-qrcode/issues/157
|
|
2568
|
+
|
|
2569
|
+
module.exports = function () {
|
|
2570
|
+
return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
|
|
1643
2574
|
/***/ },
|
|
1644
2575
|
|
|
1645
2576
|
/***/ 1385
|
|
@@ -1715,6 +2646,242 @@ $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGE
|
|
|
1715
2646
|
__webpack_require__(2405);
|
|
1716
2647
|
|
|
1717
2648
|
|
|
2649
|
+
/***/ },
|
|
2650
|
+
|
|
2651
|
+
/***/ 1427
|
|
2652
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
2653
|
+
|
|
2654
|
+
const Utils = __webpack_require__(6886)
|
|
2655
|
+
const ECCode = __webpack_require__(7518)
|
|
2656
|
+
const ECLevel = __webpack_require__(9953)
|
|
2657
|
+
const Mode = __webpack_require__(208)
|
|
2658
|
+
const VersionCheck = __webpack_require__(1878)
|
|
2659
|
+
|
|
2660
|
+
// Generator polynomial used to encode version information
|
|
2661
|
+
const G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)
|
|
2662
|
+
const G18_BCH = Utils.getBCHDigit(G18)
|
|
2663
|
+
|
|
2664
|
+
function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
|
|
2665
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
2666
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
|
|
2667
|
+
return currentVersion
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
return undefined
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
function getReservedBitsCount (mode, version) {
|
|
2675
|
+
// Character count indicator + mode indicator bits
|
|
2676
|
+
return Mode.getCharCountIndicator(mode, version) + 4
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
function getTotalBitsFromDataArray (segments, version) {
|
|
2680
|
+
let totalBits = 0
|
|
2681
|
+
|
|
2682
|
+
segments.forEach(function (data) {
|
|
2683
|
+
const reservedBits = getReservedBitsCount(data.mode, version)
|
|
2684
|
+
totalBits += reservedBits + data.getBitsLength()
|
|
2685
|
+
})
|
|
2686
|
+
|
|
2687
|
+
return totalBits
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
function getBestVersionForMixedData (segments, errorCorrectionLevel) {
|
|
2691
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
2692
|
+
const length = getTotalBitsFromDataArray(segments, currentVersion)
|
|
2693
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
|
|
2694
|
+
return currentVersion
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
return undefined
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
/**
|
|
2702
|
+
* Returns version number from a value.
|
|
2703
|
+
* If value is not a valid version, returns defaultValue
|
|
2704
|
+
*
|
|
2705
|
+
* @param {Number|String} value QR Code version
|
|
2706
|
+
* @param {Number} defaultValue Fallback value
|
|
2707
|
+
* @return {Number} QR Code version number
|
|
2708
|
+
*/
|
|
2709
|
+
exports.from = function from (value, defaultValue) {
|
|
2710
|
+
if (VersionCheck.isValid(value)) {
|
|
2711
|
+
return parseInt(value, 10)
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
return defaultValue
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
/**
|
|
2718
|
+
* Returns how much data can be stored with the specified QR code version
|
|
2719
|
+
* and error correction level
|
|
2720
|
+
*
|
|
2721
|
+
* @param {Number} version QR Code version (1-40)
|
|
2722
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
2723
|
+
* @param {Mode} mode Data mode
|
|
2724
|
+
* @return {Number} Quantity of storable data
|
|
2725
|
+
*/
|
|
2726
|
+
exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
|
|
2727
|
+
if (!VersionCheck.isValid(version)) {
|
|
2728
|
+
throw new Error('Invalid QR Code version')
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
// Use Byte mode as default
|
|
2732
|
+
if (typeof mode === 'undefined') mode = Mode.BYTE
|
|
2733
|
+
|
|
2734
|
+
// Total codewords for this QR code version (Data + Error correction)
|
|
2735
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version)
|
|
2736
|
+
|
|
2737
|
+
// Total number of error correction codewords
|
|
2738
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
|
|
2739
|
+
|
|
2740
|
+
// Total number of data codewords
|
|
2741
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
|
|
2742
|
+
|
|
2743
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits
|
|
2744
|
+
|
|
2745
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)
|
|
2746
|
+
|
|
2747
|
+
// Return max number of storable codewords
|
|
2748
|
+
switch (mode) {
|
|
2749
|
+
case Mode.NUMERIC:
|
|
2750
|
+
return Math.floor((usableBits / 10) * 3)
|
|
2751
|
+
|
|
2752
|
+
case Mode.ALPHANUMERIC:
|
|
2753
|
+
return Math.floor((usableBits / 11) * 2)
|
|
2754
|
+
|
|
2755
|
+
case Mode.KANJI:
|
|
2756
|
+
return Math.floor(usableBits / 13)
|
|
2757
|
+
|
|
2758
|
+
case Mode.BYTE:
|
|
2759
|
+
default:
|
|
2760
|
+
return Math.floor(usableBits / 8)
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
/**
|
|
2765
|
+
* Returns the minimum version needed to contain the amount of data
|
|
2766
|
+
*
|
|
2767
|
+
* @param {Segment} data Segment of data
|
|
2768
|
+
* @param {Number} [errorCorrectionLevel=H] Error correction level
|
|
2769
|
+
* @param {Mode} mode Data mode
|
|
2770
|
+
* @return {Number} QR Code version
|
|
2771
|
+
*/
|
|
2772
|
+
exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
|
|
2773
|
+
let seg
|
|
2774
|
+
|
|
2775
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)
|
|
2776
|
+
|
|
2777
|
+
if (Array.isArray(data)) {
|
|
2778
|
+
if (data.length > 1) {
|
|
2779
|
+
return getBestVersionForMixedData(data, ecl)
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
if (data.length === 0) {
|
|
2783
|
+
return 1
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
seg = data[0]
|
|
2787
|
+
} else {
|
|
2788
|
+
seg = data
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
/**
|
|
2795
|
+
* Returns version information with relative error correction bits
|
|
2796
|
+
*
|
|
2797
|
+
* The version information is included in QR Code symbols of version 7 or larger.
|
|
2798
|
+
* It consists of an 18-bit sequence containing 6 data bits,
|
|
2799
|
+
* with 12 error correction bits calculated using the (18, 6) Golay code.
|
|
2800
|
+
*
|
|
2801
|
+
* @param {Number} version QR Code version
|
|
2802
|
+
* @return {Number} Encoded version info bits
|
|
2803
|
+
*/
|
|
2804
|
+
exports.getEncodedBits = function getEncodedBits (version) {
|
|
2805
|
+
if (!VersionCheck.isValid(version) || version < 7) {
|
|
2806
|
+
throw new Error('Invalid QR Code version')
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
let d = version << 12
|
|
2810
|
+
|
|
2811
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
|
|
2812
|
+
d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
return (version << 12) | d
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
|
|
2819
|
+
/***/ },
|
|
2820
|
+
|
|
2821
|
+
/***/ 1433
|
|
2822
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
2823
|
+
|
|
2824
|
+
const Mode = __webpack_require__(208)
|
|
2825
|
+
|
|
2826
|
+
/**
|
|
2827
|
+
* Array of characters available in alphanumeric mode
|
|
2828
|
+
*
|
|
2829
|
+
* As per QR Code specification, to each character
|
|
2830
|
+
* is assigned a value from 0 to 44 which in this case coincides
|
|
2831
|
+
* with the array index
|
|
2832
|
+
*
|
|
2833
|
+
* @type {Array}
|
|
2834
|
+
*/
|
|
2835
|
+
const ALPHA_NUM_CHARS = [
|
|
2836
|
+
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
2837
|
+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
2838
|
+
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
2839
|
+
' ', '$', '%', '*', '+', '-', '.', '/', ':'
|
|
2840
|
+
]
|
|
2841
|
+
|
|
2842
|
+
function AlphanumericData (data) {
|
|
2843
|
+
this.mode = Mode.ALPHANUMERIC
|
|
2844
|
+
this.data = data
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
AlphanumericData.getBitsLength = function getBitsLength (length) {
|
|
2848
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2)
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
AlphanumericData.prototype.getLength = function getLength () {
|
|
2852
|
+
return this.data.length
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength () {
|
|
2856
|
+
return AlphanumericData.getBitsLength(this.data.length)
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
AlphanumericData.prototype.write = function write (bitBuffer) {
|
|
2860
|
+
let i
|
|
2861
|
+
|
|
2862
|
+
// Input data characters are divided into groups of two characters
|
|
2863
|
+
// and encoded as 11-bit binary codes.
|
|
2864
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
2865
|
+
// The character value of the first character is multiplied by 45
|
|
2866
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45
|
|
2867
|
+
|
|
2868
|
+
// The character value of the second digit is added to the product
|
|
2869
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])
|
|
2870
|
+
|
|
2871
|
+
// The sum is then stored as 11-bit binary number
|
|
2872
|
+
bitBuffer.put(value, 11)
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
// If the number of input data characters is not a multiple of two,
|
|
2876
|
+
// the character value of the final character is encoded as a 6-bit binary number.
|
|
2877
|
+
if (this.data.length % 2) {
|
|
2878
|
+
bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
module.exports = AlphanumericData
|
|
2883
|
+
|
|
2884
|
+
|
|
1718
2885
|
/***/ },
|
|
1719
2886
|
|
|
1720
2887
|
/***/ 1436
|
|
@@ -1988,6 +3155,22 @@ module.exports = function (object, names) {
|
|
|
1988
3155
|
};
|
|
1989
3156
|
|
|
1990
3157
|
|
|
3158
|
+
/***/ },
|
|
3159
|
+
|
|
3160
|
+
/***/ 1878
|
|
3161
|
+
(__unused_webpack_module, exports) {
|
|
3162
|
+
|
|
3163
|
+
/**
|
|
3164
|
+
* Check if QR Code version is valid
|
|
3165
|
+
*
|
|
3166
|
+
* @param {Number} version QR Code version
|
|
3167
|
+
* @return {Boolean} true if valid version, false otherwise
|
|
3168
|
+
*/
|
|
3169
|
+
exports.isValid = function isValid (version) {
|
|
3170
|
+
return !isNaN(version) && version >= 1 && version <= 40
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
|
|
1991
3174
|
/***/ },
|
|
1992
3175
|
|
|
1993
3176
|
/***/ 1928
|
|
@@ -2871,6 +4054,112 @@ __webpack_require__(3110);
|
|
|
2871
4054
|
__webpack_require__(9773);
|
|
2872
4055
|
|
|
2873
4056
|
|
|
4057
|
+
/***/ },
|
|
4058
|
+
|
|
4059
|
+
/***/ 2726
|
|
4060
|
+
(__unused_webpack_module, exports) {
|
|
4061
|
+
|
|
4062
|
+
function hex2rgba (hex) {
|
|
4063
|
+
if (typeof hex === 'number') {
|
|
4064
|
+
hex = hex.toString()
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
if (typeof hex !== 'string') {
|
|
4068
|
+
throw new Error('Color should be defined as hex string')
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
let hexCode = hex.slice().replace('#', '').split('')
|
|
4072
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
|
|
4073
|
+
throw new Error('Invalid hex color: ' + hex)
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
// Convert from short to long form (fff -> ffffff)
|
|
4077
|
+
if (hexCode.length === 3 || hexCode.length === 4) {
|
|
4078
|
+
hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
|
|
4079
|
+
return [c, c]
|
|
4080
|
+
}))
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
// Add default alpha value
|
|
4084
|
+
if (hexCode.length === 6) hexCode.push('F', 'F')
|
|
4085
|
+
|
|
4086
|
+
const hexValue = parseInt(hexCode.join(''), 16)
|
|
4087
|
+
|
|
4088
|
+
return {
|
|
4089
|
+
r: (hexValue >> 24) & 255,
|
|
4090
|
+
g: (hexValue >> 16) & 255,
|
|
4091
|
+
b: (hexValue >> 8) & 255,
|
|
4092
|
+
a: hexValue & 255,
|
|
4093
|
+
hex: '#' + hexCode.slice(0, 6).join('')
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
exports.getOptions = function getOptions (options) {
|
|
4098
|
+
if (!options) options = {}
|
|
4099
|
+
if (!options.color) options.color = {}
|
|
4100
|
+
|
|
4101
|
+
const margin = typeof options.margin === 'undefined' ||
|
|
4102
|
+
options.margin === null ||
|
|
4103
|
+
options.margin < 0
|
|
4104
|
+
? 4
|
|
4105
|
+
: options.margin
|
|
4106
|
+
|
|
4107
|
+
const width = options.width && options.width >= 21 ? options.width : undefined
|
|
4108
|
+
const scale = options.scale || 4
|
|
4109
|
+
|
|
4110
|
+
return {
|
|
4111
|
+
width: width,
|
|
4112
|
+
scale: width ? 4 : scale,
|
|
4113
|
+
margin: margin,
|
|
4114
|
+
color: {
|
|
4115
|
+
dark: hex2rgba(options.color.dark || '#000000ff'),
|
|
4116
|
+
light: hex2rgba(options.color.light || '#ffffffff')
|
|
4117
|
+
},
|
|
4118
|
+
type: options.type,
|
|
4119
|
+
rendererOpts: options.rendererOpts || {}
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
exports.getScale = function getScale (qrSize, opts) {
|
|
4124
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2
|
|
4125
|
+
? opts.width / (qrSize + opts.margin * 2)
|
|
4126
|
+
: opts.scale
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
exports.getImageWidth = function getImageWidth (qrSize, opts) {
|
|
4130
|
+
const scale = exports.getScale(qrSize, opts)
|
|
4131
|
+
return Math.floor((qrSize + opts.margin * 2) * scale)
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
exports.qrToImageData = function qrToImageData (imgData, qr, opts) {
|
|
4135
|
+
const size = qr.modules.size
|
|
4136
|
+
const data = qr.modules.data
|
|
4137
|
+
const scale = exports.getScale(size, opts)
|
|
4138
|
+
const symbolSize = Math.floor((size + opts.margin * 2) * scale)
|
|
4139
|
+
const scaledMargin = opts.margin * scale
|
|
4140
|
+
const palette = [opts.color.light, opts.color.dark]
|
|
4141
|
+
|
|
4142
|
+
for (let i = 0; i < symbolSize; i++) {
|
|
4143
|
+
for (let j = 0; j < symbolSize; j++) {
|
|
4144
|
+
let posDst = (i * symbolSize + j) * 4
|
|
4145
|
+
let pxColor = opts.color.light
|
|
4146
|
+
|
|
4147
|
+
if (i >= scaledMargin && j >= scaledMargin &&
|
|
4148
|
+
i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
4149
|
+
const iSrc = Math.floor((i - scaledMargin) / scale)
|
|
4150
|
+
const jSrc = Math.floor((j - scaledMargin) / scale)
|
|
4151
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0]
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
imgData[posDst++] = pxColor.r
|
|
4155
|
+
imgData[posDst++] = pxColor.g
|
|
4156
|
+
imgData[posDst++] = pxColor.b
|
|
4157
|
+
imgData[posDst] = pxColor.a
|
|
4158
|
+
}
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4162
|
+
|
|
2874
4163
|
/***/ },
|
|
2875
4164
|
|
|
2876
4165
|
/***/ 2731
|
|
@@ -4925,6 +6214,56 @@ $({ target: 'Array', stat: true }, {
|
|
|
4925
6214
|
});
|
|
4926
6215
|
|
|
4927
6216
|
|
|
6217
|
+
/***/ },
|
|
6218
|
+
|
|
6219
|
+
/***/ 4357
|
|
6220
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
6221
|
+
|
|
6222
|
+
const Mode = __webpack_require__(208)
|
|
6223
|
+
|
|
6224
|
+
function NumericData (data) {
|
|
6225
|
+
this.mode = Mode.NUMERIC
|
|
6226
|
+
this.data = data.toString()
|
|
6227
|
+
}
|
|
6228
|
+
|
|
6229
|
+
NumericData.getBitsLength = function getBitsLength (length) {
|
|
6230
|
+
return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
|
|
6231
|
+
}
|
|
6232
|
+
|
|
6233
|
+
NumericData.prototype.getLength = function getLength () {
|
|
6234
|
+
return this.data.length
|
|
6235
|
+
}
|
|
6236
|
+
|
|
6237
|
+
NumericData.prototype.getBitsLength = function getBitsLength () {
|
|
6238
|
+
return NumericData.getBitsLength(this.data.length)
|
|
6239
|
+
}
|
|
6240
|
+
|
|
6241
|
+
NumericData.prototype.write = function write (bitBuffer) {
|
|
6242
|
+
let i, group, value
|
|
6243
|
+
|
|
6244
|
+
// The input data string is divided into groups of three digits,
|
|
6245
|
+
// and each group is converted to its 10-bit binary equivalent.
|
|
6246
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
6247
|
+
group = this.data.substr(i, 3)
|
|
6248
|
+
value = parseInt(group, 10)
|
|
6249
|
+
|
|
6250
|
+
bitBuffer.put(value, 10)
|
|
6251
|
+
}
|
|
6252
|
+
|
|
6253
|
+
// If the number of input digits is not an exact multiple of three,
|
|
6254
|
+
// the final one or two digits are converted to 4 or 7 bits respectively.
|
|
6255
|
+
const remainingNum = this.data.length - i
|
|
6256
|
+
if (remainingNum > 0) {
|
|
6257
|
+
group = this.data.substr(i)
|
|
6258
|
+
value = parseInt(group, 10)
|
|
6259
|
+
|
|
6260
|
+
bitBuffer.put(value, remainingNum * 3 + 1)
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6263
|
+
|
|
6264
|
+
module.exports = NumericData
|
|
6265
|
+
|
|
6266
|
+
|
|
4928
6267
|
/***/ },
|
|
4929
6268
|
|
|
4930
6269
|
/***/ 4376
|
|
@@ -5338,6 +6677,42 @@ $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
|
|
|
5338
6677
|
});
|
|
5339
6678
|
|
|
5340
6679
|
|
|
6680
|
+
/***/ },
|
|
6681
|
+
|
|
6682
|
+
/***/ 4565
|
|
6683
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
6684
|
+
|
|
6685
|
+
const Utils = __webpack_require__(6886)
|
|
6686
|
+
|
|
6687
|
+
const G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)
|
|
6688
|
+
const G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)
|
|
6689
|
+
const G15_BCH = Utils.getBCHDigit(G15)
|
|
6690
|
+
|
|
6691
|
+
/**
|
|
6692
|
+
* Returns format information with relative error correction bits
|
|
6693
|
+
*
|
|
6694
|
+
* The format information is a 15-bit sequence containing 5 data bits,
|
|
6695
|
+
* with 10 error correction bits calculated using the (15, 5) BCH code.
|
|
6696
|
+
*
|
|
6697
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
6698
|
+
* @param {Number} mask Mask pattern
|
|
6699
|
+
* @return {Number} Encoded format information bits
|
|
6700
|
+
*/
|
|
6701
|
+
exports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
|
|
6702
|
+
const data = ((errorCorrectionLevel.bit << 3) | mask)
|
|
6703
|
+
let d = data << 10
|
|
6704
|
+
|
|
6705
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
|
|
6706
|
+
d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))
|
|
6707
|
+
}
|
|
6708
|
+
|
|
6709
|
+
// xor final data with mask pattern in order to ensure that
|
|
6710
|
+
// no combination of Error Correction Level and data mask pattern
|
|
6711
|
+
// will result in an all-zero data string
|
|
6712
|
+
return ((data << 10) | d) ^ G15_MASK
|
|
6713
|
+
}
|
|
6714
|
+
|
|
6715
|
+
|
|
5341
6716
|
/***/ },
|
|
5342
6717
|
|
|
5343
6718
|
/***/ 4576
|
|
@@ -5548,6 +6923,138 @@ module.exports = function combineURLs(baseURL, relativeURL) {
|
|
|
5548
6923
|
};
|
|
5549
6924
|
|
|
5550
6925
|
|
|
6926
|
+
/***/ },
|
|
6927
|
+
|
|
6928
|
+
/***/ 4713
|
|
6929
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
6930
|
+
|
|
6931
|
+
const GF = __webpack_require__(5112)
|
|
6932
|
+
|
|
6933
|
+
/**
|
|
6934
|
+
* Multiplies two polynomials inside Galois Field
|
|
6935
|
+
*
|
|
6936
|
+
* @param {Uint8Array} p1 Polynomial
|
|
6937
|
+
* @param {Uint8Array} p2 Polynomial
|
|
6938
|
+
* @return {Uint8Array} Product of p1 and p2
|
|
6939
|
+
*/
|
|
6940
|
+
exports.mul = function mul (p1, p2) {
|
|
6941
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1)
|
|
6942
|
+
|
|
6943
|
+
for (let i = 0; i < p1.length; i++) {
|
|
6944
|
+
for (let j = 0; j < p2.length; j++) {
|
|
6945
|
+
coeff[i + j] ^= GF.mul(p1[i], p2[j])
|
|
6946
|
+
}
|
|
6947
|
+
}
|
|
6948
|
+
|
|
6949
|
+
return coeff
|
|
6950
|
+
}
|
|
6951
|
+
|
|
6952
|
+
/**
|
|
6953
|
+
* Calculate the remainder of polynomials division
|
|
6954
|
+
*
|
|
6955
|
+
* @param {Uint8Array} divident Polynomial
|
|
6956
|
+
* @param {Uint8Array} divisor Polynomial
|
|
6957
|
+
* @return {Uint8Array} Remainder
|
|
6958
|
+
*/
|
|
6959
|
+
exports.mod = function mod (divident, divisor) {
|
|
6960
|
+
let result = new Uint8Array(divident)
|
|
6961
|
+
|
|
6962
|
+
while ((result.length - divisor.length) >= 0) {
|
|
6963
|
+
const coeff = result[0]
|
|
6964
|
+
|
|
6965
|
+
for (let i = 0; i < divisor.length; i++) {
|
|
6966
|
+
result[i] ^= GF.mul(divisor[i], coeff)
|
|
6967
|
+
}
|
|
6968
|
+
|
|
6969
|
+
// remove all zeros from buffer head
|
|
6970
|
+
let offset = 0
|
|
6971
|
+
while (offset < result.length && result[offset] === 0) offset++
|
|
6972
|
+
result = result.slice(offset)
|
|
6973
|
+
}
|
|
6974
|
+
|
|
6975
|
+
return result
|
|
6976
|
+
}
|
|
6977
|
+
|
|
6978
|
+
/**
|
|
6979
|
+
* Generate an irreducible generator polynomial of specified degree
|
|
6980
|
+
* (used by Reed-Solomon encoder)
|
|
6981
|
+
*
|
|
6982
|
+
* @param {Number} degree Degree of the generator polynomial
|
|
6983
|
+
* @return {Uint8Array} Buffer containing polynomial coefficients
|
|
6984
|
+
*/
|
|
6985
|
+
exports.generateECPolynomial = function generateECPolynomial (degree) {
|
|
6986
|
+
let poly = new Uint8Array([1])
|
|
6987
|
+
for (let i = 0; i < degree; i++) {
|
|
6988
|
+
poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]))
|
|
6989
|
+
}
|
|
6990
|
+
|
|
6991
|
+
return poly
|
|
6992
|
+
}
|
|
6993
|
+
|
|
6994
|
+
|
|
6995
|
+
/***/ },
|
|
6996
|
+
|
|
6997
|
+
/***/ 4764
|
|
6998
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
6999
|
+
|
|
7000
|
+
const Polynomial = __webpack_require__(4713)
|
|
7001
|
+
|
|
7002
|
+
function ReedSolomonEncoder (degree) {
|
|
7003
|
+
this.genPoly = undefined
|
|
7004
|
+
this.degree = degree
|
|
7005
|
+
|
|
7006
|
+
if (this.degree) this.initialize(this.degree)
|
|
7007
|
+
}
|
|
7008
|
+
|
|
7009
|
+
/**
|
|
7010
|
+
* Initialize the encoder.
|
|
7011
|
+
* The input param should correspond to the number of error correction codewords.
|
|
7012
|
+
*
|
|
7013
|
+
* @param {Number} degree
|
|
7014
|
+
*/
|
|
7015
|
+
ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
|
|
7016
|
+
// create an irreducible generator polynomial
|
|
7017
|
+
this.degree = degree
|
|
7018
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree)
|
|
7019
|
+
}
|
|
7020
|
+
|
|
7021
|
+
/**
|
|
7022
|
+
* Encodes a chunk of data
|
|
7023
|
+
*
|
|
7024
|
+
* @param {Uint8Array} data Buffer containing input data
|
|
7025
|
+
* @return {Uint8Array} Buffer containing encoded data
|
|
7026
|
+
*/
|
|
7027
|
+
ReedSolomonEncoder.prototype.encode = function encode (data) {
|
|
7028
|
+
if (!this.genPoly) {
|
|
7029
|
+
throw new Error('Encoder not initialized')
|
|
7030
|
+
}
|
|
7031
|
+
|
|
7032
|
+
// Calculate EC for this data block
|
|
7033
|
+
// extends data size to data+genPoly size
|
|
7034
|
+
const paddedData = new Uint8Array(data.length + this.degree)
|
|
7035
|
+
paddedData.set(data)
|
|
7036
|
+
|
|
7037
|
+
// The error correction codewords are the remainder after dividing the data codewords
|
|
7038
|
+
// by a generator polynomial
|
|
7039
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly)
|
|
7040
|
+
|
|
7041
|
+
// return EC data blocks (last n byte, where n is the degree of genPoly)
|
|
7042
|
+
// If coefficients number in remainder are less than genPoly degree,
|
|
7043
|
+
// pad with 0s to the left to reach the needed number of coefficients
|
|
7044
|
+
const start = this.degree - remainder.length
|
|
7045
|
+
if (start > 0) {
|
|
7046
|
+
const buff = new Uint8Array(this.degree)
|
|
7047
|
+
buff.set(remainder, start)
|
|
7048
|
+
|
|
7049
|
+
return buff
|
|
7050
|
+
}
|
|
7051
|
+
|
|
7052
|
+
return remainder
|
|
7053
|
+
}
|
|
7054
|
+
|
|
7055
|
+
module.exports = ReedSolomonEncoder
|
|
7056
|
+
|
|
7057
|
+
|
|
5551
7058
|
/***/ },
|
|
5552
7059
|
|
|
5553
7060
|
/***/ 4782
|
|
@@ -5696,6 +7203,67 @@ module.exports = {
|
|
|
5696
7203
|
};
|
|
5697
7204
|
|
|
5698
7205
|
|
|
7206
|
+
/***/ },
|
|
7207
|
+
|
|
7208
|
+
/***/ 4861
|
|
7209
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
7210
|
+
|
|
7211
|
+
const Mode = __webpack_require__(208)
|
|
7212
|
+
const Utils = __webpack_require__(6886)
|
|
7213
|
+
|
|
7214
|
+
function KanjiData (data) {
|
|
7215
|
+
this.mode = Mode.KANJI
|
|
7216
|
+
this.data = data
|
|
7217
|
+
}
|
|
7218
|
+
|
|
7219
|
+
KanjiData.getBitsLength = function getBitsLength (length) {
|
|
7220
|
+
return length * 13
|
|
7221
|
+
}
|
|
7222
|
+
|
|
7223
|
+
KanjiData.prototype.getLength = function getLength () {
|
|
7224
|
+
return this.data.length
|
|
7225
|
+
}
|
|
7226
|
+
|
|
7227
|
+
KanjiData.prototype.getBitsLength = function getBitsLength () {
|
|
7228
|
+
return KanjiData.getBitsLength(this.data.length)
|
|
7229
|
+
}
|
|
7230
|
+
|
|
7231
|
+
KanjiData.prototype.write = function (bitBuffer) {
|
|
7232
|
+
let i
|
|
7233
|
+
|
|
7234
|
+
// In the Shift JIS system, Kanji characters are represented by a two byte combination.
|
|
7235
|
+
// These byte values are shifted from the JIS X 0208 values.
|
|
7236
|
+
// JIS X 0208 gives details of the shift coded representation.
|
|
7237
|
+
for (i = 0; i < this.data.length; i++) {
|
|
7238
|
+
let value = Utils.toSJIS(this.data[i])
|
|
7239
|
+
|
|
7240
|
+
// For characters with Shift JIS values from 0x8140 to 0x9FFC:
|
|
7241
|
+
if (value >= 0x8140 && value <= 0x9FFC) {
|
|
7242
|
+
// Subtract 0x8140 from Shift JIS value
|
|
7243
|
+
value -= 0x8140
|
|
7244
|
+
|
|
7245
|
+
// For characters with Shift JIS values from 0xE040 to 0xEBBF
|
|
7246
|
+
} else if (value >= 0xE040 && value <= 0xEBBF) {
|
|
7247
|
+
// Subtract 0xC140 from Shift JIS value
|
|
7248
|
+
value -= 0xC140
|
|
7249
|
+
} else {
|
|
7250
|
+
throw new Error(
|
|
7251
|
+
'Invalid SJIS character: ' + this.data[i] + '\n' +
|
|
7252
|
+
'Make sure your charset is UTF-8')
|
|
7253
|
+
}
|
|
7254
|
+
|
|
7255
|
+
// Multiply most significant byte of result by 0xC0
|
|
7256
|
+
// and add least significant byte to product
|
|
7257
|
+
value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)
|
|
7258
|
+
|
|
7259
|
+
// Convert result to a 13-bit binary string
|
|
7260
|
+
bitBuffer.put(value, 13)
|
|
7261
|
+
}
|
|
7262
|
+
}
|
|
7263
|
+
|
|
7264
|
+
module.exports = KanjiData
|
|
7265
|
+
|
|
7266
|
+
|
|
5699
7267
|
/***/ },
|
|
5700
7268
|
|
|
5701
7269
|
/***/ 4864
|
|
@@ -6124,6 +7692,82 @@ $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
|
|
|
6124
7692
|
});
|
|
6125
7693
|
|
|
6126
7694
|
|
|
7695
|
+
/***/ },
|
|
7696
|
+
|
|
7697
|
+
/***/ 5112
|
|
7698
|
+
(__unused_webpack_module, exports) {
|
|
7699
|
+
|
|
7700
|
+
const EXP_TABLE = new Uint8Array(512)
|
|
7701
|
+
const LOG_TABLE = new Uint8Array(256)
|
|
7702
|
+
/**
|
|
7703
|
+
* Precompute the log and anti-log tables for faster computation later
|
|
7704
|
+
*
|
|
7705
|
+
* For each possible value in the galois field 2^8, we will pre-compute
|
|
7706
|
+
* the logarithm and anti-logarithm (exponential) of this value
|
|
7707
|
+
*
|
|
7708
|
+
* ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
|
|
7709
|
+
*/
|
|
7710
|
+
;(function initTables () {
|
|
7711
|
+
let x = 1
|
|
7712
|
+
for (let i = 0; i < 255; i++) {
|
|
7713
|
+
EXP_TABLE[i] = x
|
|
7714
|
+
LOG_TABLE[x] = i
|
|
7715
|
+
|
|
7716
|
+
x <<= 1 // multiply by 2
|
|
7717
|
+
|
|
7718
|
+
// The QR code specification says to use byte-wise modulo 100011101 arithmetic.
|
|
7719
|
+
// This means that when a number is 256 or larger, it should be XORed with 0x11D.
|
|
7720
|
+
if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
|
|
7721
|
+
x ^= 0x11D
|
|
7722
|
+
}
|
|
7723
|
+
}
|
|
7724
|
+
|
|
7725
|
+
// Optimization: double the size of the anti-log table so that we don't need to mod 255 to
|
|
7726
|
+
// stay inside the bounds (because we will mainly use this table for the multiplication of
|
|
7727
|
+
// two GF numbers, no more).
|
|
7728
|
+
// @see {@link mul}
|
|
7729
|
+
for (let i = 255; i < 512; i++) {
|
|
7730
|
+
EXP_TABLE[i] = EXP_TABLE[i - 255]
|
|
7731
|
+
}
|
|
7732
|
+
}())
|
|
7733
|
+
|
|
7734
|
+
/**
|
|
7735
|
+
* Returns log value of n inside Galois Field
|
|
7736
|
+
*
|
|
7737
|
+
* @param {Number} n
|
|
7738
|
+
* @return {Number}
|
|
7739
|
+
*/
|
|
7740
|
+
exports.log = function log (n) {
|
|
7741
|
+
if (n < 1) throw new Error('log(' + n + ')')
|
|
7742
|
+
return LOG_TABLE[n]
|
|
7743
|
+
}
|
|
7744
|
+
|
|
7745
|
+
/**
|
|
7746
|
+
* Returns anti-log value of n inside Galois Field
|
|
7747
|
+
*
|
|
7748
|
+
* @param {Number} n
|
|
7749
|
+
* @return {Number}
|
|
7750
|
+
*/
|
|
7751
|
+
exports.exp = function exp (n) {
|
|
7752
|
+
return EXP_TABLE[n]
|
|
7753
|
+
}
|
|
7754
|
+
|
|
7755
|
+
/**
|
|
7756
|
+
* Multiplies two number inside Galois Field
|
|
7757
|
+
*
|
|
7758
|
+
* @param {Number} x
|
|
7759
|
+
* @param {Number} y
|
|
7760
|
+
* @return {Number}
|
|
7761
|
+
*/
|
|
7762
|
+
exports.mul = function mul (x, y) {
|
|
7763
|
+
if (x === 0 || y === 0) return 0
|
|
7764
|
+
|
|
7765
|
+
// should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
|
|
7766
|
+
// @see {@link initTables}
|
|
7767
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
|
|
7768
|
+
}
|
|
7769
|
+
|
|
7770
|
+
|
|
6127
7771
|
/***/ },
|
|
6128
7772
|
|
|
6129
7773
|
/***/ 5155
|
|
@@ -7102,6 +8746,43 @@ module.exports = function isRawJSON(O) {
|
|
|
7102
8746
|
};
|
|
7103
8747
|
|
|
7104
8748
|
|
|
8749
|
+
/***/ },
|
|
8750
|
+
|
|
8751
|
+
/***/ 5822
|
|
8752
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
8753
|
+
|
|
8754
|
+
const Mode = __webpack_require__(208)
|
|
8755
|
+
|
|
8756
|
+
function ByteData (data) {
|
|
8757
|
+
this.mode = Mode.BYTE
|
|
8758
|
+
if (typeof (data) === 'string') {
|
|
8759
|
+
this.data = new TextEncoder().encode(data)
|
|
8760
|
+
} else {
|
|
8761
|
+
this.data = new Uint8Array(data)
|
|
8762
|
+
}
|
|
8763
|
+
}
|
|
8764
|
+
|
|
8765
|
+
ByteData.getBitsLength = function getBitsLength (length) {
|
|
8766
|
+
return length * 8
|
|
8767
|
+
}
|
|
8768
|
+
|
|
8769
|
+
ByteData.prototype.getLength = function getLength () {
|
|
8770
|
+
return this.data.length
|
|
8771
|
+
}
|
|
8772
|
+
|
|
8773
|
+
ByteData.prototype.getBitsLength = function getBitsLength () {
|
|
8774
|
+
return ByteData.getBitsLength(this.data.length)
|
|
8775
|
+
}
|
|
8776
|
+
|
|
8777
|
+
ByteData.prototype.write = function (bitBuffer) {
|
|
8778
|
+
for (let i = 0, l = this.data.length; i < l; i++) {
|
|
8779
|
+
bitBuffer.put(this.data[i], 8)
|
|
8780
|
+
}
|
|
8781
|
+
}
|
|
8782
|
+
|
|
8783
|
+
module.exports = ByteData
|
|
8784
|
+
|
|
8785
|
+
|
|
7105
8786
|
/***/ },
|
|
7106
8787
|
|
|
7107
8788
|
/***/ 5876
|
|
@@ -7466,6 +9147,179 @@ module.exports = function (iterator, fn, value, ENTRIES) {
|
|
|
7466
9147
|
};
|
|
7467
9148
|
|
|
7468
9149
|
|
|
9150
|
+
/***/ },
|
|
9151
|
+
|
|
9152
|
+
/***/ 6320
|
|
9153
|
+
(module) {
|
|
9154
|
+
|
|
9155
|
+
"use strict";
|
|
9156
|
+
|
|
9157
|
+
|
|
9158
|
+
/******************************************************************************
|
|
9159
|
+
* Created 2008-08-19.
|
|
9160
|
+
*
|
|
9161
|
+
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
|
|
9162
|
+
*
|
|
9163
|
+
* Copyright (C) 2008
|
|
9164
|
+
* Wyatt Baldwin <self@wyattbaldwin.com>
|
|
9165
|
+
* All rights reserved
|
|
9166
|
+
*
|
|
9167
|
+
* Licensed under the MIT license.
|
|
9168
|
+
*
|
|
9169
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
9170
|
+
*
|
|
9171
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
9172
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
9173
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
9174
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
9175
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
9176
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
9177
|
+
* THE SOFTWARE.
|
|
9178
|
+
*****************************************************************************/
|
|
9179
|
+
var dijkstra = {
|
|
9180
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
9181
|
+
// Predecessor map for each node that has been encountered.
|
|
9182
|
+
// node ID => predecessor node ID
|
|
9183
|
+
var predecessors = {};
|
|
9184
|
+
|
|
9185
|
+
// Costs of shortest paths from s to all nodes encountered.
|
|
9186
|
+
// node ID => cost
|
|
9187
|
+
var costs = {};
|
|
9188
|
+
costs[s] = 0;
|
|
9189
|
+
|
|
9190
|
+
// Costs of shortest paths from s to all nodes encountered; differs from
|
|
9191
|
+
// `costs` in that it provides easy access to the node that currently has
|
|
9192
|
+
// the known shortest path from s.
|
|
9193
|
+
// XXX: Do we actually need both `costs` and `open`?
|
|
9194
|
+
var open = dijkstra.PriorityQueue.make();
|
|
9195
|
+
open.push(s, 0);
|
|
9196
|
+
|
|
9197
|
+
var closest,
|
|
9198
|
+
u, v,
|
|
9199
|
+
cost_of_s_to_u,
|
|
9200
|
+
adjacent_nodes,
|
|
9201
|
+
cost_of_e,
|
|
9202
|
+
cost_of_s_to_u_plus_cost_of_e,
|
|
9203
|
+
cost_of_s_to_v,
|
|
9204
|
+
first_visit;
|
|
9205
|
+
while (!open.empty()) {
|
|
9206
|
+
// In the nodes remaining in graph that have a known cost from s,
|
|
9207
|
+
// find the node, u, that currently has the shortest path from s.
|
|
9208
|
+
closest = open.pop();
|
|
9209
|
+
u = closest.value;
|
|
9210
|
+
cost_of_s_to_u = closest.cost;
|
|
9211
|
+
|
|
9212
|
+
// Get nodes adjacent to u...
|
|
9213
|
+
adjacent_nodes = graph[u] || {};
|
|
9214
|
+
|
|
9215
|
+
// ...and explore the edges that connect u to those nodes, updating
|
|
9216
|
+
// the cost of the shortest paths to any or all of those nodes as
|
|
9217
|
+
// necessary. v is the node across the current edge from u.
|
|
9218
|
+
for (v in adjacent_nodes) {
|
|
9219
|
+
if (adjacent_nodes.hasOwnProperty(v)) {
|
|
9220
|
+
// Get the cost of the edge running from u to v.
|
|
9221
|
+
cost_of_e = adjacent_nodes[v];
|
|
9222
|
+
|
|
9223
|
+
// Cost of s to u plus the cost of u to v across e--this is *a*
|
|
9224
|
+
// cost from s to v that may or may not be less than the current
|
|
9225
|
+
// known cost to v.
|
|
9226
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
9227
|
+
|
|
9228
|
+
// If we haven't visited v yet OR if the current known cost from s to
|
|
9229
|
+
// v is greater than the new cost we just found (cost of s to u plus
|
|
9230
|
+
// cost of u to v across e), update v's cost in the cost list and
|
|
9231
|
+
// update v's predecessor in the predecessor list (it's now u).
|
|
9232
|
+
cost_of_s_to_v = costs[v];
|
|
9233
|
+
first_visit = (typeof costs[v] === 'undefined');
|
|
9234
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
9235
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
9236
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
9237
|
+
predecessors[v] = u;
|
|
9238
|
+
}
|
|
9239
|
+
}
|
|
9240
|
+
}
|
|
9241
|
+
}
|
|
9242
|
+
|
|
9243
|
+
if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
|
|
9244
|
+
var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
|
|
9245
|
+
throw new Error(msg);
|
|
9246
|
+
}
|
|
9247
|
+
|
|
9248
|
+
return predecessors;
|
|
9249
|
+
},
|
|
9250
|
+
|
|
9251
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
9252
|
+
var nodes = [];
|
|
9253
|
+
var u = d;
|
|
9254
|
+
var predecessor;
|
|
9255
|
+
while (u) {
|
|
9256
|
+
nodes.push(u);
|
|
9257
|
+
predecessor = predecessors[u];
|
|
9258
|
+
u = predecessors[u];
|
|
9259
|
+
}
|
|
9260
|
+
nodes.reverse();
|
|
9261
|
+
return nodes;
|
|
9262
|
+
},
|
|
9263
|
+
|
|
9264
|
+
find_path: function(graph, s, d) {
|
|
9265
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
9266
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(
|
|
9267
|
+
predecessors, d);
|
|
9268
|
+
},
|
|
9269
|
+
|
|
9270
|
+
/**
|
|
9271
|
+
* A very naive priority queue implementation.
|
|
9272
|
+
*/
|
|
9273
|
+
PriorityQueue: {
|
|
9274
|
+
make: function (opts) {
|
|
9275
|
+
var T = dijkstra.PriorityQueue,
|
|
9276
|
+
t = {},
|
|
9277
|
+
key;
|
|
9278
|
+
opts = opts || {};
|
|
9279
|
+
for (key in T) {
|
|
9280
|
+
if (T.hasOwnProperty(key)) {
|
|
9281
|
+
t[key] = T[key];
|
|
9282
|
+
}
|
|
9283
|
+
}
|
|
9284
|
+
t.queue = [];
|
|
9285
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
9286
|
+
return t;
|
|
9287
|
+
},
|
|
9288
|
+
|
|
9289
|
+
default_sorter: function (a, b) {
|
|
9290
|
+
return a.cost - b.cost;
|
|
9291
|
+
},
|
|
9292
|
+
|
|
9293
|
+
/**
|
|
9294
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
9295
|
+
* is at the front of the queue.
|
|
9296
|
+
*/
|
|
9297
|
+
push: function (value, cost) {
|
|
9298
|
+
var item = {value: value, cost: cost};
|
|
9299
|
+
this.queue.push(item);
|
|
9300
|
+
this.queue.sort(this.sorter);
|
|
9301
|
+
},
|
|
9302
|
+
|
|
9303
|
+
/**
|
|
9304
|
+
* Return the highest priority element in the queue.
|
|
9305
|
+
*/
|
|
9306
|
+
pop: function () {
|
|
9307
|
+
return this.queue.shift();
|
|
9308
|
+
},
|
|
9309
|
+
|
|
9310
|
+
empty: function () {
|
|
9311
|
+
return this.queue.length === 0;
|
|
9312
|
+
}
|
|
9313
|
+
}
|
|
9314
|
+
};
|
|
9315
|
+
|
|
9316
|
+
|
|
9317
|
+
// node.js module exports
|
|
9318
|
+
if (true) {
|
|
9319
|
+
module.exports = dijkstra;
|
|
9320
|
+
}
|
|
9321
|
+
|
|
9322
|
+
|
|
7469
9323
|
/***/ },
|
|
7470
9324
|
|
|
7471
9325
|
/***/ 6395
|
|
@@ -7476,6 +9330,96 @@ module.exports = function (iterator, fn, value, ENTRIES) {
|
|
|
7476
9330
|
module.exports = false;
|
|
7477
9331
|
|
|
7478
9332
|
|
|
9333
|
+
/***/ },
|
|
9334
|
+
|
|
9335
|
+
/***/ 6421
|
|
9336
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
9337
|
+
|
|
9338
|
+
/**
|
|
9339
|
+
* Alignment pattern are fixed reference pattern in defined positions
|
|
9340
|
+
* in a matrix symbology, which enables the decode software to re-synchronise
|
|
9341
|
+
* the coordinate mapping of the image modules in the event of moderate amounts
|
|
9342
|
+
* of distortion of the image.
|
|
9343
|
+
*
|
|
9344
|
+
* Alignment patterns are present only in QR Code symbols of version 2 or larger
|
|
9345
|
+
* and their number depends on the symbol version.
|
|
9346
|
+
*/
|
|
9347
|
+
|
|
9348
|
+
const getSymbolSize = (__webpack_require__(6886).getSymbolSize)
|
|
9349
|
+
|
|
9350
|
+
/**
|
|
9351
|
+
* Calculate the row/column coordinates of the center module of each alignment pattern
|
|
9352
|
+
* for the specified QR Code version.
|
|
9353
|
+
*
|
|
9354
|
+
* The alignment patterns are positioned symmetrically on either side of the diagonal
|
|
9355
|
+
* running from the top left corner of the symbol to the bottom right corner.
|
|
9356
|
+
*
|
|
9357
|
+
* Since positions are simmetrical only half of the coordinates are returned.
|
|
9358
|
+
* Each item of the array will represent in turn the x and y coordinate.
|
|
9359
|
+
* @see {@link getPositions}
|
|
9360
|
+
*
|
|
9361
|
+
* @param {Number} version QR Code version
|
|
9362
|
+
* @return {Array} Array of coordinate
|
|
9363
|
+
*/
|
|
9364
|
+
exports.getRowColCoords = function getRowColCoords (version) {
|
|
9365
|
+
if (version === 1) return []
|
|
9366
|
+
|
|
9367
|
+
const posCount = Math.floor(version / 7) + 2
|
|
9368
|
+
const size = getSymbolSize(version)
|
|
9369
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2
|
|
9370
|
+
const positions = [size - 7] // Last coord is always (size - 7)
|
|
9371
|
+
|
|
9372
|
+
for (let i = 1; i < posCount - 1; i++) {
|
|
9373
|
+
positions[i] = positions[i - 1] - intervals
|
|
9374
|
+
}
|
|
9375
|
+
|
|
9376
|
+
positions.push(6) // First coord is always 6
|
|
9377
|
+
|
|
9378
|
+
return positions.reverse()
|
|
9379
|
+
}
|
|
9380
|
+
|
|
9381
|
+
/**
|
|
9382
|
+
* Returns an array containing the positions of each alignment pattern.
|
|
9383
|
+
* Each array's element represent the center point of the pattern as (x, y) coordinates
|
|
9384
|
+
*
|
|
9385
|
+
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
|
|
9386
|
+
* and filtering out the items that overlaps with finder pattern
|
|
9387
|
+
*
|
|
9388
|
+
* @example
|
|
9389
|
+
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
|
|
9390
|
+
* The alignment patterns, therefore, are to be centered on (row, column)
|
|
9391
|
+
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
|
|
9392
|
+
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
|
|
9393
|
+
* and are not therefore used for alignment patterns.
|
|
9394
|
+
*
|
|
9395
|
+
* let pos = getPositions(7)
|
|
9396
|
+
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
|
|
9397
|
+
*
|
|
9398
|
+
* @param {Number} version QR Code version
|
|
9399
|
+
* @return {Array} Array of coordinates
|
|
9400
|
+
*/
|
|
9401
|
+
exports.getPositions = function getPositions (version) {
|
|
9402
|
+
const coords = []
|
|
9403
|
+
const pos = exports.getRowColCoords(version)
|
|
9404
|
+
const posLength = pos.length
|
|
9405
|
+
|
|
9406
|
+
for (let i = 0; i < posLength; i++) {
|
|
9407
|
+
for (let j = 0; j < posLength; j++) {
|
|
9408
|
+
// Skip if position is occupied by finder patterns
|
|
9409
|
+
if ((i === 0 && j === 0) || // top-left
|
|
9410
|
+
(i === 0 && j === posLength - 1) || // bottom-left
|
|
9411
|
+
(i === posLength - 1 && j === 0)) { // top-right
|
|
9412
|
+
continue
|
|
9413
|
+
}
|
|
9414
|
+
|
|
9415
|
+
coords.push([pos[i], pos[j]])
|
|
9416
|
+
}
|
|
9417
|
+
}
|
|
9418
|
+
|
|
9419
|
+
return coords
|
|
9420
|
+
}
|
|
9421
|
+
|
|
9422
|
+
|
|
7479
9423
|
/***/ },
|
|
7480
9424
|
|
|
7481
9425
|
/***/ 6468
|
|
@@ -7795,6 +9739,94 @@ module.exports = function (object, key, method) {
|
|
|
7795
9739
|
};
|
|
7796
9740
|
|
|
7797
9741
|
|
|
9742
|
+
/***/ },
|
|
9743
|
+
|
|
9744
|
+
/***/ 6756
|
|
9745
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
9746
|
+
|
|
9747
|
+
const Utils = __webpack_require__(2726)
|
|
9748
|
+
|
|
9749
|
+
function getColorAttrib (color, attrib) {
|
|
9750
|
+
const alpha = color.a / 255
|
|
9751
|
+
const str = attrib + '="' + color.hex + '"'
|
|
9752
|
+
|
|
9753
|
+
return alpha < 1
|
|
9754
|
+
? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"'
|
|
9755
|
+
: str
|
|
9756
|
+
}
|
|
9757
|
+
|
|
9758
|
+
function svgCmd (cmd, x, y) {
|
|
9759
|
+
let str = cmd + x
|
|
9760
|
+
if (typeof y !== 'undefined') str += ' ' + y
|
|
9761
|
+
|
|
9762
|
+
return str
|
|
9763
|
+
}
|
|
9764
|
+
|
|
9765
|
+
function qrToPath (data, size, margin) {
|
|
9766
|
+
let path = ''
|
|
9767
|
+
let moveBy = 0
|
|
9768
|
+
let newRow = false
|
|
9769
|
+
let lineLength = 0
|
|
9770
|
+
|
|
9771
|
+
for (let i = 0; i < data.length; i++) {
|
|
9772
|
+
const col = Math.floor(i % size)
|
|
9773
|
+
const row = Math.floor(i / size)
|
|
9774
|
+
|
|
9775
|
+
if (!col && !newRow) newRow = true
|
|
9776
|
+
|
|
9777
|
+
if (data[i]) {
|
|
9778
|
+
lineLength++
|
|
9779
|
+
|
|
9780
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
9781
|
+
path += newRow
|
|
9782
|
+
? svgCmd('M', col + margin, 0.5 + row + margin)
|
|
9783
|
+
: svgCmd('m', moveBy, 0)
|
|
9784
|
+
|
|
9785
|
+
moveBy = 0
|
|
9786
|
+
newRow = false
|
|
9787
|
+
}
|
|
9788
|
+
|
|
9789
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
9790
|
+
path += svgCmd('h', lineLength)
|
|
9791
|
+
lineLength = 0
|
|
9792
|
+
}
|
|
9793
|
+
} else {
|
|
9794
|
+
moveBy++
|
|
9795
|
+
}
|
|
9796
|
+
}
|
|
9797
|
+
|
|
9798
|
+
return path
|
|
9799
|
+
}
|
|
9800
|
+
|
|
9801
|
+
exports.render = function render (qrData, options, cb) {
|
|
9802
|
+
const opts = Utils.getOptions(options)
|
|
9803
|
+
const size = qrData.modules.size
|
|
9804
|
+
const data = qrData.modules.data
|
|
9805
|
+
const qrcodesize = size + opts.margin * 2
|
|
9806
|
+
|
|
9807
|
+
const bg = !opts.color.light.a
|
|
9808
|
+
? ''
|
|
9809
|
+
: '<path ' + getColorAttrib(opts.color.light, 'fill') +
|
|
9810
|
+
' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>'
|
|
9811
|
+
|
|
9812
|
+
const path =
|
|
9813
|
+
'<path ' + getColorAttrib(opts.color.dark, 'stroke') +
|
|
9814
|
+
' d="' + qrToPath(data, size, opts.margin) + '"/>'
|
|
9815
|
+
|
|
9816
|
+
const viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"'
|
|
9817
|
+
|
|
9818
|
+
const width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" '
|
|
9819
|
+
|
|
9820
|
+
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n'
|
|
9821
|
+
|
|
9822
|
+
if (typeof cb === 'function') {
|
|
9823
|
+
cb(null, svgTag)
|
|
9824
|
+
}
|
|
9825
|
+
|
|
9826
|
+
return svgTag
|
|
9827
|
+
}
|
|
9828
|
+
|
|
9829
|
+
|
|
7798
9830
|
/***/ },
|
|
7799
9831
|
|
|
7800
9832
|
/***/ 6761
|
|
@@ -8165,6 +10197,76 @@ module.exports = function (O, key, value, options) {
|
|
|
8165
10197
|
};
|
|
8166
10198
|
|
|
8167
10199
|
|
|
10200
|
+
/***/ },
|
|
10201
|
+
|
|
10202
|
+
/***/ 6886
|
|
10203
|
+
(__unused_webpack_module, exports) {
|
|
10204
|
+
|
|
10205
|
+
let toSJISFunction
|
|
10206
|
+
const CODEWORDS_COUNT = [
|
|
10207
|
+
0, // Not used
|
|
10208
|
+
26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
|
|
10209
|
+
404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
|
|
10210
|
+
1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
|
|
10211
|
+
2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
|
|
10212
|
+
]
|
|
10213
|
+
|
|
10214
|
+
/**
|
|
10215
|
+
* Returns the QR Code size for the specified version
|
|
10216
|
+
*
|
|
10217
|
+
* @param {Number} version QR Code version
|
|
10218
|
+
* @return {Number} size of QR code
|
|
10219
|
+
*/
|
|
10220
|
+
exports.getSymbolSize = function getSymbolSize (version) {
|
|
10221
|
+
if (!version) throw new Error('"version" cannot be null or undefined')
|
|
10222
|
+
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
|
|
10223
|
+
return version * 4 + 17
|
|
10224
|
+
}
|
|
10225
|
+
|
|
10226
|
+
/**
|
|
10227
|
+
* Returns the total number of codewords used to store data and EC information.
|
|
10228
|
+
*
|
|
10229
|
+
* @param {Number} version QR Code version
|
|
10230
|
+
* @return {Number} Data length in bits
|
|
10231
|
+
*/
|
|
10232
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
|
|
10233
|
+
return CODEWORDS_COUNT[version]
|
|
10234
|
+
}
|
|
10235
|
+
|
|
10236
|
+
/**
|
|
10237
|
+
* Encode data with Bose-Chaudhuri-Hocquenghem
|
|
10238
|
+
*
|
|
10239
|
+
* @param {Number} data Value to encode
|
|
10240
|
+
* @return {Number} Encoded value
|
|
10241
|
+
*/
|
|
10242
|
+
exports.getBCHDigit = function (data) {
|
|
10243
|
+
let digit = 0
|
|
10244
|
+
|
|
10245
|
+
while (data !== 0) {
|
|
10246
|
+
digit++
|
|
10247
|
+
data >>>= 1
|
|
10248
|
+
}
|
|
10249
|
+
|
|
10250
|
+
return digit
|
|
10251
|
+
}
|
|
10252
|
+
|
|
10253
|
+
exports.setToSJISFunction = function setToSJISFunction (f) {
|
|
10254
|
+
if (typeof f !== 'function') {
|
|
10255
|
+
throw new Error('"toSJISFunc" is not a valid function.')
|
|
10256
|
+
}
|
|
10257
|
+
|
|
10258
|
+
toSJISFunction = f
|
|
10259
|
+
}
|
|
10260
|
+
|
|
10261
|
+
exports.isKanjiModeEnabled = function () {
|
|
10262
|
+
return typeof toSJISFunction !== 'undefined'
|
|
10263
|
+
}
|
|
10264
|
+
|
|
10265
|
+
exports.toSJIS = function toSJIS (kanji) {
|
|
10266
|
+
return toSJISFunction(kanji)
|
|
10267
|
+
}
|
|
10268
|
+
|
|
10269
|
+
|
|
8168
10270
|
/***/ },
|
|
8169
10271
|
|
|
8170
10272
|
/***/ 6918
|
|
@@ -8659,6 +10761,44 @@ module.exports = NATIVE_SYMBOL &&
|
|
|
8659
10761
|
typeof Symbol.iterator == 'symbol';
|
|
8660
10762
|
|
|
8661
10763
|
|
|
10764
|
+
/***/ },
|
|
10765
|
+
|
|
10766
|
+
/***/ 7044
|
|
10767
|
+
(__unused_webpack_module, exports) {
|
|
10768
|
+
|
|
10769
|
+
const numeric = '[0-9]+'
|
|
10770
|
+
const alphanumeric = '[A-Z $%*+\\-./:]+'
|
|
10771
|
+
let kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
|
|
10772
|
+
'[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
|
|
10773
|
+
'[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
|
|
10774
|
+
'[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+'
|
|
10775
|
+
kanji = kanji.replace(/u/g, '\\u')
|
|
10776
|
+
|
|
10777
|
+
const byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+'
|
|
10778
|
+
|
|
10779
|
+
exports.KANJI = new RegExp(kanji, 'g')
|
|
10780
|
+
exports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g')
|
|
10781
|
+
exports.BYTE = new RegExp(byte, 'g')
|
|
10782
|
+
exports.NUMERIC = new RegExp(numeric, 'g')
|
|
10783
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')
|
|
10784
|
+
|
|
10785
|
+
const TEST_KANJI = new RegExp('^' + kanji + '$')
|
|
10786
|
+
const TEST_NUMERIC = new RegExp('^' + numeric + '$')
|
|
10787
|
+
const TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$')
|
|
10788
|
+
|
|
10789
|
+
exports.testKanji = function testKanji (str) {
|
|
10790
|
+
return TEST_KANJI.test(str)
|
|
10791
|
+
}
|
|
10792
|
+
|
|
10793
|
+
exports.testNumeric = function testNumeric (str) {
|
|
10794
|
+
return TEST_NUMERIC.test(str)
|
|
10795
|
+
}
|
|
10796
|
+
|
|
10797
|
+
exports.testAlphanumeric = function testAlphanumeric (str) {
|
|
10798
|
+
return TEST_ALPHANUMERIC.test(str)
|
|
10799
|
+
}
|
|
10800
|
+
|
|
10801
|
+
|
|
8662
10802
|
/***/ },
|
|
8663
10803
|
|
|
8664
10804
|
/***/ 7055
|
|
@@ -9022,6 +11162,148 @@ $({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
|
|
|
9022
11162
|
});
|
|
9023
11163
|
|
|
9024
11164
|
|
|
11165
|
+
/***/ },
|
|
11166
|
+
|
|
11167
|
+
/***/ 7518
|
|
11168
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
11169
|
+
|
|
11170
|
+
const ECLevel = __webpack_require__(9953)
|
|
11171
|
+
|
|
11172
|
+
const EC_BLOCKS_TABLE = [
|
|
11173
|
+
// L M Q H
|
|
11174
|
+
1, 1, 1, 1,
|
|
11175
|
+
1, 1, 1, 1,
|
|
11176
|
+
1, 1, 2, 2,
|
|
11177
|
+
1, 2, 2, 4,
|
|
11178
|
+
1, 2, 4, 4,
|
|
11179
|
+
2, 4, 4, 4,
|
|
11180
|
+
2, 4, 6, 5,
|
|
11181
|
+
2, 4, 6, 6,
|
|
11182
|
+
2, 5, 8, 8,
|
|
11183
|
+
4, 5, 8, 8,
|
|
11184
|
+
4, 5, 8, 11,
|
|
11185
|
+
4, 8, 10, 11,
|
|
11186
|
+
4, 9, 12, 16,
|
|
11187
|
+
4, 9, 16, 16,
|
|
11188
|
+
6, 10, 12, 18,
|
|
11189
|
+
6, 10, 17, 16,
|
|
11190
|
+
6, 11, 16, 19,
|
|
11191
|
+
6, 13, 18, 21,
|
|
11192
|
+
7, 14, 21, 25,
|
|
11193
|
+
8, 16, 20, 25,
|
|
11194
|
+
8, 17, 23, 25,
|
|
11195
|
+
9, 17, 23, 34,
|
|
11196
|
+
9, 18, 25, 30,
|
|
11197
|
+
10, 20, 27, 32,
|
|
11198
|
+
12, 21, 29, 35,
|
|
11199
|
+
12, 23, 34, 37,
|
|
11200
|
+
12, 25, 34, 40,
|
|
11201
|
+
13, 26, 35, 42,
|
|
11202
|
+
14, 28, 38, 45,
|
|
11203
|
+
15, 29, 40, 48,
|
|
11204
|
+
16, 31, 43, 51,
|
|
11205
|
+
17, 33, 45, 54,
|
|
11206
|
+
18, 35, 48, 57,
|
|
11207
|
+
19, 37, 51, 60,
|
|
11208
|
+
19, 38, 53, 63,
|
|
11209
|
+
20, 40, 56, 66,
|
|
11210
|
+
21, 43, 59, 70,
|
|
11211
|
+
22, 45, 62, 74,
|
|
11212
|
+
24, 47, 65, 77,
|
|
11213
|
+
25, 49, 68, 81
|
|
11214
|
+
]
|
|
11215
|
+
|
|
11216
|
+
const EC_CODEWORDS_TABLE = [
|
|
11217
|
+
// L M Q H
|
|
11218
|
+
7, 10, 13, 17,
|
|
11219
|
+
10, 16, 22, 28,
|
|
11220
|
+
15, 26, 36, 44,
|
|
11221
|
+
20, 36, 52, 64,
|
|
11222
|
+
26, 48, 72, 88,
|
|
11223
|
+
36, 64, 96, 112,
|
|
11224
|
+
40, 72, 108, 130,
|
|
11225
|
+
48, 88, 132, 156,
|
|
11226
|
+
60, 110, 160, 192,
|
|
11227
|
+
72, 130, 192, 224,
|
|
11228
|
+
80, 150, 224, 264,
|
|
11229
|
+
96, 176, 260, 308,
|
|
11230
|
+
104, 198, 288, 352,
|
|
11231
|
+
120, 216, 320, 384,
|
|
11232
|
+
132, 240, 360, 432,
|
|
11233
|
+
144, 280, 408, 480,
|
|
11234
|
+
168, 308, 448, 532,
|
|
11235
|
+
180, 338, 504, 588,
|
|
11236
|
+
196, 364, 546, 650,
|
|
11237
|
+
224, 416, 600, 700,
|
|
11238
|
+
224, 442, 644, 750,
|
|
11239
|
+
252, 476, 690, 816,
|
|
11240
|
+
270, 504, 750, 900,
|
|
11241
|
+
300, 560, 810, 960,
|
|
11242
|
+
312, 588, 870, 1050,
|
|
11243
|
+
336, 644, 952, 1110,
|
|
11244
|
+
360, 700, 1020, 1200,
|
|
11245
|
+
390, 728, 1050, 1260,
|
|
11246
|
+
420, 784, 1140, 1350,
|
|
11247
|
+
450, 812, 1200, 1440,
|
|
11248
|
+
480, 868, 1290, 1530,
|
|
11249
|
+
510, 924, 1350, 1620,
|
|
11250
|
+
540, 980, 1440, 1710,
|
|
11251
|
+
570, 1036, 1530, 1800,
|
|
11252
|
+
570, 1064, 1590, 1890,
|
|
11253
|
+
600, 1120, 1680, 1980,
|
|
11254
|
+
630, 1204, 1770, 2100,
|
|
11255
|
+
660, 1260, 1860, 2220,
|
|
11256
|
+
720, 1316, 1950, 2310,
|
|
11257
|
+
750, 1372, 2040, 2430
|
|
11258
|
+
]
|
|
11259
|
+
|
|
11260
|
+
/**
|
|
11261
|
+
* Returns the number of error correction block that the QR Code should contain
|
|
11262
|
+
* for the specified version and error correction level.
|
|
11263
|
+
*
|
|
11264
|
+
* @param {Number} version QR Code version
|
|
11265
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11266
|
+
* @return {Number} Number of error correction blocks
|
|
11267
|
+
*/
|
|
11268
|
+
exports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
|
|
11269
|
+
switch (errorCorrectionLevel) {
|
|
11270
|
+
case ECLevel.L:
|
|
11271
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
|
|
11272
|
+
case ECLevel.M:
|
|
11273
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
|
|
11274
|
+
case ECLevel.Q:
|
|
11275
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
|
|
11276
|
+
case ECLevel.H:
|
|
11277
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
|
|
11278
|
+
default:
|
|
11279
|
+
return undefined
|
|
11280
|
+
}
|
|
11281
|
+
}
|
|
11282
|
+
|
|
11283
|
+
/**
|
|
11284
|
+
* Returns the number of error correction codewords to use for the specified
|
|
11285
|
+
* version and error correction level.
|
|
11286
|
+
*
|
|
11287
|
+
* @param {Number} version QR Code version
|
|
11288
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11289
|
+
* @return {Number} Number of error correction codewords
|
|
11290
|
+
*/
|
|
11291
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
|
|
11292
|
+
switch (errorCorrectionLevel) {
|
|
11293
|
+
case ECLevel.L:
|
|
11294
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
|
|
11295
|
+
case ECLevel.M:
|
|
11296
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
|
|
11297
|
+
case ECLevel.Q:
|
|
11298
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
|
|
11299
|
+
case ECLevel.H:
|
|
11300
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
|
|
11301
|
+
default:
|
|
11302
|
+
return undefined
|
|
11303
|
+
}
|
|
11304
|
+
}
|
|
11305
|
+
|
|
11306
|
+
|
|
9025
11307
|
/***/ },
|
|
9026
11308
|
|
|
9027
11309
|
/***/ 7522
|
|
@@ -9092,6 +11374,89 @@ module.exports = INCORRECT_TO_STRING ? function toString() {
|
|
|
9092
11374
|
} : nativeErrorToString;
|
|
9093
11375
|
|
|
9094
11376
|
|
|
11377
|
+
/***/ },
|
|
11378
|
+
|
|
11379
|
+
/***/ 7583
|
|
11380
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
11381
|
+
|
|
11382
|
+
|
|
11383
|
+
const canPromise = __webpack_require__(1333)
|
|
11384
|
+
|
|
11385
|
+
const QRCode = __webpack_require__(157)
|
|
11386
|
+
const CanvasRenderer = __webpack_require__(7899)
|
|
11387
|
+
const SvgRenderer = __webpack_require__(6756)
|
|
11388
|
+
|
|
11389
|
+
function renderCanvas (renderFunc, canvas, text, opts, cb) {
|
|
11390
|
+
const args = [].slice.call(arguments, 1)
|
|
11391
|
+
const argsNum = args.length
|
|
11392
|
+
const isLastArgCb = typeof args[argsNum - 1] === 'function'
|
|
11393
|
+
|
|
11394
|
+
if (!isLastArgCb && !canPromise()) {
|
|
11395
|
+
throw new Error('Callback required as last argument')
|
|
11396
|
+
}
|
|
11397
|
+
|
|
11398
|
+
if (isLastArgCb) {
|
|
11399
|
+
if (argsNum < 2) {
|
|
11400
|
+
throw new Error('Too few arguments provided')
|
|
11401
|
+
}
|
|
11402
|
+
|
|
11403
|
+
if (argsNum === 2) {
|
|
11404
|
+
cb = text
|
|
11405
|
+
text = canvas
|
|
11406
|
+
canvas = opts = undefined
|
|
11407
|
+
} else if (argsNum === 3) {
|
|
11408
|
+
if (canvas.getContext && typeof cb === 'undefined') {
|
|
11409
|
+
cb = opts
|
|
11410
|
+
opts = undefined
|
|
11411
|
+
} else {
|
|
11412
|
+
cb = opts
|
|
11413
|
+
opts = text
|
|
11414
|
+
text = canvas
|
|
11415
|
+
canvas = undefined
|
|
11416
|
+
}
|
|
11417
|
+
}
|
|
11418
|
+
} else {
|
|
11419
|
+
if (argsNum < 1) {
|
|
11420
|
+
throw new Error('Too few arguments provided')
|
|
11421
|
+
}
|
|
11422
|
+
|
|
11423
|
+
if (argsNum === 1) {
|
|
11424
|
+
text = canvas
|
|
11425
|
+
canvas = opts = undefined
|
|
11426
|
+
} else if (argsNum === 2 && !canvas.getContext) {
|
|
11427
|
+
opts = text
|
|
11428
|
+
text = canvas
|
|
11429
|
+
canvas = undefined
|
|
11430
|
+
}
|
|
11431
|
+
|
|
11432
|
+
return new Promise(function (resolve, reject) {
|
|
11433
|
+
try {
|
|
11434
|
+
const data = QRCode.create(text, opts)
|
|
11435
|
+
resolve(renderFunc(data, canvas, opts))
|
|
11436
|
+
} catch (e) {
|
|
11437
|
+
reject(e)
|
|
11438
|
+
}
|
|
11439
|
+
})
|
|
11440
|
+
}
|
|
11441
|
+
|
|
11442
|
+
try {
|
|
11443
|
+
const data = QRCode.create(text, opts)
|
|
11444
|
+
cb(null, renderFunc(data, canvas, opts))
|
|
11445
|
+
} catch (e) {
|
|
11446
|
+
cb(e)
|
|
11447
|
+
}
|
|
11448
|
+
}
|
|
11449
|
+
|
|
11450
|
+
exports.create = QRCode.create
|
|
11451
|
+
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render)
|
|
11452
|
+
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)
|
|
11453
|
+
|
|
11454
|
+
// only svg for now.
|
|
11455
|
+
exports.toString = renderCanvas.bind(null, function (data, _, opts) {
|
|
11456
|
+
return SvgRenderer.render(data, opts)
|
|
11457
|
+
})
|
|
11458
|
+
|
|
11459
|
+
|
|
9095
11460
|
/***/ },
|
|
9096
11461
|
|
|
9097
11462
|
/***/ 7584
|
|
@@ -9445,6 +11810,35 @@ module.exports = function (namespace, method) {
|
|
|
9445
11810
|
};
|
|
9446
11811
|
|
|
9447
11812
|
|
|
11813
|
+
/***/ },
|
|
11814
|
+
|
|
11815
|
+
/***/ 7756
|
|
11816
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
11817
|
+
|
|
11818
|
+
const getSymbolSize = (__webpack_require__(6886).getSymbolSize)
|
|
11819
|
+
const FINDER_PATTERN_SIZE = 7
|
|
11820
|
+
|
|
11821
|
+
/**
|
|
11822
|
+
* Returns an array containing the positions of each finder pattern.
|
|
11823
|
+
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
|
|
11824
|
+
*
|
|
11825
|
+
* @param {Number} version QR Code version
|
|
11826
|
+
* @return {Array} Array of coordinates
|
|
11827
|
+
*/
|
|
11828
|
+
exports.getPositions = function getPositions (version) {
|
|
11829
|
+
const size = getSymbolSize(version)
|
|
11830
|
+
|
|
11831
|
+
return [
|
|
11832
|
+
// top-left
|
|
11833
|
+
[0, 0],
|
|
11834
|
+
// top-right
|
|
11835
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
11836
|
+
// bottom-left
|
|
11837
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
11838
|
+
]
|
|
11839
|
+
}
|
|
11840
|
+
|
|
11841
|
+
|
|
9448
11842
|
/***/ },
|
|
9449
11843
|
|
|
9450
11844
|
/***/ 7763
|
|
@@ -9583,6 +11977,76 @@ var userAgent = __webpack_require__(2839);
|
|
|
9583
11977
|
module.exports = /web0s(?!.*chrome)/i.test(userAgent);
|
|
9584
11978
|
|
|
9585
11979
|
|
|
11980
|
+
/***/ },
|
|
11981
|
+
|
|
11982
|
+
/***/ 7899
|
|
11983
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
11984
|
+
|
|
11985
|
+
const Utils = __webpack_require__(2726)
|
|
11986
|
+
|
|
11987
|
+
function clearCanvas (ctx, canvas, size) {
|
|
11988
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
11989
|
+
|
|
11990
|
+
if (!canvas.style) canvas.style = {}
|
|
11991
|
+
canvas.height = size
|
|
11992
|
+
canvas.width = size
|
|
11993
|
+
canvas.style.height = size + 'px'
|
|
11994
|
+
canvas.style.width = size + 'px'
|
|
11995
|
+
}
|
|
11996
|
+
|
|
11997
|
+
function getCanvasElement () {
|
|
11998
|
+
try {
|
|
11999
|
+
return document.createElement('canvas')
|
|
12000
|
+
} catch (e) {
|
|
12001
|
+
throw new Error('You need to specify a canvas element')
|
|
12002
|
+
}
|
|
12003
|
+
}
|
|
12004
|
+
|
|
12005
|
+
exports.render = function render (qrData, canvas, options) {
|
|
12006
|
+
let opts = options
|
|
12007
|
+
let canvasEl = canvas
|
|
12008
|
+
|
|
12009
|
+
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
|
|
12010
|
+
opts = canvas
|
|
12011
|
+
canvas = undefined
|
|
12012
|
+
}
|
|
12013
|
+
|
|
12014
|
+
if (!canvas) {
|
|
12015
|
+
canvasEl = getCanvasElement()
|
|
12016
|
+
}
|
|
12017
|
+
|
|
12018
|
+
opts = Utils.getOptions(opts)
|
|
12019
|
+
const size = Utils.getImageWidth(qrData.modules.size, opts)
|
|
12020
|
+
|
|
12021
|
+
const ctx = canvasEl.getContext('2d')
|
|
12022
|
+
const image = ctx.createImageData(size, size)
|
|
12023
|
+
Utils.qrToImageData(image.data, qrData, opts)
|
|
12024
|
+
|
|
12025
|
+
clearCanvas(ctx, canvasEl, size)
|
|
12026
|
+
ctx.putImageData(image, 0, 0)
|
|
12027
|
+
|
|
12028
|
+
return canvasEl
|
|
12029
|
+
}
|
|
12030
|
+
|
|
12031
|
+
exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
|
|
12032
|
+
let opts = options
|
|
12033
|
+
|
|
12034
|
+
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
|
|
12035
|
+
opts = canvas
|
|
12036
|
+
canvas = undefined
|
|
12037
|
+
}
|
|
12038
|
+
|
|
12039
|
+
if (!opts) opts = {}
|
|
12040
|
+
|
|
12041
|
+
const canvasEl = exports.render(qrData, canvas, opts)
|
|
12042
|
+
|
|
12043
|
+
const type = opts.type || 'image/png'
|
|
12044
|
+
const rendererOpts = opts.rendererOpts || {}
|
|
12045
|
+
|
|
12046
|
+
return canvasEl.toDataURL(type, rendererOpts.quality)
|
|
12047
|
+
}
|
|
12048
|
+
|
|
12049
|
+
|
|
9586
12050
|
/***/ },
|
|
9587
12051
|
|
|
9588
12052
|
/***/ 7916
|
|
@@ -10706,6 +13170,78 @@ module.exports = fails(function () {
|
|
|
10706
13170
|
});
|
|
10707
13171
|
|
|
10708
13172
|
|
|
13173
|
+
/***/ },
|
|
13174
|
+
|
|
13175
|
+
/***/ 8820
|
|
13176
|
+
(module) {
|
|
13177
|
+
|
|
13178
|
+
/**
|
|
13179
|
+
* Helper class to handle QR Code symbol modules
|
|
13180
|
+
*
|
|
13181
|
+
* @param {Number} size Symbol size
|
|
13182
|
+
*/
|
|
13183
|
+
function BitMatrix (size) {
|
|
13184
|
+
if (!size || size < 1) {
|
|
13185
|
+
throw new Error('BitMatrix size must be defined and greater than 0')
|
|
13186
|
+
}
|
|
13187
|
+
|
|
13188
|
+
this.size = size
|
|
13189
|
+
this.data = new Uint8Array(size * size)
|
|
13190
|
+
this.reservedBit = new Uint8Array(size * size)
|
|
13191
|
+
}
|
|
13192
|
+
|
|
13193
|
+
/**
|
|
13194
|
+
* Set bit value at specified location
|
|
13195
|
+
* If reserved flag is set, this bit will be ignored during masking process
|
|
13196
|
+
*
|
|
13197
|
+
* @param {Number} row
|
|
13198
|
+
* @param {Number} col
|
|
13199
|
+
* @param {Boolean} value
|
|
13200
|
+
* @param {Boolean} reserved
|
|
13201
|
+
*/
|
|
13202
|
+
BitMatrix.prototype.set = function (row, col, value, reserved) {
|
|
13203
|
+
const index = row * this.size + col
|
|
13204
|
+
this.data[index] = value
|
|
13205
|
+
if (reserved) this.reservedBit[index] = true
|
|
13206
|
+
}
|
|
13207
|
+
|
|
13208
|
+
/**
|
|
13209
|
+
* Returns bit value at specified location
|
|
13210
|
+
*
|
|
13211
|
+
* @param {Number} row
|
|
13212
|
+
* @param {Number} col
|
|
13213
|
+
* @return {Boolean}
|
|
13214
|
+
*/
|
|
13215
|
+
BitMatrix.prototype.get = function (row, col) {
|
|
13216
|
+
return this.data[row * this.size + col]
|
|
13217
|
+
}
|
|
13218
|
+
|
|
13219
|
+
/**
|
|
13220
|
+
* Applies xor operator at specified location
|
|
13221
|
+
* (used during masking process)
|
|
13222
|
+
*
|
|
13223
|
+
* @param {Number} row
|
|
13224
|
+
* @param {Number} col
|
|
13225
|
+
* @param {Boolean} value
|
|
13226
|
+
*/
|
|
13227
|
+
BitMatrix.prototype.xor = function (row, col, value) {
|
|
13228
|
+
this.data[row * this.size + col] ^= value
|
|
13229
|
+
}
|
|
13230
|
+
|
|
13231
|
+
/**
|
|
13232
|
+
* Check if bit at specified location is reserved
|
|
13233
|
+
*
|
|
13234
|
+
* @param {Number} row
|
|
13235
|
+
* @param {Number} col
|
|
13236
|
+
* @return {Boolean}
|
|
13237
|
+
*/
|
|
13238
|
+
BitMatrix.prototype.isReserved = function (row, col) {
|
|
13239
|
+
return this.reservedBit[row * this.size + col]
|
|
13240
|
+
}
|
|
13241
|
+
|
|
13242
|
+
module.exports = BitMatrix
|
|
13243
|
+
|
|
13244
|
+
|
|
10709
13245
|
/***/ },
|
|
10710
13246
|
|
|
10711
13247
|
/***/ 8980
|
|
@@ -11144,638 +13680,6 @@ $({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, {
|
|
|
11144
13680
|
});
|
|
11145
13681
|
|
|
11146
13682
|
|
|
11147
|
-
/***/ },
|
|
11148
|
-
|
|
11149
|
-
/***/ 9118
|
|
11150
|
-
(module) {
|
|
11151
|
-
|
|
11152
|
-
/**
|
|
11153
|
-
* @fileoverview
|
|
11154
|
-
* - Using the 'QRCode for Javascript library'
|
|
11155
|
-
* - Fixed dataset of 'QRCode for Javascript library' for support full-spec.
|
|
11156
|
-
* - this library has no dependencies.
|
|
11157
|
-
*
|
|
11158
|
-
* @author davidshimjs
|
|
11159
|
-
* @see <a href="http://www.d-project.com/" target="_blank">http://www.d-project.com/</a>
|
|
11160
|
-
* @see <a href="http://jeromeetienne.github.com/jquery-qrcode/" target="_blank">http://jeromeetienne.github.com/jquery-qrcode/</a>
|
|
11161
|
-
*/
|
|
11162
|
-
var QRCode;
|
|
11163
|
-
|
|
11164
|
-
(function (root, factory) {
|
|
11165
|
-
|
|
11166
|
-
/* CommonJS */
|
|
11167
|
-
if (true) module.exports = factory()
|
|
11168
|
-
|
|
11169
|
-
/* AMD module */
|
|
11170
|
-
else // removed by dead control flow
|
|
11171
|
-
{}
|
|
11172
|
-
|
|
11173
|
-
}(this, function () { //---------------------------------------------------------------------
|
|
11174
|
-
// QRCode for JavaScript
|
|
11175
|
-
//
|
|
11176
|
-
// Copyright (c) 2009 Kazuhiko Arase
|
|
11177
|
-
//
|
|
11178
|
-
// URL: http://www.d-project.com/
|
|
11179
|
-
//
|
|
11180
|
-
// Licensed under the MIT license:
|
|
11181
|
-
// http://www.opensource.org/licenses/mit-license.php
|
|
11182
|
-
//
|
|
11183
|
-
// The word "QR Code" is registered trademark of
|
|
11184
|
-
// DENSO WAVE INCORPORATED
|
|
11185
|
-
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
11186
|
-
//
|
|
11187
|
-
//---------------------------------------------------------------------
|
|
11188
|
-
function QR8bitByte(data) {
|
|
11189
|
-
this.mode = QRMode.MODE_8BIT_BYTE;
|
|
11190
|
-
this.data = data;
|
|
11191
|
-
this.parsedData = [];
|
|
11192
|
-
|
|
11193
|
-
// Added to support UTF-8 Characters
|
|
11194
|
-
for (var i = 0, l = this.data.length; i < l; i++) {
|
|
11195
|
-
var byteArray = [];
|
|
11196
|
-
var code = this.data.charCodeAt(i);
|
|
11197
|
-
|
|
11198
|
-
if (code > 0x10000) {
|
|
11199
|
-
byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);
|
|
11200
|
-
byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);
|
|
11201
|
-
byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);
|
|
11202
|
-
byteArray[3] = 0x80 | (code & 0x3F);
|
|
11203
|
-
} else if (code > 0x800) {
|
|
11204
|
-
byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);
|
|
11205
|
-
byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);
|
|
11206
|
-
byteArray[2] = 0x80 | (code & 0x3F);
|
|
11207
|
-
} else if (code > 0x80) {
|
|
11208
|
-
byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);
|
|
11209
|
-
byteArray[1] = 0x80 | (code & 0x3F);
|
|
11210
|
-
} else {
|
|
11211
|
-
byteArray[0] = code;
|
|
11212
|
-
}
|
|
11213
|
-
|
|
11214
|
-
this.parsedData.push(byteArray);
|
|
11215
|
-
}
|
|
11216
|
-
|
|
11217
|
-
this.parsedData = Array.prototype.concat.apply([], this.parsedData);
|
|
11218
|
-
|
|
11219
|
-
if (this.parsedData.length != this.data.length) {
|
|
11220
|
-
this.parsedData.unshift(191);
|
|
11221
|
-
this.parsedData.unshift(187);
|
|
11222
|
-
this.parsedData.unshift(239);
|
|
11223
|
-
}
|
|
11224
|
-
}
|
|
11225
|
-
|
|
11226
|
-
QR8bitByte.prototype = {
|
|
11227
|
-
getLength: function (buffer) {
|
|
11228
|
-
return this.parsedData.length;
|
|
11229
|
-
},
|
|
11230
|
-
write: function (buffer) {
|
|
11231
|
-
for (var i = 0, l = this.parsedData.length; i < l; i++) {
|
|
11232
|
-
buffer.put(this.parsedData[i], 8);
|
|
11233
|
-
}
|
|
11234
|
-
}
|
|
11235
|
-
};
|
|
11236
|
-
|
|
11237
|
-
function QRCodeModel(typeNumber, errorCorrectLevel) {
|
|
11238
|
-
this.typeNumber = typeNumber;
|
|
11239
|
-
this.errorCorrectLevel = errorCorrectLevel;
|
|
11240
|
-
this.modules = null;
|
|
11241
|
-
this.moduleCount = 0;
|
|
11242
|
-
this.dataCache = null;
|
|
11243
|
-
this.dataList = [];
|
|
11244
|
-
}
|
|
11245
|
-
|
|
11246
|
-
QRCodeModel.prototype={addData:function(data){var newData=new QR8bitByte(data);this.dataList.push(newData);this.dataCache=null;},isDark:function(row,col){if(row<0||this.moduleCount<=row||col<0||this.moduleCount<=col){throw new Error(row+","+col);}
|
|
11247
|
-
return this.modules[row][col];},getModuleCount:function(){return this.moduleCount;},make:function(){this.makeImpl(false,this.getBestMaskPattern());},makeImpl:function(test,maskPattern){this.moduleCount=this.typeNumber*4+17;this.modules=new Array(this.moduleCount);for(var row=0;row<this.moduleCount;row++){this.modules[row]=new Array(this.moduleCount);for(var col=0;col<this.moduleCount;col++){this.modules[row][col]=null;}}
|
|
11248
|
-
this.setupPositionProbePattern(0,0);this.setupPositionProbePattern(this.moduleCount-7,0);this.setupPositionProbePattern(0,this.moduleCount-7);this.setupPositionAdjustPattern();this.setupTimingPattern();this.setupTypeInfo(test,maskPattern);if(this.typeNumber>=7){this.setupTypeNumber(test);}
|
|
11249
|
-
if(this.dataCache==null){this.dataCache=QRCodeModel.createData(this.typeNumber,this.errorCorrectLevel,this.dataList);}
|
|
11250
|
-
this.mapData(this.dataCache,maskPattern);},setupPositionProbePattern:function(row,col){for(var r=-1;r<=7;r++){if(row+r<=-1||this.moduleCount<=row+r)continue;for(var c=-1;c<=7;c++){if(col+c<=-1||this.moduleCount<=col+c)continue;if((0<=r&&r<=6&&(c==0||c==6))||(0<=c&&c<=6&&(r==0||r==6))||(2<=r&&r<=4&&2<=c&&c<=4)){this.modules[row+r][col+c]=true;}else{this.modules[row+r][col+c]=false;}}}},getBestMaskPattern:function(){var minLostPoint=0;var pattern=0;for(var i=0;i<8;i++){this.makeImpl(true,i);var lostPoint=QRUtil.getLostPoint(this);if(i==0||minLostPoint>lostPoint){minLostPoint=lostPoint;pattern=i;}}
|
|
11251
|
-
return pattern;},createMovieClip:function(target_mc,instance_name,depth){var qr_mc=target_mc.createEmptyMovieClip(instance_name,depth);var cs=1;this.make();for(var row=0;row<this.modules.length;row++){var y=row*cs;for(var col=0;col<this.modules[row].length;col++){var x=col*cs;var dark=this.modules[row][col];if(dark){qr_mc.beginFill(0,100);qr_mc.moveTo(x,y);qr_mc.lineTo(x+cs,y);qr_mc.lineTo(x+cs,y+cs);qr_mc.lineTo(x,y+cs);qr_mc.endFill();}}}
|
|
11252
|
-
return qr_mc;},setupTimingPattern:function(){for(var r=8;r<this.moduleCount-8;r++){if(this.modules[r][6]!=null){continue;}
|
|
11253
|
-
this.modules[r][6]=(r%2==0);}
|
|
11254
|
-
for(var c=8;c<this.moduleCount-8;c++){if(this.modules[6][c]!=null){continue;}
|
|
11255
|
-
this.modules[6][c]=(c%2==0);}},setupPositionAdjustPattern:function(){var pos=QRUtil.getPatternPosition(this.typeNumber);for(var i=0;i<pos.length;i++){for(var j=0;j<pos.length;j++){var row=pos[i];var col=pos[j];if(this.modules[row][col]!=null){continue;}
|
|
11256
|
-
for(var r=-2;r<=2;r++){for(var c=-2;c<=2;c++){if(r==-2||r==2||c==-2||c==2||(r==0&&c==0)){this.modules[row+r][col+c]=true;}else{this.modules[row+r][col+c]=false;}}}}}},setupTypeNumber:function(test){var bits=QRUtil.getBCHTypeNumber(this.typeNumber);for(var i=0;i<18;i++){var mod=(!test&&((bits>>i)&1)==1);this.modules[Math.floor(i/3)][i%3+this.moduleCount-8-3]=mod;}
|
|
11257
|
-
for(var i=0;i<18;i++){var mod=(!test&&((bits>>i)&1)==1);this.modules[i%3+this.moduleCount-8-3][Math.floor(i/3)]=mod;}},setupTypeInfo:function(test,maskPattern){var data=(this.errorCorrectLevel<<3)|maskPattern;var bits=QRUtil.getBCHTypeInfo(data);for(var i=0;i<15;i++){var mod=(!test&&((bits>>i)&1)==1);if(i<6){this.modules[i][8]=mod;}else if(i<8){this.modules[i+1][8]=mod;}else{this.modules[this.moduleCount-15+i][8]=mod;}}
|
|
11258
|
-
for(var i=0;i<15;i++){var mod=(!test&&((bits>>i)&1)==1);if(i<8){this.modules[8][this.moduleCount-i-1]=mod;}else if(i<9){this.modules[8][15-i-1+1]=mod;}else{this.modules[8][15-i-1]=mod;}}
|
|
11259
|
-
this.modules[this.moduleCount-8][8]=(!test);},mapData:function(data,maskPattern){var inc=-1;var row=this.moduleCount-1;var bitIndex=7;var byteIndex=0;for(var col=this.moduleCount-1;col>0;col-=2){if(col==6)col--;while(true){for(var c=0;c<2;c++){if(this.modules[row][col-c]==null){var dark=false;if(byteIndex<data.length){dark=(((data[byteIndex]>>>bitIndex)&1)==1);}
|
|
11260
|
-
var mask=QRUtil.getMask(maskPattern,row,col-c);if(mask){dark=!dark;}
|
|
11261
|
-
this.modules[row][col-c]=dark;bitIndex--;if(bitIndex==-1){byteIndex++;bitIndex=7;}}}
|
|
11262
|
-
row+=inc;if(row<0||this.moduleCount<=row){row-=inc;inc=-inc;break;}}}}};QRCodeModel.PAD0=0xEC;QRCodeModel.PAD1=0x11;QRCodeModel.createData=function(typeNumber,errorCorrectLevel,dataList){var rsBlocks=QRRSBlock.getRSBlocks(typeNumber,errorCorrectLevel);var buffer=new QRBitBuffer();for(var i=0;i<dataList.length;i++){var data=dataList[i];buffer.put(data.mode,4);buffer.put(data.getLength(),QRUtil.getLengthInBits(data.mode,typeNumber));data.write(buffer);}
|
|
11263
|
-
var totalDataCount=0;for(var i=0;i<rsBlocks.length;i++){totalDataCount+=rsBlocks[i].dataCount;}
|
|
11264
|
-
if(buffer.getLengthInBits()>totalDataCount*8){throw new Error("code length overflow. ("
|
|
11265
|
-
+buffer.getLengthInBits()
|
|
11266
|
-
+">"
|
|
11267
|
-
+totalDataCount*8
|
|
11268
|
-
+")");}
|
|
11269
|
-
if(buffer.getLengthInBits()+4<=totalDataCount*8){buffer.put(0,4);}
|
|
11270
|
-
while(buffer.getLengthInBits()%8!=0){buffer.putBit(false);}
|
|
11271
|
-
while(true){if(buffer.getLengthInBits()>=totalDataCount*8){break;}
|
|
11272
|
-
buffer.put(QRCodeModel.PAD0,8);if(buffer.getLengthInBits()>=totalDataCount*8){break;}
|
|
11273
|
-
buffer.put(QRCodeModel.PAD1,8);}
|
|
11274
|
-
return QRCodeModel.createBytes(buffer,rsBlocks);};QRCodeModel.createBytes=function(buffer,rsBlocks){var offset=0;var maxDcCount=0;var maxEcCount=0;var dcdata=new Array(rsBlocks.length);var ecdata=new Array(rsBlocks.length);for(var r=0;r<rsBlocks.length;r++){var dcCount=rsBlocks[r].dataCount;var ecCount=rsBlocks[r].totalCount-dcCount;maxDcCount=Math.max(maxDcCount,dcCount);maxEcCount=Math.max(maxEcCount,ecCount);dcdata[r]=new Array(dcCount);for(var i=0;i<dcdata[r].length;i++){dcdata[r][i]=0xff&buffer.buffer[i+offset];}
|
|
11275
|
-
offset+=dcCount;var rsPoly=QRUtil.getErrorCorrectPolynomial(ecCount);var rawPoly=new QRPolynomial(dcdata[r],rsPoly.getLength()-1);var modPoly=rawPoly.mod(rsPoly);ecdata[r]=new Array(rsPoly.getLength()-1);for(var i=0;i<ecdata[r].length;i++){var modIndex=i+modPoly.getLength()-ecdata[r].length;ecdata[r][i]=(modIndex>=0)?modPoly.get(modIndex):0;}}
|
|
11276
|
-
var totalCodeCount=0;for(var i=0;i<rsBlocks.length;i++){totalCodeCount+=rsBlocks[i].totalCount;}
|
|
11277
|
-
var data=new Array(totalCodeCount);var index=0;for(var i=0;i<maxDcCount;i++){for(var r=0;r<rsBlocks.length;r++){if(i<dcdata[r].length){data[index++]=dcdata[r][i];}}}
|
|
11278
|
-
for(var i=0;i<maxEcCount;i++){for(var r=0;r<rsBlocks.length;r++){if(i<ecdata[r].length){data[index++]=ecdata[r][i];}}}
|
|
11279
|
-
return data;};var QRMode={MODE_NUMBER:1<<0,MODE_ALPHA_NUM:1<<1,MODE_8BIT_BYTE:1<<2,MODE_KANJI:1<<3};var QRErrorCorrectLevel={L:1,M:0,Q:3,H:2};var QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var QRUtil={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:(1<<10)|(1<<8)|(1<<5)|(1<<4)|(1<<2)|(1<<1)|(1<<0),G18:(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)|(1<<5)|(1<<2)|(1<<0),G15_MASK:(1<<14)|(1<<12)|(1<<10)|(1<<4)|(1<<1),getBCHTypeInfo:function(data){var d=data<<10;while(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G15)>=0){d^=(QRUtil.G15<<(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G15)));}
|
|
11280
|
-
return((data<<10)|d)^QRUtil.G15_MASK;},getBCHTypeNumber:function(data){var d=data<<12;while(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18)>=0){d^=(QRUtil.G18<<(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18)));}
|
|
11281
|
-
return(data<<12)|d;},getBCHDigit:function(data){var digit=0;while(data!=0){digit++;data>>>=1;}
|
|
11282
|
-
return digit;},getPatternPosition:function(typeNumber){return QRUtil.PATTERN_POSITION_TABLE[typeNumber-1];},getMask:function(maskPattern,i,j){switch(maskPattern){case QRMaskPattern.PATTERN000:return(i+j)%2==0;case QRMaskPattern.PATTERN001:return i%2==0;case QRMaskPattern.PATTERN010:return j%3==0;case QRMaskPattern.PATTERN011:return(i+j)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(i/2)+Math.floor(j/3))%2==0;case QRMaskPattern.PATTERN101:return(i*j)%2+(i*j)%3==0;case QRMaskPattern.PATTERN110:return((i*j)%2+(i*j)%3)%2==0;case QRMaskPattern.PATTERN111:return((i*j)%3+(i+j)%2)%2==0;default:throw new Error("bad maskPattern:"+maskPattern);}},getErrorCorrectPolynomial:function(errorCorrectLength){var a=new QRPolynomial([1],0);for(var i=0;i<errorCorrectLength;i++){a=a.multiply(new QRPolynomial([1,QRMath.gexp(i)],0));}
|
|
11283
|
-
return a;},getLengthInBits:function(mode,type){if(1<=type&&type<10){switch(mode){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:return 8;case QRMode.MODE_KANJI:return 8;default:throw new Error("mode:"+mode);}}else if(type<27){switch(mode){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw new Error("mode:"+mode);}}else if(type<41){switch(mode){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw new Error("mode:"+mode);}}else{throw new Error("type:"+type);}},getLostPoint:function(qrCode){var moduleCount=qrCode.getModuleCount();var lostPoint=0;for(var row=0;row<moduleCount;row++){for(var col=0;col<moduleCount;col++){var sameCount=0;var dark=qrCode.isDark(row,col);for(var r=-1;r<=1;r++){if(row+r<0||moduleCount<=row+r){continue;}
|
|
11284
|
-
for(var c=-1;c<=1;c++){if(col+c<0||moduleCount<=col+c){continue;}
|
|
11285
|
-
if(r==0&&c==0){continue;}
|
|
11286
|
-
if(dark==qrCode.isDark(row+r,col+c)){sameCount++;}}}
|
|
11287
|
-
if(sameCount>5){lostPoint+=(3+sameCount-5);}}}
|
|
11288
|
-
for(var row=0;row<moduleCount-1;row++){for(var col=0;col<moduleCount-1;col++){var count=0;if(qrCode.isDark(row,col))count++;if(qrCode.isDark(row+1,col))count++;if(qrCode.isDark(row,col+1))count++;if(qrCode.isDark(row+1,col+1))count++;if(count==0||count==4){lostPoint+=3;}}}
|
|
11289
|
-
for(var row=0;row<moduleCount;row++){for(var col=0;col<moduleCount-6;col++){if(qrCode.isDark(row,col)&&!qrCode.isDark(row,col+1)&&qrCode.isDark(row,col+2)&&qrCode.isDark(row,col+3)&&qrCode.isDark(row,col+4)&&!qrCode.isDark(row,col+5)&&qrCode.isDark(row,col+6)){lostPoint+=40;}}}
|
|
11290
|
-
for(var col=0;col<moduleCount;col++){for(var row=0;row<moduleCount-6;row++){if(qrCode.isDark(row,col)&&!qrCode.isDark(row+1,col)&&qrCode.isDark(row+2,col)&&qrCode.isDark(row+3,col)&&qrCode.isDark(row+4,col)&&!qrCode.isDark(row+5,col)&&qrCode.isDark(row+6,col)){lostPoint+=40;}}}
|
|
11291
|
-
var darkCount=0;for(var col=0;col<moduleCount;col++){for(var row=0;row<moduleCount;row++){if(qrCode.isDark(row,col)){darkCount++;}}}
|
|
11292
|
-
var ratio=Math.abs(100*darkCount/moduleCount/moduleCount-50)/5;lostPoint+=ratio*10;return lostPoint;}};var QRMath={glog:function(n){if(n<1){throw new Error("glog("+n+")");}
|
|
11293
|
-
return QRMath.LOG_TABLE[n];},gexp:function(n){while(n<0){n+=255;}
|
|
11294
|
-
while(n>=256){n-=255;}
|
|
11295
|
-
return QRMath.EXP_TABLE[n];},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var i=0;i<8;i++){QRMath.EXP_TABLE[i]=1<<i;}
|
|
11296
|
-
for(var i=8;i<256;i++){QRMath.EXP_TABLE[i]=QRMath.EXP_TABLE[i-4]^QRMath.EXP_TABLE[i-5]^QRMath.EXP_TABLE[i-6]^QRMath.EXP_TABLE[i-8];}
|
|
11297
|
-
for(var i=0;i<255;i++){QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]]=i;}
|
|
11298
|
-
function QRPolynomial(num,shift){if(num.length==undefined){throw new Error(num.length+"/"+shift);}
|
|
11299
|
-
var offset=0;while(offset<num.length&&num[offset]==0){offset++;}
|
|
11300
|
-
this.num=new Array(num.length-offset+shift);for(var i=0;i<num.length-offset;i++){this.num[i]=num[i+offset];}}
|
|
11301
|
-
QRPolynomial.prototype={get:function(index){return this.num[index];},getLength:function(){return this.num.length;},multiply:function(e){var num=new Array(this.getLength()+e.getLength()-1);for(var i=0;i<this.getLength();i++){for(var j=0;j<e.getLength();j++){num[i+j]^=QRMath.gexp(QRMath.glog(this.get(i))+QRMath.glog(e.get(j)));}}
|
|
11302
|
-
return new QRPolynomial(num,0);},mod:function(e){if(this.getLength()-e.getLength()<0){return this;}
|
|
11303
|
-
var ratio=QRMath.glog(this.get(0))-QRMath.glog(e.get(0));var num=new Array(this.getLength());for(var i=0;i<this.getLength();i++){num[i]=this.get(i);}
|
|
11304
|
-
for(var i=0;i<e.getLength();i++){num[i]^=QRMath.gexp(QRMath.glog(e.get(i))+ratio);}
|
|
11305
|
-
return new QRPolynomial(num,0).mod(e);}};function QRRSBlock(totalCount,dataCount){this.totalCount=totalCount;this.dataCount=dataCount;}
|
|
11306
|
-
QRRSBlock.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];QRRSBlock.getRSBlocks=function(typeNumber,errorCorrectLevel){var rsBlock=QRRSBlock.getRsBlockTable(typeNumber,errorCorrectLevel);if(rsBlock==undefined){throw new Error("bad rs block @ typeNumber:"+typeNumber+"/errorCorrectLevel:"+errorCorrectLevel);}
|
|
11307
|
-
var length=rsBlock.length/3;var list=[];for(var i=0;i<length;i++){var count=rsBlock[i*3+0];var totalCount=rsBlock[i*3+1];var dataCount=rsBlock[i*3+2];for(var j=0;j<count;j++){list.push(new QRRSBlock(totalCount,dataCount));}}
|
|
11308
|
-
return list;};QRRSBlock.getRsBlockTable=function(typeNumber,errorCorrectLevel){switch(errorCorrectLevel){case QRErrorCorrectLevel.L:return QRRSBlock.RS_BLOCK_TABLE[(typeNumber-1)*4+0];case QRErrorCorrectLevel.M:return QRRSBlock.RS_BLOCK_TABLE[(typeNumber-1)*4+1];case QRErrorCorrectLevel.Q:return QRRSBlock.RS_BLOCK_TABLE[(typeNumber-1)*4+2];case QRErrorCorrectLevel.H:return QRRSBlock.RS_BLOCK_TABLE[(typeNumber-1)*4+3];default:return undefined;}};function QRBitBuffer(){this.buffer=[];this.length=0;}
|
|
11309
|
-
QRBitBuffer.prototype={get:function(index){var bufIndex=Math.floor(index/8);return((this.buffer[bufIndex]>>>(7-index%8))&1)==1;},put:function(num,length){for(var i=0;i<length;i++){this.putBit(((num>>>(length-i-1))&1)==1);}},getLengthInBits:function(){return this.length;},putBit:function(bit){var bufIndex=Math.floor(this.length/8);if(this.buffer.length<=bufIndex){this.buffer.push(0);}
|
|
11310
|
-
if(bit){this.buffer[bufIndex]|=(0x80>>>(this.length%8));}
|
|
11311
|
-
this.length++;}};var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];
|
|
11312
|
-
|
|
11313
|
-
function _isSupportCanvas() {
|
|
11314
|
-
return typeof CanvasRenderingContext2D != "undefined";
|
|
11315
|
-
}
|
|
11316
|
-
|
|
11317
|
-
// android 2.x doesn't support Data-URI spec
|
|
11318
|
-
function _getAndroid() {
|
|
11319
|
-
var android = false;
|
|
11320
|
-
var sAgent = navigator.userAgent;
|
|
11321
|
-
|
|
11322
|
-
if (/android/i.test(sAgent)) { // android
|
|
11323
|
-
android = true;
|
|
11324
|
-
var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i);
|
|
11325
|
-
|
|
11326
|
-
if (aMat && aMat[1]) {
|
|
11327
|
-
android = parseFloat(aMat[1]);
|
|
11328
|
-
}
|
|
11329
|
-
}
|
|
11330
|
-
|
|
11331
|
-
return android;
|
|
11332
|
-
}
|
|
11333
|
-
|
|
11334
|
-
var svgDrawer = (function() {
|
|
11335
|
-
|
|
11336
|
-
var Drawing = function (el, htOption) {
|
|
11337
|
-
this._el = el;
|
|
11338
|
-
this._htOption = htOption;
|
|
11339
|
-
};
|
|
11340
|
-
|
|
11341
|
-
Drawing.prototype.draw = function (oQRCode) {
|
|
11342
|
-
var _htOption = this._htOption;
|
|
11343
|
-
var _el = this._el;
|
|
11344
|
-
var nCount = oQRCode.getModuleCount();
|
|
11345
|
-
var nWidth = Math.floor(_htOption.width / nCount);
|
|
11346
|
-
var nHeight = Math.floor(_htOption.height / nCount);
|
|
11347
|
-
|
|
11348
|
-
this.clear();
|
|
11349
|
-
|
|
11350
|
-
function makeSVG(tag, attrs) {
|
|
11351
|
-
var el = document.createElementNS('http://www.w3.org/2000/svg', tag);
|
|
11352
|
-
for (var k in attrs)
|
|
11353
|
-
if (attrs.hasOwnProperty(k)) el.setAttribute(k, attrs[k]);
|
|
11354
|
-
return el;
|
|
11355
|
-
}
|
|
11356
|
-
|
|
11357
|
-
var svg = makeSVG("svg" , {'viewBox': '0 0 ' + String(nCount) + " " + String(nCount), 'width': '100%', 'height': '100%', 'fill': _htOption.colorLight});
|
|
11358
|
-
svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
|
|
11359
|
-
_el.appendChild(svg);
|
|
11360
|
-
|
|
11361
|
-
svg.appendChild(makeSVG("rect", {"fill": _htOption.colorLight, "width": "100%", "height": "100%"}));
|
|
11362
|
-
svg.appendChild(makeSVG("rect", {"fill": _htOption.colorDark, "width": "1", "height": "1", "id": "template"}));
|
|
11363
|
-
|
|
11364
|
-
for (var row = 0; row < nCount; row++) {
|
|
11365
|
-
for (var col = 0; col < nCount; col++) {
|
|
11366
|
-
if (oQRCode.isDark(row, col)) {
|
|
11367
|
-
var child = makeSVG("use", {"x": String(col), "y": String(row)});
|
|
11368
|
-
child.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template")
|
|
11369
|
-
svg.appendChild(child);
|
|
11370
|
-
}
|
|
11371
|
-
}
|
|
11372
|
-
}
|
|
11373
|
-
};
|
|
11374
|
-
Drawing.prototype.clear = function () {
|
|
11375
|
-
while (this._el.hasChildNodes())
|
|
11376
|
-
this._el.removeChild(this._el.lastChild);
|
|
11377
|
-
};
|
|
11378
|
-
return Drawing;
|
|
11379
|
-
})();
|
|
11380
|
-
|
|
11381
|
-
var useSVG = document.documentElement.tagName.toLowerCase() === "svg";
|
|
11382
|
-
|
|
11383
|
-
// Drawing in DOM by using Table tag
|
|
11384
|
-
var Drawing = useSVG ? svgDrawer : !_isSupportCanvas() ? (function () {
|
|
11385
|
-
var Drawing = function (el, htOption) {
|
|
11386
|
-
this._el = el;
|
|
11387
|
-
this._htOption = htOption;
|
|
11388
|
-
};
|
|
11389
|
-
|
|
11390
|
-
/**
|
|
11391
|
-
* Draw the QRCode
|
|
11392
|
-
*
|
|
11393
|
-
* @param {QRCode} oQRCode
|
|
11394
|
-
*/
|
|
11395
|
-
Drawing.prototype.draw = function (oQRCode) {
|
|
11396
|
-
var _htOption = this._htOption;
|
|
11397
|
-
var _el = this._el;
|
|
11398
|
-
var nCount = oQRCode.getModuleCount();
|
|
11399
|
-
var nWidth = Math.floor(_htOption.width / nCount);
|
|
11400
|
-
var nHeight = Math.floor(_htOption.height / nCount);
|
|
11401
|
-
var aHTML = ['<table style="border:0;border-collapse:collapse;">'];
|
|
11402
|
-
|
|
11403
|
-
for (var row = 0; row < nCount; row++) {
|
|
11404
|
-
aHTML.push('<tr>');
|
|
11405
|
-
|
|
11406
|
-
for (var col = 0; col < nCount; col++) {
|
|
11407
|
-
aHTML.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:' + nWidth + 'px;height:' + nHeight + 'px;background-color:' + (oQRCode.isDark(row, col) ? _htOption.colorDark : _htOption.colorLight) + ';"></td>');
|
|
11408
|
-
}
|
|
11409
|
-
|
|
11410
|
-
aHTML.push('</tr>');
|
|
11411
|
-
}
|
|
11412
|
-
|
|
11413
|
-
aHTML.push('</table>');
|
|
11414
|
-
_el.innerHTML = aHTML.join('');
|
|
11415
|
-
|
|
11416
|
-
// Fix the margin values as real size.
|
|
11417
|
-
var elTable = _el.childNodes[0];
|
|
11418
|
-
var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2;
|
|
11419
|
-
var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2;
|
|
11420
|
-
|
|
11421
|
-
if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
|
|
11422
|
-
elTable.style.margin = nTopMarginTable + "px " + nLeftMarginTable + "px";
|
|
11423
|
-
}
|
|
11424
|
-
};
|
|
11425
|
-
|
|
11426
|
-
/**
|
|
11427
|
-
* Clear the QRCode
|
|
11428
|
-
*/
|
|
11429
|
-
Drawing.prototype.clear = function () {
|
|
11430
|
-
this._el.innerHTML = '';
|
|
11431
|
-
};
|
|
11432
|
-
|
|
11433
|
-
return Drawing;
|
|
11434
|
-
})() : (function () { // Drawing in Canvas
|
|
11435
|
-
function _onMakeImage() {
|
|
11436
|
-
this._elImage.src = this._elCanvas.toDataURL("image/png");
|
|
11437
|
-
this._elImage.style.display = "block";
|
|
11438
|
-
this._elCanvas.style.display = "none";
|
|
11439
|
-
}
|
|
11440
|
-
|
|
11441
|
-
// Android 2.1 bug workaround
|
|
11442
|
-
// http://code.google.com/p/android/issues/detail?id=5141
|
|
11443
|
-
if (this._android && this._android <= 2.1) {
|
|
11444
|
-
var factor = 1 / window.devicePixelRatio;
|
|
11445
|
-
var drawImage = CanvasRenderingContext2D.prototype.drawImage;
|
|
11446
|
-
CanvasRenderingContext2D.prototype.drawImage = function (image, sx, sy, sw, sh, dx, dy, dw, dh) {
|
|
11447
|
-
if (("nodeName" in image) && /img/i.test(image.nodeName)) {
|
|
11448
|
-
for (var i = arguments.length - 1; i >= 1; i--) {
|
|
11449
|
-
arguments[i] = arguments[i] * factor;
|
|
11450
|
-
}
|
|
11451
|
-
} else if (typeof dw == "undefined") {
|
|
11452
|
-
arguments[1] *= factor;
|
|
11453
|
-
arguments[2] *= factor;
|
|
11454
|
-
arguments[3] *= factor;
|
|
11455
|
-
arguments[4] *= factor;
|
|
11456
|
-
}
|
|
11457
|
-
|
|
11458
|
-
drawImage.apply(this, arguments);
|
|
11459
|
-
};
|
|
11460
|
-
}
|
|
11461
|
-
|
|
11462
|
-
/**
|
|
11463
|
-
* Check whether the user's browser supports Data URI or not
|
|
11464
|
-
*
|
|
11465
|
-
* @private
|
|
11466
|
-
* @param {Function} fSuccess Occurs if it supports Data URI
|
|
11467
|
-
* @param {Function} fFail Occurs if it doesn't support Data URI
|
|
11468
|
-
*/
|
|
11469
|
-
function _safeSetDataURI(fSuccess, fFail) {
|
|
11470
|
-
var self = this;
|
|
11471
|
-
self._fFail = fFail;
|
|
11472
|
-
self._fSuccess = fSuccess;
|
|
11473
|
-
|
|
11474
|
-
// Check it just once
|
|
11475
|
-
if (self._bSupportDataURI === null) {
|
|
11476
|
-
var el = document.createElement("img");
|
|
11477
|
-
var fOnError = function() {
|
|
11478
|
-
self._bSupportDataURI = false;
|
|
11479
|
-
|
|
11480
|
-
if (self._fFail) {
|
|
11481
|
-
self._fFail.call(self);
|
|
11482
|
-
}
|
|
11483
|
-
};
|
|
11484
|
-
var fOnSuccess = function() {
|
|
11485
|
-
self._bSupportDataURI = true;
|
|
11486
|
-
|
|
11487
|
-
if (self._fSuccess) {
|
|
11488
|
-
self._fSuccess.call(self);
|
|
11489
|
-
}
|
|
11490
|
-
};
|
|
11491
|
-
|
|
11492
|
-
el.onabort = fOnError;
|
|
11493
|
-
el.onerror = fOnError;
|
|
11494
|
-
el.onload = fOnSuccess;
|
|
11495
|
-
el.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; // the Image contains 1px data.
|
|
11496
|
-
return;
|
|
11497
|
-
} else if (self._bSupportDataURI === true && self._fSuccess) {
|
|
11498
|
-
self._fSuccess.call(self);
|
|
11499
|
-
} else if (self._bSupportDataURI === false && self._fFail) {
|
|
11500
|
-
self._fFail.call(self);
|
|
11501
|
-
}
|
|
11502
|
-
};
|
|
11503
|
-
|
|
11504
|
-
/**
|
|
11505
|
-
* Drawing QRCode by using canvas
|
|
11506
|
-
*
|
|
11507
|
-
* @constructor
|
|
11508
|
-
* @param {HTMLElement} el
|
|
11509
|
-
* @param {Object} htOption QRCode Options
|
|
11510
|
-
*/
|
|
11511
|
-
var Drawing = function (el, htOption) {
|
|
11512
|
-
this._bIsPainted = false;
|
|
11513
|
-
this._android = _getAndroid();
|
|
11514
|
-
|
|
11515
|
-
this._htOption = htOption;
|
|
11516
|
-
this._elCanvas = document.createElement("canvas");
|
|
11517
|
-
this._elCanvas.width = htOption.width;
|
|
11518
|
-
this._elCanvas.height = htOption.height;
|
|
11519
|
-
el.appendChild(this._elCanvas);
|
|
11520
|
-
this._el = el;
|
|
11521
|
-
this._oContext = this._elCanvas.getContext("2d");
|
|
11522
|
-
this._bIsPainted = false;
|
|
11523
|
-
this._elImage = document.createElement("img");
|
|
11524
|
-
this._elImage.alt = "Scan me!";
|
|
11525
|
-
this._elImage.style.display = "none";
|
|
11526
|
-
this._el.appendChild(this._elImage);
|
|
11527
|
-
this._bSupportDataURI = null;
|
|
11528
|
-
};
|
|
11529
|
-
|
|
11530
|
-
/**
|
|
11531
|
-
* Draw the QRCode
|
|
11532
|
-
*
|
|
11533
|
-
* @param {QRCode} oQRCode
|
|
11534
|
-
*/
|
|
11535
|
-
Drawing.prototype.draw = function (oQRCode) {
|
|
11536
|
-
var _elImage = this._elImage;
|
|
11537
|
-
var _oContext = this._oContext;
|
|
11538
|
-
var _htOption = this._htOption;
|
|
11539
|
-
|
|
11540
|
-
var nCount = oQRCode.getModuleCount();
|
|
11541
|
-
var nWidth = _htOption.width / nCount;
|
|
11542
|
-
var nHeight = _htOption.height / nCount;
|
|
11543
|
-
var nRoundedWidth = Math.round(nWidth);
|
|
11544
|
-
var nRoundedHeight = Math.round(nHeight);
|
|
11545
|
-
|
|
11546
|
-
_elImage.style.display = "none";
|
|
11547
|
-
this.clear();
|
|
11548
|
-
|
|
11549
|
-
for (var row = 0; row < nCount; row++) {
|
|
11550
|
-
for (var col = 0; col < nCount; col++) {
|
|
11551
|
-
var bIsDark = oQRCode.isDark(row, col);
|
|
11552
|
-
var nLeft = col * nWidth;
|
|
11553
|
-
var nTop = row * nHeight;
|
|
11554
|
-
_oContext.strokeStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
|
|
11555
|
-
_oContext.lineWidth = 1;
|
|
11556
|
-
_oContext.fillStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
|
|
11557
|
-
_oContext.fillRect(nLeft, nTop, nWidth, nHeight);
|
|
11558
|
-
|
|
11559
|
-
// 안티 앨리어싱 방지 처리
|
|
11560
|
-
_oContext.strokeRect(
|
|
11561
|
-
Math.floor(nLeft) + 0.5,
|
|
11562
|
-
Math.floor(nTop) + 0.5,
|
|
11563
|
-
nRoundedWidth,
|
|
11564
|
-
nRoundedHeight
|
|
11565
|
-
);
|
|
11566
|
-
|
|
11567
|
-
_oContext.strokeRect(
|
|
11568
|
-
Math.ceil(nLeft) - 0.5,
|
|
11569
|
-
Math.ceil(nTop) - 0.5,
|
|
11570
|
-
nRoundedWidth,
|
|
11571
|
-
nRoundedHeight
|
|
11572
|
-
);
|
|
11573
|
-
}
|
|
11574
|
-
}
|
|
11575
|
-
|
|
11576
|
-
this._bIsPainted = true;
|
|
11577
|
-
};
|
|
11578
|
-
|
|
11579
|
-
/**
|
|
11580
|
-
* Make the image from Canvas if the browser supports Data URI.
|
|
11581
|
-
*/
|
|
11582
|
-
Drawing.prototype.makeImage = function () {
|
|
11583
|
-
if (this._bIsPainted) {
|
|
11584
|
-
_safeSetDataURI.call(this, _onMakeImage);
|
|
11585
|
-
}
|
|
11586
|
-
};
|
|
11587
|
-
|
|
11588
|
-
/**
|
|
11589
|
-
* Return whether the QRCode is painted or not
|
|
11590
|
-
*
|
|
11591
|
-
* @return {Boolean}
|
|
11592
|
-
*/
|
|
11593
|
-
Drawing.prototype.isPainted = function () {
|
|
11594
|
-
return this._bIsPainted;
|
|
11595
|
-
};
|
|
11596
|
-
|
|
11597
|
-
/**
|
|
11598
|
-
* Clear the QRCode
|
|
11599
|
-
*/
|
|
11600
|
-
Drawing.prototype.clear = function () {
|
|
11601
|
-
this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height);
|
|
11602
|
-
this._bIsPainted = false;
|
|
11603
|
-
};
|
|
11604
|
-
|
|
11605
|
-
/**
|
|
11606
|
-
* @private
|
|
11607
|
-
* @param {Number} nNumber
|
|
11608
|
-
*/
|
|
11609
|
-
Drawing.prototype.round = function (nNumber) {
|
|
11610
|
-
if (!nNumber) {
|
|
11611
|
-
return nNumber;
|
|
11612
|
-
}
|
|
11613
|
-
|
|
11614
|
-
return Math.floor(nNumber * 1000) / 1000;
|
|
11615
|
-
};
|
|
11616
|
-
|
|
11617
|
-
return Drawing;
|
|
11618
|
-
})();
|
|
11619
|
-
|
|
11620
|
-
/**
|
|
11621
|
-
* Get the type by string length
|
|
11622
|
-
*
|
|
11623
|
-
* @private
|
|
11624
|
-
* @param {String} sText
|
|
11625
|
-
* @param {Number} nCorrectLevel
|
|
11626
|
-
* @return {Number} type
|
|
11627
|
-
*/
|
|
11628
|
-
function _getTypeNumber(sText, nCorrectLevel) {
|
|
11629
|
-
var nType = 1;
|
|
11630
|
-
var length = _getUTF8Length(sText);
|
|
11631
|
-
|
|
11632
|
-
for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
|
|
11633
|
-
var nLimit = 0;
|
|
11634
|
-
|
|
11635
|
-
switch (nCorrectLevel) {
|
|
11636
|
-
case QRErrorCorrectLevel.L :
|
|
11637
|
-
nLimit = QRCodeLimitLength[i][0];
|
|
11638
|
-
break;
|
|
11639
|
-
case QRErrorCorrectLevel.M :
|
|
11640
|
-
nLimit = QRCodeLimitLength[i][1];
|
|
11641
|
-
break;
|
|
11642
|
-
case QRErrorCorrectLevel.Q :
|
|
11643
|
-
nLimit = QRCodeLimitLength[i][2];
|
|
11644
|
-
break;
|
|
11645
|
-
case QRErrorCorrectLevel.H :
|
|
11646
|
-
nLimit = QRCodeLimitLength[i][3];
|
|
11647
|
-
break;
|
|
11648
|
-
}
|
|
11649
|
-
|
|
11650
|
-
if (length <= nLimit) {
|
|
11651
|
-
break;
|
|
11652
|
-
} else {
|
|
11653
|
-
nType++;
|
|
11654
|
-
}
|
|
11655
|
-
}
|
|
11656
|
-
|
|
11657
|
-
if (nType > QRCodeLimitLength.length) {
|
|
11658
|
-
throw new Error("Too long data");
|
|
11659
|
-
}
|
|
11660
|
-
|
|
11661
|
-
return nType;
|
|
11662
|
-
}
|
|
11663
|
-
|
|
11664
|
-
function _getUTF8Length(sText) {
|
|
11665
|
-
var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a');
|
|
11666
|
-
return replacedText.length + (replacedText.length != sText ? 3 : 0);
|
|
11667
|
-
}
|
|
11668
|
-
|
|
11669
|
-
/**
|
|
11670
|
-
* @class QRCode
|
|
11671
|
-
* @constructor
|
|
11672
|
-
* @example
|
|
11673
|
-
* new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie");
|
|
11674
|
-
*
|
|
11675
|
-
* @example
|
|
11676
|
-
* var oQRCode = new QRCode("test", {
|
|
11677
|
-
* text : "http://naver.com",
|
|
11678
|
-
* width : 128,
|
|
11679
|
-
* height : 128
|
|
11680
|
-
* });
|
|
11681
|
-
*
|
|
11682
|
-
* oQRCode.clear(); // Clear the QRCode.
|
|
11683
|
-
* oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode.
|
|
11684
|
-
*
|
|
11685
|
-
* @param {HTMLElement|String} el target element or 'id' attribute of element.
|
|
11686
|
-
* @param {Object|String} vOption
|
|
11687
|
-
* @param {String} vOption.text QRCode link data
|
|
11688
|
-
* @param {Number} [vOption.width=256]
|
|
11689
|
-
* @param {Number} [vOption.height=256]
|
|
11690
|
-
* @param {String} [vOption.colorDark="#000000"]
|
|
11691
|
-
* @param {String} [vOption.colorLight="#ffffff"]
|
|
11692
|
-
* @param {QRCode.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H]
|
|
11693
|
-
*/
|
|
11694
|
-
QRCode = function (el, vOption) {
|
|
11695
|
-
this._htOption = {
|
|
11696
|
-
width : 256,
|
|
11697
|
-
height : 256,
|
|
11698
|
-
typeNumber : 4,
|
|
11699
|
-
colorDark : "#000000",
|
|
11700
|
-
colorLight : "#ffffff",
|
|
11701
|
-
correctLevel : QRErrorCorrectLevel.H
|
|
11702
|
-
};
|
|
11703
|
-
|
|
11704
|
-
if (typeof vOption === 'string') {
|
|
11705
|
-
vOption = {
|
|
11706
|
-
text : vOption
|
|
11707
|
-
};
|
|
11708
|
-
}
|
|
11709
|
-
|
|
11710
|
-
// Overwrites options
|
|
11711
|
-
if (vOption) {
|
|
11712
|
-
for (var i in vOption) {
|
|
11713
|
-
this._htOption[i] = vOption[i];
|
|
11714
|
-
}
|
|
11715
|
-
}
|
|
11716
|
-
|
|
11717
|
-
if (typeof el == "string") {
|
|
11718
|
-
el = document.getElementById(el);
|
|
11719
|
-
}
|
|
11720
|
-
|
|
11721
|
-
if (this._htOption.useSVG) {
|
|
11722
|
-
Drawing = svgDrawer;
|
|
11723
|
-
}
|
|
11724
|
-
|
|
11725
|
-
this._android = _getAndroid();
|
|
11726
|
-
this._el = el;
|
|
11727
|
-
this._oQRCode = null;
|
|
11728
|
-
this._oDrawing = new Drawing(this._el, this._htOption);
|
|
11729
|
-
|
|
11730
|
-
if (this._htOption.text) {
|
|
11731
|
-
this.makeCode(this._htOption.text);
|
|
11732
|
-
}
|
|
11733
|
-
};
|
|
11734
|
-
|
|
11735
|
-
/**
|
|
11736
|
-
* Make the QRCode
|
|
11737
|
-
*
|
|
11738
|
-
* @param {String} sText link data
|
|
11739
|
-
*/
|
|
11740
|
-
QRCode.prototype.makeCode = function (sText) {
|
|
11741
|
-
this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel);
|
|
11742
|
-
this._oQRCode.addData(sText);
|
|
11743
|
-
this._oQRCode.make();
|
|
11744
|
-
this._el.title = sText;
|
|
11745
|
-
this._oDrawing.draw(this._oQRCode);
|
|
11746
|
-
this.makeImage();
|
|
11747
|
-
};
|
|
11748
|
-
|
|
11749
|
-
/**
|
|
11750
|
-
* Make the Image from Canvas element
|
|
11751
|
-
* - It occurs automatically
|
|
11752
|
-
* - Android below 3 doesn't support Data-URI spec.
|
|
11753
|
-
*
|
|
11754
|
-
* @private
|
|
11755
|
-
*/
|
|
11756
|
-
QRCode.prototype.makeImage = function () {
|
|
11757
|
-
if (typeof this._oDrawing.makeImage == "function" && (!this._android || this._android >= 3)) {
|
|
11758
|
-
this._oDrawing.makeImage();
|
|
11759
|
-
}
|
|
11760
|
-
};
|
|
11761
|
-
|
|
11762
|
-
/**
|
|
11763
|
-
* Clear the QRCode
|
|
11764
|
-
*/
|
|
11765
|
-
QRCode.prototype.clear = function () {
|
|
11766
|
-
this._oDrawing.clear();
|
|
11767
|
-
};
|
|
11768
|
-
|
|
11769
|
-
/**
|
|
11770
|
-
* @name QRCode.CorrectLevel
|
|
11771
|
-
*/
|
|
11772
|
-
QRCode.CorrectLevel = QRErrorCorrectLevel;
|
|
11773
|
-
|
|
11774
|
-
return QRCode;
|
|
11775
|
-
|
|
11776
|
-
}));
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
13683
|
/***/ },
|
|
11780
13684
|
|
|
11781
13685
|
/***/ 9137
|
|
@@ -13085,6 +14989,343 @@ $({ target: 'Object', stat: true, forced: FORCED }, {
|
|
|
13085
14989
|
});
|
|
13086
14990
|
|
|
13087
14991
|
|
|
14992
|
+
/***/ },
|
|
14993
|
+
|
|
14994
|
+
/***/ 9801
|
|
14995
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
14996
|
+
|
|
14997
|
+
const Mode = __webpack_require__(208)
|
|
14998
|
+
const NumericData = __webpack_require__(4357)
|
|
14999
|
+
const AlphanumericData = __webpack_require__(1433)
|
|
15000
|
+
const ByteData = __webpack_require__(5822)
|
|
15001
|
+
const KanjiData = __webpack_require__(4861)
|
|
15002
|
+
const Regex = __webpack_require__(7044)
|
|
15003
|
+
const Utils = __webpack_require__(6886)
|
|
15004
|
+
const dijkstra = __webpack_require__(6320)
|
|
15005
|
+
|
|
15006
|
+
/**
|
|
15007
|
+
* Returns UTF8 byte length
|
|
15008
|
+
*
|
|
15009
|
+
* @param {String} str Input string
|
|
15010
|
+
* @return {Number} Number of byte
|
|
15011
|
+
*/
|
|
15012
|
+
function getStringByteLength (str) {
|
|
15013
|
+
return unescape(encodeURIComponent(str)).length
|
|
15014
|
+
}
|
|
15015
|
+
|
|
15016
|
+
/**
|
|
15017
|
+
* Get a list of segments of the specified mode
|
|
15018
|
+
* from a string
|
|
15019
|
+
*
|
|
15020
|
+
* @param {Mode} mode Segment mode
|
|
15021
|
+
* @param {String} str String to process
|
|
15022
|
+
* @return {Array} Array of object with segments data
|
|
15023
|
+
*/
|
|
15024
|
+
function getSegments (regex, mode, str) {
|
|
15025
|
+
const segments = []
|
|
15026
|
+
let result
|
|
15027
|
+
|
|
15028
|
+
while ((result = regex.exec(str)) !== null) {
|
|
15029
|
+
segments.push({
|
|
15030
|
+
data: result[0],
|
|
15031
|
+
index: result.index,
|
|
15032
|
+
mode: mode,
|
|
15033
|
+
length: result[0].length
|
|
15034
|
+
})
|
|
15035
|
+
}
|
|
15036
|
+
|
|
15037
|
+
return segments
|
|
15038
|
+
}
|
|
15039
|
+
|
|
15040
|
+
/**
|
|
15041
|
+
* Extracts a series of segments with the appropriate
|
|
15042
|
+
* modes from a string
|
|
15043
|
+
*
|
|
15044
|
+
* @param {String} dataStr Input string
|
|
15045
|
+
* @return {Array} Array of object with segments data
|
|
15046
|
+
*/
|
|
15047
|
+
function getSegmentsFromString (dataStr) {
|
|
15048
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)
|
|
15049
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)
|
|
15050
|
+
let byteSegs
|
|
15051
|
+
let kanjiSegs
|
|
15052
|
+
|
|
15053
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
15054
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)
|
|
15055
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)
|
|
15056
|
+
} else {
|
|
15057
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)
|
|
15058
|
+
kanjiSegs = []
|
|
15059
|
+
}
|
|
15060
|
+
|
|
15061
|
+
const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)
|
|
15062
|
+
|
|
15063
|
+
return segs
|
|
15064
|
+
.sort(function (s1, s2) {
|
|
15065
|
+
return s1.index - s2.index
|
|
15066
|
+
})
|
|
15067
|
+
.map(function (obj) {
|
|
15068
|
+
return {
|
|
15069
|
+
data: obj.data,
|
|
15070
|
+
mode: obj.mode,
|
|
15071
|
+
length: obj.length
|
|
15072
|
+
}
|
|
15073
|
+
})
|
|
15074
|
+
}
|
|
15075
|
+
|
|
15076
|
+
/**
|
|
15077
|
+
* Returns how many bits are needed to encode a string of
|
|
15078
|
+
* specified length with the specified mode
|
|
15079
|
+
*
|
|
15080
|
+
* @param {Number} length String length
|
|
15081
|
+
* @param {Mode} mode Segment mode
|
|
15082
|
+
* @return {Number} Bit length
|
|
15083
|
+
*/
|
|
15084
|
+
function getSegmentBitsLength (length, mode) {
|
|
15085
|
+
switch (mode) {
|
|
15086
|
+
case Mode.NUMERIC:
|
|
15087
|
+
return NumericData.getBitsLength(length)
|
|
15088
|
+
case Mode.ALPHANUMERIC:
|
|
15089
|
+
return AlphanumericData.getBitsLength(length)
|
|
15090
|
+
case Mode.KANJI:
|
|
15091
|
+
return KanjiData.getBitsLength(length)
|
|
15092
|
+
case Mode.BYTE:
|
|
15093
|
+
return ByteData.getBitsLength(length)
|
|
15094
|
+
}
|
|
15095
|
+
}
|
|
15096
|
+
|
|
15097
|
+
/**
|
|
15098
|
+
* Merges adjacent segments which have the same mode
|
|
15099
|
+
*
|
|
15100
|
+
* @param {Array} segs Array of object with segments data
|
|
15101
|
+
* @return {Array} Array of object with segments data
|
|
15102
|
+
*/
|
|
15103
|
+
function mergeSegments (segs) {
|
|
15104
|
+
return segs.reduce(function (acc, curr) {
|
|
15105
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null
|
|
15106
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
15107
|
+
acc[acc.length - 1].data += curr.data
|
|
15108
|
+
return acc
|
|
15109
|
+
}
|
|
15110
|
+
|
|
15111
|
+
acc.push(curr)
|
|
15112
|
+
return acc
|
|
15113
|
+
}, [])
|
|
15114
|
+
}
|
|
15115
|
+
|
|
15116
|
+
/**
|
|
15117
|
+
* Generates a list of all possible nodes combination which
|
|
15118
|
+
* will be used to build a segments graph.
|
|
15119
|
+
*
|
|
15120
|
+
* Nodes are divided by groups. Each group will contain a list of all the modes
|
|
15121
|
+
* in which is possible to encode the given text.
|
|
15122
|
+
*
|
|
15123
|
+
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
|
|
15124
|
+
* The group for '12345' will contain then 3 objects, one for each
|
|
15125
|
+
* possible encoding mode.
|
|
15126
|
+
*
|
|
15127
|
+
* Each node represents a possible segment.
|
|
15128
|
+
*
|
|
15129
|
+
* @param {Array} segs Array of object with segments data
|
|
15130
|
+
* @return {Array} Array of object with segments data
|
|
15131
|
+
*/
|
|
15132
|
+
function buildNodes (segs) {
|
|
15133
|
+
const nodes = []
|
|
15134
|
+
for (let i = 0; i < segs.length; i++) {
|
|
15135
|
+
const seg = segs[i]
|
|
15136
|
+
|
|
15137
|
+
switch (seg.mode) {
|
|
15138
|
+
case Mode.NUMERIC:
|
|
15139
|
+
nodes.push([seg,
|
|
15140
|
+
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
|
|
15141
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
15142
|
+
])
|
|
15143
|
+
break
|
|
15144
|
+
case Mode.ALPHANUMERIC:
|
|
15145
|
+
nodes.push([seg,
|
|
15146
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
15147
|
+
])
|
|
15148
|
+
break
|
|
15149
|
+
case Mode.KANJI:
|
|
15150
|
+
nodes.push([seg,
|
|
15151
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
15152
|
+
])
|
|
15153
|
+
break
|
|
15154
|
+
case Mode.BYTE:
|
|
15155
|
+
nodes.push([
|
|
15156
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
15157
|
+
])
|
|
15158
|
+
}
|
|
15159
|
+
}
|
|
15160
|
+
|
|
15161
|
+
return nodes
|
|
15162
|
+
}
|
|
15163
|
+
|
|
15164
|
+
/**
|
|
15165
|
+
* Builds a graph from a list of nodes.
|
|
15166
|
+
* All segments in each node group will be connected with all the segments of
|
|
15167
|
+
* the next group and so on.
|
|
15168
|
+
*
|
|
15169
|
+
* At each connection will be assigned a weight depending on the
|
|
15170
|
+
* segment's byte length.
|
|
15171
|
+
*
|
|
15172
|
+
* @param {Array} nodes Array of object with segments data
|
|
15173
|
+
* @param {Number} version QR Code version
|
|
15174
|
+
* @return {Object} Graph of all possible segments
|
|
15175
|
+
*/
|
|
15176
|
+
function buildGraph (nodes, version) {
|
|
15177
|
+
const table = {}
|
|
15178
|
+
const graph = { start: {} }
|
|
15179
|
+
let prevNodeIds = ['start']
|
|
15180
|
+
|
|
15181
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
15182
|
+
const nodeGroup = nodes[i]
|
|
15183
|
+
const currentNodeIds = []
|
|
15184
|
+
|
|
15185
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
15186
|
+
const node = nodeGroup[j]
|
|
15187
|
+
const key = '' + i + j
|
|
15188
|
+
|
|
15189
|
+
currentNodeIds.push(key)
|
|
15190
|
+
table[key] = { node: node, lastCount: 0 }
|
|
15191
|
+
graph[key] = {}
|
|
15192
|
+
|
|
15193
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
15194
|
+
const prevNodeId = prevNodeIds[n]
|
|
15195
|
+
|
|
15196
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
15197
|
+
graph[prevNodeId][key] =
|
|
15198
|
+
getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
|
|
15199
|
+
getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)
|
|
15200
|
+
|
|
15201
|
+
table[prevNodeId].lastCount += node.length
|
|
15202
|
+
} else {
|
|
15203
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length
|
|
15204
|
+
|
|
15205
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
|
|
15206
|
+
4 + Mode.getCharCountIndicator(node.mode, version) // switch cost
|
|
15207
|
+
}
|
|
15208
|
+
}
|
|
15209
|
+
}
|
|
15210
|
+
|
|
15211
|
+
prevNodeIds = currentNodeIds
|
|
15212
|
+
}
|
|
15213
|
+
|
|
15214
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
15215
|
+
graph[prevNodeIds[n]].end = 0
|
|
15216
|
+
}
|
|
15217
|
+
|
|
15218
|
+
return { map: graph, table: table }
|
|
15219
|
+
}
|
|
15220
|
+
|
|
15221
|
+
/**
|
|
15222
|
+
* Builds a segment from a specified data and mode.
|
|
15223
|
+
* If a mode is not specified, the more suitable will be used.
|
|
15224
|
+
*
|
|
15225
|
+
* @param {String} data Input data
|
|
15226
|
+
* @param {Mode | String} modesHint Data mode
|
|
15227
|
+
* @return {Segment} Segment
|
|
15228
|
+
*/
|
|
15229
|
+
function buildSingleSegment (data, modesHint) {
|
|
15230
|
+
let mode
|
|
15231
|
+
const bestMode = Mode.getBestModeForData(data)
|
|
15232
|
+
|
|
15233
|
+
mode = Mode.from(modesHint, bestMode)
|
|
15234
|
+
|
|
15235
|
+
// Make sure data can be encoded
|
|
15236
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
|
|
15237
|
+
throw new Error('"' + data + '"' +
|
|
15238
|
+
' cannot be encoded with mode ' + Mode.toString(mode) +
|
|
15239
|
+
'.\n Suggested mode is: ' + Mode.toString(bestMode))
|
|
15240
|
+
}
|
|
15241
|
+
|
|
15242
|
+
// Use Mode.BYTE if Kanji support is disabled
|
|
15243
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
|
|
15244
|
+
mode = Mode.BYTE
|
|
15245
|
+
}
|
|
15246
|
+
|
|
15247
|
+
switch (mode) {
|
|
15248
|
+
case Mode.NUMERIC:
|
|
15249
|
+
return new NumericData(data)
|
|
15250
|
+
|
|
15251
|
+
case Mode.ALPHANUMERIC:
|
|
15252
|
+
return new AlphanumericData(data)
|
|
15253
|
+
|
|
15254
|
+
case Mode.KANJI:
|
|
15255
|
+
return new KanjiData(data)
|
|
15256
|
+
|
|
15257
|
+
case Mode.BYTE:
|
|
15258
|
+
return new ByteData(data)
|
|
15259
|
+
}
|
|
15260
|
+
}
|
|
15261
|
+
|
|
15262
|
+
/**
|
|
15263
|
+
* Builds a list of segments from an array.
|
|
15264
|
+
* Array can contain Strings or Objects with segment's info.
|
|
15265
|
+
*
|
|
15266
|
+
* For each item which is a string, will be generated a segment with the given
|
|
15267
|
+
* string and the more appropriate encoding mode.
|
|
15268
|
+
*
|
|
15269
|
+
* For each item which is an object, will be generated a segment with the given
|
|
15270
|
+
* data and mode.
|
|
15271
|
+
* Objects must contain at least the property "data".
|
|
15272
|
+
* If property "mode" is not present, the more suitable mode will be used.
|
|
15273
|
+
*
|
|
15274
|
+
* @param {Array} array Array of objects with segments data
|
|
15275
|
+
* @return {Array} Array of Segments
|
|
15276
|
+
*/
|
|
15277
|
+
exports.fromArray = function fromArray (array) {
|
|
15278
|
+
return array.reduce(function (acc, seg) {
|
|
15279
|
+
if (typeof seg === 'string') {
|
|
15280
|
+
acc.push(buildSingleSegment(seg, null))
|
|
15281
|
+
} else if (seg.data) {
|
|
15282
|
+
acc.push(buildSingleSegment(seg.data, seg.mode))
|
|
15283
|
+
}
|
|
15284
|
+
|
|
15285
|
+
return acc
|
|
15286
|
+
}, [])
|
|
15287
|
+
}
|
|
15288
|
+
|
|
15289
|
+
/**
|
|
15290
|
+
* Builds an optimized sequence of segments from a string,
|
|
15291
|
+
* which will produce the shortest possible bitstream.
|
|
15292
|
+
*
|
|
15293
|
+
* @param {String} data Input string
|
|
15294
|
+
* @param {Number} version QR Code version
|
|
15295
|
+
* @return {Array} Array of segments
|
|
15296
|
+
*/
|
|
15297
|
+
exports.fromString = function fromString (data, version) {
|
|
15298
|
+
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
15299
|
+
|
|
15300
|
+
const nodes = buildNodes(segs)
|
|
15301
|
+
const graph = buildGraph(nodes, version)
|
|
15302
|
+
const path = dijkstra.find_path(graph.map, 'start', 'end')
|
|
15303
|
+
|
|
15304
|
+
const optimizedSegs = []
|
|
15305
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
15306
|
+
optimizedSegs.push(graph.table[path[i]].node)
|
|
15307
|
+
}
|
|
15308
|
+
|
|
15309
|
+
return exports.fromArray(mergeSegments(optimizedSegs))
|
|
15310
|
+
}
|
|
15311
|
+
|
|
15312
|
+
/**
|
|
15313
|
+
* Splits a string in various segments with the modes which
|
|
15314
|
+
* best represent their content.
|
|
15315
|
+
* The produced segments are far from being optimized.
|
|
15316
|
+
* The output of this function is only used to estimate a QR Code version
|
|
15317
|
+
* which may contain the data.
|
|
15318
|
+
*
|
|
15319
|
+
* @param {string} data Input string
|
|
15320
|
+
* @return {Array} Array of segments
|
|
15321
|
+
*/
|
|
15322
|
+
exports.rawSplit = function rawSplit (data) {
|
|
15323
|
+
return exports.fromArray(
|
|
15324
|
+
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
15325
|
+
)
|
|
15326
|
+
}
|
|
15327
|
+
|
|
15328
|
+
|
|
13088
15329
|
/***/ },
|
|
13089
15330
|
|
|
13090
15331
|
/***/ 9835
|
|
@@ -13123,6 +15364,50 @@ module.exports = function (METHOD_NAME) {
|
|
|
13123
15364
|
};
|
|
13124
15365
|
|
|
13125
15366
|
|
|
15367
|
+
/***/ },
|
|
15368
|
+
|
|
15369
|
+
/***/ 9899
|
|
15370
|
+
(module) {
|
|
15371
|
+
|
|
15372
|
+
function BitBuffer () {
|
|
15373
|
+
this.buffer = []
|
|
15374
|
+
this.length = 0
|
|
15375
|
+
}
|
|
15376
|
+
|
|
15377
|
+
BitBuffer.prototype = {
|
|
15378
|
+
|
|
15379
|
+
get: function (index) {
|
|
15380
|
+
const bufIndex = Math.floor(index / 8)
|
|
15381
|
+
return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
|
|
15382
|
+
},
|
|
15383
|
+
|
|
15384
|
+
put: function (num, length) {
|
|
15385
|
+
for (let i = 0; i < length; i++) {
|
|
15386
|
+
this.putBit(((num >>> (length - i - 1)) & 1) === 1)
|
|
15387
|
+
}
|
|
15388
|
+
},
|
|
15389
|
+
|
|
15390
|
+
getLengthInBits: function () {
|
|
15391
|
+
return this.length
|
|
15392
|
+
},
|
|
15393
|
+
|
|
15394
|
+
putBit: function (bit) {
|
|
15395
|
+
const bufIndex = Math.floor(this.length / 8)
|
|
15396
|
+
if (this.buffer.length <= bufIndex) {
|
|
15397
|
+
this.buffer.push(0)
|
|
15398
|
+
}
|
|
15399
|
+
|
|
15400
|
+
if (bit) {
|
|
15401
|
+
this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))
|
|
15402
|
+
}
|
|
15403
|
+
|
|
15404
|
+
this.length++
|
|
15405
|
+
}
|
|
15406
|
+
}
|
|
15407
|
+
|
|
15408
|
+
module.exports = BitBuffer
|
|
15409
|
+
|
|
15410
|
+
|
|
13126
15411
|
/***/ },
|
|
13127
15412
|
|
|
13128
15413
|
/***/ 9904
|
|
@@ -13142,6 +15427,63 @@ $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
|
|
|
13142
15427
|
});
|
|
13143
15428
|
|
|
13144
15429
|
|
|
15430
|
+
/***/ },
|
|
15431
|
+
|
|
15432
|
+
/***/ 9953
|
|
15433
|
+
(__unused_webpack_module, exports) {
|
|
15434
|
+
|
|
15435
|
+
exports.L = { bit: 1 }
|
|
15436
|
+
exports.M = { bit: 0 }
|
|
15437
|
+
exports.Q = { bit: 3 }
|
|
15438
|
+
exports.H = { bit: 2 }
|
|
15439
|
+
|
|
15440
|
+
function fromString (string) {
|
|
15441
|
+
if (typeof string !== 'string') {
|
|
15442
|
+
throw new Error('Param is not a string')
|
|
15443
|
+
}
|
|
15444
|
+
|
|
15445
|
+
const lcStr = string.toLowerCase()
|
|
15446
|
+
|
|
15447
|
+
switch (lcStr) {
|
|
15448
|
+
case 'l':
|
|
15449
|
+
case 'low':
|
|
15450
|
+
return exports.L
|
|
15451
|
+
|
|
15452
|
+
case 'm':
|
|
15453
|
+
case 'medium':
|
|
15454
|
+
return exports.M
|
|
15455
|
+
|
|
15456
|
+
case 'q':
|
|
15457
|
+
case 'quartile':
|
|
15458
|
+
return exports.Q
|
|
15459
|
+
|
|
15460
|
+
case 'h':
|
|
15461
|
+
case 'high':
|
|
15462
|
+
return exports.H
|
|
15463
|
+
|
|
15464
|
+
default:
|
|
15465
|
+
throw new Error('Unknown EC Level: ' + string)
|
|
15466
|
+
}
|
|
15467
|
+
}
|
|
15468
|
+
|
|
15469
|
+
exports.isValid = function isValid (level) {
|
|
15470
|
+
return level && typeof level.bit !== 'undefined' &&
|
|
15471
|
+
level.bit >= 0 && level.bit < 4
|
|
15472
|
+
}
|
|
15473
|
+
|
|
15474
|
+
exports.from = function from (value, defaultValue) {
|
|
15475
|
+
if (exports.isValid(value)) {
|
|
15476
|
+
return value
|
|
15477
|
+
}
|
|
15478
|
+
|
|
15479
|
+
try {
|
|
15480
|
+
return fromString(value)
|
|
15481
|
+
} catch (e) {
|
|
15482
|
+
return defaultValue
|
|
15483
|
+
}
|
|
15484
|
+
}
|
|
15485
|
+
|
|
15486
|
+
|
|
13145
15487
|
/***/ }
|
|
13146
15488
|
|
|
13147
15489
|
/******/ });
|
|
@@ -35445,70 +37787,69 @@ const AliyunCaptchaModal_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)
|
|
|
35445
37787
|
const verifyComponents_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(verifyComponentsvue_type_script_lang_js, [['render',verifyComponentsvue_type_template_id_7d804fae_render]])
|
|
35446
37788
|
|
|
35447
37789
|
/* harmony default export */ const verifyComponents = (verifyComponents_exports_);
|
|
35448
|
-
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/QRCodeLogin.vue?vue&type=template&id=
|
|
37790
|
+
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/QRCodeLogin.vue?vue&type=template&id=5b8744aa&scoped=true
|
|
35449
37791
|
|
|
35450
|
-
var
|
|
37792
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_1 = {
|
|
35451
37793
|
"class": "qr-code-wrapper"
|
|
35452
37794
|
};
|
|
35453
|
-
var
|
|
35454
|
-
var
|
|
37795
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_2 = ["id"];
|
|
37796
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_3 = {
|
|
35455
37797
|
key: 0,
|
|
35456
37798
|
"class": "qr-login-overlay"
|
|
35457
37799
|
};
|
|
35458
|
-
var
|
|
37800
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_4 = {
|
|
35459
37801
|
key: 0,
|
|
35460
37802
|
"class": "overlay-content"
|
|
35461
37803
|
};
|
|
35462
|
-
var
|
|
37804
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_5 = {
|
|
35463
37805
|
"class": "overlay-text"
|
|
35464
37806
|
};
|
|
35465
|
-
var
|
|
37807
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_6 = {
|
|
35466
37808
|
"class": "overlay-tip"
|
|
35467
37809
|
};
|
|
35468
|
-
var
|
|
37810
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_7 = {
|
|
35469
37811
|
key: 1,
|
|
35470
37812
|
"class": "overlay-content"
|
|
35471
37813
|
};
|
|
35472
|
-
var
|
|
37814
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_8 = {
|
|
35473
37815
|
"class": "overlay-text",
|
|
35474
37816
|
style: {
|
|
35475
37817
|
"color": "red"
|
|
35476
37818
|
}
|
|
35477
37819
|
};
|
|
35478
|
-
var
|
|
37820
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_9 = {
|
|
35479
37821
|
"class": "overlay-tip"
|
|
35480
37822
|
};
|
|
35481
|
-
var
|
|
37823
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_10 = {
|
|
35482
37824
|
"class": "qr-tip"
|
|
35483
37825
|
};
|
|
35484
|
-
var
|
|
37826
|
+
var QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_11 = {
|
|
35485
37827
|
key: 0,
|
|
35486
37828
|
"class": "bind-tip"
|
|
35487
37829
|
};
|
|
35488
|
-
function
|
|
37830
|
+
function QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
35489
37831
|
return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", {
|
|
35490
37832
|
"class": (0,external_commonjs_vue_commonjs2_vue_root_Vue_.normalizeClass)(["qr-login-container", {
|
|
35491
37833
|
'qr-login-container1': $props.bdwxShow
|
|
35492
37834
|
}])
|
|
35493
|
-
}, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div",
|
|
37835
|
+
}, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_1, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("div", {
|
|
35494
37836
|
id: "qrcode-container-".concat(_ctx._uid)
|
|
35495
|
-
}, null, 8,
|
|
37837
|
+
}, null, 8, QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_2), $data.loginStatus == 1 || $data.loginStatus == 3 ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_3, [$data.loginStatus == 1 ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_4, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_5, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('已扫码')), 1), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_6, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('请在手机上确认')), 1), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("button", {
|
|
35496
37838
|
"class": "rescan-btn",
|
|
35497
37839
|
onClick: _cache[0] || (_cache[0] = function () {
|
|
35498
37840
|
return $options.handleRescanQrCode && $options.handleRescanQrCode.apply($options, arguments);
|
|
35499
37841
|
})
|
|
35500
|
-
}, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('重新扫码')), 1)])) : $data.loginStatus == 3 ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div",
|
|
37842
|
+
}, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('重新扫码')), 1)])) : $data.loginStatus == 3 ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_7, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_8, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('二维码已过期')), 1), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_9, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('请点击下方按钮刷新')), 1), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("button", {
|
|
35501
37843
|
"class": "rescan-btn",
|
|
35502
37844
|
onClick: _cache[1] || (_cache[1] = function () {
|
|
35503
37845
|
return $options.handleRescanQrCode && $options.handleRescanQrCode.apply($options, arguments);
|
|
35504
37846
|
})
|
|
35505
|
-
}, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('重新生成')), 1)])) : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)])) : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)]), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p",
|
|
37847
|
+
}, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('重新生成')), 1)])) : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)])) : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)]), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("p", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_10, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($props.bdwxShow ? $options.i18n('微信扫码进行账号绑定') : $options.i18n('微信或App扫码均可登录')), 1), $data.wxRandom ? ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.openBlock)(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementBlock)("div", QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_hoisted_11, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.toDisplayString)($options.i18n('你当前的微信暂未绑定账号或手机号,需先完成绑定,后续登录将无需重复验证,直接进入即可~')), 1)) : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.createCommentVNode)("", true)], 2);
|
|
35506
37848
|
}
|
|
35507
|
-
;// ./src/components/QRCodeLogin.vue?vue&type=template&id=
|
|
37849
|
+
;// ./src/components/QRCodeLogin.vue?vue&type=template&id=5b8744aa&scoped=true
|
|
35508
37850
|
|
|
35509
|
-
// EXTERNAL MODULE: ./node_modules/
|
|
35510
|
-
var
|
|
35511
|
-
var qrcode_default = /*#__PURE__*/__webpack_require__.n(qrcode);
|
|
37851
|
+
// EXTERNAL MODULE: ./node_modules/qrcode/lib/browser.js
|
|
37852
|
+
var browser = __webpack_require__(7583);
|
|
35512
37853
|
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/QRCodeLogin.vue?vue&type=script&lang=js
|
|
35513
37854
|
|
|
35514
37855
|
|
|
@@ -35566,7 +37907,6 @@ var qrcode_default = /*#__PURE__*/__webpack_require__.n(qrcode);
|
|
|
35566
37907
|
login_generateQrCode().then(function (_ref) {
|
|
35567
37908
|
var data = _ref.data;
|
|
35568
37909
|
_this.loading = false;
|
|
35569
|
-
// this.qrCodeUrl = data.data.qrCodeUrl;
|
|
35570
37910
|
_this.generateQRCode(data.data.qrUrl);
|
|
35571
37911
|
_this.sceneId = data.data.sceneId;
|
|
35572
37912
|
_this.expireTime = data.data.expireTime;
|
|
@@ -35580,42 +37920,62 @@ var qrcode_default = /*#__PURE__*/__webpack_require__.n(qrcode);
|
|
|
35580
37920
|
console.error(err);
|
|
35581
37921
|
});
|
|
35582
37922
|
},
|
|
37923
|
+
// 使用新的qrcode库生成二维码
|
|
35583
37924
|
generateQRCode: function generateQRCode(url) {
|
|
37925
|
+
var _this2 = this;
|
|
35584
37926
|
var containerId = "qrcode-container-".concat(this._uid);
|
|
35585
|
-
document.getElementById(containerId)
|
|
35586
|
-
|
|
35587
|
-
|
|
35588
|
-
|
|
35589
|
-
|
|
37927
|
+
var container = document.getElementById(containerId);
|
|
37928
|
+
if (!container) {
|
|
37929
|
+
console.error('二维码容器未找到');
|
|
37930
|
+
return;
|
|
37931
|
+
}
|
|
37932
|
+
|
|
37933
|
+
// 清空容器
|
|
37934
|
+
container.innerHTML = '';
|
|
37935
|
+
|
|
37936
|
+
// 使用 qrcode 库生成二维码到 Canvas
|
|
37937
|
+
browser.toCanvas(url, {
|
|
35590
37938
|
width: 240,
|
|
35591
|
-
// 宽度
|
|
35592
37939
|
height: 240,
|
|
35593
|
-
|
|
35594
|
-
|
|
35595
|
-
|
|
35596
|
-
|
|
35597
|
-
|
|
35598
|
-
|
|
37940
|
+
color: {
|
|
37941
|
+
dark: '#000000',
|
|
37942
|
+
// 前景色
|
|
37943
|
+
light: '#ffffff' // 背景色
|
|
37944
|
+
},
|
|
37945
|
+
errorCorrectionLevel: 'H',
|
|
37946
|
+
// 容错级别:L, M, Q, H
|
|
37947
|
+
margin: 1,
|
|
37948
|
+
// 边距
|
|
37949
|
+
scale: 4 // 缩放比例
|
|
37950
|
+
}, function (error, canvas) {
|
|
37951
|
+
if (error) {
|
|
37952
|
+
console.error('生成二维码失败:', error);
|
|
37953
|
+
_this2.error = '生成二维码失败,请重试';
|
|
37954
|
+
return;
|
|
37955
|
+
}
|
|
37956
|
+
|
|
37957
|
+
// 将生成的canvas添加到容器中
|
|
37958
|
+
container.appendChild(canvas);
|
|
35599
37959
|
});
|
|
35600
37960
|
},
|
|
35601
37961
|
// 轮询检查登录状态
|
|
35602
37962
|
startPolling: function startPolling() {
|
|
35603
|
-
var
|
|
37963
|
+
var _this3 = this;
|
|
35604
37964
|
this.pollTimer = setInterval(function () {
|
|
35605
|
-
checkCodeStatus(
|
|
37965
|
+
checkCodeStatus(_this3.sceneId).then(function (res) {
|
|
35606
37966
|
var status = res.data.data.status;
|
|
35607
37967
|
if (status === 1) {
|
|
35608
37968
|
// 登录中,更新状态为已扫码
|
|
35609
|
-
|
|
37969
|
+
_this3.loginStatus = status;
|
|
35610
37970
|
} else if (status === 2) {
|
|
35611
37971
|
// 登录成功,存储token并跳转
|
|
35612
|
-
|
|
35613
|
-
|
|
35614
|
-
|
|
37972
|
+
_this3.$emit('loginSuccess', res.data.data);
|
|
37973
|
+
_this3.wxRandom = res.data.data.wxRandom;
|
|
37974
|
+
_this3.clearTimers();
|
|
35615
37975
|
} else if (status === 3) {
|
|
35616
37976
|
// 二维码过期,停止轮询并显示提示
|
|
35617
|
-
|
|
35618
|
-
|
|
37977
|
+
_this3.loginStatus = 3;
|
|
37978
|
+
_this3.clearTimers();
|
|
35619
37979
|
}
|
|
35620
37980
|
// 其他状态(扫描未确认)不处理
|
|
35621
37981
|
})["catch"](function (err) {
|
|
@@ -35625,19 +37985,25 @@ var qrcode_default = /*#__PURE__*/__webpack_require__.n(qrcode);
|
|
|
35625
37985
|
},
|
|
35626
37986
|
// 倒计时
|
|
35627
37987
|
startCountdown: function startCountdown() {
|
|
35628
|
-
var
|
|
37988
|
+
var _this4 = this;
|
|
35629
37989
|
this.statusTimer = setInterval(function () {
|
|
35630
|
-
|
|
35631
|
-
if (
|
|
35632
|
-
|
|
35633
|
-
|
|
37990
|
+
_this4.expireTime--;
|
|
37991
|
+
if (_this4.expireTime <= 0) {
|
|
37992
|
+
_this4.loginStatus = 3; // 设置为过期状态
|
|
37993
|
+
_this4.clearTimers();
|
|
35634
37994
|
}
|
|
35635
37995
|
}, 1000);
|
|
35636
37996
|
},
|
|
35637
37997
|
// 清除定时器
|
|
35638
37998
|
clearTimers: function clearTimers() {
|
|
35639
|
-
if (this.pollTimer)
|
|
35640
|
-
|
|
37999
|
+
if (this.pollTimer) {
|
|
38000
|
+
clearInterval(this.pollTimer);
|
|
38001
|
+
this.pollTimer = null;
|
|
38002
|
+
}
|
|
38003
|
+
if (this.statusTimer) {
|
|
38004
|
+
clearInterval(this.statusTimer);
|
|
38005
|
+
this.statusTimer = null;
|
|
38006
|
+
}
|
|
35641
38007
|
},
|
|
35642
38008
|
// 重新扫码
|
|
35643
38009
|
handleRescanQrCode: function handleRescanQrCode() {
|
|
@@ -35648,10 +38014,10 @@ var qrcode_default = /*#__PURE__*/__webpack_require__.n(qrcode);
|
|
|
35648
38014
|
});
|
|
35649
38015
|
;// ./src/components/QRCodeLogin.vue?vue&type=script&lang=js
|
|
35650
38016
|
|
|
35651
|
-
;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/QRCodeLogin.vue?vue&type=style&index=0&id=
|
|
38017
|
+
;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/QRCodeLogin.vue?vue&type=style&index=0&id=5b8744aa&lang=scss&scoped=true
|
|
35652
38018
|
// extracted by mini-css-extract-plugin
|
|
35653
38019
|
|
|
35654
|
-
;// ./src/components/QRCodeLogin.vue?vue&type=style&index=0&id=
|
|
38020
|
+
;// ./src/components/QRCodeLogin.vue?vue&type=style&index=0&id=5b8744aa&lang=scss&scoped=true
|
|
35655
38021
|
|
|
35656
38022
|
;// ./src/components/QRCodeLogin.vue
|
|
35657
38023
|
|
|
@@ -35661,7 +38027,7 @@ var qrcode_default = /*#__PURE__*/__webpack_require__.n(qrcode);
|
|
|
35661
38027
|
;
|
|
35662
38028
|
|
|
35663
38029
|
|
|
35664
|
-
const QRCodeLogin_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(QRCodeLoginvue_type_script_lang_js, [['render',
|
|
38030
|
+
const QRCodeLogin_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(QRCodeLoginvue_type_script_lang_js, [['render',QRCodeLoginvue_type_template_id_5b8744aa_scoped_true_render],['__scopeId',"data-v-5b8744aa"]])
|
|
35665
38031
|
|
|
35666
38032
|
/* harmony default export */ const QRCodeLogin = (QRCodeLogin_exports_);
|
|
35667
38033
|
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/cli-service/node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/mobileBinding.vue?vue&type=template&id=3371c604&scoped=true
|