qodewk 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -116
- package/dist/index.cjs +2069 -34
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -3403,6 +3403,1940 @@ var require_picocolors = __commonJS({
|
|
|
3403
3403
|
}
|
|
3404
3404
|
});
|
|
3405
3405
|
|
|
3406
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
|
|
3407
|
+
var require_utils = __commonJS({
|
|
3408
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"(exports2) {
|
|
3409
|
+
"use strict";
|
|
3410
|
+
var toSJISFunction;
|
|
3411
|
+
var CODEWORDS_COUNT = [
|
|
3412
|
+
0,
|
|
3413
|
+
// Not used
|
|
3414
|
+
26,
|
|
3415
|
+
44,
|
|
3416
|
+
70,
|
|
3417
|
+
100,
|
|
3418
|
+
134,
|
|
3419
|
+
172,
|
|
3420
|
+
196,
|
|
3421
|
+
242,
|
|
3422
|
+
292,
|
|
3423
|
+
346,
|
|
3424
|
+
404,
|
|
3425
|
+
466,
|
|
3426
|
+
532,
|
|
3427
|
+
581,
|
|
3428
|
+
655,
|
|
3429
|
+
733,
|
|
3430
|
+
815,
|
|
3431
|
+
901,
|
|
3432
|
+
991,
|
|
3433
|
+
1085,
|
|
3434
|
+
1156,
|
|
3435
|
+
1258,
|
|
3436
|
+
1364,
|
|
3437
|
+
1474,
|
|
3438
|
+
1588,
|
|
3439
|
+
1706,
|
|
3440
|
+
1828,
|
|
3441
|
+
1921,
|
|
3442
|
+
2051,
|
|
3443
|
+
2185,
|
|
3444
|
+
2323,
|
|
3445
|
+
2465,
|
|
3446
|
+
2611,
|
|
3447
|
+
2761,
|
|
3448
|
+
2876,
|
|
3449
|
+
3034,
|
|
3450
|
+
3196,
|
|
3451
|
+
3362,
|
|
3452
|
+
3532,
|
|
3453
|
+
3706
|
|
3454
|
+
];
|
|
3455
|
+
exports2.getSymbolSize = function getSymbolSize(version) {
|
|
3456
|
+
if (!version) throw new Error('"version" cannot be null or undefined');
|
|
3457
|
+
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
3458
|
+
return version * 4 + 17;
|
|
3459
|
+
};
|
|
3460
|
+
exports2.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
|
|
3461
|
+
return CODEWORDS_COUNT[version];
|
|
3462
|
+
};
|
|
3463
|
+
exports2.getBCHDigit = function(data) {
|
|
3464
|
+
let digit = 0;
|
|
3465
|
+
while (data !== 0) {
|
|
3466
|
+
digit++;
|
|
3467
|
+
data >>>= 1;
|
|
3468
|
+
}
|
|
3469
|
+
return digit;
|
|
3470
|
+
};
|
|
3471
|
+
exports2.setToSJISFunction = function setToSJISFunction(f) {
|
|
3472
|
+
if (typeof f !== "function") {
|
|
3473
|
+
throw new Error('"toSJISFunc" is not a valid function.');
|
|
3474
|
+
}
|
|
3475
|
+
toSJISFunction = f;
|
|
3476
|
+
};
|
|
3477
|
+
exports2.isKanjiModeEnabled = function() {
|
|
3478
|
+
return typeof toSJISFunction !== "undefined";
|
|
3479
|
+
};
|
|
3480
|
+
exports2.toSJIS = function toSJIS(kanji) {
|
|
3481
|
+
return toSJISFunction(kanji);
|
|
3482
|
+
};
|
|
3483
|
+
}
|
|
3484
|
+
});
|
|
3485
|
+
|
|
3486
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
|
|
3487
|
+
var require_error_correction_level = __commonJS({
|
|
3488
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"(exports2) {
|
|
3489
|
+
"use strict";
|
|
3490
|
+
exports2.L = { bit: 1 };
|
|
3491
|
+
exports2.M = { bit: 0 };
|
|
3492
|
+
exports2.Q = { bit: 3 };
|
|
3493
|
+
exports2.H = { bit: 2 };
|
|
3494
|
+
function fromString(string) {
|
|
3495
|
+
if (typeof string !== "string") {
|
|
3496
|
+
throw new Error("Param is not a string");
|
|
3497
|
+
}
|
|
3498
|
+
const lcStr = string.toLowerCase();
|
|
3499
|
+
switch (lcStr) {
|
|
3500
|
+
case "l":
|
|
3501
|
+
case "low":
|
|
3502
|
+
return exports2.L;
|
|
3503
|
+
case "m":
|
|
3504
|
+
case "medium":
|
|
3505
|
+
return exports2.M;
|
|
3506
|
+
case "q":
|
|
3507
|
+
case "quartile":
|
|
3508
|
+
return exports2.Q;
|
|
3509
|
+
case "h":
|
|
3510
|
+
case "high":
|
|
3511
|
+
return exports2.H;
|
|
3512
|
+
default:
|
|
3513
|
+
throw new Error("Unknown EC Level: " + string);
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
exports2.isValid = function isValid2(level) {
|
|
3517
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
3518
|
+
};
|
|
3519
|
+
exports2.from = function from(value, defaultValue) {
|
|
3520
|
+
if (exports2.isValid(value)) {
|
|
3521
|
+
return value;
|
|
3522
|
+
}
|
|
3523
|
+
try {
|
|
3524
|
+
return fromString(value);
|
|
3525
|
+
} catch (e) {
|
|
3526
|
+
return defaultValue;
|
|
3527
|
+
}
|
|
3528
|
+
};
|
|
3529
|
+
}
|
|
3530
|
+
});
|
|
3531
|
+
|
|
3532
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
|
|
3533
|
+
var require_bit_buffer = __commonJS({
|
|
3534
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"(exports2, module2) {
|
|
3535
|
+
"use strict";
|
|
3536
|
+
function BitBuffer() {
|
|
3537
|
+
this.buffer = [];
|
|
3538
|
+
this.length = 0;
|
|
3539
|
+
}
|
|
3540
|
+
BitBuffer.prototype = {
|
|
3541
|
+
get: function(index) {
|
|
3542
|
+
const bufIndex = Math.floor(index / 8);
|
|
3543
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
3544
|
+
},
|
|
3545
|
+
put: function(num, length) {
|
|
3546
|
+
for (let i2 = 0; i2 < length; i2++) {
|
|
3547
|
+
this.putBit((num >>> length - i2 - 1 & 1) === 1);
|
|
3548
|
+
}
|
|
3549
|
+
},
|
|
3550
|
+
getLengthInBits: function() {
|
|
3551
|
+
return this.length;
|
|
3552
|
+
},
|
|
3553
|
+
putBit: function(bit) {
|
|
3554
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
3555
|
+
if (this.buffer.length <= bufIndex) {
|
|
3556
|
+
this.buffer.push(0);
|
|
3557
|
+
}
|
|
3558
|
+
if (bit) {
|
|
3559
|
+
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
3560
|
+
}
|
|
3561
|
+
this.length++;
|
|
3562
|
+
}
|
|
3563
|
+
};
|
|
3564
|
+
module2.exports = BitBuffer;
|
|
3565
|
+
}
|
|
3566
|
+
});
|
|
3567
|
+
|
|
3568
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
|
|
3569
|
+
var require_bit_matrix = __commonJS({
|
|
3570
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"(exports2, module2) {
|
|
3571
|
+
"use strict";
|
|
3572
|
+
function BitMatrix(size) {
|
|
3573
|
+
if (!size || size < 1) {
|
|
3574
|
+
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
3575
|
+
}
|
|
3576
|
+
this.size = size;
|
|
3577
|
+
this.data = new Uint8Array(size * size);
|
|
3578
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
3579
|
+
}
|
|
3580
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
3581
|
+
const index = row * this.size + col;
|
|
3582
|
+
this.data[index] = value;
|
|
3583
|
+
if (reserved) this.reservedBit[index] = true;
|
|
3584
|
+
};
|
|
3585
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
3586
|
+
return this.data[row * this.size + col];
|
|
3587
|
+
};
|
|
3588
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
3589
|
+
this.data[row * this.size + col] ^= value;
|
|
3590
|
+
};
|
|
3591
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
3592
|
+
return this.reservedBit[row * this.size + col];
|
|
3593
|
+
};
|
|
3594
|
+
module2.exports = BitMatrix;
|
|
3595
|
+
}
|
|
3596
|
+
});
|
|
3597
|
+
|
|
3598
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
|
|
3599
|
+
var require_alignment_pattern = __commonJS({
|
|
3600
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"(exports2) {
|
|
3601
|
+
"use strict";
|
|
3602
|
+
var getSymbolSize = require_utils().getSymbolSize;
|
|
3603
|
+
exports2.getRowColCoords = function getRowColCoords(version) {
|
|
3604
|
+
if (version === 1) return [];
|
|
3605
|
+
const posCount = Math.floor(version / 7) + 2;
|
|
3606
|
+
const size = getSymbolSize(version);
|
|
3607
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
3608
|
+
const positions = [size - 7];
|
|
3609
|
+
for (let i2 = 1; i2 < posCount - 1; i2++) {
|
|
3610
|
+
positions[i2] = positions[i2 - 1] - intervals;
|
|
3611
|
+
}
|
|
3612
|
+
positions.push(6);
|
|
3613
|
+
return positions.reverse();
|
|
3614
|
+
};
|
|
3615
|
+
exports2.getPositions = function getPositions(version) {
|
|
3616
|
+
const coords = [];
|
|
3617
|
+
const pos = exports2.getRowColCoords(version);
|
|
3618
|
+
const posLength = pos.length;
|
|
3619
|
+
for (let i2 = 0; i2 < posLength; i2++) {
|
|
3620
|
+
for (let j2 = 0; j2 < posLength; j2++) {
|
|
3621
|
+
if (i2 === 0 && j2 === 0 || // top-left
|
|
3622
|
+
i2 === 0 && j2 === posLength - 1 || // bottom-left
|
|
3623
|
+
i2 === posLength - 1 && j2 === 0) {
|
|
3624
|
+
continue;
|
|
3625
|
+
}
|
|
3626
|
+
coords.push([pos[i2], pos[j2]]);
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
return coords;
|
|
3630
|
+
};
|
|
3631
|
+
}
|
|
3632
|
+
});
|
|
3633
|
+
|
|
3634
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
|
|
3635
|
+
var require_finder_pattern = __commonJS({
|
|
3636
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"(exports2) {
|
|
3637
|
+
"use strict";
|
|
3638
|
+
var getSymbolSize = require_utils().getSymbolSize;
|
|
3639
|
+
var FINDER_PATTERN_SIZE = 7;
|
|
3640
|
+
exports2.getPositions = function getPositions(version) {
|
|
3641
|
+
const size = getSymbolSize(version);
|
|
3642
|
+
return [
|
|
3643
|
+
// top-left
|
|
3644
|
+
[0, 0],
|
|
3645
|
+
// top-right
|
|
3646
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
3647
|
+
// bottom-left
|
|
3648
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
3649
|
+
];
|
|
3650
|
+
};
|
|
3651
|
+
}
|
|
3652
|
+
});
|
|
3653
|
+
|
|
3654
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
|
|
3655
|
+
var require_mask_pattern = __commonJS({
|
|
3656
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"(exports2) {
|
|
3657
|
+
"use strict";
|
|
3658
|
+
exports2.Patterns = {
|
|
3659
|
+
PATTERN000: 0,
|
|
3660
|
+
PATTERN001: 1,
|
|
3661
|
+
PATTERN010: 2,
|
|
3662
|
+
PATTERN011: 3,
|
|
3663
|
+
PATTERN100: 4,
|
|
3664
|
+
PATTERN101: 5,
|
|
3665
|
+
PATTERN110: 6,
|
|
3666
|
+
PATTERN111: 7
|
|
3667
|
+
};
|
|
3668
|
+
var PenaltyScores = {
|
|
3669
|
+
N1: 3,
|
|
3670
|
+
N2: 3,
|
|
3671
|
+
N3: 40,
|
|
3672
|
+
N4: 10
|
|
3673
|
+
};
|
|
3674
|
+
exports2.isValid = function isValid2(mask) {
|
|
3675
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
3676
|
+
};
|
|
3677
|
+
exports2.from = function from(value) {
|
|
3678
|
+
return exports2.isValid(value) ? parseInt(value, 10) : void 0;
|
|
3679
|
+
};
|
|
3680
|
+
exports2.getPenaltyN1 = function getPenaltyN1(data) {
|
|
3681
|
+
const size = data.size;
|
|
3682
|
+
let points = 0;
|
|
3683
|
+
let sameCountCol = 0;
|
|
3684
|
+
let sameCountRow = 0;
|
|
3685
|
+
let lastCol = null;
|
|
3686
|
+
let lastRow = null;
|
|
3687
|
+
for (let row = 0; row < size; row++) {
|
|
3688
|
+
sameCountCol = sameCountRow = 0;
|
|
3689
|
+
lastCol = lastRow = null;
|
|
3690
|
+
for (let col = 0; col < size; col++) {
|
|
3691
|
+
let module3 = data.get(row, col);
|
|
3692
|
+
if (module3 === lastCol) {
|
|
3693
|
+
sameCountCol++;
|
|
3694
|
+
} else {
|
|
3695
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
3696
|
+
lastCol = module3;
|
|
3697
|
+
sameCountCol = 1;
|
|
3698
|
+
}
|
|
3699
|
+
module3 = data.get(col, row);
|
|
3700
|
+
if (module3 === lastRow) {
|
|
3701
|
+
sameCountRow++;
|
|
3702
|
+
} else {
|
|
3703
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
3704
|
+
lastRow = module3;
|
|
3705
|
+
sameCountRow = 1;
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
3709
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
3710
|
+
}
|
|
3711
|
+
return points;
|
|
3712
|
+
};
|
|
3713
|
+
exports2.getPenaltyN2 = function getPenaltyN2(data) {
|
|
3714
|
+
const size = data.size;
|
|
3715
|
+
let points = 0;
|
|
3716
|
+
for (let row = 0; row < size - 1; row++) {
|
|
3717
|
+
for (let col = 0; col < size - 1; col++) {
|
|
3718
|
+
const last2 = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
3719
|
+
if (last2 === 4 || last2 === 0) points++;
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
return points * PenaltyScores.N2;
|
|
3723
|
+
};
|
|
3724
|
+
exports2.getPenaltyN3 = function getPenaltyN3(data) {
|
|
3725
|
+
const size = data.size;
|
|
3726
|
+
let points = 0;
|
|
3727
|
+
let bitsCol = 0;
|
|
3728
|
+
let bitsRow = 0;
|
|
3729
|
+
for (let row = 0; row < size; row++) {
|
|
3730
|
+
bitsCol = bitsRow = 0;
|
|
3731
|
+
for (let col = 0; col < size; col++) {
|
|
3732
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
3733
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
3734
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
3735
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3738
|
+
return points * PenaltyScores.N3;
|
|
3739
|
+
};
|
|
3740
|
+
exports2.getPenaltyN4 = function getPenaltyN4(data) {
|
|
3741
|
+
let darkCount = 0;
|
|
3742
|
+
const modulesCount = data.data.length;
|
|
3743
|
+
for (let i2 = 0; i2 < modulesCount; i2++) darkCount += data.data[i2];
|
|
3744
|
+
const k2 = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10);
|
|
3745
|
+
return k2 * PenaltyScores.N4;
|
|
3746
|
+
};
|
|
3747
|
+
function getMaskAt(maskPattern, i2, j2) {
|
|
3748
|
+
switch (maskPattern) {
|
|
3749
|
+
case exports2.Patterns.PATTERN000:
|
|
3750
|
+
return (i2 + j2) % 2 === 0;
|
|
3751
|
+
case exports2.Patterns.PATTERN001:
|
|
3752
|
+
return i2 % 2 === 0;
|
|
3753
|
+
case exports2.Patterns.PATTERN010:
|
|
3754
|
+
return j2 % 3 === 0;
|
|
3755
|
+
case exports2.Patterns.PATTERN011:
|
|
3756
|
+
return (i2 + j2) % 3 === 0;
|
|
3757
|
+
case exports2.Patterns.PATTERN100:
|
|
3758
|
+
return (Math.floor(i2 / 2) + Math.floor(j2 / 3)) % 2 === 0;
|
|
3759
|
+
case exports2.Patterns.PATTERN101:
|
|
3760
|
+
return i2 * j2 % 2 + i2 * j2 % 3 === 0;
|
|
3761
|
+
case exports2.Patterns.PATTERN110:
|
|
3762
|
+
return (i2 * j2 % 2 + i2 * j2 % 3) % 2 === 0;
|
|
3763
|
+
case exports2.Patterns.PATTERN111:
|
|
3764
|
+
return (i2 * j2 % 3 + (i2 + j2) % 2) % 2 === 0;
|
|
3765
|
+
default:
|
|
3766
|
+
throw new Error("bad maskPattern:" + maskPattern);
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
exports2.applyMask = function applyMask(pattern, data) {
|
|
3770
|
+
const size = data.size;
|
|
3771
|
+
for (let col = 0; col < size; col++) {
|
|
3772
|
+
for (let row = 0; row < size; row++) {
|
|
3773
|
+
if (data.isReserved(row, col)) continue;
|
|
3774
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
};
|
|
3778
|
+
exports2.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
3779
|
+
const numPatterns = Object.keys(exports2.Patterns).length;
|
|
3780
|
+
let bestPattern = 0;
|
|
3781
|
+
let lowerPenalty = Infinity;
|
|
3782
|
+
for (let p2 = 0; p2 < numPatterns; p2++) {
|
|
3783
|
+
setupFormatFunc(p2);
|
|
3784
|
+
exports2.applyMask(p2, data);
|
|
3785
|
+
const penalty = exports2.getPenaltyN1(data) + exports2.getPenaltyN2(data) + exports2.getPenaltyN3(data) + exports2.getPenaltyN4(data);
|
|
3786
|
+
exports2.applyMask(p2, data);
|
|
3787
|
+
if (penalty < lowerPenalty) {
|
|
3788
|
+
lowerPenalty = penalty;
|
|
3789
|
+
bestPattern = p2;
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
return bestPattern;
|
|
3793
|
+
};
|
|
3794
|
+
}
|
|
3795
|
+
});
|
|
3796
|
+
|
|
3797
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
|
|
3798
|
+
var require_error_correction_code = __commonJS({
|
|
3799
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"(exports2) {
|
|
3800
|
+
"use strict";
|
|
3801
|
+
var ECLevel = require_error_correction_level();
|
|
3802
|
+
var EC_BLOCKS_TABLE = [
|
|
3803
|
+
// L M Q H
|
|
3804
|
+
1,
|
|
3805
|
+
1,
|
|
3806
|
+
1,
|
|
3807
|
+
1,
|
|
3808
|
+
1,
|
|
3809
|
+
1,
|
|
3810
|
+
1,
|
|
3811
|
+
1,
|
|
3812
|
+
1,
|
|
3813
|
+
1,
|
|
3814
|
+
2,
|
|
3815
|
+
2,
|
|
3816
|
+
1,
|
|
3817
|
+
2,
|
|
3818
|
+
2,
|
|
3819
|
+
4,
|
|
3820
|
+
1,
|
|
3821
|
+
2,
|
|
3822
|
+
4,
|
|
3823
|
+
4,
|
|
3824
|
+
2,
|
|
3825
|
+
4,
|
|
3826
|
+
4,
|
|
3827
|
+
4,
|
|
3828
|
+
2,
|
|
3829
|
+
4,
|
|
3830
|
+
6,
|
|
3831
|
+
5,
|
|
3832
|
+
2,
|
|
3833
|
+
4,
|
|
3834
|
+
6,
|
|
3835
|
+
6,
|
|
3836
|
+
2,
|
|
3837
|
+
5,
|
|
3838
|
+
8,
|
|
3839
|
+
8,
|
|
3840
|
+
4,
|
|
3841
|
+
5,
|
|
3842
|
+
8,
|
|
3843
|
+
8,
|
|
3844
|
+
4,
|
|
3845
|
+
5,
|
|
3846
|
+
8,
|
|
3847
|
+
11,
|
|
3848
|
+
4,
|
|
3849
|
+
8,
|
|
3850
|
+
10,
|
|
3851
|
+
11,
|
|
3852
|
+
4,
|
|
3853
|
+
9,
|
|
3854
|
+
12,
|
|
3855
|
+
16,
|
|
3856
|
+
4,
|
|
3857
|
+
9,
|
|
3858
|
+
16,
|
|
3859
|
+
16,
|
|
3860
|
+
6,
|
|
3861
|
+
10,
|
|
3862
|
+
12,
|
|
3863
|
+
18,
|
|
3864
|
+
6,
|
|
3865
|
+
10,
|
|
3866
|
+
17,
|
|
3867
|
+
16,
|
|
3868
|
+
6,
|
|
3869
|
+
11,
|
|
3870
|
+
16,
|
|
3871
|
+
19,
|
|
3872
|
+
6,
|
|
3873
|
+
13,
|
|
3874
|
+
18,
|
|
3875
|
+
21,
|
|
3876
|
+
7,
|
|
3877
|
+
14,
|
|
3878
|
+
21,
|
|
3879
|
+
25,
|
|
3880
|
+
8,
|
|
3881
|
+
16,
|
|
3882
|
+
20,
|
|
3883
|
+
25,
|
|
3884
|
+
8,
|
|
3885
|
+
17,
|
|
3886
|
+
23,
|
|
3887
|
+
25,
|
|
3888
|
+
9,
|
|
3889
|
+
17,
|
|
3890
|
+
23,
|
|
3891
|
+
34,
|
|
3892
|
+
9,
|
|
3893
|
+
18,
|
|
3894
|
+
25,
|
|
3895
|
+
30,
|
|
3896
|
+
10,
|
|
3897
|
+
20,
|
|
3898
|
+
27,
|
|
3899
|
+
32,
|
|
3900
|
+
12,
|
|
3901
|
+
21,
|
|
3902
|
+
29,
|
|
3903
|
+
35,
|
|
3904
|
+
12,
|
|
3905
|
+
23,
|
|
3906
|
+
34,
|
|
3907
|
+
37,
|
|
3908
|
+
12,
|
|
3909
|
+
25,
|
|
3910
|
+
34,
|
|
3911
|
+
40,
|
|
3912
|
+
13,
|
|
3913
|
+
26,
|
|
3914
|
+
35,
|
|
3915
|
+
42,
|
|
3916
|
+
14,
|
|
3917
|
+
28,
|
|
3918
|
+
38,
|
|
3919
|
+
45,
|
|
3920
|
+
15,
|
|
3921
|
+
29,
|
|
3922
|
+
40,
|
|
3923
|
+
48,
|
|
3924
|
+
16,
|
|
3925
|
+
31,
|
|
3926
|
+
43,
|
|
3927
|
+
51,
|
|
3928
|
+
17,
|
|
3929
|
+
33,
|
|
3930
|
+
45,
|
|
3931
|
+
54,
|
|
3932
|
+
18,
|
|
3933
|
+
35,
|
|
3934
|
+
48,
|
|
3935
|
+
57,
|
|
3936
|
+
19,
|
|
3937
|
+
37,
|
|
3938
|
+
51,
|
|
3939
|
+
60,
|
|
3940
|
+
19,
|
|
3941
|
+
38,
|
|
3942
|
+
53,
|
|
3943
|
+
63,
|
|
3944
|
+
20,
|
|
3945
|
+
40,
|
|
3946
|
+
56,
|
|
3947
|
+
66,
|
|
3948
|
+
21,
|
|
3949
|
+
43,
|
|
3950
|
+
59,
|
|
3951
|
+
70,
|
|
3952
|
+
22,
|
|
3953
|
+
45,
|
|
3954
|
+
62,
|
|
3955
|
+
74,
|
|
3956
|
+
24,
|
|
3957
|
+
47,
|
|
3958
|
+
65,
|
|
3959
|
+
77,
|
|
3960
|
+
25,
|
|
3961
|
+
49,
|
|
3962
|
+
68,
|
|
3963
|
+
81
|
|
3964
|
+
];
|
|
3965
|
+
var EC_CODEWORDS_TABLE = [
|
|
3966
|
+
// L M Q H
|
|
3967
|
+
7,
|
|
3968
|
+
10,
|
|
3969
|
+
13,
|
|
3970
|
+
17,
|
|
3971
|
+
10,
|
|
3972
|
+
16,
|
|
3973
|
+
22,
|
|
3974
|
+
28,
|
|
3975
|
+
15,
|
|
3976
|
+
26,
|
|
3977
|
+
36,
|
|
3978
|
+
44,
|
|
3979
|
+
20,
|
|
3980
|
+
36,
|
|
3981
|
+
52,
|
|
3982
|
+
64,
|
|
3983
|
+
26,
|
|
3984
|
+
48,
|
|
3985
|
+
72,
|
|
3986
|
+
88,
|
|
3987
|
+
36,
|
|
3988
|
+
64,
|
|
3989
|
+
96,
|
|
3990
|
+
112,
|
|
3991
|
+
40,
|
|
3992
|
+
72,
|
|
3993
|
+
108,
|
|
3994
|
+
130,
|
|
3995
|
+
48,
|
|
3996
|
+
88,
|
|
3997
|
+
132,
|
|
3998
|
+
156,
|
|
3999
|
+
60,
|
|
4000
|
+
110,
|
|
4001
|
+
160,
|
|
4002
|
+
192,
|
|
4003
|
+
72,
|
|
4004
|
+
130,
|
|
4005
|
+
192,
|
|
4006
|
+
224,
|
|
4007
|
+
80,
|
|
4008
|
+
150,
|
|
4009
|
+
224,
|
|
4010
|
+
264,
|
|
4011
|
+
96,
|
|
4012
|
+
176,
|
|
4013
|
+
260,
|
|
4014
|
+
308,
|
|
4015
|
+
104,
|
|
4016
|
+
198,
|
|
4017
|
+
288,
|
|
4018
|
+
352,
|
|
4019
|
+
120,
|
|
4020
|
+
216,
|
|
4021
|
+
320,
|
|
4022
|
+
384,
|
|
4023
|
+
132,
|
|
4024
|
+
240,
|
|
4025
|
+
360,
|
|
4026
|
+
432,
|
|
4027
|
+
144,
|
|
4028
|
+
280,
|
|
4029
|
+
408,
|
|
4030
|
+
480,
|
|
4031
|
+
168,
|
|
4032
|
+
308,
|
|
4033
|
+
448,
|
|
4034
|
+
532,
|
|
4035
|
+
180,
|
|
4036
|
+
338,
|
|
4037
|
+
504,
|
|
4038
|
+
588,
|
|
4039
|
+
196,
|
|
4040
|
+
364,
|
|
4041
|
+
546,
|
|
4042
|
+
650,
|
|
4043
|
+
224,
|
|
4044
|
+
416,
|
|
4045
|
+
600,
|
|
4046
|
+
700,
|
|
4047
|
+
224,
|
|
4048
|
+
442,
|
|
4049
|
+
644,
|
|
4050
|
+
750,
|
|
4051
|
+
252,
|
|
4052
|
+
476,
|
|
4053
|
+
690,
|
|
4054
|
+
816,
|
|
4055
|
+
270,
|
|
4056
|
+
504,
|
|
4057
|
+
750,
|
|
4058
|
+
900,
|
|
4059
|
+
300,
|
|
4060
|
+
560,
|
|
4061
|
+
810,
|
|
4062
|
+
960,
|
|
4063
|
+
312,
|
|
4064
|
+
588,
|
|
4065
|
+
870,
|
|
4066
|
+
1050,
|
|
4067
|
+
336,
|
|
4068
|
+
644,
|
|
4069
|
+
952,
|
|
4070
|
+
1110,
|
|
4071
|
+
360,
|
|
4072
|
+
700,
|
|
4073
|
+
1020,
|
|
4074
|
+
1200,
|
|
4075
|
+
390,
|
|
4076
|
+
728,
|
|
4077
|
+
1050,
|
|
4078
|
+
1260,
|
|
4079
|
+
420,
|
|
4080
|
+
784,
|
|
4081
|
+
1140,
|
|
4082
|
+
1350,
|
|
4083
|
+
450,
|
|
4084
|
+
812,
|
|
4085
|
+
1200,
|
|
4086
|
+
1440,
|
|
4087
|
+
480,
|
|
4088
|
+
868,
|
|
4089
|
+
1290,
|
|
4090
|
+
1530,
|
|
4091
|
+
510,
|
|
4092
|
+
924,
|
|
4093
|
+
1350,
|
|
4094
|
+
1620,
|
|
4095
|
+
540,
|
|
4096
|
+
980,
|
|
4097
|
+
1440,
|
|
4098
|
+
1710,
|
|
4099
|
+
570,
|
|
4100
|
+
1036,
|
|
4101
|
+
1530,
|
|
4102
|
+
1800,
|
|
4103
|
+
570,
|
|
4104
|
+
1064,
|
|
4105
|
+
1590,
|
|
4106
|
+
1890,
|
|
4107
|
+
600,
|
|
4108
|
+
1120,
|
|
4109
|
+
1680,
|
|
4110
|
+
1980,
|
|
4111
|
+
630,
|
|
4112
|
+
1204,
|
|
4113
|
+
1770,
|
|
4114
|
+
2100,
|
|
4115
|
+
660,
|
|
4116
|
+
1260,
|
|
4117
|
+
1860,
|
|
4118
|
+
2220,
|
|
4119
|
+
720,
|
|
4120
|
+
1316,
|
|
4121
|
+
1950,
|
|
4122
|
+
2310,
|
|
4123
|
+
750,
|
|
4124
|
+
1372,
|
|
4125
|
+
2040,
|
|
4126
|
+
2430
|
|
4127
|
+
];
|
|
4128
|
+
exports2.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
|
|
4129
|
+
switch (errorCorrectionLevel) {
|
|
4130
|
+
case ECLevel.L:
|
|
4131
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
4132
|
+
case ECLevel.M:
|
|
4133
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
4134
|
+
case ECLevel.Q:
|
|
4135
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
4136
|
+
case ECLevel.H:
|
|
4137
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
4138
|
+
default:
|
|
4139
|
+
return void 0;
|
|
4140
|
+
}
|
|
4141
|
+
};
|
|
4142
|
+
exports2.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
|
|
4143
|
+
switch (errorCorrectionLevel) {
|
|
4144
|
+
case ECLevel.L:
|
|
4145
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
4146
|
+
case ECLevel.M:
|
|
4147
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
4148
|
+
case ECLevel.Q:
|
|
4149
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
4150
|
+
case ECLevel.H:
|
|
4151
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
4152
|
+
default:
|
|
4153
|
+
return void 0;
|
|
4154
|
+
}
|
|
4155
|
+
};
|
|
4156
|
+
}
|
|
4157
|
+
});
|
|
4158
|
+
|
|
4159
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
|
|
4160
|
+
var require_galois_field = __commonJS({
|
|
4161
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js"(exports2) {
|
|
4162
|
+
"use strict";
|
|
4163
|
+
var EXP_TABLE = new Uint8Array(512);
|
|
4164
|
+
var LOG_TABLE = new Uint8Array(256);
|
|
4165
|
+
(function initTables() {
|
|
4166
|
+
let x2 = 1;
|
|
4167
|
+
for (let i2 = 0; i2 < 255; i2++) {
|
|
4168
|
+
EXP_TABLE[i2] = x2;
|
|
4169
|
+
LOG_TABLE[x2] = i2;
|
|
4170
|
+
x2 <<= 1;
|
|
4171
|
+
if (x2 & 256) {
|
|
4172
|
+
x2 ^= 285;
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
for (let i2 = 255; i2 < 512; i2++) {
|
|
4176
|
+
EXP_TABLE[i2] = EXP_TABLE[i2 - 255];
|
|
4177
|
+
}
|
|
4178
|
+
})();
|
|
4179
|
+
exports2.log = function log(n) {
|
|
4180
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
4181
|
+
return LOG_TABLE[n];
|
|
4182
|
+
};
|
|
4183
|
+
exports2.exp = function exp(n) {
|
|
4184
|
+
return EXP_TABLE[n];
|
|
4185
|
+
};
|
|
4186
|
+
exports2.mul = function mul(x2, y2) {
|
|
4187
|
+
if (x2 === 0 || y2 === 0) return 0;
|
|
4188
|
+
return EXP_TABLE[LOG_TABLE[x2] + LOG_TABLE[y2]];
|
|
4189
|
+
};
|
|
4190
|
+
}
|
|
4191
|
+
});
|
|
4192
|
+
|
|
4193
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
|
|
4194
|
+
var require_polynomial = __commonJS({
|
|
4195
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js"(exports2) {
|
|
4196
|
+
"use strict";
|
|
4197
|
+
var GF = require_galois_field();
|
|
4198
|
+
exports2.mul = function mul(p1, p2) {
|
|
4199
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
4200
|
+
for (let i2 = 0; i2 < p1.length; i2++) {
|
|
4201
|
+
for (let j2 = 0; j2 < p2.length; j2++) {
|
|
4202
|
+
coeff[i2 + j2] ^= GF.mul(p1[i2], p2[j2]);
|
|
4203
|
+
}
|
|
4204
|
+
}
|
|
4205
|
+
return coeff;
|
|
4206
|
+
};
|
|
4207
|
+
exports2.mod = function mod(divident, divisor) {
|
|
4208
|
+
let result = new Uint8Array(divident);
|
|
4209
|
+
while (result.length - divisor.length >= 0) {
|
|
4210
|
+
const coeff = result[0];
|
|
4211
|
+
for (let i2 = 0; i2 < divisor.length; i2++) {
|
|
4212
|
+
result[i2] ^= GF.mul(divisor[i2], coeff);
|
|
4213
|
+
}
|
|
4214
|
+
let offset = 0;
|
|
4215
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
4216
|
+
result = result.slice(offset);
|
|
4217
|
+
}
|
|
4218
|
+
return result;
|
|
4219
|
+
};
|
|
4220
|
+
exports2.generateECPolynomial = function generateECPolynomial(degree) {
|
|
4221
|
+
let poly = new Uint8Array([1]);
|
|
4222
|
+
for (let i2 = 0; i2 < degree; i2++) {
|
|
4223
|
+
poly = exports2.mul(poly, new Uint8Array([1, GF.exp(i2)]));
|
|
4224
|
+
}
|
|
4225
|
+
return poly;
|
|
4226
|
+
};
|
|
4227
|
+
}
|
|
4228
|
+
});
|
|
4229
|
+
|
|
4230
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
4231
|
+
var require_reed_solomon_encoder = __commonJS({
|
|
4232
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"(exports2, module2) {
|
|
4233
|
+
"use strict";
|
|
4234
|
+
var Polynomial = require_polynomial();
|
|
4235
|
+
function ReedSolomonEncoder(degree) {
|
|
4236
|
+
this.genPoly = void 0;
|
|
4237
|
+
this.degree = degree;
|
|
4238
|
+
if (this.degree) this.initialize(this.degree);
|
|
4239
|
+
}
|
|
4240
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
4241
|
+
this.degree = degree;
|
|
4242
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
4243
|
+
};
|
|
4244
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
4245
|
+
if (!this.genPoly) {
|
|
4246
|
+
throw new Error("Encoder not initialized");
|
|
4247
|
+
}
|
|
4248
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
4249
|
+
paddedData.set(data);
|
|
4250
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
4251
|
+
const start = this.degree - remainder.length;
|
|
4252
|
+
if (start > 0) {
|
|
4253
|
+
const buff = new Uint8Array(this.degree);
|
|
4254
|
+
buff.set(remainder, start);
|
|
4255
|
+
return buff;
|
|
4256
|
+
}
|
|
4257
|
+
return remainder;
|
|
4258
|
+
};
|
|
4259
|
+
module2.exports = ReedSolomonEncoder;
|
|
4260
|
+
}
|
|
4261
|
+
});
|
|
4262
|
+
|
|
4263
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
|
|
4264
|
+
var require_version_check = __commonJS({
|
|
4265
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"(exports2) {
|
|
4266
|
+
"use strict";
|
|
4267
|
+
exports2.isValid = function isValid2(version) {
|
|
4268
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
4269
|
+
};
|
|
4270
|
+
}
|
|
4271
|
+
});
|
|
4272
|
+
|
|
4273
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
|
|
4274
|
+
var require_regex = __commonJS({
|
|
4275
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(exports2) {
|
|
4276
|
+
"use strict";
|
|
4277
|
+
var numeric = "[0-9]+";
|
|
4278
|
+
var alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
4279
|
+
var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
4280
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
4281
|
+
var byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
4282
|
+
exports2.KANJI = new RegExp(kanji, "g");
|
|
4283
|
+
exports2.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
4284
|
+
exports2.BYTE = new RegExp(byte, "g");
|
|
4285
|
+
exports2.NUMERIC = new RegExp(numeric, "g");
|
|
4286
|
+
exports2.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
4287
|
+
var TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
4288
|
+
var TEST_NUMERIC = new RegExp("^" + numeric + "$");
|
|
4289
|
+
var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
4290
|
+
exports2.testKanji = function testKanji(str) {
|
|
4291
|
+
return TEST_KANJI.test(str);
|
|
4292
|
+
};
|
|
4293
|
+
exports2.testNumeric = function testNumeric(str) {
|
|
4294
|
+
return TEST_NUMERIC.test(str);
|
|
4295
|
+
};
|
|
4296
|
+
exports2.testAlphanumeric = function testAlphanumeric(str) {
|
|
4297
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
});
|
|
4301
|
+
|
|
4302
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
|
|
4303
|
+
var require_mode = __commonJS({
|
|
4304
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"(exports2) {
|
|
4305
|
+
"use strict";
|
|
4306
|
+
var VersionCheck = require_version_check();
|
|
4307
|
+
var Regex = require_regex();
|
|
4308
|
+
exports2.NUMERIC = {
|
|
4309
|
+
id: "Numeric",
|
|
4310
|
+
bit: 1 << 0,
|
|
4311
|
+
ccBits: [10, 12, 14]
|
|
4312
|
+
};
|
|
4313
|
+
exports2.ALPHANUMERIC = {
|
|
4314
|
+
id: "Alphanumeric",
|
|
4315
|
+
bit: 1 << 1,
|
|
4316
|
+
ccBits: [9, 11, 13]
|
|
4317
|
+
};
|
|
4318
|
+
exports2.BYTE = {
|
|
4319
|
+
id: "Byte",
|
|
4320
|
+
bit: 1 << 2,
|
|
4321
|
+
ccBits: [8, 16, 16]
|
|
4322
|
+
};
|
|
4323
|
+
exports2.KANJI = {
|
|
4324
|
+
id: "Kanji",
|
|
4325
|
+
bit: 1 << 3,
|
|
4326
|
+
ccBits: [8, 10, 12]
|
|
4327
|
+
};
|
|
4328
|
+
exports2.MIXED = {
|
|
4329
|
+
bit: -1
|
|
4330
|
+
};
|
|
4331
|
+
exports2.getCharCountIndicator = function getCharCountIndicator(mode, version) {
|
|
4332
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
4333
|
+
if (!VersionCheck.isValid(version)) {
|
|
4334
|
+
throw new Error("Invalid version: " + version);
|
|
4335
|
+
}
|
|
4336
|
+
if (version >= 1 && version < 10) return mode.ccBits[0];
|
|
4337
|
+
else if (version < 27) return mode.ccBits[1];
|
|
4338
|
+
return mode.ccBits[2];
|
|
4339
|
+
};
|
|
4340
|
+
exports2.getBestModeForData = function getBestModeForData(dataStr) {
|
|
4341
|
+
if (Regex.testNumeric(dataStr)) return exports2.NUMERIC;
|
|
4342
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports2.ALPHANUMERIC;
|
|
4343
|
+
else if (Regex.testKanji(dataStr)) return exports2.KANJI;
|
|
4344
|
+
else return exports2.BYTE;
|
|
4345
|
+
};
|
|
4346
|
+
exports2.toString = function toString(mode) {
|
|
4347
|
+
if (mode && mode.id) return mode.id;
|
|
4348
|
+
throw new Error("Invalid mode");
|
|
4349
|
+
};
|
|
4350
|
+
exports2.isValid = function isValid2(mode) {
|
|
4351
|
+
return mode && mode.bit && mode.ccBits;
|
|
4352
|
+
};
|
|
4353
|
+
function fromString(string) {
|
|
4354
|
+
if (typeof string !== "string") {
|
|
4355
|
+
throw new Error("Param is not a string");
|
|
4356
|
+
}
|
|
4357
|
+
const lcStr = string.toLowerCase();
|
|
4358
|
+
switch (lcStr) {
|
|
4359
|
+
case "numeric":
|
|
4360
|
+
return exports2.NUMERIC;
|
|
4361
|
+
case "alphanumeric":
|
|
4362
|
+
return exports2.ALPHANUMERIC;
|
|
4363
|
+
case "kanji":
|
|
4364
|
+
return exports2.KANJI;
|
|
4365
|
+
case "byte":
|
|
4366
|
+
return exports2.BYTE;
|
|
4367
|
+
default:
|
|
4368
|
+
throw new Error("Unknown mode: " + string);
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
exports2.from = function from(value, defaultValue) {
|
|
4372
|
+
if (exports2.isValid(value)) {
|
|
4373
|
+
return value;
|
|
4374
|
+
}
|
|
4375
|
+
try {
|
|
4376
|
+
return fromString(value);
|
|
4377
|
+
} catch (e) {
|
|
4378
|
+
return defaultValue;
|
|
4379
|
+
}
|
|
4380
|
+
};
|
|
4381
|
+
}
|
|
4382
|
+
});
|
|
4383
|
+
|
|
4384
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
|
|
4385
|
+
var require_version = __commonJS({
|
|
4386
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"(exports2) {
|
|
4387
|
+
"use strict";
|
|
4388
|
+
var Utils = require_utils();
|
|
4389
|
+
var ECCode = require_error_correction_code();
|
|
4390
|
+
var ECLevel = require_error_correction_level();
|
|
4391
|
+
var Mode = require_mode();
|
|
4392
|
+
var VersionCheck = require_version_check();
|
|
4393
|
+
var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
|
|
4394
|
+
var G18_BCH = Utils.getBCHDigit(G18);
|
|
4395
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
4396
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
4397
|
+
if (length <= exports2.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
|
|
4398
|
+
return currentVersion;
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4401
|
+
return void 0;
|
|
4402
|
+
}
|
|
4403
|
+
function getReservedBitsCount(mode, version) {
|
|
4404
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
4405
|
+
}
|
|
4406
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
4407
|
+
let totalBits = 0;
|
|
4408
|
+
segments.forEach(function(data) {
|
|
4409
|
+
const reservedBits = getReservedBitsCount(data.mode, version);
|
|
4410
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
4411
|
+
});
|
|
4412
|
+
return totalBits;
|
|
4413
|
+
}
|
|
4414
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
4415
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
4416
|
+
const length = getTotalBitsFromDataArray(segments, currentVersion);
|
|
4417
|
+
if (length <= exports2.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
|
|
4418
|
+
return currentVersion;
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
return void 0;
|
|
4422
|
+
}
|
|
4423
|
+
exports2.from = function from(value, defaultValue) {
|
|
4424
|
+
if (VersionCheck.isValid(value)) {
|
|
4425
|
+
return parseInt(value, 10);
|
|
4426
|
+
}
|
|
4427
|
+
return defaultValue;
|
|
4428
|
+
};
|
|
4429
|
+
exports2.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
|
|
4430
|
+
if (!VersionCheck.isValid(version)) {
|
|
4431
|
+
throw new Error("Invalid QR Code version");
|
|
4432
|
+
}
|
|
4433
|
+
if (typeof mode === "undefined") mode = Mode.BYTE;
|
|
4434
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
4435
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
4436
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
4437
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
4438
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
4439
|
+
switch (mode) {
|
|
4440
|
+
case Mode.NUMERIC:
|
|
4441
|
+
return Math.floor(usableBits / 10 * 3);
|
|
4442
|
+
case Mode.ALPHANUMERIC:
|
|
4443
|
+
return Math.floor(usableBits / 11 * 2);
|
|
4444
|
+
case Mode.KANJI:
|
|
4445
|
+
return Math.floor(usableBits / 13);
|
|
4446
|
+
case Mode.BYTE:
|
|
4447
|
+
default:
|
|
4448
|
+
return Math.floor(usableBits / 8);
|
|
4449
|
+
}
|
|
4450
|
+
};
|
|
4451
|
+
exports2.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
|
|
4452
|
+
let seg;
|
|
4453
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
4454
|
+
if (Array.isArray(data)) {
|
|
4455
|
+
if (data.length > 1) {
|
|
4456
|
+
return getBestVersionForMixedData(data, ecl);
|
|
4457
|
+
}
|
|
4458
|
+
if (data.length === 0) {
|
|
4459
|
+
return 1;
|
|
4460
|
+
}
|
|
4461
|
+
seg = data[0];
|
|
4462
|
+
} else {
|
|
4463
|
+
seg = data;
|
|
4464
|
+
}
|
|
4465
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
4466
|
+
};
|
|
4467
|
+
exports2.getEncodedBits = function getEncodedBits(version) {
|
|
4468
|
+
if (!VersionCheck.isValid(version) || version < 7) {
|
|
4469
|
+
throw new Error("Invalid QR Code version");
|
|
4470
|
+
}
|
|
4471
|
+
let d = version << 12;
|
|
4472
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
|
|
4473
|
+
d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
4474
|
+
}
|
|
4475
|
+
return version << 12 | d;
|
|
4476
|
+
};
|
|
4477
|
+
}
|
|
4478
|
+
});
|
|
4479
|
+
|
|
4480
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
|
|
4481
|
+
var require_format_info = __commonJS({
|
|
4482
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"(exports2) {
|
|
4483
|
+
"use strict";
|
|
4484
|
+
var Utils = require_utils();
|
|
4485
|
+
var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
|
|
4486
|
+
var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
|
|
4487
|
+
var G15_BCH = Utils.getBCHDigit(G15);
|
|
4488
|
+
exports2.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
4489
|
+
const data = errorCorrectionLevel.bit << 3 | mask;
|
|
4490
|
+
let d = data << 10;
|
|
4491
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
|
|
4492
|
+
d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
4493
|
+
}
|
|
4494
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
4495
|
+
};
|
|
4496
|
+
}
|
|
4497
|
+
});
|
|
4498
|
+
|
|
4499
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
|
|
4500
|
+
var require_numeric_data = __commonJS({
|
|
4501
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"(exports2, module2) {
|
|
4502
|
+
"use strict";
|
|
4503
|
+
var Mode = require_mode();
|
|
4504
|
+
function NumericData(data) {
|
|
4505
|
+
this.mode = Mode.NUMERIC;
|
|
4506
|
+
this.data = data.toString();
|
|
4507
|
+
}
|
|
4508
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
4509
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
4510
|
+
};
|
|
4511
|
+
NumericData.prototype.getLength = function getLength() {
|
|
4512
|
+
return this.data.length;
|
|
4513
|
+
};
|
|
4514
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
4515
|
+
return NumericData.getBitsLength(this.data.length);
|
|
4516
|
+
};
|
|
4517
|
+
NumericData.prototype.write = function write(bitBuffer) {
|
|
4518
|
+
let i2, group, value;
|
|
4519
|
+
for (i2 = 0; i2 + 3 <= this.data.length; i2 += 3) {
|
|
4520
|
+
group = this.data.substr(i2, 3);
|
|
4521
|
+
value = parseInt(group, 10);
|
|
4522
|
+
bitBuffer.put(value, 10);
|
|
4523
|
+
}
|
|
4524
|
+
const remainingNum = this.data.length - i2;
|
|
4525
|
+
if (remainingNum > 0) {
|
|
4526
|
+
group = this.data.substr(i2);
|
|
4527
|
+
value = parseInt(group, 10);
|
|
4528
|
+
bitBuffer.put(value, remainingNum * 3 + 1);
|
|
4529
|
+
}
|
|
4530
|
+
};
|
|
4531
|
+
module2.exports = NumericData;
|
|
4532
|
+
}
|
|
4533
|
+
});
|
|
4534
|
+
|
|
4535
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
4536
|
+
var require_alphanumeric_data = __commonJS({
|
|
4537
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"(exports2, module2) {
|
|
4538
|
+
"use strict";
|
|
4539
|
+
var Mode = require_mode();
|
|
4540
|
+
var ALPHA_NUM_CHARS = [
|
|
4541
|
+
"0",
|
|
4542
|
+
"1",
|
|
4543
|
+
"2",
|
|
4544
|
+
"3",
|
|
4545
|
+
"4",
|
|
4546
|
+
"5",
|
|
4547
|
+
"6",
|
|
4548
|
+
"7",
|
|
4549
|
+
"8",
|
|
4550
|
+
"9",
|
|
4551
|
+
"A",
|
|
4552
|
+
"B",
|
|
4553
|
+
"C",
|
|
4554
|
+
"D",
|
|
4555
|
+
"E",
|
|
4556
|
+
"F",
|
|
4557
|
+
"G",
|
|
4558
|
+
"H",
|
|
4559
|
+
"I",
|
|
4560
|
+
"J",
|
|
4561
|
+
"K",
|
|
4562
|
+
"L",
|
|
4563
|
+
"M",
|
|
4564
|
+
"N",
|
|
4565
|
+
"O",
|
|
4566
|
+
"P",
|
|
4567
|
+
"Q",
|
|
4568
|
+
"R",
|
|
4569
|
+
"S",
|
|
4570
|
+
"T",
|
|
4571
|
+
"U",
|
|
4572
|
+
"V",
|
|
4573
|
+
"W",
|
|
4574
|
+
"X",
|
|
4575
|
+
"Y",
|
|
4576
|
+
"Z",
|
|
4577
|
+
" ",
|
|
4578
|
+
"$",
|
|
4579
|
+
"%",
|
|
4580
|
+
"*",
|
|
4581
|
+
"+",
|
|
4582
|
+
"-",
|
|
4583
|
+
".",
|
|
4584
|
+
"/",
|
|
4585
|
+
":"
|
|
4586
|
+
];
|
|
4587
|
+
function AlphanumericData(data) {
|
|
4588
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
4589
|
+
this.data = data;
|
|
4590
|
+
}
|
|
4591
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
4592
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
4593
|
+
};
|
|
4594
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
4595
|
+
return this.data.length;
|
|
4596
|
+
};
|
|
4597
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
4598
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
4599
|
+
};
|
|
4600
|
+
AlphanumericData.prototype.write = function write(bitBuffer) {
|
|
4601
|
+
let i2;
|
|
4602
|
+
for (i2 = 0; i2 + 2 <= this.data.length; i2 += 2) {
|
|
4603
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i2]) * 45;
|
|
4604
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i2 + 1]);
|
|
4605
|
+
bitBuffer.put(value, 11);
|
|
4606
|
+
}
|
|
4607
|
+
if (this.data.length % 2) {
|
|
4608
|
+
bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i2]), 6);
|
|
4609
|
+
}
|
|
4610
|
+
};
|
|
4611
|
+
module2.exports = AlphanumericData;
|
|
4612
|
+
}
|
|
4613
|
+
});
|
|
4614
|
+
|
|
4615
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
|
|
4616
|
+
var require_byte_data = __commonJS({
|
|
4617
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"(exports2, module2) {
|
|
4618
|
+
"use strict";
|
|
4619
|
+
var Mode = require_mode();
|
|
4620
|
+
function ByteData(data) {
|
|
4621
|
+
this.mode = Mode.BYTE;
|
|
4622
|
+
if (typeof data === "string") {
|
|
4623
|
+
this.data = new TextEncoder().encode(data);
|
|
4624
|
+
} else {
|
|
4625
|
+
this.data = new Uint8Array(data);
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
4629
|
+
return length * 8;
|
|
4630
|
+
};
|
|
4631
|
+
ByteData.prototype.getLength = function getLength() {
|
|
4632
|
+
return this.data.length;
|
|
4633
|
+
};
|
|
4634
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
4635
|
+
return ByteData.getBitsLength(this.data.length);
|
|
4636
|
+
};
|
|
4637
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
4638
|
+
for (let i2 = 0, l = this.data.length; i2 < l; i2++) {
|
|
4639
|
+
bitBuffer.put(this.data[i2], 8);
|
|
4640
|
+
}
|
|
4641
|
+
};
|
|
4642
|
+
module2.exports = ByteData;
|
|
4643
|
+
}
|
|
4644
|
+
});
|
|
4645
|
+
|
|
4646
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
|
|
4647
|
+
var require_kanji_data = __commonJS({
|
|
4648
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"(exports2, module2) {
|
|
4649
|
+
"use strict";
|
|
4650
|
+
var Mode = require_mode();
|
|
4651
|
+
var Utils = require_utils();
|
|
4652
|
+
function KanjiData(data) {
|
|
4653
|
+
this.mode = Mode.KANJI;
|
|
4654
|
+
this.data = data;
|
|
4655
|
+
}
|
|
4656
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
4657
|
+
return length * 13;
|
|
4658
|
+
};
|
|
4659
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
4660
|
+
return this.data.length;
|
|
4661
|
+
};
|
|
4662
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
4663
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
4664
|
+
};
|
|
4665
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
4666
|
+
let i2;
|
|
4667
|
+
for (i2 = 0; i2 < this.data.length; i2++) {
|
|
4668
|
+
let value = Utils.toSJIS(this.data[i2]);
|
|
4669
|
+
if (value >= 33088 && value <= 40956) {
|
|
4670
|
+
value -= 33088;
|
|
4671
|
+
} else if (value >= 57408 && value <= 60351) {
|
|
4672
|
+
value -= 49472;
|
|
4673
|
+
} else {
|
|
4674
|
+
throw new Error(
|
|
4675
|
+
"Invalid SJIS character: " + this.data[i2] + "\nMake sure your charset is UTF-8"
|
|
4676
|
+
);
|
|
4677
|
+
}
|
|
4678
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
4679
|
+
bitBuffer.put(value, 13);
|
|
4680
|
+
}
|
|
4681
|
+
};
|
|
4682
|
+
module2.exports = KanjiData;
|
|
4683
|
+
}
|
|
4684
|
+
});
|
|
4685
|
+
|
|
4686
|
+
// ../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
|
|
4687
|
+
var require_dijkstra = __commonJS({
|
|
4688
|
+
"../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js"(exports2, module2) {
|
|
4689
|
+
"use strict";
|
|
4690
|
+
var dijkstra = {
|
|
4691
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
4692
|
+
var predecessors = {};
|
|
4693
|
+
var costs = {};
|
|
4694
|
+
costs[s] = 0;
|
|
4695
|
+
var open = dijkstra.PriorityQueue.make();
|
|
4696
|
+
open.push(s, 0);
|
|
4697
|
+
var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
|
|
4698
|
+
while (!open.empty()) {
|
|
4699
|
+
closest = open.pop();
|
|
4700
|
+
u = closest.value;
|
|
4701
|
+
cost_of_s_to_u = closest.cost;
|
|
4702
|
+
adjacent_nodes = graph[u] || {};
|
|
4703
|
+
for (v in adjacent_nodes) {
|
|
4704
|
+
if (adjacent_nodes.hasOwnProperty(v)) {
|
|
4705
|
+
cost_of_e = adjacent_nodes[v];
|
|
4706
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
4707
|
+
cost_of_s_to_v = costs[v];
|
|
4708
|
+
first_visit = typeof costs[v] === "undefined";
|
|
4709
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
4710
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
4711
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
4712
|
+
predecessors[v] = u;
|
|
4713
|
+
}
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4717
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
4718
|
+
var msg = ["Could not find a path from ", s, " to ", d, "."].join("");
|
|
4719
|
+
throw new Error(msg);
|
|
4720
|
+
}
|
|
4721
|
+
return predecessors;
|
|
4722
|
+
},
|
|
4723
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
4724
|
+
var nodes = [];
|
|
4725
|
+
var u = d;
|
|
4726
|
+
var predecessor;
|
|
4727
|
+
while (u) {
|
|
4728
|
+
nodes.push(u);
|
|
4729
|
+
predecessor = predecessors[u];
|
|
4730
|
+
u = predecessors[u];
|
|
4731
|
+
}
|
|
4732
|
+
nodes.reverse();
|
|
4733
|
+
return nodes;
|
|
4734
|
+
},
|
|
4735
|
+
find_path: function(graph, s, d) {
|
|
4736
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
4737
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(
|
|
4738
|
+
predecessors,
|
|
4739
|
+
d
|
|
4740
|
+
);
|
|
4741
|
+
},
|
|
4742
|
+
/**
|
|
4743
|
+
* A very naive priority queue implementation.
|
|
4744
|
+
*/
|
|
4745
|
+
PriorityQueue: {
|
|
4746
|
+
make: function(opts) {
|
|
4747
|
+
var T2 = dijkstra.PriorityQueue, t2 = {}, key;
|
|
4748
|
+
opts = opts || {};
|
|
4749
|
+
for (key in T2) {
|
|
4750
|
+
if (T2.hasOwnProperty(key)) {
|
|
4751
|
+
t2[key] = T2[key];
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
t2.queue = [];
|
|
4755
|
+
t2.sorter = opts.sorter || T2.default_sorter;
|
|
4756
|
+
return t2;
|
|
4757
|
+
},
|
|
4758
|
+
default_sorter: function(a, b2) {
|
|
4759
|
+
return a.cost - b2.cost;
|
|
4760
|
+
},
|
|
4761
|
+
/**
|
|
4762
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
4763
|
+
* is at the front of the queue.
|
|
4764
|
+
*/
|
|
4765
|
+
push: function(value, cost) {
|
|
4766
|
+
var item = { value, cost };
|
|
4767
|
+
this.queue.push(item);
|
|
4768
|
+
this.queue.sort(this.sorter);
|
|
4769
|
+
},
|
|
4770
|
+
/**
|
|
4771
|
+
* Return the highest priority element in the queue.
|
|
4772
|
+
*/
|
|
4773
|
+
pop: function() {
|
|
4774
|
+
return this.queue.shift();
|
|
4775
|
+
},
|
|
4776
|
+
empty: function() {
|
|
4777
|
+
return this.queue.length === 0;
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
};
|
|
4781
|
+
if (typeof module2 !== "undefined") {
|
|
4782
|
+
module2.exports = dijkstra;
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
});
|
|
4786
|
+
|
|
4787
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
|
|
4788
|
+
var require_segments = __commonJS({
|
|
4789
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js"(exports2) {
|
|
4790
|
+
"use strict";
|
|
4791
|
+
var Mode = require_mode();
|
|
4792
|
+
var NumericData = require_numeric_data();
|
|
4793
|
+
var AlphanumericData = require_alphanumeric_data();
|
|
4794
|
+
var ByteData = require_byte_data();
|
|
4795
|
+
var KanjiData = require_kanji_data();
|
|
4796
|
+
var Regex = require_regex();
|
|
4797
|
+
var Utils = require_utils();
|
|
4798
|
+
var dijkstra = require_dijkstra();
|
|
4799
|
+
function getStringByteLength(str) {
|
|
4800
|
+
return unescape(encodeURIComponent(str)).length;
|
|
4801
|
+
}
|
|
4802
|
+
function getSegments(regex, mode, str) {
|
|
4803
|
+
const segments = [];
|
|
4804
|
+
let result;
|
|
4805
|
+
while ((result = regex.exec(str)) !== null) {
|
|
4806
|
+
segments.push({
|
|
4807
|
+
data: result[0],
|
|
4808
|
+
index: result.index,
|
|
4809
|
+
mode,
|
|
4810
|
+
length: result[0].length
|
|
4811
|
+
});
|
|
4812
|
+
}
|
|
4813
|
+
return segments;
|
|
4814
|
+
}
|
|
4815
|
+
function getSegmentsFromString(dataStr) {
|
|
4816
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
4817
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
4818
|
+
let byteSegs;
|
|
4819
|
+
let kanjiSegs;
|
|
4820
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
4821
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
4822
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
4823
|
+
} else {
|
|
4824
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
4825
|
+
kanjiSegs = [];
|
|
4826
|
+
}
|
|
4827
|
+
const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
|
|
4828
|
+
return segs.sort(function(s1, s2) {
|
|
4829
|
+
return s1.index - s2.index;
|
|
4830
|
+
}).map(function(obj) {
|
|
4831
|
+
return {
|
|
4832
|
+
data: obj.data,
|
|
4833
|
+
mode: obj.mode,
|
|
4834
|
+
length: obj.length
|
|
4835
|
+
};
|
|
4836
|
+
});
|
|
4837
|
+
}
|
|
4838
|
+
function getSegmentBitsLength(length, mode) {
|
|
4839
|
+
switch (mode) {
|
|
4840
|
+
case Mode.NUMERIC:
|
|
4841
|
+
return NumericData.getBitsLength(length);
|
|
4842
|
+
case Mode.ALPHANUMERIC:
|
|
4843
|
+
return AlphanumericData.getBitsLength(length);
|
|
4844
|
+
case Mode.KANJI:
|
|
4845
|
+
return KanjiData.getBitsLength(length);
|
|
4846
|
+
case Mode.BYTE:
|
|
4847
|
+
return ByteData.getBitsLength(length);
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
function mergeSegments(segs) {
|
|
4851
|
+
return segs.reduce(function(acc, curr) {
|
|
4852
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
4853
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
4854
|
+
acc[acc.length - 1].data += curr.data;
|
|
4855
|
+
return acc;
|
|
4856
|
+
}
|
|
4857
|
+
acc.push(curr);
|
|
4858
|
+
return acc;
|
|
4859
|
+
}, []);
|
|
4860
|
+
}
|
|
4861
|
+
function buildNodes(segs) {
|
|
4862
|
+
const nodes = [];
|
|
4863
|
+
for (let i2 = 0; i2 < segs.length; i2++) {
|
|
4864
|
+
const seg = segs[i2];
|
|
4865
|
+
switch (seg.mode) {
|
|
4866
|
+
case Mode.NUMERIC:
|
|
4867
|
+
nodes.push([
|
|
4868
|
+
seg,
|
|
4869
|
+
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
|
|
4870
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
4871
|
+
]);
|
|
4872
|
+
break;
|
|
4873
|
+
case Mode.ALPHANUMERIC:
|
|
4874
|
+
nodes.push([
|
|
4875
|
+
seg,
|
|
4876
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
4877
|
+
]);
|
|
4878
|
+
break;
|
|
4879
|
+
case Mode.KANJI:
|
|
4880
|
+
nodes.push([
|
|
4881
|
+
seg,
|
|
4882
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
4883
|
+
]);
|
|
4884
|
+
break;
|
|
4885
|
+
case Mode.BYTE:
|
|
4886
|
+
nodes.push([
|
|
4887
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
4888
|
+
]);
|
|
4889
|
+
}
|
|
4890
|
+
}
|
|
4891
|
+
return nodes;
|
|
4892
|
+
}
|
|
4893
|
+
function buildGraph(nodes, version) {
|
|
4894
|
+
const table = {};
|
|
4895
|
+
const graph = { start: {} };
|
|
4896
|
+
let prevNodeIds = ["start"];
|
|
4897
|
+
for (let i2 = 0; i2 < nodes.length; i2++) {
|
|
4898
|
+
const nodeGroup = nodes[i2];
|
|
4899
|
+
const currentNodeIds = [];
|
|
4900
|
+
for (let j2 = 0; j2 < nodeGroup.length; j2++) {
|
|
4901
|
+
const node = nodeGroup[j2];
|
|
4902
|
+
const key = "" + i2 + j2;
|
|
4903
|
+
currentNodeIds.push(key);
|
|
4904
|
+
table[key] = { node, lastCount: 0 };
|
|
4905
|
+
graph[key] = {};
|
|
4906
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
4907
|
+
const prevNodeId = prevNodeIds[n];
|
|
4908
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
4909
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
4910
|
+
table[prevNodeId].lastCount += node.length;
|
|
4911
|
+
} else {
|
|
4912
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
4913
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4917
|
+
prevNodeIds = currentNodeIds;
|
|
4918
|
+
}
|
|
4919
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
4920
|
+
graph[prevNodeIds[n]].end = 0;
|
|
4921
|
+
}
|
|
4922
|
+
return { map: graph, table };
|
|
4923
|
+
}
|
|
4924
|
+
function buildSingleSegment(data, modesHint) {
|
|
4925
|
+
let mode;
|
|
4926
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
4927
|
+
mode = Mode.from(modesHint, bestMode);
|
|
4928
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
|
|
4929
|
+
throw new Error('"' + data + '" cannot be encoded with mode ' + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
|
|
4930
|
+
}
|
|
4931
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
|
|
4932
|
+
mode = Mode.BYTE;
|
|
4933
|
+
}
|
|
4934
|
+
switch (mode) {
|
|
4935
|
+
case Mode.NUMERIC:
|
|
4936
|
+
return new NumericData(data);
|
|
4937
|
+
case Mode.ALPHANUMERIC:
|
|
4938
|
+
return new AlphanumericData(data);
|
|
4939
|
+
case Mode.KANJI:
|
|
4940
|
+
return new KanjiData(data);
|
|
4941
|
+
case Mode.BYTE:
|
|
4942
|
+
return new ByteData(data);
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4945
|
+
exports2.fromArray = function fromArray(array) {
|
|
4946
|
+
return array.reduce(function(acc, seg) {
|
|
4947
|
+
if (typeof seg === "string") {
|
|
4948
|
+
acc.push(buildSingleSegment(seg, null));
|
|
4949
|
+
} else if (seg.data) {
|
|
4950
|
+
acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
4951
|
+
}
|
|
4952
|
+
return acc;
|
|
4953
|
+
}, []);
|
|
4954
|
+
};
|
|
4955
|
+
exports2.fromString = function fromString(data, version) {
|
|
4956
|
+
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
4957
|
+
const nodes = buildNodes(segs);
|
|
4958
|
+
const graph = buildGraph(nodes, version);
|
|
4959
|
+
const path7 = dijkstra.find_path(graph.map, "start", "end");
|
|
4960
|
+
const optimizedSegs = [];
|
|
4961
|
+
for (let i2 = 1; i2 < path7.length - 1; i2++) {
|
|
4962
|
+
optimizedSegs.push(graph.table[path7[i2]].node);
|
|
4963
|
+
}
|
|
4964
|
+
return exports2.fromArray(mergeSegments(optimizedSegs));
|
|
4965
|
+
};
|
|
4966
|
+
exports2.rawSplit = function rawSplit(data) {
|
|
4967
|
+
return exports2.fromArray(
|
|
4968
|
+
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
4969
|
+
);
|
|
4970
|
+
};
|
|
4971
|
+
}
|
|
4972
|
+
});
|
|
4973
|
+
|
|
4974
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js
|
|
4975
|
+
var require_qrcode = __commonJS({
|
|
4976
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"(exports2) {
|
|
4977
|
+
"use strict";
|
|
4978
|
+
var Utils = require_utils();
|
|
4979
|
+
var ECLevel = require_error_correction_level();
|
|
4980
|
+
var BitBuffer = require_bit_buffer();
|
|
4981
|
+
var BitMatrix = require_bit_matrix();
|
|
4982
|
+
var AlignmentPattern = require_alignment_pattern();
|
|
4983
|
+
var FinderPattern = require_finder_pattern();
|
|
4984
|
+
var MaskPattern = require_mask_pattern();
|
|
4985
|
+
var ECCode = require_error_correction_code();
|
|
4986
|
+
var ReedSolomonEncoder = require_reed_solomon_encoder();
|
|
4987
|
+
var Version = require_version();
|
|
4988
|
+
var FormatInfo = require_format_info();
|
|
4989
|
+
var Mode = require_mode();
|
|
4990
|
+
var Segments = require_segments();
|
|
4991
|
+
function setupFinderPattern(matrix, version) {
|
|
4992
|
+
const size = matrix.size;
|
|
4993
|
+
const pos = FinderPattern.getPositions(version);
|
|
4994
|
+
for (let i2 = 0; i2 < pos.length; i2++) {
|
|
4995
|
+
const row = pos[i2][0];
|
|
4996
|
+
const col = pos[i2][1];
|
|
4997
|
+
for (let r2 = -1; r2 <= 7; r2++) {
|
|
4998
|
+
if (row + r2 <= -1 || size <= row + r2) continue;
|
|
4999
|
+
for (let c3 = -1; c3 <= 7; c3++) {
|
|
5000
|
+
if (col + c3 <= -1 || size <= col + c3) continue;
|
|
5001
|
+
if (r2 >= 0 && r2 <= 6 && (c3 === 0 || c3 === 6) || c3 >= 0 && c3 <= 6 && (r2 === 0 || r2 === 6) || r2 >= 2 && r2 <= 4 && c3 >= 2 && c3 <= 4) {
|
|
5002
|
+
matrix.set(row + r2, col + c3, true, true);
|
|
5003
|
+
} else {
|
|
5004
|
+
matrix.set(row + r2, col + c3, false, true);
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
}
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
function setupTimingPattern(matrix) {
|
|
5011
|
+
const size = matrix.size;
|
|
5012
|
+
for (let r2 = 8; r2 < size - 8; r2++) {
|
|
5013
|
+
const value = r2 % 2 === 0;
|
|
5014
|
+
matrix.set(r2, 6, value, true);
|
|
5015
|
+
matrix.set(6, r2, value, true);
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
function setupAlignmentPattern(matrix, version) {
|
|
5019
|
+
const pos = AlignmentPattern.getPositions(version);
|
|
5020
|
+
for (let i2 = 0; i2 < pos.length; i2++) {
|
|
5021
|
+
const row = pos[i2][0];
|
|
5022
|
+
const col = pos[i2][1];
|
|
5023
|
+
for (let r2 = -2; r2 <= 2; r2++) {
|
|
5024
|
+
for (let c3 = -2; c3 <= 2; c3++) {
|
|
5025
|
+
if (r2 === -2 || r2 === 2 || c3 === -2 || c3 === 2 || r2 === 0 && c3 === 0) {
|
|
5026
|
+
matrix.set(row + r2, col + c3, true, true);
|
|
5027
|
+
} else {
|
|
5028
|
+
matrix.set(row + r2, col + c3, false, true);
|
|
5029
|
+
}
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
}
|
|
5033
|
+
}
|
|
5034
|
+
function setupVersionInfo(matrix, version) {
|
|
5035
|
+
const size = matrix.size;
|
|
5036
|
+
const bits = Version.getEncodedBits(version);
|
|
5037
|
+
let row, col, mod;
|
|
5038
|
+
for (let i2 = 0; i2 < 18; i2++) {
|
|
5039
|
+
row = Math.floor(i2 / 3);
|
|
5040
|
+
col = i2 % 3 + size - 8 - 3;
|
|
5041
|
+
mod = (bits >> i2 & 1) === 1;
|
|
5042
|
+
matrix.set(row, col, mod, true);
|
|
5043
|
+
matrix.set(col, row, mod, true);
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
5047
|
+
const size = matrix.size;
|
|
5048
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
|
|
5049
|
+
let i2, mod;
|
|
5050
|
+
for (i2 = 0; i2 < 15; i2++) {
|
|
5051
|
+
mod = (bits >> i2 & 1) === 1;
|
|
5052
|
+
if (i2 < 6) {
|
|
5053
|
+
matrix.set(i2, 8, mod, true);
|
|
5054
|
+
} else if (i2 < 8) {
|
|
5055
|
+
matrix.set(i2 + 1, 8, mod, true);
|
|
5056
|
+
} else {
|
|
5057
|
+
matrix.set(size - 15 + i2, 8, mod, true);
|
|
5058
|
+
}
|
|
5059
|
+
if (i2 < 8) {
|
|
5060
|
+
matrix.set(8, size - i2 - 1, mod, true);
|
|
5061
|
+
} else if (i2 < 9) {
|
|
5062
|
+
matrix.set(8, 15 - i2 - 1 + 1, mod, true);
|
|
5063
|
+
} else {
|
|
5064
|
+
matrix.set(8, 15 - i2 - 1, mod, true);
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
matrix.set(size - 8, 8, 1, true);
|
|
5068
|
+
}
|
|
5069
|
+
function setupData(matrix, data) {
|
|
5070
|
+
const size = matrix.size;
|
|
5071
|
+
let inc = -1;
|
|
5072
|
+
let row = size - 1;
|
|
5073
|
+
let bitIndex = 7;
|
|
5074
|
+
let byteIndex = 0;
|
|
5075
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
5076
|
+
if (col === 6) col--;
|
|
5077
|
+
while (true) {
|
|
5078
|
+
for (let c3 = 0; c3 < 2; c3++) {
|
|
5079
|
+
if (!matrix.isReserved(row, col - c3)) {
|
|
5080
|
+
let dark = false;
|
|
5081
|
+
if (byteIndex < data.length) {
|
|
5082
|
+
dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
5083
|
+
}
|
|
5084
|
+
matrix.set(row, col - c3, dark);
|
|
5085
|
+
bitIndex--;
|
|
5086
|
+
if (bitIndex === -1) {
|
|
5087
|
+
byteIndex++;
|
|
5088
|
+
bitIndex = 7;
|
|
5089
|
+
}
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
row += inc;
|
|
5093
|
+
if (row < 0 || size <= row) {
|
|
5094
|
+
row -= inc;
|
|
5095
|
+
inc = -inc;
|
|
5096
|
+
break;
|
|
5097
|
+
}
|
|
5098
|
+
}
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
5102
|
+
const buffer = new BitBuffer();
|
|
5103
|
+
segments.forEach(function(data) {
|
|
5104
|
+
buffer.put(data.mode.bit, 4);
|
|
5105
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
|
|
5106
|
+
data.write(buffer);
|
|
5107
|
+
});
|
|
5108
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
5109
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
5110
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
5111
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
|
|
5112
|
+
buffer.put(0, 4);
|
|
5113
|
+
}
|
|
5114
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
5115
|
+
buffer.putBit(0);
|
|
5116
|
+
}
|
|
5117
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
5118
|
+
for (let i2 = 0; i2 < remainingByte; i2++) {
|
|
5119
|
+
buffer.put(i2 % 2 ? 17 : 236, 8);
|
|
5120
|
+
}
|
|
5121
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
5122
|
+
}
|
|
5123
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
5124
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
5125
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
5126
|
+
const dataTotalCodewords = totalCodewords - ecTotalCodewords;
|
|
5127
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
|
|
5128
|
+
const blocksInGroup2 = totalCodewords % ecTotalBlocks;
|
|
5129
|
+
const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
|
|
5130
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
5131
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
5132
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
5133
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
5134
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
5135
|
+
let offset = 0;
|
|
5136
|
+
const dcData = new Array(ecTotalBlocks);
|
|
5137
|
+
const ecData = new Array(ecTotalBlocks);
|
|
5138
|
+
let maxDataSize = 0;
|
|
5139
|
+
const buffer = new Uint8Array(bitBuffer.buffer);
|
|
5140
|
+
for (let b2 = 0; b2 < ecTotalBlocks; b2++) {
|
|
5141
|
+
const dataSize = b2 < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
5142
|
+
dcData[b2] = buffer.slice(offset, offset + dataSize);
|
|
5143
|
+
ecData[b2] = rs.encode(dcData[b2]);
|
|
5144
|
+
offset += dataSize;
|
|
5145
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
5146
|
+
}
|
|
5147
|
+
const data = new Uint8Array(totalCodewords);
|
|
5148
|
+
let index = 0;
|
|
5149
|
+
let i2, r2;
|
|
5150
|
+
for (i2 = 0; i2 < maxDataSize; i2++) {
|
|
5151
|
+
for (r2 = 0; r2 < ecTotalBlocks; r2++) {
|
|
5152
|
+
if (i2 < dcData[r2].length) {
|
|
5153
|
+
data[index++] = dcData[r2][i2];
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
}
|
|
5157
|
+
for (i2 = 0; i2 < ecCount; i2++) {
|
|
5158
|
+
for (r2 = 0; r2 < ecTotalBlocks; r2++) {
|
|
5159
|
+
data[index++] = ecData[r2][i2];
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
return data;
|
|
5163
|
+
}
|
|
5164
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
5165
|
+
let segments;
|
|
5166
|
+
if (Array.isArray(data)) {
|
|
5167
|
+
segments = Segments.fromArray(data);
|
|
5168
|
+
} else if (typeof data === "string") {
|
|
5169
|
+
let estimatedVersion = version;
|
|
5170
|
+
if (!estimatedVersion) {
|
|
5171
|
+
const rawSegments = Segments.rawSplit(data);
|
|
5172
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
5173
|
+
}
|
|
5174
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
5175
|
+
} else {
|
|
5176
|
+
throw new Error("Invalid data");
|
|
5177
|
+
}
|
|
5178
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
5179
|
+
if (!bestVersion) {
|
|
5180
|
+
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
5181
|
+
}
|
|
5182
|
+
if (!version) {
|
|
5183
|
+
version = bestVersion;
|
|
5184
|
+
} else if (version < bestVersion) {
|
|
5185
|
+
throw new Error(
|
|
5186
|
+
"\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n"
|
|
5187
|
+
);
|
|
5188
|
+
}
|
|
5189
|
+
const dataBits = createData(version, errorCorrectionLevel, segments);
|
|
5190
|
+
const moduleCount = Utils.getSymbolSize(version);
|
|
5191
|
+
const modules = new BitMatrix(moduleCount);
|
|
5192
|
+
setupFinderPattern(modules, version);
|
|
5193
|
+
setupTimingPattern(modules);
|
|
5194
|
+
setupAlignmentPattern(modules, version);
|
|
5195
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0);
|
|
5196
|
+
if (version >= 7) {
|
|
5197
|
+
setupVersionInfo(modules, version);
|
|
5198
|
+
}
|
|
5199
|
+
setupData(modules, dataBits);
|
|
5200
|
+
if (isNaN(maskPattern)) {
|
|
5201
|
+
maskPattern = MaskPattern.getBestMask(
|
|
5202
|
+
modules,
|
|
5203
|
+
setupFormatInfo.bind(null, modules, errorCorrectionLevel)
|
|
5204
|
+
);
|
|
5205
|
+
}
|
|
5206
|
+
MaskPattern.applyMask(maskPattern, modules);
|
|
5207
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
|
|
5208
|
+
return {
|
|
5209
|
+
modules,
|
|
5210
|
+
version,
|
|
5211
|
+
errorCorrectionLevel,
|
|
5212
|
+
maskPattern,
|
|
5213
|
+
segments
|
|
5214
|
+
};
|
|
5215
|
+
}
|
|
5216
|
+
exports2.create = function create(data, options) {
|
|
5217
|
+
if (typeof data === "undefined" || data === "") {
|
|
5218
|
+
throw new Error("No input text");
|
|
5219
|
+
}
|
|
5220
|
+
let errorCorrectionLevel = ECLevel.M;
|
|
5221
|
+
let version;
|
|
5222
|
+
let mask;
|
|
5223
|
+
if (typeof options !== "undefined") {
|
|
5224
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
5225
|
+
version = Version.from(options.version);
|
|
5226
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
5227
|
+
if (options.toSJISFunc) {
|
|
5228
|
+
Utils.setToSJISFunction(options.toSJISFunc);
|
|
5229
|
+
}
|
|
5230
|
+
}
|
|
5231
|
+
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
5232
|
+
};
|
|
5233
|
+
}
|
|
5234
|
+
});
|
|
5235
|
+
|
|
5236
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js
|
|
5237
|
+
var require_terminal = __commonJS({
|
|
5238
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"(exports2) {
|
|
5239
|
+
"use strict";
|
|
5240
|
+
exports2.render = function(qrData, options, cb) {
|
|
5241
|
+
const size = qrData.modules.size;
|
|
5242
|
+
const data = qrData.modules.data;
|
|
5243
|
+
const black = "\x1B[40m \x1B[0m";
|
|
5244
|
+
const white = "\x1B[47m \x1B[0m";
|
|
5245
|
+
let output = "";
|
|
5246
|
+
const hMargin = Array(size + 3).join(white);
|
|
5247
|
+
const vMargin = Array(2).join(white);
|
|
5248
|
+
output += hMargin + "\n";
|
|
5249
|
+
for (let i2 = 0; i2 < size; ++i2) {
|
|
5250
|
+
output += white;
|
|
5251
|
+
for (let j2 = 0; j2 < size; j2++) {
|
|
5252
|
+
output += data[i2 * size + j2] ? black : white;
|
|
5253
|
+
}
|
|
5254
|
+
output += vMargin + "\n";
|
|
5255
|
+
}
|
|
5256
|
+
output += hMargin + "\n";
|
|
5257
|
+
if (typeof cb === "function") {
|
|
5258
|
+
cb(null, output);
|
|
5259
|
+
}
|
|
5260
|
+
return output;
|
|
5261
|
+
};
|
|
5262
|
+
}
|
|
5263
|
+
});
|
|
5264
|
+
|
|
5265
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js
|
|
5266
|
+
var require_terminal_small = __commonJS({
|
|
5267
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js"(exports2) {
|
|
5268
|
+
"use strict";
|
|
5269
|
+
var backgroundWhite = "\x1B[47m";
|
|
5270
|
+
var backgroundBlack = "\x1B[40m";
|
|
5271
|
+
var foregroundWhite = "\x1B[37m";
|
|
5272
|
+
var foregroundBlack = "\x1B[30m";
|
|
5273
|
+
var reset = "\x1B[0m";
|
|
5274
|
+
var lineSetupNormal = backgroundWhite + foregroundBlack;
|
|
5275
|
+
var lineSetupInverse = backgroundBlack + foregroundWhite;
|
|
5276
|
+
var createPalette = function(lineSetup, foregroundWhite2, foregroundBlack2) {
|
|
5277
|
+
return {
|
|
5278
|
+
// 1 ... white, 2 ... black, 0 ... transparent (default)
|
|
5279
|
+
"00": reset + " " + lineSetup,
|
|
5280
|
+
"01": reset + foregroundWhite2 + "\u2584" + lineSetup,
|
|
5281
|
+
"02": reset + foregroundBlack2 + "\u2584" + lineSetup,
|
|
5282
|
+
10: reset + foregroundWhite2 + "\u2580" + lineSetup,
|
|
5283
|
+
11: " ",
|
|
5284
|
+
12: "\u2584",
|
|
5285
|
+
20: reset + foregroundBlack2 + "\u2580" + lineSetup,
|
|
5286
|
+
21: "\u2580",
|
|
5287
|
+
22: "\u2588"
|
|
5288
|
+
};
|
|
5289
|
+
};
|
|
5290
|
+
var mkCodePixel = function(modules, size, x2, y2) {
|
|
5291
|
+
const sizePlus = size + 1;
|
|
5292
|
+
if (x2 >= sizePlus || y2 >= sizePlus || y2 < -1 || x2 < -1) return "0";
|
|
5293
|
+
if (x2 >= size || y2 >= size || y2 < 0 || x2 < 0) return "1";
|
|
5294
|
+
const idx = y2 * size + x2;
|
|
5295
|
+
return modules[idx] ? "2" : "1";
|
|
5296
|
+
};
|
|
5297
|
+
var mkCode = function(modules, size, x2, y2) {
|
|
5298
|
+
return mkCodePixel(modules, size, x2, y2) + mkCodePixel(modules, size, x2, y2 + 1);
|
|
5299
|
+
};
|
|
5300
|
+
exports2.render = function(qrData, options, cb) {
|
|
5301
|
+
const size = qrData.modules.size;
|
|
5302
|
+
const data = qrData.modules.data;
|
|
5303
|
+
const inverse = !!(options && options.inverse);
|
|
5304
|
+
const lineSetup = options && options.inverse ? lineSetupInverse : lineSetupNormal;
|
|
5305
|
+
const white = inverse ? foregroundBlack : foregroundWhite;
|
|
5306
|
+
const black = inverse ? foregroundWhite : foregroundBlack;
|
|
5307
|
+
const palette = createPalette(lineSetup, white, black);
|
|
5308
|
+
const newLine = reset + "\n" + lineSetup;
|
|
5309
|
+
let output = lineSetup;
|
|
5310
|
+
for (let y2 = -1; y2 < size + 1; y2 += 2) {
|
|
5311
|
+
for (let x2 = -1; x2 < size; x2++) {
|
|
5312
|
+
output += palette[mkCode(data, size, x2, y2)];
|
|
5313
|
+
}
|
|
5314
|
+
output += palette[mkCode(data, size, size, y2)] + newLine;
|
|
5315
|
+
}
|
|
5316
|
+
output += reset;
|
|
5317
|
+
if (typeof cb === "function") {
|
|
5318
|
+
cb(null, output);
|
|
5319
|
+
}
|
|
5320
|
+
return output;
|
|
5321
|
+
};
|
|
5322
|
+
}
|
|
5323
|
+
});
|
|
5324
|
+
|
|
5325
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js
|
|
5326
|
+
var require_terminal2 = __commonJS({
|
|
5327
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"(exports2) {
|
|
5328
|
+
"use strict";
|
|
5329
|
+
var big = require_terminal();
|
|
5330
|
+
var small = require_terminal_small();
|
|
5331
|
+
exports2.render = function(qrData, options, cb) {
|
|
5332
|
+
if (options && options.small) {
|
|
5333
|
+
return small.render(qrData, options, cb);
|
|
5334
|
+
}
|
|
5335
|
+
return big.render(qrData, options, cb);
|
|
5336
|
+
};
|
|
5337
|
+
}
|
|
5338
|
+
});
|
|
5339
|
+
|
|
3406
5340
|
// ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
|
|
3407
5341
|
var require_ms = __commonJS({
|
|
3408
5342
|
"../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports2, module2) {
|
|
@@ -4177,6 +6111,19 @@ var {
|
|
|
4177
6111
|
// src/index.ts
|
|
4178
6112
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
4179
6113
|
|
|
6114
|
+
// src/qr.ts
|
|
6115
|
+
var import_qrcode = __toESM(require_qrcode(), 1);
|
|
6116
|
+
var import_terminal = __toESM(require_terminal2(), 1);
|
|
6117
|
+
function renderTerminalQr(text) {
|
|
6118
|
+
try {
|
|
6119
|
+
const data = import_qrcode.default.create(text, { errorCorrectionLevel: "M" });
|
|
6120
|
+
const rendered = import_terminal.default.render(data, { small: true });
|
|
6121
|
+
return rendered.split("\n").filter((r2) => r2.length > 0);
|
|
6122
|
+
} catch {
|
|
6123
|
+
return [];
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
|
|
4180
6127
|
// ../core/dist/index.js
|
|
4181
6128
|
var crypto2 = __toESM(require("crypto"), 1);
|
|
4182
6129
|
|
|
@@ -13269,6 +15216,32 @@ var path = __toESM(require("path"), 1);
|
|
|
13269
15216
|
function computeSaltedHash(value, salt = "qodewk-default-salt") {
|
|
13270
15217
|
return crypto.createHmac("sha256", salt).update(value).digest("hex");
|
|
13271
15218
|
}
|
|
15219
|
+
function parseSinceOption(since) {
|
|
15220
|
+
if (!since)
|
|
15221
|
+
return void 0;
|
|
15222
|
+
if (since instanceof Date)
|
|
15223
|
+
return since;
|
|
15224
|
+
const s = since.trim().toLowerCase();
|
|
15225
|
+
const now = /* @__PURE__ */ new Date();
|
|
15226
|
+
if (s === "today") {
|
|
15227
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
15228
|
+
}
|
|
15229
|
+
const hoursMatch = s.match(/^(\d+)\s*h(?:ours?)?$/);
|
|
15230
|
+
if (hoursMatch && hoursMatch[1]) {
|
|
15231
|
+
const hours = parseInt(hoursMatch[1], 10);
|
|
15232
|
+
return new Date(now.getTime() - hours * 60 * 60 * 1e3);
|
|
15233
|
+
}
|
|
15234
|
+
const daysMatch = s.match(/^(\d+)\s*d(?:ays?)?$/);
|
|
15235
|
+
if (daysMatch && daysMatch[1]) {
|
|
15236
|
+
const days = parseInt(daysMatch[1], 10);
|
|
15237
|
+
return new Date(now.getTime() - days * 24 * 60 * 60 * 1e3);
|
|
15238
|
+
}
|
|
15239
|
+
const parsed = new Date(since);
|
|
15240
|
+
if (!isNaN(parsed.getTime())) {
|
|
15241
|
+
return parsed;
|
|
15242
|
+
}
|
|
15243
|
+
return void 0;
|
|
15244
|
+
}
|
|
13272
15245
|
async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
13273
15246
|
const options = typeof optionsOrPath === "string" ? { repoPath: optionsOrPath } : optionsOrPath;
|
|
13274
15247
|
const repoPath = options.repoPath || process.cwd();
|
|
@@ -13282,18 +15255,43 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
13282
15255
|
let headSha = options.headSha || "0000000000000000000000000000000000000000";
|
|
13283
15256
|
let baseSha = options.baseSha;
|
|
13284
15257
|
let commitMessage = void 0;
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
15258
|
+
let commitsCount = 1;
|
|
15259
|
+
const sinceDate = parseSinceOption(options.since);
|
|
15260
|
+
if (sinceDate && !options.baseSha) {
|
|
15261
|
+
try {
|
|
15262
|
+
const sinceIso = sinceDate.toISOString();
|
|
15263
|
+
const commitsRaw = await git.raw(["log", `--since=${sinceIso}`, "--format=%H"]);
|
|
15264
|
+
const commitShas = commitsRaw.split("\n").map((s) => s.trim()).filter(Boolean);
|
|
15265
|
+
if (commitShas.length > 0) {
|
|
15266
|
+
commitsCount = commitShas.length;
|
|
15267
|
+
if (!options.headSha) {
|
|
15268
|
+
headSha = commitShas[0];
|
|
15269
|
+
}
|
|
15270
|
+
const oldestSha = commitShas[commitShas.length - 1];
|
|
15271
|
+
try {
|
|
15272
|
+
const parentSha = (await git.raw(["rev-parse", `${oldestSha}^`])).trim();
|
|
15273
|
+
baseSha = parentSha;
|
|
15274
|
+
} catch {
|
|
15275
|
+
baseSha = oldestSha;
|
|
15276
|
+
}
|
|
13290
15277
|
}
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
15278
|
+
} catch {
|
|
15279
|
+
}
|
|
15280
|
+
}
|
|
15281
|
+
if (!baseSha) {
|
|
15282
|
+
try {
|
|
15283
|
+
const log = await git.log({ maxCount: 2 });
|
|
15284
|
+
if (log.latest) {
|
|
15285
|
+
if (!options.headSha) {
|
|
15286
|
+
headSha = log.latest.hash;
|
|
15287
|
+
}
|
|
15288
|
+
commitMessage = log.latest.message;
|
|
15289
|
+
if (!options.baseSha && log.all.length > 1 && log.all[1]) {
|
|
15290
|
+
baseSha = log.all[1].hash;
|
|
15291
|
+
}
|
|
13294
15292
|
}
|
|
15293
|
+
} catch {
|
|
13295
15294
|
}
|
|
13296
|
-
} catch {
|
|
13297
15295
|
}
|
|
13298
15296
|
let repoIdentifier = path.basename(path.resolve(repoPath));
|
|
13299
15297
|
try {
|
|
@@ -13308,13 +15306,18 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
13308
15306
|
const repoHash = computeSaltedHash(repoIdentifier);
|
|
13309
15307
|
let diffSummary;
|
|
13310
15308
|
if (baseSha && headSha && baseSha !== headSha) {
|
|
13311
|
-
|
|
15309
|
+
const status = await git.status();
|
|
15310
|
+
if (status.files.length > 0) {
|
|
15311
|
+
diffSummary = await git.diffSummary([baseSha]);
|
|
15312
|
+
} else {
|
|
15313
|
+
diffSummary = await git.diffSummary([`${baseSha}..${headSha}`]);
|
|
15314
|
+
}
|
|
13312
15315
|
} else {
|
|
13313
15316
|
const status = await git.status();
|
|
13314
15317
|
if (status.files.length > 0) {
|
|
13315
15318
|
diffSummary = await git.diffSummary(["HEAD"]);
|
|
13316
15319
|
} else if (baseSha) {
|
|
13317
|
-
diffSummary = await git.diffSummary([`${baseSha}
|
|
15320
|
+
diffSummary = await git.diffSummary([`${baseSha}..${headSha}`]);
|
|
13318
15321
|
} else if (headSha !== "0000000000000000000000000000000000000000") {
|
|
13319
15322
|
diffSummary = await git.diffSummary([headSha]);
|
|
13320
15323
|
} else {
|
|
@@ -13359,7 +15362,8 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
13359
15362
|
baseSha,
|
|
13360
15363
|
repoHash,
|
|
13361
15364
|
projectAlias,
|
|
13362
|
-
commitMessage
|
|
15365
|
+
commitMessage,
|
|
15366
|
+
commitsCount
|
|
13363
15367
|
};
|
|
13364
15368
|
}
|
|
13365
15369
|
function mapExtensionToLanguage(ext) {
|
|
@@ -14120,7 +16124,7 @@ var LocalStateDB = class {
|
|
|
14120
16124
|
};
|
|
14121
16125
|
|
|
14122
16126
|
// ../core/dist/harvester/index.js
|
|
14123
|
-
function
|
|
16127
|
+
function parseSinceOption2(since) {
|
|
14124
16128
|
if (!since)
|
|
14125
16129
|
return void 0;
|
|
14126
16130
|
if (since instanceof Date)
|
|
@@ -14148,7 +16152,7 @@ function parseSinceOption(since) {
|
|
|
14148
16152
|
return void 0;
|
|
14149
16153
|
}
|
|
14150
16154
|
async function harvestUniversalFootprints(options) {
|
|
14151
|
-
const sinceDate =
|
|
16155
|
+
const sinceDate = parseSinceOption2(options.since);
|
|
14152
16156
|
const alias = options.projectAlias || "";
|
|
14153
16157
|
let allFootprints = [];
|
|
14154
16158
|
if (!options.platform || options.platform === "all" || options.platform === "antigravity") {
|
|
@@ -14285,7 +16289,8 @@ function estimateCost(options) {
|
|
|
14285
16289
|
|
|
14286
16290
|
// ../core/dist/format.js
|
|
14287
16291
|
function formatMarkdownReceipt(receipt, publicUrl) {
|
|
14288
|
-
const
|
|
16292
|
+
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || process.env.QODEWK_APP_URL || "https://qodewk.flinkeo.online";
|
|
16293
|
+
const url = publicUrl || `${baseUrl}/r/${receipt.receipt.id}`;
|
|
14289
16294
|
const totalTokens = (receipt.ai.tokens.input + receipt.ai.tokens.output).toLocaleString();
|
|
14290
16295
|
const costPrefix = receipt.ai.mode === "verified" ? "$" : "~$";
|
|
14291
16296
|
const confidencePercent = `${Math.round(receipt.ai.confidence * 100)}%`;
|
|
@@ -14318,7 +16323,8 @@ async function generateReceipt(options = {}) {
|
|
|
14318
16323
|
const metrics = await extractGitMetrics({
|
|
14319
16324
|
repoPath: options.repoPath || process.cwd(),
|
|
14320
16325
|
baseSha: options.baseSha,
|
|
14321
|
-
headSha: options.headSha
|
|
16326
|
+
headSha: options.headSha,
|
|
16327
|
+
since: options.since
|
|
14322
16328
|
});
|
|
14323
16329
|
const repoPath = options.repoPath || process.cwd();
|
|
14324
16330
|
const harvestResult = await harvestUniversalFootprints({
|
|
@@ -14380,7 +16386,7 @@ async function generateReceipt(options = {}) {
|
|
|
14380
16386
|
branch: options.anonymizeBranch ? "anonymized-branch" : metrics.branch,
|
|
14381
16387
|
headSha: metrics.headSha,
|
|
14382
16388
|
baseSha: metrics.baseSha,
|
|
14383
|
-
commitsCount: 1
|
|
16389
|
+
commitsCount: metrics.commitsCount || 1
|
|
14384
16390
|
},
|
|
14385
16391
|
mutation: {
|
|
14386
16392
|
files: metrics.files,
|
|
@@ -14412,7 +16418,7 @@ async function generateReceipt(options = {}) {
|
|
|
14412
16418
|
|
|
14413
16419
|
// src/index.ts
|
|
14414
16420
|
var program2 = new Command();
|
|
14415
|
-
program2.name("qodewk").description("Universal telemetry and digital receipt generator for the AI coding agent era").version("0.1.
|
|
16421
|
+
program2.name("qodewk").description("Universal telemetry and digital receipt generator for the AI coding agent era").version("0.1.10").option("-j, --json", "Output receipt in machine-readable JSON format").option("-f, --format <format>", "Output format (terminal, json, markdown)", "terminal").option("-o, --out <path>", "Write receipt output to specified file path").option("-p, --provider <provider>", "Specify AI provider (antigravity, claude, cursor, etc.)").option("-m, --model <model>", "Specify AI model identifier").option("-s, --since <duration>", "Harvest agent footprints since duration (e.g. today, 24h, 7d)").option("--today", "Harvest agent footprints for today").option("--platform <platform>", "Filter agent platform (antigravity, claude, cursor, all)").option("--anon", "Anonymize branch name in output").option("--barcode", "Render 1D barcode simulation instead of scannable 2D QR code").action(async (options) => {
|
|
14416
16422
|
try {
|
|
14417
16423
|
const since = options.today ? "today" : options.since;
|
|
14418
16424
|
const receipt = await generateReceipt({
|
|
@@ -14428,13 +16434,13 @@ program2.name("qodewk").description("Universal telemetry and digital receipt gen
|
|
|
14428
16434
|
db.close();
|
|
14429
16435
|
} catch {
|
|
14430
16436
|
}
|
|
14431
|
-
outputReceipt(receipt, options);
|
|
16437
|
+
await outputReceipt(receipt, options);
|
|
14432
16438
|
} catch (err) {
|
|
14433
16439
|
console.error(import_picocolors.default.red(`Error generating receipt: ${err.message}`));
|
|
14434
16440
|
process.exit(1);
|
|
14435
16441
|
}
|
|
14436
16442
|
});
|
|
14437
|
-
program2.command("audit").description("Audit PR or branch diff against a target base commit").option("-b, --base <base>", "Base git ref or commit SHA (e.g. origin/main)").option("-h, --head <head>", "Head git ref or commit SHA").option("-f, --format <format>", "Output format (terminal, json, markdown)", "terminal").option("-o, --out <path>", "Write receipt output to specified file path").option("-p, --provider <provider>", "Specify AI provider").option("-m, --model <model>", "Specify AI model").action(async (options) => {
|
|
16443
|
+
program2.command("audit").description("Audit PR or branch diff against a target base commit").option("-b, --base <base>", "Base git ref or commit SHA (e.g. origin/main)").option("-h, --head <head>", "Head git ref or commit SHA").option("-f, --format <format>", "Output format (terminal, json, markdown)", "terminal").option("-o, --out <path>", "Write receipt output to specified file path").option("-p, --provider <provider>", "Specify AI provider").option("-m, --model <model>", "Specify AI model").option("--barcode", "Render 1D barcode simulation instead of scannable 2D QR code").action(async (options) => {
|
|
14438
16444
|
try {
|
|
14439
16445
|
const receipt = await generateReceipt({
|
|
14440
16446
|
baseSha: options.base,
|
|
@@ -14442,13 +16448,13 @@ program2.command("audit").description("Audit PR or branch diff against a target
|
|
|
14442
16448
|
provider: options.provider,
|
|
14443
16449
|
model: options.model
|
|
14444
16450
|
});
|
|
14445
|
-
outputReceipt(receipt, options);
|
|
16451
|
+
await outputReceipt(receipt, options);
|
|
14446
16452
|
} catch (err) {
|
|
14447
16453
|
console.error(import_picocolors.default.red(`Error auditing git range: ${err.message}`));
|
|
14448
16454
|
process.exit(1);
|
|
14449
16455
|
}
|
|
14450
16456
|
});
|
|
14451
|
-
program2.command("share").description("Publish privacy-safe receipt to Qodewk cloud and get a shareable URL").option("-p, --provider <provider>", "Specify AI provider").option("-m, --model <model>", "Specify AI model").action(async (options) => {
|
|
16457
|
+
program2.command("share").description("Publish privacy-safe receipt to Qodewk cloud and get a shareable URL").option("-p, --provider <provider>", "Specify AI provider").option("-m, --model <model>", "Specify AI model").option("--barcode", "Render 1D barcode simulation instead of scannable 2D QR code").action(async (options) => {
|
|
14452
16458
|
try {
|
|
14453
16459
|
const receipt = await generateReceipt({
|
|
14454
16460
|
provider: options.provider,
|
|
@@ -14457,10 +16463,10 @@ program2.command("share").description("Publish privacy-safe receipt to Qodewk cl
|
|
|
14457
16463
|
if (process.env.QODEWK_TELEMETRY === "off") {
|
|
14458
16464
|
console.log(import_picocolors.default.yellow("\n\u26A0\uFE0F Cloud publishing is disabled because QODEWK_TELEMETRY=off."));
|
|
14459
16465
|
console.log(import_picocolors.default.dim("Telemetry remains strictly stored in local SQLite (~/.qodewk/state.db).\n"));
|
|
14460
|
-
renderTerminalReceipt(receipt);
|
|
16466
|
+
await renderTerminalReceipt(receipt, void 0, options.barcode);
|
|
14461
16467
|
return;
|
|
14462
16468
|
}
|
|
14463
|
-
const endpoint = process.env.QODEWK_API_URL || "https://qodewk.
|
|
16469
|
+
const endpoint = process.env.QODEWK_API_URL || "https://qodewk.flinkeo.online/api/receipts";
|
|
14464
16470
|
console.log(import_picocolors.default.dim(`Publishing receipt ${receipt.receipt.id} to ${endpoint}...`));
|
|
14465
16471
|
try {
|
|
14466
16472
|
const response = await fetch(endpoint, {
|
|
@@ -14477,11 +16483,11 @@ program2.command("share").description("Publish privacy-safe receipt to Qodewk cl
|
|
|
14477
16483
|
const db = new LocalStateDB();
|
|
14478
16484
|
db.saveReceipt(receipt, data.claimToken);
|
|
14479
16485
|
db.close();
|
|
14480
|
-
renderTerminalReceipt(receipt, data.url);
|
|
16486
|
+
await renderTerminalReceipt(receipt, data.url, options.barcode);
|
|
14481
16487
|
} catch (networkErr) {
|
|
14482
16488
|
console.log(import_picocolors.default.yellow(`
|
|
14483
16489
|
Could not reach cloud API (${networkErr.message}). Rendered locally:`));
|
|
14484
|
-
renderTerminalReceipt(receipt);
|
|
16490
|
+
await renderTerminalReceipt(receipt, void 0, options.barcode);
|
|
14485
16491
|
}
|
|
14486
16492
|
} catch (err) {
|
|
14487
16493
|
console.error(import_picocolors.default.red(`Error sharing receipt: ${err.message}`));
|
|
@@ -14495,7 +16501,7 @@ var ansiHex = (hexColor) => {
|
|
|
14495
16501
|
const b2 = num & 255;
|
|
14496
16502
|
return (text) => `\x1B[38;2;${r2};${g};${b2}m${text}\x1B[39m`;
|
|
14497
16503
|
};
|
|
14498
|
-
function outputReceipt(receipt, options, publicUrl) {
|
|
16504
|
+
async function outputReceipt(receipt, options, publicUrl) {
|
|
14499
16505
|
let content = "";
|
|
14500
16506
|
const format = options.json ? "json" : options.format || "terminal";
|
|
14501
16507
|
if (format === "json") {
|
|
@@ -14508,7 +16514,7 @@ function outputReceipt(receipt, options, publicUrl) {
|
|
|
14508
16514
|
console.log(import_picocolors.default.green(`\u2713 Receipt written to ${options.out}`));
|
|
14509
16515
|
}
|
|
14510
16516
|
if (format === "terminal" && !options.out) {
|
|
14511
|
-
renderTerminalReceipt(receipt, publicUrl);
|
|
16517
|
+
await renderTerminalReceipt(receipt, publicUrl, options.barcode);
|
|
14512
16518
|
} else if (format !== "terminal" && !options.out) {
|
|
14513
16519
|
console.log(content);
|
|
14514
16520
|
}
|
|
@@ -14519,7 +16525,7 @@ var stripAnsi = (str) => {
|
|
|
14519
16525
|
var visibleWidth = (str) => {
|
|
14520
16526
|
return stripAnsi(str).length;
|
|
14521
16527
|
};
|
|
14522
|
-
function renderTerminalReceipt(receipt, publicUrl) {
|
|
16528
|
+
async function renderTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
14523
16529
|
const coral = ansiHex("#cc785c");
|
|
14524
16530
|
const green = ansiHex("#5db872");
|
|
14525
16531
|
const red = ansiHex("#c64545");
|
|
@@ -14569,7 +16575,8 @@ function renderTerminalReceipt(receipt, publicUrl) {
|
|
|
14569
16575
|
printRow(`TASK: ${taskClean}`);
|
|
14570
16576
|
}
|
|
14571
16577
|
printDivider("=");
|
|
14572
|
-
|
|
16578
|
+
const itemsHeader = receipt.repository.commitsCount && receipt.repository.commitsCount > 1 ? `ITEMS CHANGED (${receipt.repository.commitsCount} COMMITS)` : "ITEMS CHANGED";
|
|
16579
|
+
printRowSplit(itemsHeader, "QTY");
|
|
14573
16580
|
printDivider("-");
|
|
14574
16581
|
printRowSplit("Files Touched", String(receipt.mutation.files));
|
|
14575
16582
|
printRowSplit("Lines Inserted", green("+ " + receipt.mutation.insertions));
|
|
@@ -14603,10 +16610,33 @@ function renderTerminalReceipt(receipt, publicUrl) {
|
|
|
14603
16610
|
);
|
|
14604
16611
|
printDivider("=");
|
|
14605
16612
|
printRow("");
|
|
14606
|
-
|
|
14607
|
-
const urlToDisplay = publicUrl ||
|
|
14608
|
-
const
|
|
14609
|
-
|
|
16613
|
+
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || process.env.QODEWK_APP_URL || "https://qodewk.flinkeo.online";
|
|
16614
|
+
const urlToDisplay = publicUrl || `${baseUrl}/r/${receipt.receipt.id}`;
|
|
16615
|
+
const displayHost = baseUrl.replace(/^https?:\/\//, "");
|
|
16616
|
+
if (useBarcode) {
|
|
16617
|
+
const barChars = ["||| ", "| | ", "|||| ", "|| | ", "|| || "];
|
|
16618
|
+
let barcodePattern = "||| ";
|
|
16619
|
+
for (let i2 = 0; i2 < 7; i2++) {
|
|
16620
|
+
const charCode = receipt.receipt.id.charCodeAt(i2 % receipt.receipt.id.length) + (receipt.receipt.id.charCodeAt((i2 + 7) % receipt.receipt.id.length) || 0);
|
|
16621
|
+
barcodePattern += barChars[charCode % barChars.length];
|
|
16622
|
+
}
|
|
16623
|
+
barcodePattern += "|||";
|
|
16624
|
+
printCenteredRow(import_picocolors.default.bold(barcodePattern));
|
|
16625
|
+
} else {
|
|
16626
|
+
const qrRows = renderTerminalQr(urlToDisplay);
|
|
16627
|
+
if (qrRows.length > 0) {
|
|
16628
|
+
printCenteredRow(import_picocolors.default.dim("--- SCAN WITH PHONE ---"));
|
|
16629
|
+
printRow("");
|
|
16630
|
+
for (const qrRow of qrRows) {
|
|
16631
|
+
printCenteredRow(qrRow);
|
|
16632
|
+
}
|
|
16633
|
+
printRow("");
|
|
16634
|
+
} else {
|
|
16635
|
+
printCenteredRow(import_picocolors.default.bold("||| | ||||| ||| |||| |||||| |||| ||| ||||||| |||"));
|
|
16636
|
+
}
|
|
16637
|
+
}
|
|
16638
|
+
printCenteredRow(import_picocolors.default.cyan(displayHost));
|
|
16639
|
+
printCenteredRow(import_picocolors.default.underline(import_picocolors.default.cyan(`r/${receipt.receipt.id}`)));
|
|
14610
16640
|
printRow("");
|
|
14611
16641
|
if (process.env.QODEWK_TELEMETRY === "off") {
|
|
14612
16642
|
printRow(` ${teal("[\u2713]")} QODEWK_TELEMETRY=off (Cloud sync disabled)`);
|
|
@@ -14614,5 +16644,10 @@ function renderTerminalReceipt(receipt, publicUrl) {
|
|
|
14614
16644
|
printRow(` ${green("[\u2713]")} Source code was never uploaded to Qodewk`);
|
|
14615
16645
|
console.log(" " + import_picocolors.default.bold(coral("\\/".repeat(28))));
|
|
14616
16646
|
console.log("");
|
|
16647
|
+
console.log(` ${import_picocolors.default.dim("\u{1F517} Public Receipt:")} ${import_picocolors.default.underline(import_picocolors.default.cyan(urlToDisplay))}`);
|
|
16648
|
+
if (!useBarcode) {
|
|
16649
|
+
console.log(` ${import_picocolors.default.dim("\u{1F4CA} View classic 1D barcode:")} ${import_picocolors.default.cyan("pnpm qodewk --barcode")}`);
|
|
16650
|
+
}
|
|
16651
|
+
console.log("");
|
|
14617
16652
|
}
|
|
14618
16653
|
program2.parse(process.argv);
|