qodewk 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -9
- package/dist/index.cjs +600 -2075
- package/package.json +1 -1
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}`);
|
|
6125
4367
|
}
|
|
4368
|
+
candidates.push(input.receiptId);
|
|
4369
|
+
if (input.receiptId.length > 12) {
|
|
4370
|
+
candidates.push(input.receiptId.replace(/^rec_/, "").slice(0, 12));
|
|
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
|
|
@@ -15256,6 +13506,7 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
15256
13506
|
let headSha = options.headSha || "0000000000000000000000000000000000000000";
|
|
15257
13507
|
let baseSha = options.baseSha;
|
|
15258
13508
|
let commitMessage = void 0;
|
|
13509
|
+
let commitDate = void 0;
|
|
15259
13510
|
let commitsCount = 1;
|
|
15260
13511
|
const sinceDate = parseSinceOption(options.since);
|
|
15261
13512
|
if (sinceDate && !options.baseSha) {
|
|
@@ -15287,6 +13538,7 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
15287
13538
|
headSha = log.latest.hash;
|
|
15288
13539
|
}
|
|
15289
13540
|
commitMessage = log.latest.message;
|
|
13541
|
+
commitDate = log.latest.date;
|
|
15290
13542
|
if (!options.baseSha && log.all.length > 1 && log.all[1]) {
|
|
15291
13543
|
baseSha = log.all[1].hash;
|
|
15292
13544
|
}
|
|
@@ -15306,22 +13558,34 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
15306
13558
|
const projectAlias = path.basename(path.resolve(repoPath)).toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
15307
13559
|
const repoHash = computeSaltedHash(repoIdentifier);
|
|
15308
13560
|
let diffSummary;
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
13561
|
+
try {
|
|
13562
|
+
if (baseSha && headSha && baseSha !== headSha) {
|
|
13563
|
+
const status = await git.status();
|
|
13564
|
+
if (status.files.length > 0) {
|
|
13565
|
+
diffSummary = await git.diffSummary([baseSha]);
|
|
13566
|
+
} else {
|
|
13567
|
+
diffSummary = await git.diffSummary([`${baseSha}...${headSha}`]).catch(async () => {
|
|
13568
|
+
return await git.diffSummary([`${baseSha}..${headSha}`]);
|
|
13569
|
+
});
|
|
13570
|
+
}
|
|
15313
13571
|
} else {
|
|
15314
|
-
|
|
13572
|
+
const status = await git.status();
|
|
13573
|
+
if (status.files.length > 0) {
|
|
13574
|
+
diffSummary = await git.diffSummary(["HEAD"]);
|
|
13575
|
+
} else if (baseSha) {
|
|
13576
|
+
diffSummary = await git.diffSummary([`${baseSha}..${headSha}`]);
|
|
13577
|
+
} else if (headSha !== "0000000000000000000000000000000000000000") {
|
|
13578
|
+
diffSummary = await git.diffSummary([`${headSha}~1..${headSha}`]).catch(async () => {
|
|
13579
|
+
return await git.diffSummary([headSha]);
|
|
13580
|
+
});
|
|
13581
|
+
} else {
|
|
13582
|
+
diffSummary = { changed: 0, insertions: 0, deletions: 0, files: [] };
|
|
13583
|
+
}
|
|
15315
13584
|
}
|
|
15316
|
-
}
|
|
15317
|
-
|
|
15318
|
-
if (status.files.length > 0) {
|
|
13585
|
+
} catch {
|
|
13586
|
+
try {
|
|
15319
13587
|
diffSummary = await git.diffSummary(["HEAD"]);
|
|
15320
|
-
}
|
|
15321
|
-
diffSummary = await git.diffSummary([`${baseSha}..${headSha}`]);
|
|
15322
|
-
} else if (headSha !== "0000000000000000000000000000000000000000") {
|
|
15323
|
-
diffSummary = await git.diffSummary([headSha]);
|
|
15324
|
-
} else {
|
|
13588
|
+
} catch {
|
|
15325
13589
|
diffSummary = { changed: 0, insertions: 0, deletions: 0, files: [] };
|
|
15326
13590
|
}
|
|
15327
13591
|
}
|
|
@@ -15371,6 +13635,7 @@ async function extractGitMetrics(optionsOrPath = process.cwd()) {
|
|
|
15371
13635
|
repoHash,
|
|
15372
13636
|
projectAlias,
|
|
15373
13637
|
commitMessage,
|
|
13638
|
+
commitDate,
|
|
15374
13639
|
commitsCount
|
|
15375
13640
|
};
|
|
15376
13641
|
}
|
|
@@ -15666,6 +13931,120 @@ function computeCost(inputTokens, outputTokens, cachedTokens, card) {
|
|
|
15666
13931
|
return Number((freshCost + cacheCost + outCost).toFixed(4));
|
|
15667
13932
|
}
|
|
15668
13933
|
|
|
13934
|
+
// ../core/dist/harvester/scoring.js
|
|
13935
|
+
function normalizeFilePath(filePath, repoPath) {
|
|
13936
|
+
let p2 = filePath.replace(/\\/g, "/").trim();
|
|
13937
|
+
p2 = p2.replace(/^file:\/\/\/?/, "");
|
|
13938
|
+
if (repoPath) {
|
|
13939
|
+
const normRepo = repoPath.replace(/\\/g, "/").replace(/\/$/, "");
|
|
13940
|
+
if (p2.toLowerCase().startsWith(normRepo.toLowerCase())) {
|
|
13941
|
+
p2 = p2.slice(normRepo.length);
|
|
13942
|
+
}
|
|
13943
|
+
}
|
|
13944
|
+
p2 = p2.replace(/^\.?\//, "");
|
|
13945
|
+
return p2.toLowerCase();
|
|
13946
|
+
}
|
|
13947
|
+
function scoreFootprint(fp, gitCtx) {
|
|
13948
|
+
if (!gitCtx) {
|
|
13949
|
+
return 0.5;
|
|
13950
|
+
}
|
|
13951
|
+
let score = 0.1;
|
|
13952
|
+
if (fp.boundCommitSha && gitCtx.headSha) {
|
|
13953
|
+
const bound = fp.boundCommitSha.toLowerCase().trim();
|
|
13954
|
+
const head = gitCtx.headSha.toLowerCase().trim();
|
|
13955
|
+
if (bound === head || bound.startsWith(head.slice(0, 7)) || head.startsWith(bound.slice(0, 7))) {
|
|
13956
|
+
score += 1;
|
|
13957
|
+
} else {
|
|
13958
|
+
score -= 0.5;
|
|
13959
|
+
}
|
|
13960
|
+
}
|
|
13961
|
+
if (gitCtx.changedFiles && gitCtx.changedFiles.length > 0) {
|
|
13962
|
+
const normChanged = gitCtx.changedFiles.map((f) => normalizeFilePath(f, fp.repoPath));
|
|
13963
|
+
const normEdited = (fp.filesEdited || []).map((f) => normalizeFilePath(f, fp.repoPath));
|
|
13964
|
+
if (normEdited.length > 0) {
|
|
13965
|
+
let matches = 0;
|
|
13966
|
+
for (const cf of normChanged) {
|
|
13967
|
+
const found = normEdited.some((ef) => ef === cf || cf.endsWith("/" + ef) || ef.endsWith("/" + cf) || cf.endsWith(ef) || ef.endsWith(cf));
|
|
13968
|
+
if (found)
|
|
13969
|
+
matches++;
|
|
13970
|
+
}
|
|
13971
|
+
const ratio = matches / normChanged.length;
|
|
13972
|
+
if (matches > 0) {
|
|
13973
|
+
score += ratio * 0.4;
|
|
13974
|
+
} else {
|
|
13975
|
+
score -= 0.15;
|
|
13976
|
+
}
|
|
13977
|
+
}
|
|
13978
|
+
}
|
|
13979
|
+
if (gitCtx.commitDate && fp.timestamp) {
|
|
13980
|
+
try {
|
|
13981
|
+
const commitTime = new Date(gitCtx.commitDate).getTime();
|
|
13982
|
+
const fpTime = new Date(fp.timestamp).getTime();
|
|
13983
|
+
if (!isNaN(commitTime) && !isNaN(fpTime)) {
|
|
13984
|
+
const diffMinutes = Math.abs(commitTime - fpTime) / (60 * 1e3);
|
|
13985
|
+
if (diffMinutes <= 15) {
|
|
13986
|
+
score += 0.25;
|
|
13987
|
+
} else if (diffMinutes <= 60) {
|
|
13988
|
+
score += 0.2;
|
|
13989
|
+
} else if (diffMinutes <= 180) {
|
|
13990
|
+
score += 0.15;
|
|
13991
|
+
} else if (diffMinutes <= 720) {
|
|
13992
|
+
score += 0.08;
|
|
13993
|
+
} else if (diffMinutes <= 1440) {
|
|
13994
|
+
score += 0.03;
|
|
13995
|
+
} else {
|
|
13996
|
+
score -= 0.1;
|
|
13997
|
+
}
|
|
13998
|
+
}
|
|
13999
|
+
} catch {
|
|
14000
|
+
}
|
|
14001
|
+
}
|
|
14002
|
+
switch (fp.mode) {
|
|
14003
|
+
case "verified":
|
|
14004
|
+
score += 0.1;
|
|
14005
|
+
break;
|
|
14006
|
+
case "observed":
|
|
14007
|
+
score += 0.08;
|
|
14008
|
+
break;
|
|
14009
|
+
case "imported":
|
|
14010
|
+
score += 0.05;
|
|
14011
|
+
break;
|
|
14012
|
+
case "estimated":
|
|
14013
|
+
score += 0.02;
|
|
14014
|
+
break;
|
|
14015
|
+
default:
|
|
14016
|
+
break;
|
|
14017
|
+
}
|
|
14018
|
+
return Math.max(0, Math.round(score * 100) / 100);
|
|
14019
|
+
}
|
|
14020
|
+
function selectPrimaryFootprint(footprints, gitCtx) {
|
|
14021
|
+
if (footprints.length === 0) {
|
|
14022
|
+
return { primary: void 0, rankedFootprints: [] };
|
|
14023
|
+
}
|
|
14024
|
+
if (!gitCtx || !gitCtx.headSha && !gitCtx.commitDate && (!gitCtx.changedFiles || gitCtx.changedFiles.length === 0)) {
|
|
14025
|
+
const sorted2 = [...footprints].sort((a, b2) => new Date(b2.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
14026
|
+
return { primary: sorted2[0], rankedFootprints: sorted2 };
|
|
14027
|
+
}
|
|
14028
|
+
const scored = footprints.map((fp) => {
|
|
14029
|
+
const score = scoreFootprint(fp, gitCtx);
|
|
14030
|
+
return {
|
|
14031
|
+
...fp,
|
|
14032
|
+
attributionScore: score
|
|
14033
|
+
};
|
|
14034
|
+
});
|
|
14035
|
+
scored.sort((a, b2) => {
|
|
14036
|
+
const scoreDiff = (b2.attributionScore || 0) - (a.attributionScore || 0);
|
|
14037
|
+
if (Math.abs(scoreDiff) > 1e-3) {
|
|
14038
|
+
return scoreDiff;
|
|
14039
|
+
}
|
|
14040
|
+
return new Date(b2.timestamp).getTime() - new Date(a.timestamp).getTime();
|
|
14041
|
+
});
|
|
14042
|
+
return {
|
|
14043
|
+
primary: scored[0],
|
|
14044
|
+
rankedFootprints: scored
|
|
14045
|
+
};
|
|
14046
|
+
}
|
|
14047
|
+
|
|
15669
14048
|
// ../core/dist/harvester/antigravity.js
|
|
15670
14049
|
var import_meta = {};
|
|
15671
14050
|
function getSqliteDatabase() {
|
|
@@ -15752,7 +14131,7 @@ function harvestAntigravityFootprints(repoPath, sinceDate) {
|
|
|
15752
14131
|
if ((tc.name === "replace_file_content" || tc.name === "write_to_file") && tc.args) {
|
|
15753
14132
|
const file = tc.args.TargetFile || tc.args.targetFile;
|
|
15754
14133
|
if (file) {
|
|
15755
|
-
filesEdited.add(
|
|
14134
|
+
filesEdited.add(normalizeFilePath(String(file), repoPath));
|
|
15756
14135
|
}
|
|
15757
14136
|
}
|
|
15758
14137
|
}
|
|
@@ -15844,7 +14223,7 @@ function harvestClaudeFootprints(repoPath, projectAlias, sinceDate) {
|
|
|
15844
14223
|
}
|
|
15845
14224
|
if (data.tool_name === "Edit" || data.tool_name === "Write") {
|
|
15846
14225
|
if (data.tool_input?.file_path) {
|
|
15847
|
-
filesEdited.add(
|
|
14226
|
+
filesEdited.add(normalizeFilePath(String(data.tool_input.file_path), repoPath));
|
|
15848
14227
|
}
|
|
15849
14228
|
}
|
|
15850
14229
|
} catch {
|
|
@@ -15904,88 +14283,236 @@ function getSqliteDatabase2() {
|
|
|
15904
14283
|
}
|
|
15905
14284
|
function harvestCursorFootprints(repoPath, sinceDate) {
|
|
15906
14285
|
const footprints = [];
|
|
15907
|
-
const
|
|
15908
|
-
|
|
15909
|
-
return footprints;
|
|
15910
|
-
let storageDir = "";
|
|
15911
|
-
if (process.platform === "win32") {
|
|
15912
|
-
storageDir = path5.join(process.env.APPDATA || path5.join(os4.homedir(), "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
|
|
15913
|
-
} else if (process.platform === "darwin") {
|
|
15914
|
-
storageDir = path5.join(os4.homedir(), "Library", "Application Support", "Cursor", "User", "workspaceStorage");
|
|
15915
|
-
} else {
|
|
15916
|
-
storageDir = path5.join(os4.homedir(), ".config", "Cursor", "User", "workspaceStorage");
|
|
15917
|
-
}
|
|
15918
|
-
if (!fs4.existsSync(storageDir))
|
|
15919
|
-
return footprints;
|
|
14286
|
+
const normTarget = repoPath.toLowerCase().replace(/\\/g, "/").replace(/\/$/, "");
|
|
14287
|
+
const targetBasename = path5.basename(repoPath).toLowerCase();
|
|
15920
14288
|
try {
|
|
15921
|
-
const
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
const
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
|
|
15936
|
-
|
|
15937
|
-
|
|
15938
|
-
|
|
15939
|
-
|
|
15940
|
-
|
|
15941
|
-
|
|
15942
|
-
|
|
15943
|
-
|
|
15944
|
-
|
|
15945
|
-
|
|
15946
|
-
|
|
15947
|
-
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
14289
|
+
const cursorProjectsDir = path5.join(os4.homedir(), ".cursor", "projects");
|
|
14290
|
+
if (fs4.existsSync(cursorProjectsDir)) {
|
|
14291
|
+
const projectDirs = fs4.readdirSync(cursorProjectsDir);
|
|
14292
|
+
for (const pDir of projectDirs) {
|
|
14293
|
+
const cleanPDir = pDir.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
14294
|
+
const cleanTarget = normTarget.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
14295
|
+
const cleanBase = targetBasename.replace(/[^a-z0-9]/g, "");
|
|
14296
|
+
if (cleanPDir.includes(cleanTarget) || cleanTarget.includes(cleanPDir) || cleanPDir.endsWith(cleanBase)) {
|
|
14297
|
+
const transcriptsDir = path5.join(cursorProjectsDir, pDir, "agent-transcripts");
|
|
14298
|
+
if (!fs4.existsSync(transcriptsDir))
|
|
14299
|
+
continue;
|
|
14300
|
+
const sessionDirs = fs4.readdirSync(transcriptsDir);
|
|
14301
|
+
for (const sDir of sessionDirs) {
|
|
14302
|
+
const sPath = path5.join(transcriptsDir, sDir);
|
|
14303
|
+
if (!fs4.statSync(sPath).isDirectory())
|
|
14304
|
+
continue;
|
|
14305
|
+
const jsonlFile = path5.join(sPath, `${sDir}.jsonl`);
|
|
14306
|
+
if (!fs4.existsSync(jsonlFile))
|
|
14307
|
+
continue;
|
|
14308
|
+
const stat = fs4.statSync(jsonlFile);
|
|
14309
|
+
if (sinceDate && stat.mtime < sinceDate)
|
|
14310
|
+
continue;
|
|
14311
|
+
try {
|
|
14312
|
+
const content = fs4.readFileSync(jsonlFile, "utf-8");
|
|
14313
|
+
const lines = content.split("\n");
|
|
14314
|
+
let stepCount = 0;
|
|
14315
|
+
let taskTitle = "";
|
|
14316
|
+
let model = "claude-3-5-sonnet";
|
|
14317
|
+
const filesEditedSet = /* @__PURE__ */ new Set();
|
|
14318
|
+
for (const line of lines) {
|
|
14319
|
+
if (!line.trim())
|
|
14320
|
+
continue;
|
|
14321
|
+
try {
|
|
14322
|
+
const entry = JSON.parse(line);
|
|
14323
|
+
if (!taskTitle && entry.role === "user" && entry.message?.content) {
|
|
14324
|
+
for (const c3 of entry.message.content) {
|
|
14325
|
+
if (c3.type === "text" && c3.text) {
|
|
14326
|
+
const m = c3.text.match(/<user_query>\s*([\s\S]*?)\s*<\/user_query>/);
|
|
14327
|
+
if (m && m[1]) {
|
|
14328
|
+
taskTitle = m[1].replace(/\n/g, " ").trim().slice(0, 60);
|
|
14329
|
+
} else if (!c3.text.startsWith("<timestamp>")) {
|
|
14330
|
+
taskTitle = c3.text.replace(/\n/g, " ").trim().slice(0, 60);
|
|
14331
|
+
}
|
|
14332
|
+
}
|
|
14333
|
+
}
|
|
14334
|
+
}
|
|
14335
|
+
if (entry.role === "assistant" && entry.message?.content) {
|
|
14336
|
+
for (const c3 of entry.message.content) {
|
|
14337
|
+
if (c3.type === "tool_use") {
|
|
14338
|
+
stepCount++;
|
|
14339
|
+
const name = (c3.name || "").toLowerCase();
|
|
14340
|
+
const inp = c3.input || {};
|
|
14341
|
+
if (name.includes("replace") || name.includes("edit") || name.includes("write") || name.includes("diff") || name.includes("apply")) {
|
|
14342
|
+
const target = inp.path || inp.file_path || inp.target_file || inp.file;
|
|
14343
|
+
if (target && typeof target === "string") {
|
|
14344
|
+
filesEditedSet.add(normalizeFilePath(target, repoPath));
|
|
14345
|
+
}
|
|
14346
|
+
}
|
|
14347
|
+
}
|
|
14348
|
+
}
|
|
14349
|
+
}
|
|
14350
|
+
} catch {
|
|
14351
|
+
}
|
|
14352
|
+
}
|
|
14353
|
+
if (stepCount > 0) {
|
|
14354
|
+
const rateCard = getRateCard(model);
|
|
14355
|
+
const estInput = stepCount * 3e3;
|
|
14356
|
+
const estCached = Math.round(estInput * 0.6);
|
|
14357
|
+
const estOutput = stepCount * 450;
|
|
14358
|
+
const cost = computeCost(estInput, estOutput, estCached, rateCard);
|
|
14359
|
+
footprints.push({
|
|
14360
|
+
id: `cursor_transcript_${sDir}`,
|
|
14361
|
+
platform: "cursor",
|
|
14362
|
+
sessionId: sDir,
|
|
14363
|
+
repoPath,
|
|
14364
|
+
taskTitle: taskTitle || "Cursor Agent Session",
|
|
14365
|
+
model,
|
|
14366
|
+
stepsCount: stepCount,
|
|
14367
|
+
filesEdited: Array.from(filesEditedSet),
|
|
14368
|
+
timestamp: stat.mtime.toISOString(),
|
|
14369
|
+
tokens: {
|
|
14370
|
+
input: estInput,
|
|
14371
|
+
output: estOutput,
|
|
14372
|
+
cached: estCached
|
|
14373
|
+
},
|
|
14374
|
+
cost,
|
|
14375
|
+
mode: "imported",
|
|
14376
|
+
confidence: 0.85,
|
|
14377
|
+
rawTranscriptPath: jsonlFile
|
|
14378
|
+
});
|
|
14379
|
+
}
|
|
14380
|
+
} catch {
|
|
15955
14381
|
}
|
|
15956
14382
|
}
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
15981
|
-
|
|
15982
|
-
|
|
14383
|
+
}
|
|
14384
|
+
}
|
|
14385
|
+
}
|
|
14386
|
+
} catch {
|
|
14387
|
+
}
|
|
14388
|
+
const DatabaseSync2 = getSqliteDatabase2();
|
|
14389
|
+
if (DatabaseSync2) {
|
|
14390
|
+
let storageDir = "";
|
|
14391
|
+
if (process.platform === "win32") {
|
|
14392
|
+
storageDir = path5.join(process.env.APPDATA || path5.join(os4.homedir(), "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
|
|
14393
|
+
} else if (process.platform === "darwin") {
|
|
14394
|
+
storageDir = path5.join(os4.homedir(), "Library", "Application Support", "Cursor", "User", "workspaceStorage");
|
|
14395
|
+
} else {
|
|
14396
|
+
storageDir = path5.join(os4.homedir(), ".config", "Cursor", "User", "workspaceStorage");
|
|
14397
|
+
}
|
|
14398
|
+
if (fs4.existsSync(storageDir)) {
|
|
14399
|
+
try {
|
|
14400
|
+
const wsDirs = fs4.readdirSync(storageDir);
|
|
14401
|
+
for (const ws of wsDirs) {
|
|
14402
|
+
const wsPath = path5.join(storageDir, ws);
|
|
14403
|
+
const wsJsonPath = path5.join(wsPath, "workspace.json");
|
|
14404
|
+
if (!fs4.existsSync(wsJsonPath))
|
|
14405
|
+
continue;
|
|
14406
|
+
try {
|
|
14407
|
+
const wsJson = JSON.parse(fs4.readFileSync(wsJsonPath, "utf-8"));
|
|
14408
|
+
let folderUri = wsJson.folder || wsJson.workspace || "";
|
|
14409
|
+
try {
|
|
14410
|
+
folderUri = decodeURIComponent(folderUri.replace(/^file:\/\/\/?/, ""));
|
|
14411
|
+
} catch {
|
|
14412
|
+
}
|
|
14413
|
+
const folder = folderUri.toLowerCase().replace(/\\/g, "/");
|
|
14414
|
+
if (!folder.includes(normTarget) && !normTarget.includes(folder) && !folder.endsWith(targetBasename)) {
|
|
14415
|
+
continue;
|
|
14416
|
+
}
|
|
14417
|
+
const dbFile = path5.join(wsPath, "state.vscdb");
|
|
14418
|
+
if (!fs4.existsSync(dbFile))
|
|
14419
|
+
continue;
|
|
14420
|
+
const dbStat = fs4.statSync(dbFile);
|
|
14421
|
+
if (sinceDate && dbStat.mtime < sinceDate)
|
|
14422
|
+
continue;
|
|
14423
|
+
const db = new DatabaseSync2(dbFile, { readOnly: true });
|
|
14424
|
+
try {
|
|
14425
|
+
const rowRecent = db.prepare("SELECT value FROM ItemTable WHERE key = 'aiCodeTracking.recentCommit' LIMIT 1").get();
|
|
14426
|
+
if (rowRecent && rowRecent.value) {
|
|
14427
|
+
const recent = JSON.parse(rowRecent.value);
|
|
14428
|
+
if (recent && recent.commitHash) {
|
|
14429
|
+
const added = Number(recent.linesAdded || recent.composerLinesAdded || 0);
|
|
14430
|
+
const deleted = Number(recent.linesDeleted || recent.composerLinesDeleted || 0);
|
|
14431
|
+
const estOut = Math.max(Math.round((added + deleted) * 35 / 4), 100);
|
|
14432
|
+
const estIn = estOut * 20;
|
|
14433
|
+
const estCached = Math.round(estIn * 0.6);
|
|
14434
|
+
const rateCard = getRateCard("claude-3-7-sonnet");
|
|
14435
|
+
const cost = computeCost(estIn, estOut, estCached, rateCard);
|
|
14436
|
+
const commitDate = recent.commitDate ? new Date(recent.commitDate).toISOString() : recent.timestamp ? new Date(recent.timestamp).toISOString() : dbStat.mtime.toISOString();
|
|
14437
|
+
footprints.push({
|
|
14438
|
+
id: `cursor_commit_${recent.commitHash.slice(0, 12)}`,
|
|
14439
|
+
platform: "cursor",
|
|
14440
|
+
sessionId: ws,
|
|
14441
|
+
repoPath,
|
|
14442
|
+
taskTitle: recent.commitMessage || "Cursor AI Commit",
|
|
14443
|
+
model: "claude-3-7-sonnet",
|
|
14444
|
+
stepsCount: Math.max(Math.round((added + deleted) / 10), 1),
|
|
14445
|
+
filesEdited: [],
|
|
14446
|
+
timestamp: commitDate,
|
|
14447
|
+
boundCommitSha: recent.commitHash,
|
|
14448
|
+
tokens: {
|
|
14449
|
+
input: estIn,
|
|
14450
|
+
output: estOut,
|
|
14451
|
+
cached: estCached
|
|
14452
|
+
},
|
|
14453
|
+
cost,
|
|
14454
|
+
mode: "verified",
|
|
14455
|
+
confidence: 0.95,
|
|
14456
|
+
rawTranscriptPath: dbFile
|
|
14457
|
+
});
|
|
14458
|
+
}
|
|
14459
|
+
}
|
|
14460
|
+
} catch {
|
|
14461
|
+
}
|
|
14462
|
+
const rowLegacy = db.prepare("SELECT value FROM ItemTable WHERE key = 'workbench.panel.aichat.chatdata' OR key = 'aiService.generations' LIMIT 1").get();
|
|
14463
|
+
if (rowLegacy && rowLegacy.value) {
|
|
14464
|
+
try {
|
|
14465
|
+
const parsed = JSON.parse(rowLegacy.value);
|
|
14466
|
+
const tabs = parsed.tabs || (Array.isArray(parsed) ? parsed : []);
|
|
14467
|
+
let stepCount = 0;
|
|
14468
|
+
let taskTitle = "";
|
|
14469
|
+
let model = "claude-3-5-sonnet";
|
|
14470
|
+
for (const tab of tabs) {
|
|
14471
|
+
const bubbles = tab.bubbles || [];
|
|
14472
|
+
stepCount += bubbles.length;
|
|
14473
|
+
if (!taskTitle && tab.chatTitle)
|
|
14474
|
+
taskTitle = tab.chatTitle;
|
|
14475
|
+
for (const b2 of bubbles) {
|
|
14476
|
+
if (b2.modelType)
|
|
14477
|
+
model = b2.modelType;
|
|
14478
|
+
}
|
|
14479
|
+
}
|
|
14480
|
+
if (stepCount > 0) {
|
|
14481
|
+
const rateCard = getRateCard(model);
|
|
14482
|
+
const estInput = stepCount * 2500;
|
|
14483
|
+
const estCached = Math.round(estInput * 0.6);
|
|
14484
|
+
const estOutput = stepCount * 250;
|
|
14485
|
+
const cost = computeCost(estInput, estOutput, estCached, rateCard);
|
|
14486
|
+
footprints.push({
|
|
14487
|
+
id: `cursor_chat_${ws}`,
|
|
14488
|
+
platform: "cursor",
|
|
14489
|
+
sessionId: ws,
|
|
14490
|
+
repoPath,
|
|
14491
|
+
taskTitle: taskTitle || "Cursor Chat Session",
|
|
14492
|
+
model,
|
|
14493
|
+
stepsCount: stepCount,
|
|
14494
|
+
filesEdited: [],
|
|
14495
|
+
timestamp: dbStat.mtime.toISOString(),
|
|
14496
|
+
tokens: {
|
|
14497
|
+
input: estInput,
|
|
14498
|
+
output: estOutput,
|
|
14499
|
+
cached: estCached
|
|
14500
|
+
},
|
|
14501
|
+
cost,
|
|
14502
|
+
mode: "imported",
|
|
14503
|
+
confidence: 0.8,
|
|
14504
|
+
rawTranscriptPath: dbFile
|
|
14505
|
+
});
|
|
14506
|
+
}
|
|
14507
|
+
} catch {
|
|
14508
|
+
}
|
|
14509
|
+
}
|
|
14510
|
+
} catch {
|
|
15983
14511
|
}
|
|
15984
14512
|
}
|
|
15985
14513
|
} catch {
|
|
15986
14514
|
}
|
|
15987
14515
|
}
|
|
15988
|
-
} catch {
|
|
15989
14516
|
}
|
|
15990
14517
|
return footprints;
|
|
15991
14518
|
}
|
|
@@ -16190,7 +14717,8 @@ async function harvestUniversalFootprints(options) {
|
|
|
16190
14717
|
const cursorFootprints = harvestCursorFootprints(options.repoPath, sinceDate);
|
|
16191
14718
|
allFootprints.push(...cursorFootprints);
|
|
16192
14719
|
}
|
|
16193
|
-
|
|
14720
|
+
const { primary, rankedFootprints } = selectPrimaryFootprint(allFootprints, options.gitContext);
|
|
14721
|
+
allFootprints = rankedFootprints;
|
|
16194
14722
|
try {
|
|
16195
14723
|
const db = new LocalStateDB();
|
|
16196
14724
|
for (const fp of allFootprints) {
|
|
@@ -16217,7 +14745,6 @@ async function harvestUniversalFootprints(options) {
|
|
|
16217
14745
|
totalCached += fp.tokens.cached;
|
|
16218
14746
|
totalCost += fp.cost;
|
|
16219
14747
|
}
|
|
16220
|
-
const primary = allFootprints[0];
|
|
16221
14748
|
return {
|
|
16222
14749
|
footprints: allFootprints,
|
|
16223
14750
|
primaryFootprint: primary,
|
|
@@ -16251,16 +14778,16 @@ function estimateCost(options) {
|
|
|
16251
14778
|
totalCost += s.cost;
|
|
16252
14779
|
}
|
|
16253
14780
|
return {
|
|
16254
|
-
provider: primary.provider,
|
|
16255
|
-
model: primary.model || "claude-3-7-sonnet",
|
|
14781
|
+
provider: options.provider || primary.provider,
|
|
14782
|
+
model: options.model || primary.model || "claude-3-7-sonnet",
|
|
16256
14783
|
tokens: {
|
|
16257
14784
|
input: totalInput,
|
|
16258
14785
|
output: totalOutput,
|
|
16259
14786
|
cached: totalCached
|
|
16260
14787
|
},
|
|
16261
14788
|
cost: Number(totalCost.toFixed(4)),
|
|
16262
|
-
mode: primary.mode,
|
|
16263
|
-
confidence: primary.confidence,
|
|
14789
|
+
mode: options.mode || primary.mode,
|
|
14790
|
+
confidence: options.confidence !== void 0 ? options.confidence : primary.confidence,
|
|
16264
14791
|
sessions: options.sessions
|
|
16265
14792
|
};
|
|
16266
14793
|
}
|
|
@@ -16380,7 +14907,13 @@ async function generateReceipt(options = {}) {
|
|
|
16380
14907
|
repoPath,
|
|
16381
14908
|
projectAlias: metrics.projectAlias,
|
|
16382
14909
|
since: options.since,
|
|
16383
|
-
platform: options.platform
|
|
14910
|
+
platform: options.platform,
|
|
14911
|
+
gitContext: {
|
|
14912
|
+
headSha: metrics.headSha,
|
|
14913
|
+
commitDate: metrics.commitDate,
|
|
14914
|
+
changedFiles: metrics.changedFiles,
|
|
14915
|
+
branch: metrics.branch
|
|
14916
|
+
}
|
|
16384
14917
|
});
|
|
16385
14918
|
const primaryFp = harvestResult.primaryFootprint;
|
|
16386
14919
|
const detected = detectProviderFromCommit(metrics.commitMessage);
|
|
@@ -16558,7 +15091,7 @@ function uninstallHookFile(hookFile) {
|
|
|
16558
15091
|
return "removed";
|
|
16559
15092
|
}
|
|
16560
15093
|
var program2 = new Command();
|
|
16561
|
-
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 1D barcode
|
|
15094
|
+
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) => {
|
|
16562
15095
|
try {
|
|
16563
15096
|
const receipt = await generateReceipt({
|
|
16564
15097
|
provider: options.provider,
|
|
@@ -16576,7 +15109,7 @@ program2.name("qodewk").description("Universal telemetry and digital receipt gen
|
|
|
16576
15109
|
process.exit(1);
|
|
16577
15110
|
}
|
|
16578
15111
|
});
|
|
16579
|
-
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 1D barcode
|
|
15112
|
+
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) => {
|
|
16580
15113
|
try {
|
|
16581
15114
|
const receipt = await generateReceipt({
|
|
16582
15115
|
baseSha: options.base,
|
|
@@ -16596,7 +15129,7 @@ program2.command("audit").description("Audit PR or branch diff against a target
|
|
|
16596
15129
|
process.exit(1);
|
|
16597
15130
|
}
|
|
16598
15131
|
});
|
|
16599
|
-
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 1D barcode
|
|
15132
|
+
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) => {
|
|
16600
15133
|
try {
|
|
16601
15134
|
const receipt = await generateReceipt({
|
|
16602
15135
|
provider: options.provider,
|
|
@@ -16616,7 +15149,7 @@ Cloud publishing is disabled (${localFlag ? "--local" : "QODEWK_TELEMETRY=off"})
|
|
|
16616
15149
|
);
|
|
16617
15150
|
console.log(import_picocolors.default.dim("Telemetry remains strictly stored in local SQLite (~/.qodewk/state.db).\n"));
|
|
16618
15151
|
persistReceipt(receipt);
|
|
16619
|
-
await renderTerminalReceipt(receipt
|
|
15152
|
+
await renderTerminalReceipt(receipt);
|
|
16620
15153
|
return;
|
|
16621
15154
|
}
|
|
16622
15155
|
const sanitized = sanitizeReceiptForShare(receipt);
|
|
@@ -16656,7 +15189,7 @@ Cloud publishing is disabled (${localFlag ? "--local" : "QODEWK_TELEMETRY=off"})
|
|
|
16656
15189
|
console.log(` ${import_picocolors.default.yellow(data.claimToken)}`);
|
|
16657
15190
|
console.log(import_picocolors.default.dim(" Saved to ~/.qodewk/state.db \u2014 required to prove authorship later."));
|
|
16658
15191
|
console.log("");
|
|
16659
|
-
await renderTerminalReceipt(sanitized, data.url
|
|
15192
|
+
await renderTerminalReceipt(sanitized, data.url);
|
|
16660
15193
|
if (options.json) {
|
|
16661
15194
|
console.log(JSON.stringify({ url: data.url, claimToken: data.claimToken, receipt: sanitized }, null, 2));
|
|
16662
15195
|
}
|
|
@@ -16665,7 +15198,7 @@ Cloud publishing is disabled (${localFlag ? "--local" : "QODEWK_TELEMETRY=off"})
|
|
|
16665
15198
|
console.log(import_picocolors.default.yellow(`
|
|
16666
15199
|
Could not reach cloud API (${message}). Rendered locally:`));
|
|
16667
15200
|
persistReceipt(receipt);
|
|
16668
|
-
await renderTerminalReceipt(receipt
|
|
15201
|
+
await renderTerminalReceipt(receipt);
|
|
16669
15202
|
}
|
|
16670
15203
|
} catch (err) {
|
|
16671
15204
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -16756,7 +15289,7 @@ var stripAnsi = (str) => {
|
|
|
16756
15289
|
var visibleWidth = (str) => {
|
|
16757
15290
|
return stripAnsi(str).length;
|
|
16758
15291
|
};
|
|
16759
|
-
function buildTerminalReceipt(receipt, publicUrl
|
|
15292
|
+
function buildTerminalReceipt(receipt, publicUrl) {
|
|
16760
15293
|
const lines = [];
|
|
16761
15294
|
const coral = ansiHex("#cc785c");
|
|
16762
15295
|
const green = ansiHex("#5db872");
|
|
@@ -16823,6 +15356,12 @@ function buildTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16823
15356
|
const provString = receipt.ai.provider + " \xB7 " + (receipt.ai.model || "Unknown");
|
|
16824
15357
|
const cleanProv = provString.length > 40 ? provString.slice(0, 39) + "\u2026" : provString;
|
|
16825
15358
|
printRow(`Provider: ${cleanProv}`);
|
|
15359
|
+
if (receipt.ai.sessions && receipt.ai.sessions.length > 1) {
|
|
15360
|
+
const others = receipt.ai.sessions.slice(1).map((s) => s.provider).filter((p2, i2, arr) => arr.indexOf(p2) === i2 && p2 !== receipt.ai.provider);
|
|
15361
|
+
if (others.length > 0) {
|
|
15362
|
+
printRow(import_picocolors.default.dim(`Also seen: ${others.join(", ")}`));
|
|
15363
|
+
}
|
|
15364
|
+
}
|
|
16826
15365
|
if (receipt.ai.aiWrittenRatio !== void 0) {
|
|
16827
15366
|
const aiPct = Math.round(receipt.ai.aiWrittenRatio * 100);
|
|
16828
15367
|
printRowSplit("AI Written Code", `${aiPct}% (Human: ${100 - aiPct}%)`);
|
|
@@ -16840,30 +15379,19 @@ function buildTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16840
15379
|
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || process.env.QODEWK_APP_URL || "https://qodewk.flinkeo.online";
|
|
16841
15380
|
const isPublished = Boolean(publicUrl);
|
|
16842
15381
|
const displayHost = baseUrl.replace(/^https?:\/\//, "");
|
|
16843
|
-
|
|
16844
|
-
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
printRow("");
|
|
16857
|
-
for (const qrRow of qrRows) {
|
|
16858
|
-
printCenteredRow(qrRow);
|
|
16859
|
-
}
|
|
16860
|
-
printRow("");
|
|
16861
|
-
} else {
|
|
16862
|
-
printCenteredRow(import_picocolors.default.bold("||| | ||||| ||| |||| |||||| |||| ||| ||||||| |||"));
|
|
16863
|
-
}
|
|
16864
|
-
} else {
|
|
16865
|
-
printCenteredRow(import_picocolors.default.dim("--- LOCAL PROOF (NOT PUBLISHED) ---"));
|
|
16866
|
-
printCenteredRow(import_picocolors.default.dim(`id ${receipt.receipt.id.slice(0, 28)}`));
|
|
15382
|
+
const barcodePayload = pickBarcodePayload({
|
|
15383
|
+
publicUrl,
|
|
15384
|
+
receiptId: receipt.receipt.id,
|
|
15385
|
+
displayHost,
|
|
15386
|
+
maxChars: 28
|
|
15387
|
+
});
|
|
15388
|
+
const barcodeRows = renderTerminalBarcode(barcodePayload, {
|
|
15389
|
+
maxWidth: INNER_WIDTH,
|
|
15390
|
+
height: 3,
|
|
15391
|
+
quietZone: 8
|
|
15392
|
+
});
|
|
15393
|
+
for (const barRow of barcodeRows) {
|
|
15394
|
+
printCenteredRow(import_picocolors.default.bold(barRow));
|
|
16867
15395
|
}
|
|
16868
15396
|
if (isPublished) {
|
|
16869
15397
|
printCenteredRow(import_picocolors.default.cyan(displayHost));
|
|
@@ -16884,14 +15412,11 @@ function buildTerminalReceipt(receipt, publicUrl, useBarcode) {
|
|
|
16884
15412
|
push(` ${import_picocolors.default.dim("Saved to local DB:")} ${import_picocolors.default.dim("~/.qodewk/state.db")}`);
|
|
16885
15413
|
push(` ${import_picocolors.default.dim("To publish & get shareable URL:")} ${import_picocolors.default.cyan("qodewk share")}`);
|
|
16886
15414
|
}
|
|
16887
|
-
if (!useBarcode) {
|
|
16888
|
-
push(` ${import_picocolors.default.dim("View classic 1D barcode:")} ${import_picocolors.default.cyan("qodewk --barcode")}`);
|
|
16889
|
-
}
|
|
16890
15415
|
push("");
|
|
16891
15416
|
return lines.join("\n");
|
|
16892
15417
|
}
|
|
16893
|
-
async function renderTerminalReceipt(receipt, publicUrl
|
|
16894
|
-
console.log(buildTerminalReceipt(receipt, publicUrl
|
|
15418
|
+
async function renderTerminalReceipt(receipt, publicUrl) {
|
|
15419
|
+
console.log(buildTerminalReceipt(receipt, publicUrl));
|
|
16895
15420
|
}
|
|
16896
15421
|
async function outputReceipt(receipt, options, publicUrl) {
|
|
16897
15422
|
const format = options.json ? "json" : options.format || "terminal";
|
|
@@ -16901,7 +15426,7 @@ async function outputReceipt(receipt, options, publicUrl) {
|
|
|
16901
15426
|
} else if (format === "markdown") {
|
|
16902
15427
|
content = formatMarkdownReceipt(receipt, publicUrl);
|
|
16903
15428
|
} else {
|
|
16904
|
-
content = buildTerminalReceipt(receipt, publicUrl
|
|
15429
|
+
content = buildTerminalReceipt(receipt, publicUrl);
|
|
16905
15430
|
}
|
|
16906
15431
|
if (options.out) {
|
|
16907
15432
|
const fileContent = format === "terminal" ? stripAnsi(content) : content;
|