tesseract-agent 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-bundle/cli.js +1142 -39
- package/package.json +4 -2
package/dist-bundle/cli.js
CHANGED
|
@@ -4769,6 +4769,1076 @@ var init_dist = __esm({
|
|
|
4769
4769
|
}
|
|
4770
4770
|
});
|
|
4771
4771
|
|
|
4772
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
|
|
4773
|
+
var require_QRMode = __commonJS({
|
|
4774
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRMode.js"(exports, module) {
|
|
4775
|
+
module.exports = {
|
|
4776
|
+
MODE_NUMBER: 1 << 0,
|
|
4777
|
+
MODE_ALPHA_NUM: 1 << 1,
|
|
4778
|
+
MODE_8BIT_BYTE: 1 << 2,
|
|
4779
|
+
MODE_KANJI: 1 << 3
|
|
4780
|
+
};
|
|
4781
|
+
}
|
|
4782
|
+
});
|
|
4783
|
+
|
|
4784
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js
|
|
4785
|
+
var require_QR8bitByte = __commonJS({
|
|
4786
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js"(exports, module) {
|
|
4787
|
+
var QRMode = require_QRMode();
|
|
4788
|
+
function QR8bitByte(data) {
|
|
4789
|
+
this.mode = QRMode.MODE_8BIT_BYTE;
|
|
4790
|
+
this.data = data;
|
|
4791
|
+
}
|
|
4792
|
+
QR8bitByte.prototype = {
|
|
4793
|
+
getLength: function() {
|
|
4794
|
+
return this.data.length;
|
|
4795
|
+
},
|
|
4796
|
+
write: function(buffer) {
|
|
4797
|
+
for (var i = 0; i < this.data.length; i++) {
|
|
4798
|
+
buffer.put(this.data.charCodeAt(i), 8);
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
};
|
|
4802
|
+
module.exports = QR8bitByte;
|
|
4803
|
+
}
|
|
4804
|
+
});
|
|
4805
|
+
|
|
4806
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRMath.js
|
|
4807
|
+
var require_QRMath = __commonJS({
|
|
4808
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRMath.js"(exports, module) {
|
|
4809
|
+
var QRMath = {
|
|
4810
|
+
glog: function(n) {
|
|
4811
|
+
if (n < 1) {
|
|
4812
|
+
throw new Error("glog(" + n + ")");
|
|
4813
|
+
}
|
|
4814
|
+
return QRMath.LOG_TABLE[n];
|
|
4815
|
+
},
|
|
4816
|
+
gexp: function(n) {
|
|
4817
|
+
while (n < 0) {
|
|
4818
|
+
n += 255;
|
|
4819
|
+
}
|
|
4820
|
+
while (n >= 256) {
|
|
4821
|
+
n -= 255;
|
|
4822
|
+
}
|
|
4823
|
+
return QRMath.EXP_TABLE[n];
|
|
4824
|
+
},
|
|
4825
|
+
EXP_TABLE: new Array(256),
|
|
4826
|
+
LOG_TABLE: new Array(256)
|
|
4827
|
+
};
|
|
4828
|
+
for (i = 0; i < 8; i++) {
|
|
4829
|
+
QRMath.EXP_TABLE[i] = 1 << i;
|
|
4830
|
+
}
|
|
4831
|
+
var i;
|
|
4832
|
+
for (i = 8; i < 256; i++) {
|
|
4833
|
+
QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
|
|
4834
|
+
}
|
|
4835
|
+
var i;
|
|
4836
|
+
for (i = 0; i < 255; i++) {
|
|
4837
|
+
QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
|
|
4838
|
+
}
|
|
4839
|
+
var i;
|
|
4840
|
+
module.exports = QRMath;
|
|
4841
|
+
}
|
|
4842
|
+
});
|
|
4843
|
+
|
|
4844
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js
|
|
4845
|
+
var require_QRPolynomial = __commonJS({
|
|
4846
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js"(exports, module) {
|
|
4847
|
+
var QRMath = require_QRMath();
|
|
4848
|
+
function QRPolynomial(num, shift) {
|
|
4849
|
+
if (num.length === void 0) {
|
|
4850
|
+
throw new Error(num.length + "/" + shift);
|
|
4851
|
+
}
|
|
4852
|
+
var offset = 0;
|
|
4853
|
+
while (offset < num.length && num[offset] === 0) {
|
|
4854
|
+
offset++;
|
|
4855
|
+
}
|
|
4856
|
+
this.num = new Array(num.length - offset + shift);
|
|
4857
|
+
for (var i = 0; i < num.length - offset; i++) {
|
|
4858
|
+
this.num[i] = num[i + offset];
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
QRPolynomial.prototype = {
|
|
4862
|
+
get: function(index) {
|
|
4863
|
+
return this.num[index];
|
|
4864
|
+
},
|
|
4865
|
+
getLength: function() {
|
|
4866
|
+
return this.num.length;
|
|
4867
|
+
},
|
|
4868
|
+
multiply: function(e) {
|
|
4869
|
+
var num = new Array(this.getLength() + e.getLength() - 1);
|
|
4870
|
+
for (var i = 0; i < this.getLength(); i++) {
|
|
4871
|
+
for (var j = 0; j < e.getLength(); j++) {
|
|
4872
|
+
num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
return new QRPolynomial(num, 0);
|
|
4876
|
+
},
|
|
4877
|
+
mod: function(e) {
|
|
4878
|
+
if (this.getLength() - e.getLength() < 0) {
|
|
4879
|
+
return this;
|
|
4880
|
+
}
|
|
4881
|
+
var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0));
|
|
4882
|
+
var num = new Array(this.getLength());
|
|
4883
|
+
for (var i = 0; i < this.getLength(); i++) {
|
|
4884
|
+
num[i] = this.get(i);
|
|
4885
|
+
}
|
|
4886
|
+
for (var x = 0; x < e.getLength(); x++) {
|
|
4887
|
+
num[x] ^= QRMath.gexp(QRMath.glog(e.get(x)) + ratio);
|
|
4888
|
+
}
|
|
4889
|
+
return new QRPolynomial(num, 0).mod(e);
|
|
4890
|
+
}
|
|
4891
|
+
};
|
|
4892
|
+
module.exports = QRPolynomial;
|
|
4893
|
+
}
|
|
4894
|
+
});
|
|
4895
|
+
|
|
4896
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js
|
|
4897
|
+
var require_QRMaskPattern = __commonJS({
|
|
4898
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js"(exports, module) {
|
|
4899
|
+
module.exports = {
|
|
4900
|
+
PATTERN000: 0,
|
|
4901
|
+
PATTERN001: 1,
|
|
4902
|
+
PATTERN010: 2,
|
|
4903
|
+
PATTERN011: 3,
|
|
4904
|
+
PATTERN100: 4,
|
|
4905
|
+
PATTERN101: 5,
|
|
4906
|
+
PATTERN110: 6,
|
|
4907
|
+
PATTERN111: 7
|
|
4908
|
+
};
|
|
4909
|
+
}
|
|
4910
|
+
});
|
|
4911
|
+
|
|
4912
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js
|
|
4913
|
+
var require_QRUtil = __commonJS({
|
|
4914
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js"(exports, module) {
|
|
4915
|
+
var QRMode = require_QRMode();
|
|
4916
|
+
var QRPolynomial = require_QRPolynomial();
|
|
4917
|
+
var QRMath = require_QRMath();
|
|
4918
|
+
var QRMaskPattern = require_QRMaskPattern();
|
|
4919
|
+
var QRUtil = {
|
|
4920
|
+
PATTERN_POSITION_TABLE: [
|
|
4921
|
+
[],
|
|
4922
|
+
[6, 18],
|
|
4923
|
+
[6, 22],
|
|
4924
|
+
[6, 26],
|
|
4925
|
+
[6, 30],
|
|
4926
|
+
[6, 34],
|
|
4927
|
+
[6, 22, 38],
|
|
4928
|
+
[6, 24, 42],
|
|
4929
|
+
[6, 26, 46],
|
|
4930
|
+
[6, 28, 50],
|
|
4931
|
+
[6, 30, 54],
|
|
4932
|
+
[6, 32, 58],
|
|
4933
|
+
[6, 34, 62],
|
|
4934
|
+
[6, 26, 46, 66],
|
|
4935
|
+
[6, 26, 48, 70],
|
|
4936
|
+
[6, 26, 50, 74],
|
|
4937
|
+
[6, 30, 54, 78],
|
|
4938
|
+
[6, 30, 56, 82],
|
|
4939
|
+
[6, 30, 58, 86],
|
|
4940
|
+
[6, 34, 62, 90],
|
|
4941
|
+
[6, 28, 50, 72, 94],
|
|
4942
|
+
[6, 26, 50, 74, 98],
|
|
4943
|
+
[6, 30, 54, 78, 102],
|
|
4944
|
+
[6, 28, 54, 80, 106],
|
|
4945
|
+
[6, 32, 58, 84, 110],
|
|
4946
|
+
[6, 30, 58, 86, 114],
|
|
4947
|
+
[6, 34, 62, 90, 118],
|
|
4948
|
+
[6, 26, 50, 74, 98, 122],
|
|
4949
|
+
[6, 30, 54, 78, 102, 126],
|
|
4950
|
+
[6, 26, 52, 78, 104, 130],
|
|
4951
|
+
[6, 30, 56, 82, 108, 134],
|
|
4952
|
+
[6, 34, 60, 86, 112, 138],
|
|
4953
|
+
[6, 30, 58, 86, 114, 142],
|
|
4954
|
+
[6, 34, 62, 90, 118, 146],
|
|
4955
|
+
[6, 30, 54, 78, 102, 126, 150],
|
|
4956
|
+
[6, 24, 50, 76, 102, 128, 154],
|
|
4957
|
+
[6, 28, 54, 80, 106, 132, 158],
|
|
4958
|
+
[6, 32, 58, 84, 110, 136, 162],
|
|
4959
|
+
[6, 26, 54, 82, 110, 138, 166],
|
|
4960
|
+
[6, 30, 58, 86, 114, 142, 170]
|
|
4961
|
+
],
|
|
4962
|
+
G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,
|
|
4963
|
+
G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
|
|
4964
|
+
G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
|
|
4965
|
+
getBCHTypeInfo: function(data) {
|
|
4966
|
+
var d = data << 10;
|
|
4967
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
|
|
4968
|
+
d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
|
|
4969
|
+
}
|
|
4970
|
+
return (data << 10 | d) ^ QRUtil.G15_MASK;
|
|
4971
|
+
},
|
|
4972
|
+
getBCHTypeNumber: function(data) {
|
|
4973
|
+
var d = data << 12;
|
|
4974
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
|
|
4975
|
+
d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
|
|
4976
|
+
}
|
|
4977
|
+
return data << 12 | d;
|
|
4978
|
+
},
|
|
4979
|
+
getBCHDigit: function(data) {
|
|
4980
|
+
var digit = 0;
|
|
4981
|
+
while (data !== 0) {
|
|
4982
|
+
digit++;
|
|
4983
|
+
data >>>= 1;
|
|
4984
|
+
}
|
|
4985
|
+
return digit;
|
|
4986
|
+
},
|
|
4987
|
+
getPatternPosition: function(typeNumber) {
|
|
4988
|
+
return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
4989
|
+
},
|
|
4990
|
+
getMask: function(maskPattern, i, j) {
|
|
4991
|
+
switch (maskPattern) {
|
|
4992
|
+
case QRMaskPattern.PATTERN000:
|
|
4993
|
+
return (i + j) % 2 === 0;
|
|
4994
|
+
case QRMaskPattern.PATTERN001:
|
|
4995
|
+
return i % 2 === 0;
|
|
4996
|
+
case QRMaskPattern.PATTERN010:
|
|
4997
|
+
return j % 3 === 0;
|
|
4998
|
+
case QRMaskPattern.PATTERN011:
|
|
4999
|
+
return (i + j) % 3 === 0;
|
|
5000
|
+
case QRMaskPattern.PATTERN100:
|
|
5001
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
5002
|
+
case QRMaskPattern.PATTERN101:
|
|
5003
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
5004
|
+
case QRMaskPattern.PATTERN110:
|
|
5005
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
5006
|
+
case QRMaskPattern.PATTERN111:
|
|
5007
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
5008
|
+
default:
|
|
5009
|
+
throw new Error("bad maskPattern:" + maskPattern);
|
|
5010
|
+
}
|
|
5011
|
+
},
|
|
5012
|
+
getErrorCorrectPolynomial: function(errorCorrectLength) {
|
|
5013
|
+
var a = new QRPolynomial([1], 0);
|
|
5014
|
+
for (var i = 0; i < errorCorrectLength; i++) {
|
|
5015
|
+
a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
|
|
5016
|
+
}
|
|
5017
|
+
return a;
|
|
5018
|
+
},
|
|
5019
|
+
getLengthInBits: function(mode, type) {
|
|
5020
|
+
if (1 <= type && type < 10) {
|
|
5021
|
+
switch (mode) {
|
|
5022
|
+
case QRMode.MODE_NUMBER:
|
|
5023
|
+
return 10;
|
|
5024
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
5025
|
+
return 9;
|
|
5026
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
5027
|
+
return 8;
|
|
5028
|
+
case QRMode.MODE_KANJI:
|
|
5029
|
+
return 8;
|
|
5030
|
+
default:
|
|
5031
|
+
throw new Error("mode:" + mode);
|
|
5032
|
+
}
|
|
5033
|
+
} else if (type < 27) {
|
|
5034
|
+
switch (mode) {
|
|
5035
|
+
case QRMode.MODE_NUMBER:
|
|
5036
|
+
return 12;
|
|
5037
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
5038
|
+
return 11;
|
|
5039
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
5040
|
+
return 16;
|
|
5041
|
+
case QRMode.MODE_KANJI:
|
|
5042
|
+
return 10;
|
|
5043
|
+
default:
|
|
5044
|
+
throw new Error("mode:" + mode);
|
|
5045
|
+
}
|
|
5046
|
+
} else if (type < 41) {
|
|
5047
|
+
switch (mode) {
|
|
5048
|
+
case QRMode.MODE_NUMBER:
|
|
5049
|
+
return 14;
|
|
5050
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
5051
|
+
return 13;
|
|
5052
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
5053
|
+
return 16;
|
|
5054
|
+
case QRMode.MODE_KANJI:
|
|
5055
|
+
return 12;
|
|
5056
|
+
default:
|
|
5057
|
+
throw new Error("mode:" + mode);
|
|
5058
|
+
}
|
|
5059
|
+
} else {
|
|
5060
|
+
throw new Error("type:" + type);
|
|
5061
|
+
}
|
|
5062
|
+
},
|
|
5063
|
+
getLostPoint: function(qrCode) {
|
|
5064
|
+
var moduleCount = qrCode.getModuleCount();
|
|
5065
|
+
var lostPoint = 0;
|
|
5066
|
+
var row = 0;
|
|
5067
|
+
var col = 0;
|
|
5068
|
+
for (row = 0; row < moduleCount; row++) {
|
|
5069
|
+
for (col = 0; col < moduleCount; col++) {
|
|
5070
|
+
var sameCount = 0;
|
|
5071
|
+
var dark = qrCode.isDark(row, col);
|
|
5072
|
+
for (var r = -1; r <= 1; r++) {
|
|
5073
|
+
if (row + r < 0 || moduleCount <= row + r) {
|
|
5074
|
+
continue;
|
|
5075
|
+
}
|
|
5076
|
+
for (var c = -1; c <= 1; c++) {
|
|
5077
|
+
if (col + c < 0 || moduleCount <= col + c) {
|
|
5078
|
+
continue;
|
|
5079
|
+
}
|
|
5080
|
+
if (r === 0 && c === 0) {
|
|
5081
|
+
continue;
|
|
5082
|
+
}
|
|
5083
|
+
if (dark === qrCode.isDark(row + r, col + c)) {
|
|
5084
|
+
sameCount++;
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
if (sameCount > 5) {
|
|
5089
|
+
lostPoint += 3 + sameCount - 5;
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
}
|
|
5093
|
+
for (row = 0; row < moduleCount - 1; row++) {
|
|
5094
|
+
for (col = 0; col < moduleCount - 1; col++) {
|
|
5095
|
+
var count = 0;
|
|
5096
|
+
if (qrCode.isDark(row, col)) count++;
|
|
5097
|
+
if (qrCode.isDark(row + 1, col)) count++;
|
|
5098
|
+
if (qrCode.isDark(row, col + 1)) count++;
|
|
5099
|
+
if (qrCode.isDark(row + 1, col + 1)) count++;
|
|
5100
|
+
if (count === 0 || count === 4) {
|
|
5101
|
+
lostPoint += 3;
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
for (row = 0; row < moduleCount; row++) {
|
|
5106
|
+
for (col = 0; col < moduleCount - 6; col++) {
|
|
5107
|
+
if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) {
|
|
5108
|
+
lostPoint += 40;
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
for (col = 0; col < moduleCount; col++) {
|
|
5113
|
+
for (row = 0; row < moduleCount - 6; row++) {
|
|
5114
|
+
if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) {
|
|
5115
|
+
lostPoint += 40;
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5119
|
+
var darkCount = 0;
|
|
5120
|
+
for (col = 0; col < moduleCount; col++) {
|
|
5121
|
+
for (row = 0; row < moduleCount; row++) {
|
|
5122
|
+
if (qrCode.isDark(row, col)) {
|
|
5123
|
+
darkCount++;
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
|
5128
|
+
lostPoint += ratio * 10;
|
|
5129
|
+
return lostPoint;
|
|
5130
|
+
}
|
|
5131
|
+
};
|
|
5132
|
+
module.exports = QRUtil;
|
|
5133
|
+
}
|
|
5134
|
+
});
|
|
5135
|
+
|
|
5136
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js
|
|
5137
|
+
var require_QRErrorCorrectLevel = __commonJS({
|
|
5138
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js"(exports, module) {
|
|
5139
|
+
module.exports = {
|
|
5140
|
+
L: 1,
|
|
5141
|
+
M: 0,
|
|
5142
|
+
Q: 3,
|
|
5143
|
+
H: 2
|
|
5144
|
+
};
|
|
5145
|
+
}
|
|
5146
|
+
});
|
|
5147
|
+
|
|
5148
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js
|
|
5149
|
+
var require_QRRSBlock = __commonJS({
|
|
5150
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js"(exports, module) {
|
|
5151
|
+
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
5152
|
+
function QRRSBlock(totalCount, dataCount) {
|
|
5153
|
+
this.totalCount = totalCount;
|
|
5154
|
+
this.dataCount = dataCount;
|
|
5155
|
+
}
|
|
5156
|
+
QRRSBlock.RS_BLOCK_TABLE = [
|
|
5157
|
+
// L
|
|
5158
|
+
// M
|
|
5159
|
+
// Q
|
|
5160
|
+
// H
|
|
5161
|
+
// 1
|
|
5162
|
+
[1, 26, 19],
|
|
5163
|
+
[1, 26, 16],
|
|
5164
|
+
[1, 26, 13],
|
|
5165
|
+
[1, 26, 9],
|
|
5166
|
+
// 2
|
|
5167
|
+
[1, 44, 34],
|
|
5168
|
+
[1, 44, 28],
|
|
5169
|
+
[1, 44, 22],
|
|
5170
|
+
[1, 44, 16],
|
|
5171
|
+
// 3
|
|
5172
|
+
[1, 70, 55],
|
|
5173
|
+
[1, 70, 44],
|
|
5174
|
+
[2, 35, 17],
|
|
5175
|
+
[2, 35, 13],
|
|
5176
|
+
// 4
|
|
5177
|
+
[1, 100, 80],
|
|
5178
|
+
[2, 50, 32],
|
|
5179
|
+
[2, 50, 24],
|
|
5180
|
+
[4, 25, 9],
|
|
5181
|
+
// 5
|
|
5182
|
+
[1, 134, 108],
|
|
5183
|
+
[2, 67, 43],
|
|
5184
|
+
[2, 33, 15, 2, 34, 16],
|
|
5185
|
+
[2, 33, 11, 2, 34, 12],
|
|
5186
|
+
// 6
|
|
5187
|
+
[2, 86, 68],
|
|
5188
|
+
[4, 43, 27],
|
|
5189
|
+
[4, 43, 19],
|
|
5190
|
+
[4, 43, 15],
|
|
5191
|
+
// 7
|
|
5192
|
+
[2, 98, 78],
|
|
5193
|
+
[4, 49, 31],
|
|
5194
|
+
[2, 32, 14, 4, 33, 15],
|
|
5195
|
+
[4, 39, 13, 1, 40, 14],
|
|
5196
|
+
// 8
|
|
5197
|
+
[2, 121, 97],
|
|
5198
|
+
[2, 60, 38, 2, 61, 39],
|
|
5199
|
+
[4, 40, 18, 2, 41, 19],
|
|
5200
|
+
[4, 40, 14, 2, 41, 15],
|
|
5201
|
+
// 9
|
|
5202
|
+
[2, 146, 116],
|
|
5203
|
+
[3, 58, 36, 2, 59, 37],
|
|
5204
|
+
[4, 36, 16, 4, 37, 17],
|
|
5205
|
+
[4, 36, 12, 4, 37, 13],
|
|
5206
|
+
// 10
|
|
5207
|
+
[2, 86, 68, 2, 87, 69],
|
|
5208
|
+
[4, 69, 43, 1, 70, 44],
|
|
5209
|
+
[6, 43, 19, 2, 44, 20],
|
|
5210
|
+
[6, 43, 15, 2, 44, 16],
|
|
5211
|
+
// 11
|
|
5212
|
+
[4, 101, 81],
|
|
5213
|
+
[1, 80, 50, 4, 81, 51],
|
|
5214
|
+
[4, 50, 22, 4, 51, 23],
|
|
5215
|
+
[3, 36, 12, 8, 37, 13],
|
|
5216
|
+
// 12
|
|
5217
|
+
[2, 116, 92, 2, 117, 93],
|
|
5218
|
+
[6, 58, 36, 2, 59, 37],
|
|
5219
|
+
[4, 46, 20, 6, 47, 21],
|
|
5220
|
+
[7, 42, 14, 4, 43, 15],
|
|
5221
|
+
// 13
|
|
5222
|
+
[4, 133, 107],
|
|
5223
|
+
[8, 59, 37, 1, 60, 38],
|
|
5224
|
+
[8, 44, 20, 4, 45, 21],
|
|
5225
|
+
[12, 33, 11, 4, 34, 12],
|
|
5226
|
+
// 14
|
|
5227
|
+
[3, 145, 115, 1, 146, 116],
|
|
5228
|
+
[4, 64, 40, 5, 65, 41],
|
|
5229
|
+
[11, 36, 16, 5, 37, 17],
|
|
5230
|
+
[11, 36, 12, 5, 37, 13],
|
|
5231
|
+
// 15
|
|
5232
|
+
[5, 109, 87, 1, 110, 88],
|
|
5233
|
+
[5, 65, 41, 5, 66, 42],
|
|
5234
|
+
[5, 54, 24, 7, 55, 25],
|
|
5235
|
+
[11, 36, 12],
|
|
5236
|
+
// 16
|
|
5237
|
+
[5, 122, 98, 1, 123, 99],
|
|
5238
|
+
[7, 73, 45, 3, 74, 46],
|
|
5239
|
+
[15, 43, 19, 2, 44, 20],
|
|
5240
|
+
[3, 45, 15, 13, 46, 16],
|
|
5241
|
+
// 17
|
|
5242
|
+
[1, 135, 107, 5, 136, 108],
|
|
5243
|
+
[10, 74, 46, 1, 75, 47],
|
|
5244
|
+
[1, 50, 22, 15, 51, 23],
|
|
5245
|
+
[2, 42, 14, 17, 43, 15],
|
|
5246
|
+
// 18
|
|
5247
|
+
[5, 150, 120, 1, 151, 121],
|
|
5248
|
+
[9, 69, 43, 4, 70, 44],
|
|
5249
|
+
[17, 50, 22, 1, 51, 23],
|
|
5250
|
+
[2, 42, 14, 19, 43, 15],
|
|
5251
|
+
// 19
|
|
5252
|
+
[3, 141, 113, 4, 142, 114],
|
|
5253
|
+
[3, 70, 44, 11, 71, 45],
|
|
5254
|
+
[17, 47, 21, 4, 48, 22],
|
|
5255
|
+
[9, 39, 13, 16, 40, 14],
|
|
5256
|
+
// 20
|
|
5257
|
+
[3, 135, 107, 5, 136, 108],
|
|
5258
|
+
[3, 67, 41, 13, 68, 42],
|
|
5259
|
+
[15, 54, 24, 5, 55, 25],
|
|
5260
|
+
[15, 43, 15, 10, 44, 16],
|
|
5261
|
+
// 21
|
|
5262
|
+
[4, 144, 116, 4, 145, 117],
|
|
5263
|
+
[17, 68, 42],
|
|
5264
|
+
[17, 50, 22, 6, 51, 23],
|
|
5265
|
+
[19, 46, 16, 6, 47, 17],
|
|
5266
|
+
// 22
|
|
5267
|
+
[2, 139, 111, 7, 140, 112],
|
|
5268
|
+
[17, 74, 46],
|
|
5269
|
+
[7, 54, 24, 16, 55, 25],
|
|
5270
|
+
[34, 37, 13],
|
|
5271
|
+
// 23
|
|
5272
|
+
[4, 151, 121, 5, 152, 122],
|
|
5273
|
+
[4, 75, 47, 14, 76, 48],
|
|
5274
|
+
[11, 54, 24, 14, 55, 25],
|
|
5275
|
+
[16, 45, 15, 14, 46, 16],
|
|
5276
|
+
// 24
|
|
5277
|
+
[6, 147, 117, 4, 148, 118],
|
|
5278
|
+
[6, 73, 45, 14, 74, 46],
|
|
5279
|
+
[11, 54, 24, 16, 55, 25],
|
|
5280
|
+
[30, 46, 16, 2, 47, 17],
|
|
5281
|
+
// 25
|
|
5282
|
+
[8, 132, 106, 4, 133, 107],
|
|
5283
|
+
[8, 75, 47, 13, 76, 48],
|
|
5284
|
+
[7, 54, 24, 22, 55, 25],
|
|
5285
|
+
[22, 45, 15, 13, 46, 16],
|
|
5286
|
+
// 26
|
|
5287
|
+
[10, 142, 114, 2, 143, 115],
|
|
5288
|
+
[19, 74, 46, 4, 75, 47],
|
|
5289
|
+
[28, 50, 22, 6, 51, 23],
|
|
5290
|
+
[33, 46, 16, 4, 47, 17],
|
|
5291
|
+
// 27
|
|
5292
|
+
[8, 152, 122, 4, 153, 123],
|
|
5293
|
+
[22, 73, 45, 3, 74, 46],
|
|
5294
|
+
[8, 53, 23, 26, 54, 24],
|
|
5295
|
+
[12, 45, 15, 28, 46, 16],
|
|
5296
|
+
// 28
|
|
5297
|
+
[3, 147, 117, 10, 148, 118],
|
|
5298
|
+
[3, 73, 45, 23, 74, 46],
|
|
5299
|
+
[4, 54, 24, 31, 55, 25],
|
|
5300
|
+
[11, 45, 15, 31, 46, 16],
|
|
5301
|
+
// 29
|
|
5302
|
+
[7, 146, 116, 7, 147, 117],
|
|
5303
|
+
[21, 73, 45, 7, 74, 46],
|
|
5304
|
+
[1, 53, 23, 37, 54, 24],
|
|
5305
|
+
[19, 45, 15, 26, 46, 16],
|
|
5306
|
+
// 30
|
|
5307
|
+
[5, 145, 115, 10, 146, 116],
|
|
5308
|
+
[19, 75, 47, 10, 76, 48],
|
|
5309
|
+
[15, 54, 24, 25, 55, 25],
|
|
5310
|
+
[23, 45, 15, 25, 46, 16],
|
|
5311
|
+
// 31
|
|
5312
|
+
[13, 145, 115, 3, 146, 116],
|
|
5313
|
+
[2, 74, 46, 29, 75, 47],
|
|
5314
|
+
[42, 54, 24, 1, 55, 25],
|
|
5315
|
+
[23, 45, 15, 28, 46, 16],
|
|
5316
|
+
// 32
|
|
5317
|
+
[17, 145, 115],
|
|
5318
|
+
[10, 74, 46, 23, 75, 47],
|
|
5319
|
+
[10, 54, 24, 35, 55, 25],
|
|
5320
|
+
[19, 45, 15, 35, 46, 16],
|
|
5321
|
+
// 33
|
|
5322
|
+
[17, 145, 115, 1, 146, 116],
|
|
5323
|
+
[14, 74, 46, 21, 75, 47],
|
|
5324
|
+
[29, 54, 24, 19, 55, 25],
|
|
5325
|
+
[11, 45, 15, 46, 46, 16],
|
|
5326
|
+
// 34
|
|
5327
|
+
[13, 145, 115, 6, 146, 116],
|
|
5328
|
+
[14, 74, 46, 23, 75, 47],
|
|
5329
|
+
[44, 54, 24, 7, 55, 25],
|
|
5330
|
+
[59, 46, 16, 1, 47, 17],
|
|
5331
|
+
// 35
|
|
5332
|
+
[12, 151, 121, 7, 152, 122],
|
|
5333
|
+
[12, 75, 47, 26, 76, 48],
|
|
5334
|
+
[39, 54, 24, 14, 55, 25],
|
|
5335
|
+
[22, 45, 15, 41, 46, 16],
|
|
5336
|
+
// 36
|
|
5337
|
+
[6, 151, 121, 14, 152, 122],
|
|
5338
|
+
[6, 75, 47, 34, 76, 48],
|
|
5339
|
+
[46, 54, 24, 10, 55, 25],
|
|
5340
|
+
[2, 45, 15, 64, 46, 16],
|
|
5341
|
+
// 37
|
|
5342
|
+
[17, 152, 122, 4, 153, 123],
|
|
5343
|
+
[29, 74, 46, 14, 75, 47],
|
|
5344
|
+
[49, 54, 24, 10, 55, 25],
|
|
5345
|
+
[24, 45, 15, 46, 46, 16],
|
|
5346
|
+
// 38
|
|
5347
|
+
[4, 152, 122, 18, 153, 123],
|
|
5348
|
+
[13, 74, 46, 32, 75, 47],
|
|
5349
|
+
[48, 54, 24, 14, 55, 25],
|
|
5350
|
+
[42, 45, 15, 32, 46, 16],
|
|
5351
|
+
// 39
|
|
5352
|
+
[20, 147, 117, 4, 148, 118],
|
|
5353
|
+
[40, 75, 47, 7, 76, 48],
|
|
5354
|
+
[43, 54, 24, 22, 55, 25],
|
|
5355
|
+
[10, 45, 15, 67, 46, 16],
|
|
5356
|
+
// 40
|
|
5357
|
+
[19, 148, 118, 6, 149, 119],
|
|
5358
|
+
[18, 75, 47, 31, 76, 48],
|
|
5359
|
+
[34, 54, 24, 34, 55, 25],
|
|
5360
|
+
[20, 45, 15, 61, 46, 16]
|
|
5361
|
+
];
|
|
5362
|
+
QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
|
|
5363
|
+
var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
|
|
5364
|
+
if (rsBlock === void 0) {
|
|
5365
|
+
throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
|
|
5366
|
+
}
|
|
5367
|
+
var length = rsBlock.length / 3;
|
|
5368
|
+
var list = [];
|
|
5369
|
+
for (var i = 0; i < length; i++) {
|
|
5370
|
+
var count = rsBlock[i * 3 + 0];
|
|
5371
|
+
var totalCount = rsBlock[i * 3 + 1];
|
|
5372
|
+
var dataCount = rsBlock[i * 3 + 2];
|
|
5373
|
+
for (var j = 0; j < count; j++) {
|
|
5374
|
+
list.push(new QRRSBlock(totalCount, dataCount));
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
return list;
|
|
5378
|
+
};
|
|
5379
|
+
QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
|
|
5380
|
+
switch (errorCorrectLevel) {
|
|
5381
|
+
case QRErrorCorrectLevel.L:
|
|
5382
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
|
5383
|
+
case QRErrorCorrectLevel.M:
|
|
5384
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
|
5385
|
+
case QRErrorCorrectLevel.Q:
|
|
5386
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
|
5387
|
+
case QRErrorCorrectLevel.H:
|
|
5388
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
|
5389
|
+
default:
|
|
5390
|
+
return void 0;
|
|
5391
|
+
}
|
|
5392
|
+
};
|
|
5393
|
+
module.exports = QRRSBlock;
|
|
5394
|
+
}
|
|
5395
|
+
});
|
|
5396
|
+
|
|
5397
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js
|
|
5398
|
+
var require_QRBitBuffer = __commonJS({
|
|
5399
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js"(exports, module) {
|
|
5400
|
+
function QRBitBuffer() {
|
|
5401
|
+
this.buffer = [];
|
|
5402
|
+
this.length = 0;
|
|
5403
|
+
}
|
|
5404
|
+
QRBitBuffer.prototype = {
|
|
5405
|
+
get: function(index) {
|
|
5406
|
+
var bufIndex = Math.floor(index / 8);
|
|
5407
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
|
|
5408
|
+
},
|
|
5409
|
+
put: function(num, length) {
|
|
5410
|
+
for (var i = 0; i < length; i++) {
|
|
5411
|
+
this.putBit((num >>> length - i - 1 & 1) == 1);
|
|
5412
|
+
}
|
|
5413
|
+
},
|
|
5414
|
+
getLengthInBits: function() {
|
|
5415
|
+
return this.length;
|
|
5416
|
+
},
|
|
5417
|
+
putBit: function(bit) {
|
|
5418
|
+
var bufIndex = Math.floor(this.length / 8);
|
|
5419
|
+
if (this.buffer.length <= bufIndex) {
|
|
5420
|
+
this.buffer.push(0);
|
|
5421
|
+
}
|
|
5422
|
+
if (bit) {
|
|
5423
|
+
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
5424
|
+
}
|
|
5425
|
+
this.length++;
|
|
5426
|
+
}
|
|
5427
|
+
};
|
|
5428
|
+
module.exports = QRBitBuffer;
|
|
5429
|
+
}
|
|
5430
|
+
});
|
|
5431
|
+
|
|
5432
|
+
// ../../node_modules/qrcode-terminal/vendor/QRCode/index.js
|
|
5433
|
+
var require_QRCode = __commonJS({
|
|
5434
|
+
"../../node_modules/qrcode-terminal/vendor/QRCode/index.js"(exports, module) {
|
|
5435
|
+
var QR8bitByte = require_QR8bitByte();
|
|
5436
|
+
var QRUtil = require_QRUtil();
|
|
5437
|
+
var QRPolynomial = require_QRPolynomial();
|
|
5438
|
+
var QRRSBlock = require_QRRSBlock();
|
|
5439
|
+
var QRBitBuffer = require_QRBitBuffer();
|
|
5440
|
+
function QRCode(typeNumber, errorCorrectLevel) {
|
|
5441
|
+
this.typeNumber = typeNumber;
|
|
5442
|
+
this.errorCorrectLevel = errorCorrectLevel;
|
|
5443
|
+
this.modules = null;
|
|
5444
|
+
this.moduleCount = 0;
|
|
5445
|
+
this.dataCache = null;
|
|
5446
|
+
this.dataList = [];
|
|
5447
|
+
}
|
|
5448
|
+
QRCode.prototype = {
|
|
5449
|
+
addData: function(data) {
|
|
5450
|
+
var newData = new QR8bitByte(data);
|
|
5451
|
+
this.dataList.push(newData);
|
|
5452
|
+
this.dataCache = null;
|
|
5453
|
+
},
|
|
5454
|
+
isDark: function(row, col) {
|
|
5455
|
+
if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
|
|
5456
|
+
throw new Error(row + "," + col);
|
|
5457
|
+
}
|
|
5458
|
+
return this.modules[row][col];
|
|
5459
|
+
},
|
|
5460
|
+
getModuleCount: function() {
|
|
5461
|
+
return this.moduleCount;
|
|
5462
|
+
},
|
|
5463
|
+
make: function() {
|
|
5464
|
+
if (this.typeNumber < 1) {
|
|
5465
|
+
var typeNumber = 1;
|
|
5466
|
+
for (typeNumber = 1; typeNumber < 40; typeNumber++) {
|
|
5467
|
+
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
|
|
5468
|
+
var buffer = new QRBitBuffer();
|
|
5469
|
+
var totalDataCount = 0;
|
|
5470
|
+
for (var i = 0; i < rsBlocks.length; i++) {
|
|
5471
|
+
totalDataCount += rsBlocks[i].dataCount;
|
|
5472
|
+
}
|
|
5473
|
+
for (var x = 0; x < this.dataList.length; x++) {
|
|
5474
|
+
var data = this.dataList[x];
|
|
5475
|
+
buffer.put(data.mode, 4);
|
|
5476
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
|
|
5477
|
+
data.write(buffer);
|
|
5478
|
+
}
|
|
5479
|
+
if (buffer.getLengthInBits() <= totalDataCount * 8)
|
|
5480
|
+
break;
|
|
5481
|
+
}
|
|
5482
|
+
this.typeNumber = typeNumber;
|
|
5483
|
+
}
|
|
5484
|
+
this.makeImpl(false, this.getBestMaskPattern());
|
|
5485
|
+
},
|
|
5486
|
+
makeImpl: function(test, maskPattern) {
|
|
5487
|
+
this.moduleCount = this.typeNumber * 4 + 17;
|
|
5488
|
+
this.modules = new Array(this.moduleCount);
|
|
5489
|
+
for (var row = 0; row < this.moduleCount; row++) {
|
|
5490
|
+
this.modules[row] = new Array(this.moduleCount);
|
|
5491
|
+
for (var col = 0; col < this.moduleCount; col++) {
|
|
5492
|
+
this.modules[row][col] = null;
|
|
5493
|
+
}
|
|
5494
|
+
}
|
|
5495
|
+
this.setupPositionProbePattern(0, 0);
|
|
5496
|
+
this.setupPositionProbePattern(this.moduleCount - 7, 0);
|
|
5497
|
+
this.setupPositionProbePattern(0, this.moduleCount - 7);
|
|
5498
|
+
this.setupPositionAdjustPattern();
|
|
5499
|
+
this.setupTimingPattern();
|
|
5500
|
+
this.setupTypeInfo(test, maskPattern);
|
|
5501
|
+
if (this.typeNumber >= 7) {
|
|
5502
|
+
this.setupTypeNumber(test);
|
|
5503
|
+
}
|
|
5504
|
+
if (this.dataCache === null) {
|
|
5505
|
+
this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
|
|
5506
|
+
}
|
|
5507
|
+
this.mapData(this.dataCache, maskPattern);
|
|
5508
|
+
},
|
|
5509
|
+
setupPositionProbePattern: function(row, col) {
|
|
5510
|
+
for (var r = -1; r <= 7; r++) {
|
|
5511
|
+
if (row + r <= -1 || this.moduleCount <= row + r) continue;
|
|
5512
|
+
for (var c = -1; c <= 7; c++) {
|
|
5513
|
+
if (col + c <= -1 || this.moduleCount <= col + c) continue;
|
|
5514
|
+
if (0 <= r && r <= 6 && (c === 0 || c === 6) || 0 <= c && c <= 6 && (r === 0 || r === 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
|
|
5515
|
+
this.modules[row + r][col + c] = true;
|
|
5516
|
+
} else {
|
|
5517
|
+
this.modules[row + r][col + c] = false;
|
|
5518
|
+
}
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5521
|
+
},
|
|
5522
|
+
getBestMaskPattern: function() {
|
|
5523
|
+
var minLostPoint = 0;
|
|
5524
|
+
var pattern = 0;
|
|
5525
|
+
for (var i = 0; i < 8; i++) {
|
|
5526
|
+
this.makeImpl(true, i);
|
|
5527
|
+
var lostPoint = QRUtil.getLostPoint(this);
|
|
5528
|
+
if (i === 0 || minLostPoint > lostPoint) {
|
|
5529
|
+
minLostPoint = lostPoint;
|
|
5530
|
+
pattern = i;
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
return pattern;
|
|
5534
|
+
},
|
|
5535
|
+
createMovieClip: function(target_mc, instance_name, depth) {
|
|
5536
|
+
var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
|
|
5537
|
+
var cs = 1;
|
|
5538
|
+
this.make();
|
|
5539
|
+
for (var row = 0; row < this.modules.length; row++) {
|
|
5540
|
+
var y = row * cs;
|
|
5541
|
+
for (var col = 0; col < this.modules[row].length; col++) {
|
|
5542
|
+
var x = col * cs;
|
|
5543
|
+
var dark = this.modules[row][col];
|
|
5544
|
+
if (dark) {
|
|
5545
|
+
qr_mc.beginFill(0, 100);
|
|
5546
|
+
qr_mc.moveTo(x, y);
|
|
5547
|
+
qr_mc.lineTo(x + cs, y);
|
|
5548
|
+
qr_mc.lineTo(x + cs, y + cs);
|
|
5549
|
+
qr_mc.lineTo(x, y + cs);
|
|
5550
|
+
qr_mc.endFill();
|
|
5551
|
+
}
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5554
|
+
return qr_mc;
|
|
5555
|
+
},
|
|
5556
|
+
setupTimingPattern: function() {
|
|
5557
|
+
for (var r = 8; r < this.moduleCount - 8; r++) {
|
|
5558
|
+
if (this.modules[r][6] !== null) {
|
|
5559
|
+
continue;
|
|
5560
|
+
}
|
|
5561
|
+
this.modules[r][6] = r % 2 === 0;
|
|
5562
|
+
}
|
|
5563
|
+
for (var c = 8; c < this.moduleCount - 8; c++) {
|
|
5564
|
+
if (this.modules[6][c] !== null) {
|
|
5565
|
+
continue;
|
|
5566
|
+
}
|
|
5567
|
+
this.modules[6][c] = c % 2 === 0;
|
|
5568
|
+
}
|
|
5569
|
+
},
|
|
5570
|
+
setupPositionAdjustPattern: function() {
|
|
5571
|
+
var pos = QRUtil.getPatternPosition(this.typeNumber);
|
|
5572
|
+
for (var i = 0; i < pos.length; i++) {
|
|
5573
|
+
for (var j = 0; j < pos.length; j++) {
|
|
5574
|
+
var row = pos[i];
|
|
5575
|
+
var col = pos[j];
|
|
5576
|
+
if (this.modules[row][col] !== null) {
|
|
5577
|
+
continue;
|
|
5578
|
+
}
|
|
5579
|
+
for (var r = -2; r <= 2; r++) {
|
|
5580
|
+
for (var c = -2; c <= 2; c++) {
|
|
5581
|
+
if (Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0) {
|
|
5582
|
+
this.modules[row + r][col + c] = true;
|
|
5583
|
+
} else {
|
|
5584
|
+
this.modules[row + r][col + c] = false;
|
|
5585
|
+
}
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
}
|
|
5589
|
+
}
|
|
5590
|
+
},
|
|
5591
|
+
setupTypeNumber: function(test) {
|
|
5592
|
+
var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
|
|
5593
|
+
var mod;
|
|
5594
|
+
for (var i = 0; i < 18; i++) {
|
|
5595
|
+
mod = !test && (bits >> i & 1) === 1;
|
|
5596
|
+
this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
|
|
5597
|
+
}
|
|
5598
|
+
for (var x = 0; x < 18; x++) {
|
|
5599
|
+
mod = !test && (bits >> x & 1) === 1;
|
|
5600
|
+
this.modules[x % 3 + this.moduleCount - 8 - 3][Math.floor(x / 3)] = mod;
|
|
5601
|
+
}
|
|
5602
|
+
},
|
|
5603
|
+
setupTypeInfo: function(test, maskPattern) {
|
|
5604
|
+
var data = this.errorCorrectLevel << 3 | maskPattern;
|
|
5605
|
+
var bits = QRUtil.getBCHTypeInfo(data);
|
|
5606
|
+
var mod;
|
|
5607
|
+
for (var v = 0; v < 15; v++) {
|
|
5608
|
+
mod = !test && (bits >> v & 1) === 1;
|
|
5609
|
+
if (v < 6) {
|
|
5610
|
+
this.modules[v][8] = mod;
|
|
5611
|
+
} else if (v < 8) {
|
|
5612
|
+
this.modules[v + 1][8] = mod;
|
|
5613
|
+
} else {
|
|
5614
|
+
this.modules[this.moduleCount - 15 + v][8] = mod;
|
|
5615
|
+
}
|
|
5616
|
+
}
|
|
5617
|
+
for (var h = 0; h < 15; h++) {
|
|
5618
|
+
mod = !test && (bits >> h & 1) === 1;
|
|
5619
|
+
if (h < 8) {
|
|
5620
|
+
this.modules[8][this.moduleCount - h - 1] = mod;
|
|
5621
|
+
} else if (h < 9) {
|
|
5622
|
+
this.modules[8][15 - h - 1 + 1] = mod;
|
|
5623
|
+
} else {
|
|
5624
|
+
this.modules[8][15 - h - 1] = mod;
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
this.modules[this.moduleCount - 8][8] = !test;
|
|
5628
|
+
},
|
|
5629
|
+
mapData: function(data, maskPattern) {
|
|
5630
|
+
var inc = -1;
|
|
5631
|
+
var row = this.moduleCount - 1;
|
|
5632
|
+
var bitIndex = 7;
|
|
5633
|
+
var byteIndex = 0;
|
|
5634
|
+
for (var col = this.moduleCount - 1; col > 0; col -= 2) {
|
|
5635
|
+
if (col === 6) col--;
|
|
5636
|
+
while (true) {
|
|
5637
|
+
for (var c = 0; c < 2; c++) {
|
|
5638
|
+
if (this.modules[row][col - c] === null) {
|
|
5639
|
+
var dark = false;
|
|
5640
|
+
if (byteIndex < data.length) {
|
|
5641
|
+
dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
5642
|
+
}
|
|
5643
|
+
var mask = QRUtil.getMask(maskPattern, row, col - c);
|
|
5644
|
+
if (mask) {
|
|
5645
|
+
dark = !dark;
|
|
5646
|
+
}
|
|
5647
|
+
this.modules[row][col - c] = dark;
|
|
5648
|
+
bitIndex--;
|
|
5649
|
+
if (bitIndex === -1) {
|
|
5650
|
+
byteIndex++;
|
|
5651
|
+
bitIndex = 7;
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
}
|
|
5655
|
+
row += inc;
|
|
5656
|
+
if (row < 0 || this.moduleCount <= row) {
|
|
5657
|
+
row -= inc;
|
|
5658
|
+
inc = -inc;
|
|
5659
|
+
break;
|
|
5660
|
+
}
|
|
5661
|
+
}
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
};
|
|
5665
|
+
QRCode.PAD0 = 236;
|
|
5666
|
+
QRCode.PAD1 = 17;
|
|
5667
|
+
QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
|
|
5668
|
+
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
|
|
5669
|
+
var buffer = new QRBitBuffer();
|
|
5670
|
+
for (var i = 0; i < dataList.length; i++) {
|
|
5671
|
+
var data = dataList[i];
|
|
5672
|
+
buffer.put(data.mode, 4);
|
|
5673
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
|
|
5674
|
+
data.write(buffer);
|
|
5675
|
+
}
|
|
5676
|
+
var totalDataCount = 0;
|
|
5677
|
+
for (var x = 0; x < rsBlocks.length; x++) {
|
|
5678
|
+
totalDataCount += rsBlocks[x].dataCount;
|
|
5679
|
+
}
|
|
5680
|
+
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
5681
|
+
throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
|
|
5682
|
+
}
|
|
5683
|
+
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
|
5684
|
+
buffer.put(0, 4);
|
|
5685
|
+
}
|
|
5686
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
5687
|
+
buffer.putBit(false);
|
|
5688
|
+
}
|
|
5689
|
+
while (true) {
|
|
5690
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
5691
|
+
break;
|
|
5692
|
+
}
|
|
5693
|
+
buffer.put(QRCode.PAD0, 8);
|
|
5694
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
5695
|
+
break;
|
|
5696
|
+
}
|
|
5697
|
+
buffer.put(QRCode.PAD1, 8);
|
|
5698
|
+
}
|
|
5699
|
+
return QRCode.createBytes(buffer, rsBlocks);
|
|
5700
|
+
};
|
|
5701
|
+
QRCode.createBytes = function(buffer, rsBlocks) {
|
|
5702
|
+
var offset = 0;
|
|
5703
|
+
var maxDcCount = 0;
|
|
5704
|
+
var maxEcCount = 0;
|
|
5705
|
+
var dcdata = new Array(rsBlocks.length);
|
|
5706
|
+
var ecdata = new Array(rsBlocks.length);
|
|
5707
|
+
for (var r = 0; r < rsBlocks.length; r++) {
|
|
5708
|
+
var dcCount = rsBlocks[r].dataCount;
|
|
5709
|
+
var ecCount = rsBlocks[r].totalCount - dcCount;
|
|
5710
|
+
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
5711
|
+
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
5712
|
+
dcdata[r] = new Array(dcCount);
|
|
5713
|
+
for (var i = 0; i < dcdata[r].length; i++) {
|
|
5714
|
+
dcdata[r][i] = 255 & buffer.buffer[i + offset];
|
|
5715
|
+
}
|
|
5716
|
+
offset += dcCount;
|
|
5717
|
+
var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
5718
|
+
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
|
5719
|
+
var modPoly = rawPoly.mod(rsPoly);
|
|
5720
|
+
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
5721
|
+
for (var x = 0; x < ecdata[r].length; x++) {
|
|
5722
|
+
var modIndex = x + modPoly.getLength() - ecdata[r].length;
|
|
5723
|
+
ecdata[r][x] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
5726
|
+
var totalCodeCount = 0;
|
|
5727
|
+
for (var y = 0; y < rsBlocks.length; y++) {
|
|
5728
|
+
totalCodeCount += rsBlocks[y].totalCount;
|
|
5729
|
+
}
|
|
5730
|
+
var data = new Array(totalCodeCount);
|
|
5731
|
+
var index = 0;
|
|
5732
|
+
for (var z = 0; z < maxDcCount; z++) {
|
|
5733
|
+
for (var s = 0; s < rsBlocks.length; s++) {
|
|
5734
|
+
if (z < dcdata[s].length) {
|
|
5735
|
+
data[index++] = dcdata[s][z];
|
|
5736
|
+
}
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
for (var xx = 0; xx < maxEcCount; xx++) {
|
|
5740
|
+
for (var t = 0; t < rsBlocks.length; t++) {
|
|
5741
|
+
if (xx < ecdata[t].length) {
|
|
5742
|
+
data[index++] = ecdata[t][xx];
|
|
5743
|
+
}
|
|
5744
|
+
}
|
|
5745
|
+
}
|
|
5746
|
+
return data;
|
|
5747
|
+
};
|
|
5748
|
+
module.exports = QRCode;
|
|
5749
|
+
}
|
|
5750
|
+
});
|
|
5751
|
+
|
|
5752
|
+
// ../../node_modules/qrcode-terminal/lib/main.js
|
|
5753
|
+
var require_main = __commonJS({
|
|
5754
|
+
"../../node_modules/qrcode-terminal/lib/main.js"(exports, module) {
|
|
5755
|
+
var QRCode = require_QRCode();
|
|
5756
|
+
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
5757
|
+
var black = "\x1B[40m \x1B[0m";
|
|
5758
|
+
var white = "\x1B[47m \x1B[0m";
|
|
5759
|
+
var toCell = function(isBlack) {
|
|
5760
|
+
return isBlack ? black : white;
|
|
5761
|
+
};
|
|
5762
|
+
var repeat = function(color) {
|
|
5763
|
+
return {
|
|
5764
|
+
times: function(count) {
|
|
5765
|
+
return new Array(count).join(color);
|
|
5766
|
+
}
|
|
5767
|
+
};
|
|
5768
|
+
};
|
|
5769
|
+
var fill = function(length, value) {
|
|
5770
|
+
var arr = new Array(length);
|
|
5771
|
+
for (var i = 0; i < length; i++) {
|
|
5772
|
+
arr[i] = value;
|
|
5773
|
+
}
|
|
5774
|
+
return arr;
|
|
5775
|
+
};
|
|
5776
|
+
module.exports = {
|
|
5777
|
+
error: QRErrorCorrectLevel.L,
|
|
5778
|
+
generate: function(input, opts, cb) {
|
|
5779
|
+
if (typeof opts === "function") {
|
|
5780
|
+
cb = opts;
|
|
5781
|
+
opts = {};
|
|
5782
|
+
}
|
|
5783
|
+
var qrcode = new QRCode(-1, this.error);
|
|
5784
|
+
qrcode.addData(input);
|
|
5785
|
+
qrcode.make();
|
|
5786
|
+
var output = "";
|
|
5787
|
+
if (opts && opts.small) {
|
|
5788
|
+
var BLACK = true, WHITE = false;
|
|
5789
|
+
var moduleCount = qrcode.getModuleCount();
|
|
5790
|
+
var moduleData = qrcode.modules.slice();
|
|
5791
|
+
var oddRow = moduleCount % 2 === 1;
|
|
5792
|
+
if (oddRow) {
|
|
5793
|
+
moduleData.push(fill(moduleCount, WHITE));
|
|
5794
|
+
}
|
|
5795
|
+
var platte = {
|
|
5796
|
+
WHITE_ALL: "\u2588",
|
|
5797
|
+
WHITE_BLACK: "\u2580",
|
|
5798
|
+
BLACK_WHITE: "\u2584",
|
|
5799
|
+
BLACK_ALL: " "
|
|
5800
|
+
};
|
|
5801
|
+
var borderTop = repeat(platte.BLACK_WHITE).times(moduleCount + 3);
|
|
5802
|
+
var borderBottom = repeat(platte.WHITE_BLACK).times(moduleCount + 3);
|
|
5803
|
+
output += borderTop + "\n";
|
|
5804
|
+
for (var row = 0; row < moduleCount; row += 2) {
|
|
5805
|
+
output += platte.WHITE_ALL;
|
|
5806
|
+
for (var col = 0; col < moduleCount; col++) {
|
|
5807
|
+
if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === WHITE) {
|
|
5808
|
+
output += platte.WHITE_ALL;
|
|
5809
|
+
} else if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === BLACK) {
|
|
5810
|
+
output += platte.WHITE_BLACK;
|
|
5811
|
+
} else if (moduleData[row][col] === BLACK && moduleData[row + 1][col] === WHITE) {
|
|
5812
|
+
output += platte.BLACK_WHITE;
|
|
5813
|
+
} else {
|
|
5814
|
+
output += platte.BLACK_ALL;
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
output += platte.WHITE_ALL + "\n";
|
|
5818
|
+
}
|
|
5819
|
+
if (!oddRow) {
|
|
5820
|
+
output += borderBottom;
|
|
5821
|
+
}
|
|
5822
|
+
} else {
|
|
5823
|
+
var border = repeat(white).times(qrcode.getModuleCount() + 3);
|
|
5824
|
+
output += border + "\n";
|
|
5825
|
+
qrcode.modules.forEach(function(row2) {
|
|
5826
|
+
output += white;
|
|
5827
|
+
output += row2.map(toCell).join("");
|
|
5828
|
+
output += white + "\n";
|
|
5829
|
+
});
|
|
5830
|
+
output += border;
|
|
5831
|
+
}
|
|
5832
|
+
if (cb) cb(output);
|
|
5833
|
+
else console.log(output);
|
|
5834
|
+
},
|
|
5835
|
+
setErrorLevel: function(error) {
|
|
5836
|
+
this.error = QRErrorCorrectLevel[error] || this.error;
|
|
5837
|
+
}
|
|
5838
|
+
};
|
|
5839
|
+
}
|
|
5840
|
+
});
|
|
5841
|
+
|
|
4772
5842
|
// src/cli.ts
|
|
4773
5843
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4774
5844
|
import { platform as platform2 } from "node:os";
|
|
@@ -6458,6 +7528,7 @@ async function runDaemon(opts = {}) {
|
|
|
6458
7528
|
}
|
|
6459
7529
|
|
|
6460
7530
|
// src/auth.ts
|
|
7531
|
+
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
6461
7532
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
6462
7533
|
import { existsSync as existsSync6, rmSync } from "node:fs";
|
|
6463
7534
|
import { join as join7 } from "node:path";
|
|
@@ -6490,7 +7561,7 @@ var ETX = String.fromCharCode(3);
|
|
|
6490
7561
|
var DEL = String.fromCharCode(127);
|
|
6491
7562
|
var BS = String.fromCharCode(8);
|
|
6492
7563
|
var ERASE = BS + " " + BS;
|
|
6493
|
-
function ask(question
|
|
7564
|
+
function ask(question) {
|
|
6494
7565
|
const { stdin, stdout } = process;
|
|
6495
7566
|
return new Promise((resolve3) => {
|
|
6496
7567
|
stdout.write(question);
|
|
@@ -6536,57 +7607,90 @@ function ask(question, hidden = false) {
|
|
|
6536
7607
|
if (ch === DEL || ch === BS) {
|
|
6537
7608
|
if (buf) {
|
|
6538
7609
|
buf = buf.slice(0, -1);
|
|
6539
|
-
|
|
7610
|
+
stdout.write(ERASE);
|
|
6540
7611
|
}
|
|
6541
7612
|
continue;
|
|
6542
7613
|
}
|
|
6543
7614
|
buf += ch;
|
|
6544
|
-
|
|
7615
|
+
stdout.write(ch);
|
|
6545
7616
|
}
|
|
6546
7617
|
}
|
|
6547
7618
|
stdin.on("data", onData);
|
|
6548
7619
|
});
|
|
6549
7620
|
}
|
|
6550
|
-
async function
|
|
6551
|
-
const
|
|
6552
|
-
const
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
headers: { "Content-Type": "application/json" },
|
|
6561
|
-
body: JSON.stringify({ email, password })
|
|
6562
|
-
});
|
|
6563
|
-
if (!r.ok) throw new Error(`Login failed (${r.status}): ${await r.text().catch(() => "") || "check your credentials"}`);
|
|
6564
|
-
token = (await r.json()).token;
|
|
7621
|
+
async function fetchJson(url, init) {
|
|
7622
|
+
const r = await fetch(url, { ...init, headers: { "Content-Type": "application/json", ...init?.headers ?? {} } });
|
|
7623
|
+
const data = await r.json().catch(() => ({}));
|
|
7624
|
+
if (!r.ok) throw new Error(data.message || `Request failed (${r.status})`);
|
|
7625
|
+
return data;
|
|
7626
|
+
}
|
|
7627
|
+
function printQr(url) {
|
|
7628
|
+
try {
|
|
7629
|
+
import_qrcode_terminal.default.generate(url, { small: true });
|
|
7630
|
+
} catch {
|
|
6565
7631
|
}
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
if (!userId) throw new Error("Could not read the user id from the token (is it a valid tesseract token?).");
|
|
6569
|
-
const deviceId2 = readCredentials()?.deviceId ?? randomUUID2().slice(0, 8);
|
|
6570
|
-
const label = opts.name ?? defaultLabel();
|
|
6571
|
-
const mr = await fetch(`${api}/auth/device-token`, {
|
|
6572
|
-
method: "POST",
|
|
6573
|
-
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
6574
|
-
body: JSON.stringify({ deviceId: deviceId2, label })
|
|
6575
|
-
});
|
|
6576
|
-
if (!mr.ok) throw new Error(`Could not provision a device token (${mr.status}): ${await mr.text().catch(() => "") || "is your plan allowed to host?"}`);
|
|
6577
|
-
const dt = await mr.json();
|
|
7632
|
+
}
|
|
7633
|
+
function persist(api, relay, deviceId2, dt) {
|
|
6578
7634
|
writeCredentials({
|
|
6579
7635
|
accessToken: dt.accessToken,
|
|
6580
7636
|
refreshSecret: dt.refreshSecret,
|
|
6581
7637
|
dtid: dt.dtid,
|
|
6582
7638
|
deviceId: deviceId2,
|
|
6583
|
-
userId,
|
|
7639
|
+
userId: decodeJwtSub(dt.accessToken) ?? "",
|
|
6584
7640
|
backendOrigin: relay,
|
|
6585
7641
|
apiOrigin: api,
|
|
6586
7642
|
expiresAt: dt.expiresAt
|
|
6587
7643
|
});
|
|
6588
|
-
|
|
6589
|
-
|
|
7644
|
+
}
|
|
7645
|
+
async function login(opts) {
|
|
7646
|
+
const api = (opts.api ?? DEFAULT_API).replace(/\/$/, "");
|
|
7647
|
+
const relay = (opts.relay ?? defaultRelay(api)).replace(/\/$/, "");
|
|
7648
|
+
const deviceId2 = readCredentials()?.deviceId ?? randomUUID2().slice(0, 8);
|
|
7649
|
+
const label = opts.name ?? defaultLabel();
|
|
7650
|
+
if (opts.token) {
|
|
7651
|
+
const dt = await fetchJson(`${api}/auth/device-token`, {
|
|
7652
|
+
method: "POST",
|
|
7653
|
+
headers: { Authorization: `Bearer ${opts.token}` },
|
|
7654
|
+
body: JSON.stringify({ deviceId: deviceId2, label })
|
|
7655
|
+
});
|
|
7656
|
+
persist(api, relay, deviceId2, dt);
|
|
7657
|
+
console.log(`Logged in. This machine ("${label}", device ${deviceId2}) is connected.`);
|
|
7658
|
+
console.log("Next: `tesseract-agent install` (background service) or `tesseract-agent run` (foreground).");
|
|
7659
|
+
return;
|
|
7660
|
+
}
|
|
7661
|
+
const start2 = await fetchJson(`${api}/auth/cli/start`, { method: "POST" });
|
|
7662
|
+
const url = `${api}/?authorize=${start2.requestId}`;
|
|
7663
|
+
console.log();
|
|
7664
|
+
console.log("To connect this machine, open this URL and sign in (Google or email):");
|
|
7665
|
+
console.log();
|
|
7666
|
+
console.log(` ${url}`);
|
|
7667
|
+
console.log();
|
|
7668
|
+
printQr(url);
|
|
7669
|
+
console.log();
|
|
7670
|
+
console.log("Then enter the one-time code shown in the browser.");
|
|
7671
|
+
console.log();
|
|
7672
|
+
for (; ; ) {
|
|
7673
|
+
const code = await ask("One-time code: ");
|
|
7674
|
+
if (!code) {
|
|
7675
|
+
console.log("Cancelled.");
|
|
7676
|
+
return;
|
|
7677
|
+
}
|
|
7678
|
+
try {
|
|
7679
|
+
const dt = await fetchJson(`${api}/auth/cli/redeem`, {
|
|
7680
|
+
method: "POST",
|
|
7681
|
+
body: JSON.stringify({ requestId: start2.requestId, code, deviceId: deviceId2, label })
|
|
7682
|
+
});
|
|
7683
|
+
persist(api, relay, deviceId2, dt);
|
|
7684
|
+
console.log();
|
|
7685
|
+
console.log(`Logged in. This machine ("${label}", device ${deviceId2}) is connected.`);
|
|
7686
|
+
console.log("Next: `tesseract-agent install` (background service) or `tesseract-agent run` (foreground).");
|
|
7687
|
+
return;
|
|
7688
|
+
} catch (e) {
|
|
7689
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
7690
|
+
console.log(` ${msg}`);
|
|
7691
|
+
if (/again/i.test(msg)) return;
|
|
7692
|
+
}
|
|
7693
|
+
}
|
|
6590
7694
|
}
|
|
6591
7695
|
async function logout() {
|
|
6592
7696
|
const c = readCredentials();
|
|
@@ -6718,7 +7822,7 @@ function logs(system, follow) {
|
|
|
6718
7822
|
}
|
|
6719
7823
|
|
|
6720
7824
|
// src/cli.ts
|
|
6721
|
-
var CLI_VERSION = process.env.CCB_DAEMON_VERSION ?? "0.1.
|
|
7825
|
+
var CLI_VERSION = process.env.CCB_DAEMON_VERSION ?? "0.1.3";
|
|
6722
7826
|
function parseFlags(argv) {
|
|
6723
7827
|
const out = {};
|
|
6724
7828
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -6738,7 +7842,7 @@ function parseFlags(argv) {
|
|
|
6738
7842
|
var HELP = `tesseract-agent \u2014 run agents on this machine remotely, under your account.
|
|
6739
7843
|
|
|
6740
7844
|
Usage:
|
|
6741
|
-
tesseract-agent login [--
|
|
7845
|
+
tesseract-agent login [--token JWT] [--name LABEL] [--api URL] [--relay URL]
|
|
6742
7846
|
tesseract-agent install [--system] Install + start the background service (systemd)
|
|
6743
7847
|
tesseract-agent uninstall [--system] Stop + remove the service
|
|
6744
7848
|
tesseract-agent start | stop | restart Control the service
|
|
@@ -6749,9 +7853,9 @@ Usage:
|
|
|
6749
7853
|
tesseract-agent logout Revoke this device's token + wipe local state
|
|
6750
7854
|
tesseract-agent --help
|
|
6751
7855
|
|
|
6752
|
-
login
|
|
6753
|
-
|
|
6754
|
-
|
|
7856
|
+
login: opens a browser sign-in (Google or email) and prints a URL + QR; sign in
|
|
7857
|
+
there and paste the one-time code shown. --token JWT skips the browser (automation).
|
|
7858
|
+
--api defaults to https://tesseract.fineguide.ai; --relay defaults to --api.`;
|
|
6755
7859
|
function requireLinux(cmd) {
|
|
6756
7860
|
if (platform2() !== "linux") {
|
|
6757
7861
|
console.error(`\`tesseract-agent ${cmd}\` manages a systemd service and is Linux-only. Use \`tesseract-agent run\` elsewhere (e.g. in Docker, or under launchd via the desktop app).`);
|
|
@@ -6768,7 +7872,6 @@ async function main() {
|
|
|
6768
7872
|
api: typeof flags.api === "string" ? flags.api : void 0,
|
|
6769
7873
|
relay: typeof flags.relay === "string" ? flags.relay : void 0,
|
|
6770
7874
|
token: typeof flags.token === "string" ? flags.token : void 0,
|
|
6771
|
-
email: typeof flags.email === "string" ? flags.email : void 0,
|
|
6772
7875
|
name: typeof flags.name === "string" ? flags.name : void 0
|
|
6773
7876
|
});
|
|
6774
7877
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tesseract-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
"@fineguide-tesseract/agent-core": "*",
|
|
38
38
|
"@fineguide-tesseract/host-core": "*",
|
|
39
39
|
"@fineguide-tesseract/shared": "*",
|
|
40
|
-
"@types/node": "^22.0.0"
|
|
40
|
+
"@types/node": "^22.0.0",
|
|
41
|
+
"@types/qrcode-terminal": "^0.12.0",
|
|
42
|
+
"qrcode-terminal": "^0.12.0"
|
|
41
43
|
}
|
|
42
44
|
}
|