qodewk 0.2.1 → 0.2.3
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 +4 -0
- package/dist/index.cjs +513 -2095
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3403,1940 +3403,6 @@ 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 path8 = dijkstra.find_path(graph.map, "start", "end");
|
|
4960
|
-
const optimizedSegs = [];
|
|
4961
|
-
for (let i2 = 1; i2 < path8.length - 1; i2++) {
|
|
4962
|
-
optimizedSegs.push(graph.table[path8[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
|
-
|
|
5340
3406
|
// ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
|
|
5341
3407
|
var require_ms = __commonJS({
|
|
5342
3408
|
"../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports2, module2) {
|
|
@@ -6112,17 +4178,201 @@ var {
|
|
|
6112
4178
|
// src/index.ts
|
|
6113
4179
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
6114
4180
|
|
|
6115
|
-
// src/
|
|
6116
|
-
var
|
|
6117
|
-
|
|
6118
|
-
|
|
4181
|
+
// src/barcode.ts
|
|
4182
|
+
var CODE128_PATTERNS = [
|
|
4183
|
+
"11011001100",
|
|
4184
|
+
"11001101100",
|
|
4185
|
+
"11001100110",
|
|
4186
|
+
"10010011000",
|
|
4187
|
+
"10010001100",
|
|
4188
|
+
"10001001100",
|
|
4189
|
+
"10011001000",
|
|
4190
|
+
"10011000100",
|
|
4191
|
+
"10001100100",
|
|
4192
|
+
"11001001000",
|
|
4193
|
+
"11001000100",
|
|
4194
|
+
"11000100100",
|
|
4195
|
+
"10110011100",
|
|
4196
|
+
"10011011100",
|
|
4197
|
+
"10011001110",
|
|
4198
|
+
"10111001100",
|
|
4199
|
+
"10011101100",
|
|
4200
|
+
"10011100110",
|
|
4201
|
+
"11001110010",
|
|
4202
|
+
"11001011100",
|
|
4203
|
+
"11001001110",
|
|
4204
|
+
"11011100100",
|
|
4205
|
+
"11001110100",
|
|
4206
|
+
"11101101110",
|
|
4207
|
+
"11101001100",
|
|
4208
|
+
"11100101100",
|
|
4209
|
+
"11100100110",
|
|
4210
|
+
"11101100100",
|
|
4211
|
+
"11100110100",
|
|
4212
|
+
"11100110010",
|
|
4213
|
+
"11011011000",
|
|
4214
|
+
"11011000110",
|
|
4215
|
+
"11000110110",
|
|
4216
|
+
"10100011000",
|
|
4217
|
+
"10001011000",
|
|
4218
|
+
"10001000110",
|
|
4219
|
+
"10110001000",
|
|
4220
|
+
"10001101000",
|
|
4221
|
+
"10001100010",
|
|
4222
|
+
"11010001000",
|
|
4223
|
+
"11000101000",
|
|
4224
|
+
"11000100010",
|
|
4225
|
+
"10110111000",
|
|
4226
|
+
"10110001110",
|
|
4227
|
+
"10001101110",
|
|
4228
|
+
"10111011000",
|
|
4229
|
+
"10111000110",
|
|
4230
|
+
"10001110110",
|
|
4231
|
+
"11101110110",
|
|
4232
|
+
"11010001110",
|
|
4233
|
+
"11000101110",
|
|
4234
|
+
"11011101000",
|
|
4235
|
+
"11011100010",
|
|
4236
|
+
"11011101110",
|
|
4237
|
+
"11101011000",
|
|
4238
|
+
"11101000110",
|
|
4239
|
+
"11100010110",
|
|
4240
|
+
"11101101000",
|
|
4241
|
+
"11101100010",
|
|
4242
|
+
"11100011010",
|
|
4243
|
+
"11101111010",
|
|
4244
|
+
"11001000010",
|
|
4245
|
+
"11110001010",
|
|
4246
|
+
"10100110000",
|
|
4247
|
+
"10100001100",
|
|
4248
|
+
"10010110000",
|
|
4249
|
+
"10010000110",
|
|
4250
|
+
"10000101100",
|
|
4251
|
+
"10000100110",
|
|
4252
|
+
"10110010000",
|
|
4253
|
+
"10110000100",
|
|
4254
|
+
"10011010000",
|
|
4255
|
+
"10011000010",
|
|
4256
|
+
"10000110100",
|
|
4257
|
+
"10000110010",
|
|
4258
|
+
"11000010010",
|
|
4259
|
+
"11001010000",
|
|
4260
|
+
"11110111010",
|
|
4261
|
+
"11000010100",
|
|
4262
|
+
"10001111010",
|
|
4263
|
+
"10100111100",
|
|
4264
|
+
"10010111100",
|
|
4265
|
+
"10010011110",
|
|
4266
|
+
"10111100100",
|
|
4267
|
+
"10011110100",
|
|
4268
|
+
"10011110010",
|
|
4269
|
+
"11110100100",
|
|
4270
|
+
"11110010100",
|
|
4271
|
+
"11110010010",
|
|
4272
|
+
"11011011110",
|
|
4273
|
+
"11011110110",
|
|
4274
|
+
"11110110110",
|
|
4275
|
+
"10101111000",
|
|
4276
|
+
"10100011110",
|
|
4277
|
+
"10001011110",
|
|
4278
|
+
"10111101000",
|
|
4279
|
+
"10111100010",
|
|
4280
|
+
"11110101000",
|
|
4281
|
+
"11110100010",
|
|
4282
|
+
"10111011110",
|
|
4283
|
+
"10111101110",
|
|
4284
|
+
"11101011110",
|
|
4285
|
+
"11110101110",
|
|
4286
|
+
"11010000100",
|
|
4287
|
+
"11010010000",
|
|
4288
|
+
"11010011100",
|
|
4289
|
+
"1100011101011"
|
|
4290
|
+
];
|
|
4291
|
+
var START_B = 104;
|
|
4292
|
+
var STOP = 106;
|
|
4293
|
+
function encodeCode128B(text) {
|
|
4294
|
+
const codes = [START_B];
|
|
4295
|
+
for (const ch of text) {
|
|
4296
|
+
const code = ch.charCodeAt(0) - 32;
|
|
4297
|
+
if (code < 0 || code > 95) {
|
|
4298
|
+
throw new Error(`Code 128-B cannot encode character: ${JSON.stringify(ch)}`);
|
|
4299
|
+
}
|
|
4300
|
+
codes.push(code);
|
|
4301
|
+
}
|
|
4302
|
+
let checksum = START_B;
|
|
4303
|
+
for (let i2 = 1; i2 < codes.length; i2++) {
|
|
4304
|
+
checksum += codes[i2] * i2;
|
|
4305
|
+
}
|
|
4306
|
+
codes.push(checksum % 103);
|
|
4307
|
+
codes.push(STOP);
|
|
4308
|
+
return codes;
|
|
4309
|
+
}
|
|
4310
|
+
function code128Modules(text) {
|
|
4311
|
+
const codes = encodeCode128B(text);
|
|
4312
|
+
let modules = "";
|
|
4313
|
+
for (const code of codes) {
|
|
4314
|
+
modules += CODE128_PATTERNS[code] ?? "";
|
|
4315
|
+
}
|
|
4316
|
+
return modules;
|
|
4317
|
+
}
|
|
4318
|
+
function renderTerminalBarcode(text, options = {}) {
|
|
4319
|
+
const maxWidth = Math.max(16, options.maxWidth ?? 52);
|
|
4320
|
+
const height = Math.max(2, options.height ?? 3);
|
|
4321
|
+
const quietZone = Math.max(0, options.quietZone ?? 10);
|
|
4322
|
+
let payload = text;
|
|
4323
|
+
payload = [...payload].filter((ch) => {
|
|
4324
|
+
const c3 = ch.charCodeAt(0);
|
|
4325
|
+
return c3 >= 32 && c3 <= 126;
|
|
4326
|
+
}).join("");
|
|
4327
|
+
if (!payload) payload = "QODEWK";
|
|
4328
|
+
let modules;
|
|
6119
4329
|
try {
|
|
6120
|
-
|
|
6121
|
-
const rendered = import_terminal.default.render(data, { small: true });
|
|
6122
|
-
return rendered.split("\n").filter((r2) => r2.length > 0);
|
|
4330
|
+
modules = code128Modules(payload);
|
|
6123
4331
|
} catch {
|
|
6124
|
-
|
|
4332
|
+
modules = code128Modules("QODEWK");
|
|
4333
|
+
}
|
|
4334
|
+
const withQuiet = "0".repeat(quietZone) + modules + "0".repeat(quietZone);
|
|
4335
|
+
const scaled = downsampleModules(withQuiet, maxWidth);
|
|
4336
|
+
const row = modulesToBlocks(scaled);
|
|
4337
|
+
return Array.from({ length: height }, () => row);
|
|
4338
|
+
}
|
|
4339
|
+
function downsampleModules(modules, maxWidth) {
|
|
4340
|
+
if (modules.length <= maxWidth) return modules;
|
|
4341
|
+
const out = [];
|
|
4342
|
+
const ratio = modules.length / maxWidth;
|
|
4343
|
+
for (let i2 = 0; i2 < maxWidth; i2++) {
|
|
4344
|
+
const start = Math.floor(i2 * ratio);
|
|
4345
|
+
const end = Math.max(start + 1, Math.floor((i2 + 1) * ratio));
|
|
4346
|
+
let bars = 0;
|
|
4347
|
+
for (let j2 = start; j2 < end && j2 < modules.length; j2++) {
|
|
4348
|
+
if (modules[j2] === "1") bars++;
|
|
4349
|
+
}
|
|
4350
|
+
out.push(bars * 2 >= end - start ? "1" : "0");
|
|
4351
|
+
}
|
|
4352
|
+
return out.join("");
|
|
4353
|
+
}
|
|
4354
|
+
function modulesToBlocks(modules) {
|
|
4355
|
+
let out = "";
|
|
4356
|
+
for (const bit of modules) {
|
|
4357
|
+
out += bit === "1" ? "\u2588" : " ";
|
|
4358
|
+
}
|
|
4359
|
+
return out;
|
|
4360
|
+
}
|
|
4361
|
+
function pickBarcodePayload(input) {
|
|
4362
|
+
const maxChars = input.maxChars ?? 24;
|
|
4363
|
+
const candidates = [];
|
|
4364
|
+
if (input.publicUrl) candidates.push(input.publicUrl);
|
|
4365
|
+
if (input.displayHost && input.receiptId) {
|
|
4366
|
+
candidates.push(`${input.displayHost}/r/${input.receiptId}`);
|
|
4367
|
+
}
|
|
4368
|
+
candidates.push(input.receiptId);
|
|
4369
|
+
if (input.receiptId.length > 12) {
|
|
4370
|
+
candidates.push(input.receiptId.replace(/^rec_/, "").slice(0, 12));
|
|
6125
4371
|
}
|
|
4372
|
+
for (const c3 of candidates) {
|
|
4373
|
+
if (c3.length <= maxChars) return c3;
|
|
4374
|
+
}
|
|
4375
|
+
return candidates[candidates.length - 1].slice(0, maxChars);
|
|
6126
4376
|
}
|
|
6127
4377
|
|
|
6128
4378
|
// ../core/dist/index.js
|
|
@@ -15332,9 +13582,15 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
15332
13582
|
let renames = 0;
|
|
15333
13583
|
const extCounts = {};
|
|
15334
13584
|
let totalTrackedFiles = 0;
|
|
13585
|
+
const changedFiles = [];
|
|
15335
13586
|
for (const f of diffSummary.files) {
|
|
15336
13587
|
if (f.file.includes(" => ")) {
|
|
15337
13588
|
renames++;
|
|
13589
|
+
const dest = f.file.split(" => ").pop()?.trim();
|
|
13590
|
+
if (dest)
|
|
13591
|
+
changedFiles.push(dest.replace(/\\/g, "/"));
|
|
13592
|
+
} else {
|
|
13593
|
+
changedFiles.push(f.file.replace(/\\/g, "/"));
|
|
15338
13594
|
}
|
|
15339
13595
|
const ext = path.extname(f.file).replace(/^\./, "").toLowerCase();
|
|
15340
13596
|
const lang = mapExtensionToLanguage(ext);
|
|
@@ -15358,6 +13614,7 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
15358
13614
|
netLines,
|
|
15359
13615
|
renames,
|
|
15360
13616
|
languages,
|
|
13617
|
+
changedFiles,
|
|
15361
13618
|
branch,
|
|
15362
13619
|
headSha,
|
|
15363
13620
|
baseSha,
|
|
@@ -15367,6 +13624,21 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
15367
13624
|
commitsCount
|
|
15368
13625
|
};
|
|
15369
13626
|
}
|
|
13627
|
+
function computeAiWrittenRatio(changedFiles, aiEditedFiles) {
|
|
13628
|
+
if (changedFiles.length === 0 || aiEditedFiles.length === 0) {
|
|
13629
|
+
return void 0;
|
|
13630
|
+
}
|
|
13631
|
+
const norm = (f) => f.replace(/\\/g, "/").replace(/^\.\//, "").toLowerCase();
|
|
13632
|
+
const aiNorm = aiEditedFiles.map(norm);
|
|
13633
|
+
let hit = 0;
|
|
13634
|
+
for (const cf of changedFiles) {
|
|
13635
|
+
const c3 = norm(cf);
|
|
13636
|
+
const matched = aiNorm.some((a) => a === c3 || c3.endsWith("/" + a) || a.endsWith("/" + c3) || c3.endsWith(a) || a.endsWith(c3));
|
|
13637
|
+
if (matched)
|
|
13638
|
+
hit++;
|
|
13639
|
+
}
|
|
13640
|
+
return Math.round(hit / changedFiles.length * 100) / 100;
|
|
13641
|
+
}
|
|
15370
13642
|
function mapExtensionToLanguage(ext) {
|
|
15371
13643
|
const map = {
|
|
15372
13644
|
ts: "TypeScript",
|
|
@@ -16296,9 +14568,12 @@ function formatMarkdownReceipt(receipt, publicUrl) {
|
|
|
16296
14568
|
const costPrefix = receipt.ai.mode === "verified" ? "$" : "~$";
|
|
16297
14569
|
const confidencePercent = `${Math.round(receipt.ai.confidence * 100)}%`;
|
|
16298
14570
|
const confidenceTier = receipt.ai.confidence >= 0.8 ? "High" : receipt.ai.confidence >= 0.4 ? "Medium" : "Low";
|
|
14571
|
+
const tokenProvenance = receipt.ai.mode === "verified" || receipt.ai.mode === "observed" ? "Observed" : "Estimated";
|
|
14572
|
+
const costProvenance = receipt.ai.mode === "verified" ? "Verified" : receipt.ai.mode === "observed" ? "Observed" : "Estimated";
|
|
14573
|
+
const tokenDisplay = receipt.ai.mode === "verified" || receipt.ai.mode === "observed" ? totalTokens : `~${totalTokens}`;
|
|
16299
14574
|
const lines = [
|
|
16300
14575
|
`<!-- QODEWK_RECEIPT_START:${receipt.receipt.id} -->`,
|
|
16301
|
-
`###
|
|
14576
|
+
`### Qodewk Telemetry Receipt`,
|
|
16302
14577
|
``,
|
|
16303
14578
|
`| Metric | Measurement | Provenance |`,
|
|
16304
14579
|
`| :--- | :--- | :--- |`,
|
|
@@ -16307,19 +14582,42 @@ function formatMarkdownReceipt(receipt, publicUrl) {
|
|
|
16307
14582
|
`| **Lines Deleted** | \`-${receipt.mutation.deletions}\` | Observed |`,
|
|
16308
14583
|
`| **Net Delta** | \`${receipt.mutation.netLines >= 0 ? "+" : ""}${receipt.mutation.netLines}\` | Observed |`,
|
|
16309
14584
|
`| **AI Model** | \`${receipt.ai.provider} \xB7 ${receipt.ai.model || "Unknown"}\` | ${receipt.ai.mode} |`,
|
|
16310
|
-
`| **Tokens Consumed** |
|
|
16311
|
-
`| **AI Spend** | \`${costPrefix}${receipt.ai.cost.toFixed(2)}\` |
|
|
14585
|
+
`| **Tokens Consumed** | \`${tokenDisplay}\` | ${tokenProvenance} |`,
|
|
14586
|
+
`| **AI Spend** | \`${costPrefix}${receipt.ai.cost.toFixed(2)}\` | ${costProvenance} |`,
|
|
16312
14587
|
`| **Confidence** | \`${confidencePercent}\` (${confidenceTier}) | Dual-Engine |`,
|
|
16313
14588
|
``,
|
|
16314
|
-
`>
|
|
14589
|
+
`> **Privacy Guarantee:** *Source code was never uploaded to Qodewk. Telemetry computed strictly from cryptographic Git metadata.*`,
|
|
16315
14590
|
``,
|
|
16316
|
-
|
|
14591
|
+
`[**View Full Digital Receipt \u2192**](${url})`,
|
|
16317
14592
|
`<!-- QODEWK_RECEIPT_END -->`
|
|
16318
14593
|
];
|
|
16319
14594
|
return lines.join("\n");
|
|
16320
14595
|
}
|
|
16321
14596
|
|
|
16322
14597
|
// ../core/dist/index.js
|
|
14598
|
+
function sanitizeReceiptForShare(receipt) {
|
|
14599
|
+
const sessions = receipt.ai.sessions?.map((s) => ({
|
|
14600
|
+
provider: s.provider,
|
|
14601
|
+
model: s.model,
|
|
14602
|
+
task: s.task,
|
|
14603
|
+
tokens: s.tokens,
|
|
14604
|
+
cost: s.cost,
|
|
14605
|
+
confidence: s.confidence,
|
|
14606
|
+
mode: s.mode
|
|
14607
|
+
}));
|
|
14608
|
+
return {
|
|
14609
|
+
...receipt,
|
|
14610
|
+
privacy: {
|
|
14611
|
+
...receipt.privacy,
|
|
14612
|
+
sourceExcluded: true,
|
|
14613
|
+
isPublic: true
|
|
14614
|
+
},
|
|
14615
|
+
ai: {
|
|
14616
|
+
...receipt.ai,
|
|
14617
|
+
sessions
|
|
14618
|
+
}
|
|
14619
|
+
};
|
|
14620
|
+
}
|
|
16323
14621
|
async function generateReceipt(options = {}) {
|
|
16324
14622
|
const metrics = await extractGitMetrics({
|
|
16325
14623
|
repoPath: options.repoPath || process.cwd(),
|
|
@@ -16335,7 +14633,7 @@ async function generateReceipt(options = {}) {
|
|
|
16335
14633
|
platform: options.platform
|
|
16336
14634
|
});
|
|
16337
14635
|
const primaryFp = harvestResult.primaryFootprint;
|
|
16338
|
-
|
|
14636
|
+
const detected = detectProviderFromCommit(metrics.commitMessage);
|
|
16339
14637
|
const provider = options.provider || primaryFp?.platform || detected?.provider || "unknown";
|
|
16340
14638
|
const model = options.model || primaryFp?.model || detected?.model;
|
|
16341
14639
|
const task = options.task || primaryFp?.taskTitle || (harvestResult.tasks.length > 0 ? harvestResult.tasks[0] : void 0);
|
|
@@ -16349,10 +14647,7 @@ async function generateReceipt(options = {}) {
|
|
|
16349
14647
|
confidence: fp.confidence,
|
|
16350
14648
|
mode: fp.mode
|
|
16351
14649
|
}));
|
|
16352
|
-
|
|
16353
|
-
if (primaryFp) {
|
|
16354
|
-
aiWrittenRatio = 0.88;
|
|
16355
|
-
}
|
|
14650
|
+
const aiWrittenRatio = computeAiWrittenRatio(metrics.changedFiles, harvestResult.filesEdited);
|
|
16356
14651
|
const costResult = estimateCost({
|
|
16357
14652
|
files: metrics.files,
|
|
16358
14653
|
insertions: metrics.insertions,
|
|
@@ -16362,18 +14657,22 @@ async function generateReceipt(options = {}) {
|
|
|
16362
14657
|
sessions: sessions.length > 0 ? sessions : void 0,
|
|
16363
14658
|
confidence: primaryFp?.confidence || detected?.confidence
|
|
16364
14659
|
});
|
|
16365
|
-
const receiptId = `rec_${crypto2.randomBytes(12).toString("hex")}`;
|
|
16366
14660
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
16367
14661
|
const payloadToHash = {
|
|
16368
14662
|
repoHash: metrics.repoHash,
|
|
16369
14663
|
headSha: metrics.headSha,
|
|
14664
|
+
baseSha: metrics.baseSha,
|
|
16370
14665
|
files: metrics.files,
|
|
16371
14666
|
insertions: metrics.insertions,
|
|
16372
14667
|
deletions: metrics.deletions,
|
|
16373
14668
|
cost: costResult.cost,
|
|
16374
|
-
tokens: costResult.tokens
|
|
14669
|
+
tokens: costResult.tokens,
|
|
14670
|
+
mode: costResult.mode,
|
|
14671
|
+
provider: costResult.provider,
|
|
14672
|
+
model: costResult.model
|
|
16375
14673
|
};
|
|
16376
14674
|
const contentHash = crypto2.createHash("sha256").update(JSON.stringify(payloadToHash)).digest("hex");
|
|
14675
|
+
const receiptId = `rec_${contentHash.slice(0, 24)}`;
|
|
16377
14676
|
const receipt = {
|
|
16378
14677
|
version: "1.0",
|
|
16379
14678
|
receipt: {
|
|
@@ -16410,7 +14709,7 @@ async function generateReceipt(options = {}) {
|
|
|
16410
14709
|
},
|
|
16411
14710
|
privacy: {
|
|
16412
14711
|
sourceExcluded: true,
|
|
16413
|
-
isPublic: options.isPublic ??
|
|
14712
|
+
isPublic: options.isPublic ?? false,
|
|
16414
14713
|
anonymizeBranch: options.anonymizeBranch ?? false
|
|
16415
14714
|
}
|
|
16416
14715
|
};
|
|
@@ -16418,154 +14717,279 @@ async function generateReceipt(options = {}) {
|
|
|
16418
14717
|
}
|
|
16419
14718
|
|
|
16420
14719
|
// src/index.ts
|
|
14720
|
+
var SHARE_PAYLOAD_MAX_BYTES = 5e4;
|
|
14721
|
+
function resolveCliVersion() {
|
|
14722
|
+
try {
|
|
14723
|
+
const argv1 = process.argv[1] ? path7.dirname(path7.resolve(process.argv[1])) : process.cwd();
|
|
14724
|
+
const candidates = [
|
|
14725
|
+
path7.join(argv1, "..", "package.json"),
|
|
14726
|
+
path7.join(argv1, "package.json")
|
|
14727
|
+
];
|
|
14728
|
+
for (const candidate of candidates) {
|
|
14729
|
+
if (!fs6.existsSync(candidate)) continue;
|
|
14730
|
+
const pkg = JSON.parse(fs6.readFileSync(candidate, "utf-8"));
|
|
14731
|
+
if (pkg.name === "qodewk" && pkg.version) return pkg.version;
|
|
14732
|
+
}
|
|
14733
|
+
} catch {
|
|
14734
|
+
}
|
|
14735
|
+
return "0.2.1";
|
|
14736
|
+
}
|
|
14737
|
+
function resolveSince(options) {
|
|
14738
|
+
return options.today ? "today" : options.since;
|
|
14739
|
+
}
|
|
14740
|
+
function persistReceipt(receipt, claimToken) {
|
|
14741
|
+
try {
|
|
14742
|
+
const db = new LocalStateDB();
|
|
14743
|
+
db.saveReceipt(receipt, claimToken);
|
|
14744
|
+
db.close();
|
|
14745
|
+
} catch {
|
|
14746
|
+
}
|
|
14747
|
+
}
|
|
14748
|
+
function resolveGitHooksDir(cwd = process.cwd()) {
|
|
14749
|
+
const gitPath = path7.join(cwd, ".git");
|
|
14750
|
+
if (!fs6.existsSync(gitPath)) return null;
|
|
14751
|
+
let gitCommonDir;
|
|
14752
|
+
const stat = fs6.statSync(gitPath);
|
|
14753
|
+
if (stat.isDirectory()) {
|
|
14754
|
+
gitCommonDir = gitPath;
|
|
14755
|
+
} else {
|
|
14756
|
+
const content = fs6.readFileSync(gitPath, "utf-8");
|
|
14757
|
+
const match = content.match(/gitdir:\s*(.+)/i);
|
|
14758
|
+
if (!match?.[1]) return null;
|
|
14759
|
+
let gitDir = match[1].trim();
|
|
14760
|
+
if (!path7.isAbsolute(gitDir)) {
|
|
14761
|
+
gitDir = path7.resolve(cwd, gitDir);
|
|
14762
|
+
}
|
|
14763
|
+
const commonFile = path7.join(gitDir, "commondir");
|
|
14764
|
+
if (fs6.existsSync(commonFile)) {
|
|
14765
|
+
let common = fs6.readFileSync(commonFile, "utf-8").trim();
|
|
14766
|
+
if (!path7.isAbsolute(common)) {
|
|
14767
|
+
common = path7.resolve(gitDir, common);
|
|
14768
|
+
}
|
|
14769
|
+
gitCommonDir = common;
|
|
14770
|
+
} else if (path7.basename(path7.dirname(gitDir)) === "worktrees") {
|
|
14771
|
+
gitCommonDir = path7.dirname(path7.dirname(gitDir));
|
|
14772
|
+
} else {
|
|
14773
|
+
gitCommonDir = gitDir;
|
|
14774
|
+
}
|
|
14775
|
+
}
|
|
14776
|
+
return path7.join(gitCommonDir, "hooks");
|
|
14777
|
+
}
|
|
14778
|
+
var HOOK_MARKER_BEGIN = "# --- BEGIN QODEWK HOOK ---";
|
|
14779
|
+
var HOOK_MARKER_END = "# --- END QODEWK HOOK ---";
|
|
14780
|
+
var HOOK_SNIPPET = `
|
|
14781
|
+
${HOOK_MARKER_BEGIN}
|
|
14782
|
+
# Non-blocking Qodewk background recorder (< 5ms)
|
|
14783
|
+
if command -v qodewk >/dev/null 2>&1 || command -v pnpm >/dev/null 2>&1 || [ -f "./node_modules/.bin/qodewk" ]; then
|
|
14784
|
+
( ( qodewk record || pnpm qodewk record || npx qodewk record ) >/dev/null 2>&1 & )
|
|
14785
|
+
fi
|
|
14786
|
+
${HOOK_MARKER_END}
|
|
14787
|
+
`;
|
|
14788
|
+
function installHookFile(hookFile) {
|
|
14789
|
+
let content = "";
|
|
14790
|
+
if (fs6.existsSync(hookFile)) {
|
|
14791
|
+
content = fs6.readFileSync(hookFile, "utf-8");
|
|
14792
|
+
} else {
|
|
14793
|
+
content = "#!/bin/sh\n";
|
|
14794
|
+
}
|
|
14795
|
+
if (content.includes(HOOK_MARKER_BEGIN)) {
|
|
14796
|
+
return "exists";
|
|
14797
|
+
}
|
|
14798
|
+
fs6.writeFileSync(hookFile, content + HOOK_SNIPPET, { mode: 493 });
|
|
14799
|
+
return "installed";
|
|
14800
|
+
}
|
|
14801
|
+
function uninstallHookFile(hookFile) {
|
|
14802
|
+
if (!fs6.existsSync(hookFile)) return "absent";
|
|
14803
|
+
const content = fs6.readFileSync(hookFile, "utf-8");
|
|
14804
|
+
if (!content.includes(HOOK_MARKER_BEGIN)) return "missing";
|
|
14805
|
+
const regex = new RegExp(`\\n?${HOOK_MARKER_BEGIN}[\\s\\S]*?${HOOK_MARKER_END}\\n?`, "g");
|
|
14806
|
+
const updated = content.replace(regex, "");
|
|
14807
|
+
fs6.writeFileSync(hookFile, updated, { mode: 493 });
|
|
14808
|
+
return "removed";
|
|
14809
|
+
}
|
|
16421
14810
|
var program2 = new Command();
|
|
16422
|
-
program2.name("qodewk").description("Universal telemetry and digital receipt generator for the AI coding agent era").version(
|
|
14811
|
+
program2.name("qodewk").description("Universal telemetry and digital receipt generator for the AI coding agent era").version(resolveCliVersion()).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("--local", "Force local-only mode (never open network sockets)").option("--barcode", "Render classic 1D thermal barcode (always on; kept for compatibility)").action(async (options) => {
|
|
16423
14812
|
try {
|
|
16424
|
-
const since = options.today ? "today" : options.since;
|
|
16425
14813
|
const receipt = await generateReceipt({
|
|
16426
14814
|
provider: options.provider,
|
|
16427
14815
|
model: options.model,
|
|
16428
|
-
since,
|
|
14816
|
+
since: resolveSince(options),
|
|
16429
14817
|
platform: options.platform,
|
|
16430
|
-
anonymizeBranch: options.anon
|
|
14818
|
+
anonymizeBranch: options.anon,
|
|
14819
|
+
isPublic: false
|
|
16431
14820
|
});
|
|
16432
|
-
|
|
16433
|
-
const db = new LocalStateDB();
|
|
16434
|
-
db.saveReceipt(receipt);
|
|
16435
|
-
db.close();
|
|
16436
|
-
} catch {
|
|
16437
|
-
}
|
|
14821
|
+
persistReceipt(receipt);
|
|
16438
14822
|
await outputReceipt(receipt, options);
|
|
16439
14823
|
} catch (err) {
|
|
16440
|
-
|
|
14824
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
14825
|
+
console.error(import_picocolors.default.red(`Error generating receipt: ${message}`));
|
|
16441
14826
|
process.exit(1);
|
|
16442
14827
|
}
|
|
16443
14828
|
});
|
|
16444
|
-
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
|
|
14829
|
+
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("-s, --since <duration>", "Harvest agent footprints since duration").option("--today", "Harvest agent footprints for today").option("--platform <platform>", "Filter agent platform").option("--anon", "Anonymize branch name in output").option("--barcode", "Render classic 1D thermal barcode (always on; kept for compatibility)").action(async (options) => {
|
|
16445
14830
|
try {
|
|
16446
14831
|
const receipt = await generateReceipt({
|
|
16447
14832
|
baseSha: options.base,
|
|
16448
14833
|
headSha: options.head,
|
|
16449
14834
|
provider: options.provider,
|
|
16450
|
-
model: options.model
|
|
14835
|
+
model: options.model,
|
|
14836
|
+
since: resolveSince(options),
|
|
14837
|
+
platform: options.platform,
|
|
14838
|
+
anonymizeBranch: options.anon,
|
|
14839
|
+
isPublic: false
|
|
16451
14840
|
});
|
|
14841
|
+
persistReceipt(receipt);
|
|
16452
14842
|
await outputReceipt(receipt, options);
|
|
16453
14843
|
} catch (err) {
|
|
16454
|
-
|
|
14844
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
14845
|
+
console.error(import_picocolors.default.red(`Error auditing git range: ${message}`));
|
|
16455
14846
|
process.exit(1);
|
|
16456
14847
|
}
|
|
16457
14848
|
});
|
|
16458
|
-
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
|
|
14849
|
+
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("-s, --since <duration>", "Harvest agent footprints since duration").option("--today", "Harvest agent footprints for today").option("--platform <platform>", "Filter agent platform").option("--anon", "Anonymize branch name in output").option("-f, --format <format>", "Local fallback output format", "terminal").option("-j, --json", "Also print JSON after share").option("--barcode", "Render classic 1D thermal barcode (always on; kept for compatibility)").action(async (options) => {
|
|
16459
14850
|
try {
|
|
16460
14851
|
const receipt = await generateReceipt({
|
|
16461
14852
|
provider: options.provider,
|
|
16462
|
-
model: options.model
|
|
14853
|
+
model: options.model,
|
|
14854
|
+
since: resolveSince(options),
|
|
14855
|
+
platform: options.platform,
|
|
14856
|
+
anonymizeBranch: options.anon,
|
|
14857
|
+
isPublic: false
|
|
16463
14858
|
});
|
|
16464
|
-
|
|
16465
|
-
|
|
14859
|
+
const localFlag = program2.opts().local === true;
|
|
14860
|
+
if (process.env.QODEWK_TELEMETRY === "off" || localFlag) {
|
|
14861
|
+
console.log(
|
|
14862
|
+
import_picocolors.default.yellow(
|
|
14863
|
+
`
|
|
14864
|
+
Cloud publishing is disabled (${localFlag ? "--local" : "QODEWK_TELEMETRY=off"}).`
|
|
14865
|
+
)
|
|
14866
|
+
);
|
|
16466
14867
|
console.log(import_picocolors.default.dim("Telemetry remains strictly stored in local SQLite (~/.qodewk/state.db).\n"));
|
|
16467
|
-
|
|
14868
|
+
persistReceipt(receipt);
|
|
14869
|
+
await renderTerminalReceipt(receipt);
|
|
16468
14870
|
return;
|
|
16469
14871
|
}
|
|
14872
|
+
const sanitized = sanitizeReceiptForShare(receipt);
|
|
14873
|
+
let body = JSON.stringify(sanitized);
|
|
14874
|
+
if (Buffer.byteLength(body, "utf-8") > SHARE_PAYLOAD_MAX_BYTES && sanitized.ai.sessions) {
|
|
14875
|
+
const trimmed2 = {
|
|
14876
|
+
...sanitized,
|
|
14877
|
+
ai: { ...sanitized.ai, sessions: void 0 }
|
|
14878
|
+
};
|
|
14879
|
+
body = JSON.stringify(trimmed2);
|
|
14880
|
+
}
|
|
14881
|
+
if (Buffer.byteLength(body, "utf-8") > SHARE_PAYLOAD_MAX_BYTES) {
|
|
14882
|
+
console.error(import_picocolors.default.red("Sanitized receipt still exceeds the 50 KB cloud payload limit."));
|
|
14883
|
+
process.exit(1);
|
|
14884
|
+
}
|
|
16470
14885
|
const endpoint = process.env.QODEWK_API_URL || `${process.env.NEXT_PUBLIC_APP_URL || process.env.QODEWK_APP_URL || "https://qodewk.flinkeo.online"}/api/receipts`;
|
|
16471
|
-
console.log(import_picocolors.default.dim(`Publishing receipt ${
|
|
14886
|
+
console.log(import_picocolors.default.dim(`Publishing receipt ${sanitized.receipt.id} to ${endpoint}...`));
|
|
16472
14887
|
try {
|
|
16473
14888
|
const response = await fetch(endpoint, {
|
|
16474
14889
|
method: "POST",
|
|
16475
14890
|
headers: {
|
|
16476
|
-
"Content-Type": "application/json"
|
|
14891
|
+
"Content-Type": "application/json",
|
|
14892
|
+
"Content-Length": String(Buffer.byteLength(body, "utf-8"))
|
|
16477
14893
|
},
|
|
16478
|
-
body
|
|
14894
|
+
body
|
|
16479
14895
|
});
|
|
16480
14896
|
if (!response.ok) {
|
|
16481
|
-
|
|
14897
|
+
const errText = await response.text().catch(() => "");
|
|
14898
|
+
throw new Error(`API responded with status ${response.status}${errText ? `: ${errText.slice(0, 200)}` : ""}`);
|
|
16482
14899
|
}
|
|
16483
14900
|
const data = await response.json();
|
|
16484
|
-
|
|
16485
|
-
|
|
16486
|
-
|
|
16487
|
-
|
|
14901
|
+
persistReceipt(sanitized, data.claimToken);
|
|
14902
|
+
console.log("");
|
|
14903
|
+
console.log(import_picocolors.default.green(" Published successfully."));
|
|
14904
|
+
console.log(` ${import_picocolors.default.dim("Public URL:")} ${import_picocolors.default.underline(import_picocolors.default.cyan(data.url))}`);
|
|
14905
|
+
console.log(` ${import_picocolors.default.bold(import_picocolors.default.yellow(" Claim token (store securely \u2014 shown once):"))}`);
|
|
14906
|
+
console.log(` ${import_picocolors.default.yellow(data.claimToken)}`);
|
|
14907
|
+
console.log(import_picocolors.default.dim(" Saved to ~/.qodewk/state.db \u2014 required to prove authorship later."));
|
|
14908
|
+
console.log("");
|
|
14909
|
+
await renderTerminalReceipt(sanitized, data.url);
|
|
14910
|
+
if (options.json) {
|
|
14911
|
+
console.log(JSON.stringify({ url: data.url, claimToken: data.claimToken, receipt: sanitized }, null, 2));
|
|
14912
|
+
}
|
|
16488
14913
|
} catch (networkErr) {
|
|
14914
|
+
const message = networkErr instanceof Error ? networkErr.message : String(networkErr);
|
|
16489
14915
|
console.log(import_picocolors.default.yellow(`
|
|
16490
|
-
Could not reach cloud API (${
|
|
16491
|
-
|
|
14916
|
+
Could not reach cloud API (${message}). Rendered locally:`));
|
|
14917
|
+
persistReceipt(receipt);
|
|
14918
|
+
await renderTerminalReceipt(receipt);
|
|
16492
14919
|
}
|
|
16493
14920
|
} catch (err) {
|
|
16494
|
-
|
|
14921
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
14922
|
+
console.error(import_picocolors.default.red(`Error sharing receipt: ${message}`));
|
|
16495
14923
|
process.exit(1);
|
|
16496
14924
|
}
|
|
16497
14925
|
});
|
|
16498
|
-
program2.command("record").description("Silently record local telemetry receipt into SQLite (used by git hooks)").action(async () => {
|
|
14926
|
+
program2.command("record").alias("record-event").description("Silently record local telemetry receipt into SQLite (used by git hooks)").action(async () => {
|
|
16499
14927
|
try {
|
|
16500
|
-
const receipt = await generateReceipt();
|
|
16501
|
-
|
|
16502
|
-
db.saveReceipt(receipt);
|
|
16503
|
-
db.close();
|
|
14928
|
+
const receipt = await generateReceipt({ isPublic: false });
|
|
14929
|
+
persistReceipt(receipt);
|
|
16504
14930
|
process.exit(0);
|
|
16505
14931
|
} catch {
|
|
16506
14932
|
process.exit(0);
|
|
16507
14933
|
}
|
|
16508
14934
|
});
|
|
16509
|
-
var hookCommand = program2.command("hook").description("Manage non-blocking Git hooks for automatic telemetry recording");
|
|
16510
|
-
hookCommand.command("install").description("Install non-blocking post-commit
|
|
14935
|
+
var hookCommand = program2.command("hook").aliases(["hooks"]).description("Manage non-blocking Git hooks for automatic telemetry recording");
|
|
14936
|
+
hookCommand.command("install").description("Install non-blocking post-commit and post-rewrite Git hooks").action(async () => {
|
|
16511
14937
|
try {
|
|
16512
|
-
const
|
|
16513
|
-
if (!
|
|
16514
|
-
console.error(import_picocolors.default.red("Error: Current directory is not a Git repository
|
|
14938
|
+
const hooksDir = resolveGitHooksDir();
|
|
14939
|
+
if (!hooksDir) {
|
|
14940
|
+
console.error(import_picocolors.default.red("Error: Current directory is not a Git repository (.git not found)."));
|
|
16515
14941
|
process.exit(1);
|
|
16516
14942
|
}
|
|
16517
|
-
const hooksDir = path7.join(gitDir, "hooks");
|
|
16518
14943
|
if (!fs6.existsSync(hooksDir)) {
|
|
16519
14944
|
fs6.mkdirSync(hooksDir, { recursive: true });
|
|
16520
14945
|
}
|
|
16521
|
-
const
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
const
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16528
|
-
( ( qodewk record || pnpm qodewk record || npx qodewk record ) >/dev/null 2>&1 & )
|
|
16529
|
-
fi
|
|
16530
|
-
${hookMarkerEnd}
|
|
16531
|
-
`;
|
|
16532
|
-
let content = "";
|
|
16533
|
-
if (fs6.existsSync(hookFile)) {
|
|
16534
|
-
content = fs6.readFileSync(hookFile, "utf-8");
|
|
16535
|
-
} else {
|
|
16536
|
-
content = "#!/bin/sh\n";
|
|
14946
|
+
const targets = ["post-commit", "post-rewrite"];
|
|
14947
|
+
let installed = 0;
|
|
14948
|
+
let existing = 0;
|
|
14949
|
+
for (const name of targets) {
|
|
14950
|
+
const result = installHookFile(path7.join(hooksDir, name));
|
|
14951
|
+
if (result === "installed") installed++;
|
|
14952
|
+
else existing++;
|
|
16537
14953
|
}
|
|
16538
|
-
if (
|
|
16539
|
-
console.log(import_picocolors.default.yellow("Qodewk
|
|
14954
|
+
if (installed === 0 && existing > 0) {
|
|
14955
|
+
console.log(import_picocolors.default.yellow("Qodewk Git hooks are already installed (post-commit, post-rewrite)."));
|
|
16540
14956
|
return;
|
|
16541
14957
|
}
|
|
16542
|
-
|
|
16543
|
-
|
|
14958
|
+
console.log(
|
|
14959
|
+
import_picocolors.default.green(
|
|
14960
|
+
`\u2713 Non-blocking Qodewk hooks installed in ${hooksDir} (post-commit${installed > 1 || existing > 0 ? ", post-rewrite" : installed === 1 && targets.length === 2 ? " + post-rewrite" : ""})`
|
|
14961
|
+
)
|
|
14962
|
+
);
|
|
14963
|
+
if (existing > 0) {
|
|
14964
|
+
console.log(import_picocolors.default.dim(` (${existing} hook file(s) already contained the Qodewk marker)`));
|
|
14965
|
+
}
|
|
16544
14966
|
} catch (err) {
|
|
16545
|
-
|
|
14967
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
14968
|
+
console.error(import_picocolors.default.red(`Failed to install Git hook: ${message}`));
|
|
16546
14969
|
process.exit(1);
|
|
16547
14970
|
}
|
|
16548
14971
|
});
|
|
16549
|
-
hookCommand.command("uninstall").description("Remove Qodewk post-commit Git
|
|
14972
|
+
hookCommand.command("uninstall").description("Remove Qodewk post-commit and post-rewrite Git hooks").action(async () => {
|
|
16550
14973
|
try {
|
|
16551
|
-
const
|
|
16552
|
-
if (!
|
|
16553
|
-
console.log(import_picocolors.default.yellow("No
|
|
14974
|
+
const hooksDir = resolveGitHooksDir();
|
|
14975
|
+
if (!hooksDir) {
|
|
14976
|
+
console.log(import_picocolors.default.yellow("No Git repository found."));
|
|
16554
14977
|
return;
|
|
16555
14978
|
}
|
|
16556
|
-
const
|
|
16557
|
-
|
|
16558
|
-
const
|
|
16559
|
-
|
|
16560
|
-
|
|
14979
|
+
const targets = ["post-commit", "post-rewrite"];
|
|
14980
|
+
let removed = 0;
|
|
14981
|
+
for (const name of targets) {
|
|
14982
|
+
const result = uninstallHookFile(path7.join(hooksDir, name));
|
|
14983
|
+
if (result === "removed") removed++;
|
|
14984
|
+
}
|
|
14985
|
+
if (removed === 0) {
|
|
14986
|
+
console.log(import_picocolors.default.yellow("Qodewk hooks are not installed."));
|
|
16561
14987
|
return;
|
|
16562
14988
|
}
|
|
16563
|
-
|
|
16564
|
-
const updated = content.replace(regex, "");
|
|
16565
|
-
fs6.writeFileSync(hookFile, updated, { mode: 493 });
|
|
16566
|
-
console.log(import_picocolors.default.green("\u2713 Qodewk post-commit hook removed."));
|
|
14989
|
+
console.log(import_picocolors.default.green(`\u2713 Qodewk hook markers removed from ${removed} file(s).`));
|
|
16567
14990
|
} catch (err) {
|
|
16568
|
-
|
|
14991
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
14992
|
+
console.error(import_picocolors.default.red(`Failed to uninstall hook: ${message}`));
|
|
16569
14993
|
process.exit(1);
|
|
16570
14994
|
}
|
|
16571
14995
|
});
|
|
@@ -16576,64 +15000,48 @@ var ansiHex = (hexColor) => {
|
|
|
16576
15000
|
const b2 = num & 255;
|
|
16577
15001
|
return (text) => `\x1B[38;2;${r2};${g};${b2}m${text}\x1B[39m`;
|
|
16578
15002
|
};
|
|
16579
|
-
async function outputReceipt(receipt, options, publicUrl) {
|
|
16580
|
-
let content = "";
|
|
16581
|
-
const format = options.json ? "json" : options.format || "terminal";
|
|
16582
|
-
if (format === "json") {
|
|
16583
|
-
content = JSON.stringify(receipt, null, 2);
|
|
16584
|
-
} else if (format === "markdown") {
|
|
16585
|
-
content = formatMarkdownReceipt(receipt, publicUrl);
|
|
16586
|
-
}
|
|
16587
|
-
if (options.out) {
|
|
16588
|
-
fs6.writeFileSync(options.out, content || formatMarkdownReceipt(receipt, publicUrl), "utf-8");
|
|
16589
|
-
console.log(import_picocolors.default.green(`\u2713 Receipt written to ${options.out}`));
|
|
16590
|
-
}
|
|
16591
|
-
if (format === "terminal" && !options.out) {
|
|
16592
|
-
await renderTerminalReceipt(receipt, publicUrl, options.barcode);
|
|
16593
|
-
} else if (format !== "terminal" && !options.out) {
|
|
16594
|
-
console.log(content);
|
|
16595
|
-
}
|
|
16596
|
-
}
|
|
16597
15003
|
var stripAnsi = (str) => {
|
|
16598
15004
|
return str.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").replace(/\x1B\([B0]/g, "");
|
|
16599
15005
|
};
|
|
16600
15006
|
var visibleWidth = (str) => {
|
|
16601
15007
|
return stripAnsi(str).length;
|
|
16602
15008
|
};
|
|
16603
|
-
|
|
15009
|
+
function buildTerminalReceipt(receipt, publicUrl) {
|
|
15010
|
+
const lines = [];
|
|
16604
15011
|
const coral = ansiHex("#cc785c");
|
|
16605
15012
|
const green = ansiHex("#5db872");
|
|
16606
15013
|
const red = ansiHex("#c64545");
|
|
16607
15014
|
const teal = ansiHex("#5db8a6");
|
|
16608
15015
|
const INNER_WIDTH = 52;
|
|
15016
|
+
const push = (line) => lines.push(line);
|
|
16609
15017
|
const printRow = (content, width = INNER_WIDTH) => {
|
|
16610
15018
|
const visLen = visibleWidth(content);
|
|
16611
15019
|
const pad = Math.max(0, width - visLen);
|
|
16612
|
-
|
|
15020
|
+
push(` | ${content}${" ".repeat(pad)} |`);
|
|
16613
15021
|
};
|
|
16614
15022
|
const printRowSplit = (left, right, width = INNER_WIDTH) => {
|
|
16615
15023
|
const leftVis = visibleWidth(left);
|
|
16616
15024
|
const rightVis = visibleWidth(right);
|
|
16617
15025
|
const pad = Math.max(1, width - leftVis - rightVis);
|
|
16618
|
-
|
|
15026
|
+
push(` | ${left}${" ".repeat(pad)}${right} |`);
|
|
16619
15027
|
};
|
|
16620
15028
|
const printCenteredRow = (content, width = INNER_WIDTH) => {
|
|
16621
15029
|
const visLen = visibleWidth(content);
|
|
16622
15030
|
const totalPad = Math.max(0, width - visLen);
|
|
16623
15031
|
const leftPad = Math.floor(totalPad / 2);
|
|
16624
15032
|
const rightPad = totalPad - leftPad;
|
|
16625
|
-
|
|
15033
|
+
push(` | ${" ".repeat(leftPad)}${content}${" ".repeat(rightPad)} |`);
|
|
16626
15034
|
};
|
|
16627
15035
|
const printDivider = (char = "=", width = INNER_WIDTH) => {
|
|
16628
|
-
|
|
15036
|
+
push(` | ${char.repeat(width)} |`);
|
|
16629
15037
|
};
|
|
16630
15038
|
const totalTokens = (receipt.ai.tokens.input + receipt.ai.tokens.output).toLocaleString();
|
|
16631
15039
|
const inputK = `${Math.round(receipt.ai.tokens.input / 1e3)}k`;
|
|
16632
15040
|
const outputK = `${Math.round(receipt.ai.tokens.output / 1e3)}k`;
|
|
16633
15041
|
const costPrefix = receipt.ai.mode === "verified" ? "$" : "~$";
|
|
16634
15042
|
const confidencePercent = `${Math.round(receipt.ai.confidence * 100)}%`;
|
|
16635
|
-
|
|
16636
|
-
|
|
15043
|
+
push("");
|
|
15044
|
+
push(" " + import_picocolors.default.bold(coral("/\\".repeat(28))));
|
|
16637
15045
|
printCenteredRow(import_picocolors.default.bold(import_picocolors.default.white("Q O D E W K")));
|
|
16638
15046
|
printCenteredRow(coral("*** PROOF OF SHIPMENT ***"));
|
|
16639
15047
|
printRow("");
|
|
@@ -16675,41 +15083,26 @@ async function renderTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16675
15083
|
printRowSplit("Total Tokens:", totalTokens);
|
|
16676
15084
|
printDivider("=");
|
|
16677
15085
|
const costLabel = receipt.ai.mode === "verified" ? "VERIFIED AI COST" : "ESTIMATED AI COST";
|
|
16678
|
-
printRowSplit(
|
|
16679
|
-
|
|
16680
|
-
import_picocolors.default.bold(coral(costPrefix + receipt.ai.cost.toFixed(2)))
|
|
16681
|
-
);
|
|
16682
|
-
printRowSplit(
|
|
16683
|
-
`CONFIDENCE: ${confidencePercent}`,
|
|
16684
|
-
`[Mode: ${receipt.ai.mode}]`
|
|
16685
|
-
);
|
|
15086
|
+
printRowSplit(costLabel, import_picocolors.default.bold(coral(costPrefix + receipt.ai.cost.toFixed(2))));
|
|
15087
|
+
printRowSplit(`CONFIDENCE: ${confidencePercent}`, `[Mode: ${receipt.ai.mode}]`);
|
|
16686
15088
|
printDivider("=");
|
|
16687
15089
|
printRow("");
|
|
16688
15090
|
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || process.env.QODEWK_APP_URL || "https://qodewk.flinkeo.online";
|
|
16689
15091
|
const isPublished = Boolean(publicUrl);
|
|
16690
|
-
const urlToDisplay = publicUrl || `${baseUrl}/r/${receipt.receipt.id}`;
|
|
16691
15092
|
const displayHost = baseUrl.replace(/^https?:\/\//, "");
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
|
|
16698
|
-
|
|
16699
|
-
|
|
16700
|
-
|
|
16701
|
-
|
|
16702
|
-
|
|
16703
|
-
|
|
16704
|
-
|
|
16705
|
-
printRow("");
|
|
16706
|
-
for (const qrRow of qrRows) {
|
|
16707
|
-
printCenteredRow(qrRow);
|
|
16708
|
-
}
|
|
16709
|
-
printRow("");
|
|
16710
|
-
} else {
|
|
16711
|
-
printCenteredRow(import_picocolors.default.bold("||| | ||||| ||| |||| |||||| |||| ||| ||||||| |||"));
|
|
16712
|
-
}
|
|
15093
|
+
const barcodePayload = pickBarcodePayload({
|
|
15094
|
+
publicUrl,
|
|
15095
|
+
receiptId: receipt.receipt.id,
|
|
15096
|
+
displayHost,
|
|
15097
|
+
maxChars: 28
|
|
15098
|
+
});
|
|
15099
|
+
const barcodeRows = renderTerminalBarcode(barcodePayload, {
|
|
15100
|
+
maxWidth: INNER_WIDTH,
|
|
15101
|
+
height: 3,
|
|
15102
|
+
quietZone: 8
|
|
15103
|
+
});
|
|
15104
|
+
for (const barRow of barcodeRows) {
|
|
15105
|
+
printCenteredRow(import_picocolors.default.bold(barRow));
|
|
16713
15106
|
}
|
|
16714
15107
|
if (isPublished) {
|
|
16715
15108
|
printCenteredRow(import_picocolors.default.cyan(displayHost));
|
|
@@ -16722,17 +15115,42 @@ async function renderTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16722
15115
|
printRow(` ${teal("[\u2713]")} QODEWK_TELEMETRY=off (Cloud sync disabled)`);
|
|
16723
15116
|
}
|
|
16724
15117
|
printRow(` ${green("[\u2713]")} Source code was never uploaded to Qodewk`);
|
|
16725
|
-
|
|
16726
|
-
|
|
16727
|
-
if (isPublished) {
|
|
16728
|
-
|
|
15118
|
+
push(" " + import_picocolors.default.bold(coral("\\/".repeat(28))));
|
|
15119
|
+
push("");
|
|
15120
|
+
if (isPublished && publicUrl) {
|
|
15121
|
+
push(` ${import_picocolors.default.dim("Public Receipt:")} ${import_picocolors.default.underline(import_picocolors.default.cyan(publicUrl))}`);
|
|
16729
15122
|
} else {
|
|
16730
|
-
|
|
16731
|
-
|
|
15123
|
+
push(` ${import_picocolors.default.dim("Saved to local DB:")} ${import_picocolors.default.dim("~/.qodewk/state.db")}`);
|
|
15124
|
+
push(` ${import_picocolors.default.dim("To publish & get shareable URL:")} ${import_picocolors.default.cyan("qodewk share")}`);
|
|
16732
15125
|
}
|
|
16733
|
-
|
|
16734
|
-
|
|
15126
|
+
push("");
|
|
15127
|
+
return lines.join("\n");
|
|
15128
|
+
}
|
|
15129
|
+
async function renderTerminalReceipt(receipt, publicUrl) {
|
|
15130
|
+
console.log(buildTerminalReceipt(receipt, publicUrl));
|
|
15131
|
+
}
|
|
15132
|
+
async function outputReceipt(receipt, options, publicUrl) {
|
|
15133
|
+
const format = options.json ? "json" : options.format || "terminal";
|
|
15134
|
+
let content;
|
|
15135
|
+
if (format === "json") {
|
|
15136
|
+
content = JSON.stringify(receipt, null, 2);
|
|
15137
|
+
} else if (format === "markdown") {
|
|
15138
|
+
content = formatMarkdownReceipt(receipt, publicUrl);
|
|
15139
|
+
} else {
|
|
15140
|
+
content = buildTerminalReceipt(receipt, publicUrl);
|
|
15141
|
+
}
|
|
15142
|
+
if (options.out) {
|
|
15143
|
+
const fileContent = format === "terminal" ? stripAnsi(content) : content;
|
|
15144
|
+
fs6.writeFileSync(options.out, fileContent.endsWith("\n") ? fileContent : fileContent + "\n", "utf-8");
|
|
15145
|
+
console.log(import_picocolors.default.green(`\u2713 Receipt written to ${options.out}`));
|
|
15146
|
+
}
|
|
15147
|
+
if (!options.out) {
|
|
15148
|
+
if (format === "terminal") {
|
|
15149
|
+
console.log(content);
|
|
15150
|
+
} else {
|
|
15151
|
+
console.log(content);
|
|
15152
|
+
}
|
|
15153
|
+
} else if (format !== "terminal") {
|
|
16735
15154
|
}
|
|
16736
|
-
console.log("");
|
|
16737
15155
|
}
|
|
16738
15156
|
program2.parse(process.argv);
|