@liangrk/claude-code-wechatbot 0.3.1 → 0.3.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/setup.js +1033 -983
- package/dist/wechat-channel.js +14921 -7678
- package/package.json +4 -3
package/dist/setup.js
CHANGED
|
@@ -1,1053 +1,1098 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
var __create = Object.create;
|
|
4
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
5
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
-
var cached = cache.get(mod);
|
|
18
|
-
if (cached)
|
|
19
|
-
return cached;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
16
|
}
|
|
21
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
-
for (let key of __getOwnPropNames(mod))
|
|
24
|
-
if (!__hasOwnProp.call(to, key))
|
|
25
|
-
__defProp(to, key, {
|
|
26
|
-
get: __accessProp.bind(mod, key),
|
|
27
|
-
enumerable: true
|
|
28
|
-
});
|
|
29
|
-
if (canCache)
|
|
30
|
-
cache.set(mod, to);
|
|
31
17
|
return to;
|
|
32
18
|
};
|
|
33
|
-
var
|
|
34
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
35
27
|
|
|
36
28
|
// node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
|
|
37
|
-
var require_QRMode = __commonJS(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
var require_QRMode = __commonJS({
|
|
30
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRMode.js"(exports, module) {
|
|
31
|
+
module.exports = {
|
|
32
|
+
MODE_NUMBER: 1 << 0,
|
|
33
|
+
MODE_ALPHA_NUM: 1 << 1,
|
|
34
|
+
MODE_8BIT_BYTE: 1 << 2,
|
|
35
|
+
MODE_KANJI: 1 << 3
|
|
36
|
+
};
|
|
37
|
+
}
|
|
44
38
|
});
|
|
45
39
|
|
|
46
40
|
// node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js
|
|
47
|
-
var require_QR8bitByte = __commonJS(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
QR8bitByte.prototype = {
|
|
54
|
-
getLength: function() {
|
|
55
|
-
return this.data.length;
|
|
56
|
-
},
|
|
57
|
-
write: function(buffer) {
|
|
58
|
-
for (var i = 0;i < this.data.length; i++) {
|
|
59
|
-
buffer.put(this.data.charCodeAt(i), 8);
|
|
60
|
-
}
|
|
41
|
+
var require_QR8bitByte = __commonJS({
|
|
42
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js"(exports, module) {
|
|
43
|
+
var QRMode = require_QRMode();
|
|
44
|
+
function QR8bitByte(data) {
|
|
45
|
+
this.mode = QRMode.MODE_8BIT_BYTE;
|
|
46
|
+
this.data = data;
|
|
61
47
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (n < 1) {
|
|
71
|
-
throw new Error("glog(" + n + ")");
|
|
72
|
-
}
|
|
73
|
-
return QRMath.LOG_TABLE[n];
|
|
74
|
-
},
|
|
75
|
-
gexp: function(n) {
|
|
76
|
-
while (n < 0) {
|
|
77
|
-
n += 255;
|
|
78
|
-
}
|
|
79
|
-
while (n >= 256) {
|
|
80
|
-
n -= 255;
|
|
48
|
+
QR8bitByte.prototype = {
|
|
49
|
+
getLength: function() {
|
|
50
|
+
return this.data.length;
|
|
51
|
+
},
|
|
52
|
+
write: function(buffer) {
|
|
53
|
+
for (var i = 0; i < this.data.length; i++) {
|
|
54
|
+
buffer.put(this.data.charCodeAt(i), 8);
|
|
55
|
+
}
|
|
81
56
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
EXP_TABLE: new Array(256),
|
|
85
|
-
LOG_TABLE: new Array(256)
|
|
86
|
-
};
|
|
87
|
-
for (i = 0;i < 8; i++) {
|
|
88
|
-
QRMath.EXP_TABLE[i] = 1 << i;
|
|
89
|
-
}
|
|
90
|
-
var i;
|
|
91
|
-
for (i = 8;i < 256; i++) {
|
|
92
|
-
QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
|
|
93
|
-
}
|
|
94
|
-
var i;
|
|
95
|
-
for (i = 0;i < 255; i++) {
|
|
96
|
-
QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
|
|
57
|
+
};
|
|
58
|
+
module.exports = QR8bitByte;
|
|
97
59
|
}
|
|
98
|
-
var i;
|
|
99
|
-
module.exports = QRMath;
|
|
100
60
|
});
|
|
101
61
|
|
|
102
|
-
// node_modules/qrcode-terminal/vendor/QRCode/
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
62
|
+
// node_modules/qrcode-terminal/vendor/QRCode/QRMath.js
|
|
63
|
+
var require_QRMath = __commonJS({
|
|
64
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRMath.js"(exports, module) {
|
|
65
|
+
var QRMath = {
|
|
66
|
+
glog: function(n) {
|
|
67
|
+
if (n < 1) {
|
|
68
|
+
throw new Error("glog(" + n + ")");
|
|
69
|
+
}
|
|
70
|
+
return QRMath.LOG_TABLE[n];
|
|
71
|
+
},
|
|
72
|
+
gexp: function(n) {
|
|
73
|
+
while (n < 0) {
|
|
74
|
+
n += 255;
|
|
75
|
+
}
|
|
76
|
+
while (n >= 256) {
|
|
77
|
+
n -= 255;
|
|
78
|
+
}
|
|
79
|
+
return QRMath.EXP_TABLE[n];
|
|
80
|
+
},
|
|
81
|
+
EXP_TABLE: new Array(256),
|
|
82
|
+
LOG_TABLE: new Array(256)
|
|
83
|
+
};
|
|
84
|
+
for (i = 0; i < 8; i++) {
|
|
85
|
+
QRMath.EXP_TABLE[i] = 1 << i;
|
|
108
86
|
}
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
87
|
+
var i;
|
|
88
|
+
for (i = 8; i < 256; i++) {
|
|
89
|
+
QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
|
|
112
90
|
}
|
|
113
|
-
|
|
114
|
-
for (
|
|
115
|
-
|
|
91
|
+
var i;
|
|
92
|
+
for (i = 0; i < 255; i++) {
|
|
93
|
+
QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
|
|
116
94
|
}
|
|
95
|
+
var i;
|
|
96
|
+
module.exports = QRMath;
|
|
117
97
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
for (var i = 0;i < this.getLength(); i++) {
|
|
128
|
-
for (var j = 0;j < e.getLength(); j++) {
|
|
129
|
-
num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return new QRPolynomial(num, 0);
|
|
133
|
-
},
|
|
134
|
-
mod: function(e) {
|
|
135
|
-
if (this.getLength() - e.getLength() < 0) {
|
|
136
|
-
return this;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js
|
|
101
|
+
var require_QRPolynomial = __commonJS({
|
|
102
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js"(exports, module) {
|
|
103
|
+
var QRMath = require_QRMath();
|
|
104
|
+
function QRPolynomial(num, shift) {
|
|
105
|
+
if (num.length === void 0) {
|
|
106
|
+
throw new Error(num.length + "/" + shift);
|
|
137
107
|
}
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
num[i] = this.get(i);
|
|
108
|
+
var offset = 0;
|
|
109
|
+
while (offset < num.length && num[offset] === 0) {
|
|
110
|
+
offset++;
|
|
142
111
|
}
|
|
143
|
-
|
|
144
|
-
|
|
112
|
+
this.num = new Array(num.length - offset + shift);
|
|
113
|
+
for (var i = 0; i < num.length - offset; i++) {
|
|
114
|
+
this.num[i] = num[i + offset];
|
|
145
115
|
}
|
|
146
|
-
return new QRPolynomial(num, 0).mod(e);
|
|
147
116
|
}
|
|
148
|
-
|
|
149
|
-
|
|
117
|
+
QRPolynomial.prototype = {
|
|
118
|
+
get: function(index) {
|
|
119
|
+
return this.num[index];
|
|
120
|
+
},
|
|
121
|
+
getLength: function() {
|
|
122
|
+
return this.num.length;
|
|
123
|
+
},
|
|
124
|
+
multiply: function(e) {
|
|
125
|
+
var num = new Array(this.getLength() + e.getLength() - 1);
|
|
126
|
+
for (var i = 0; i < this.getLength(); i++) {
|
|
127
|
+
for (var j = 0; j < e.getLength(); j++) {
|
|
128
|
+
num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return new QRPolynomial(num, 0);
|
|
132
|
+
},
|
|
133
|
+
mod: function(e) {
|
|
134
|
+
if (this.getLength() - e.getLength() < 0) {
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0));
|
|
138
|
+
var num = new Array(this.getLength());
|
|
139
|
+
for (var i = 0; i < this.getLength(); i++) {
|
|
140
|
+
num[i] = this.get(i);
|
|
141
|
+
}
|
|
142
|
+
for (var x = 0; x < e.getLength(); x++) {
|
|
143
|
+
num[x] ^= QRMath.gexp(QRMath.glog(e.get(x)) + ratio);
|
|
144
|
+
}
|
|
145
|
+
return new QRPolynomial(num, 0).mod(e);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
module.exports = QRPolynomial;
|
|
149
|
+
}
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
// node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js
|
|
153
|
-
var require_QRMaskPattern = __commonJS(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
153
|
+
var require_QRMaskPattern = __commonJS({
|
|
154
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js"(exports, module) {
|
|
155
|
+
module.exports = {
|
|
156
|
+
PATTERN000: 0,
|
|
157
|
+
PATTERN001: 1,
|
|
158
|
+
PATTERN010: 2,
|
|
159
|
+
PATTERN011: 3,
|
|
160
|
+
PATTERN100: 4,
|
|
161
|
+
PATTERN101: 5,
|
|
162
|
+
PATTERN110: 6,
|
|
163
|
+
PATTERN111: 7
|
|
164
|
+
};
|
|
165
|
+
}
|
|
164
166
|
});
|
|
165
167
|
|
|
166
168
|
// node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js
|
|
167
|
-
var require_QRUtil = __commonJS(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
[
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return (data << 10 | d) ^ QRUtil.G15_MASK;
|
|
224
|
-
},
|
|
225
|
-
getBCHTypeNumber: function(data) {
|
|
226
|
-
var d = data << 12;
|
|
227
|
-
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
|
|
228
|
-
d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
|
|
229
|
-
}
|
|
230
|
-
return data << 12 | d;
|
|
231
|
-
},
|
|
232
|
-
getBCHDigit: function(data) {
|
|
233
|
-
var digit = 0;
|
|
234
|
-
while (data !== 0) {
|
|
235
|
-
digit++;
|
|
236
|
-
data >>>= 1;
|
|
237
|
-
}
|
|
238
|
-
return digit;
|
|
239
|
-
},
|
|
240
|
-
getPatternPosition: function(typeNumber) {
|
|
241
|
-
return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
242
|
-
},
|
|
243
|
-
getMask: function(maskPattern, i, j) {
|
|
244
|
-
switch (maskPattern) {
|
|
245
|
-
case QRMaskPattern.PATTERN000:
|
|
246
|
-
return (i + j) % 2 === 0;
|
|
247
|
-
case QRMaskPattern.PATTERN001:
|
|
248
|
-
return i % 2 === 0;
|
|
249
|
-
case QRMaskPattern.PATTERN010:
|
|
250
|
-
return j % 3 === 0;
|
|
251
|
-
case QRMaskPattern.PATTERN011:
|
|
252
|
-
return (i + j) % 3 === 0;
|
|
253
|
-
case QRMaskPattern.PATTERN100:
|
|
254
|
-
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
255
|
-
case QRMaskPattern.PATTERN101:
|
|
256
|
-
return i * j % 2 + i * j % 3 === 0;
|
|
257
|
-
case QRMaskPattern.PATTERN110:
|
|
258
|
-
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
259
|
-
case QRMaskPattern.PATTERN111:
|
|
260
|
-
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
261
|
-
default:
|
|
262
|
-
throw new Error("bad maskPattern:" + maskPattern);
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
getErrorCorrectPolynomial: function(errorCorrectLength) {
|
|
266
|
-
var a = new QRPolynomial([1], 0);
|
|
267
|
-
for (var i = 0;i < errorCorrectLength; i++) {
|
|
268
|
-
a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
|
|
269
|
-
}
|
|
270
|
-
return a;
|
|
271
|
-
},
|
|
272
|
-
getLengthInBits: function(mode, type) {
|
|
273
|
-
if (1 <= type && type < 10) {
|
|
274
|
-
switch (mode) {
|
|
275
|
-
case QRMode.MODE_NUMBER:
|
|
276
|
-
return 10;
|
|
277
|
-
case QRMode.MODE_ALPHA_NUM:
|
|
278
|
-
return 9;
|
|
279
|
-
case QRMode.MODE_8BIT_BYTE:
|
|
280
|
-
return 8;
|
|
281
|
-
case QRMode.MODE_KANJI:
|
|
282
|
-
return 8;
|
|
283
|
-
default:
|
|
284
|
-
throw new Error("mode:" + mode);
|
|
169
|
+
var require_QRUtil = __commonJS({
|
|
170
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js"(exports, module) {
|
|
171
|
+
var QRMode = require_QRMode();
|
|
172
|
+
var QRPolynomial = require_QRPolynomial();
|
|
173
|
+
var QRMath = require_QRMath();
|
|
174
|
+
var QRMaskPattern = require_QRMaskPattern();
|
|
175
|
+
var QRUtil = {
|
|
176
|
+
PATTERN_POSITION_TABLE: [
|
|
177
|
+
[],
|
|
178
|
+
[6, 18],
|
|
179
|
+
[6, 22],
|
|
180
|
+
[6, 26],
|
|
181
|
+
[6, 30],
|
|
182
|
+
[6, 34],
|
|
183
|
+
[6, 22, 38],
|
|
184
|
+
[6, 24, 42],
|
|
185
|
+
[6, 26, 46],
|
|
186
|
+
[6, 28, 50],
|
|
187
|
+
[6, 30, 54],
|
|
188
|
+
[6, 32, 58],
|
|
189
|
+
[6, 34, 62],
|
|
190
|
+
[6, 26, 46, 66],
|
|
191
|
+
[6, 26, 48, 70],
|
|
192
|
+
[6, 26, 50, 74],
|
|
193
|
+
[6, 30, 54, 78],
|
|
194
|
+
[6, 30, 56, 82],
|
|
195
|
+
[6, 30, 58, 86],
|
|
196
|
+
[6, 34, 62, 90],
|
|
197
|
+
[6, 28, 50, 72, 94],
|
|
198
|
+
[6, 26, 50, 74, 98],
|
|
199
|
+
[6, 30, 54, 78, 102],
|
|
200
|
+
[6, 28, 54, 80, 106],
|
|
201
|
+
[6, 32, 58, 84, 110],
|
|
202
|
+
[6, 30, 58, 86, 114],
|
|
203
|
+
[6, 34, 62, 90, 118],
|
|
204
|
+
[6, 26, 50, 74, 98, 122],
|
|
205
|
+
[6, 30, 54, 78, 102, 126],
|
|
206
|
+
[6, 26, 52, 78, 104, 130],
|
|
207
|
+
[6, 30, 56, 82, 108, 134],
|
|
208
|
+
[6, 34, 60, 86, 112, 138],
|
|
209
|
+
[6, 30, 58, 86, 114, 142],
|
|
210
|
+
[6, 34, 62, 90, 118, 146],
|
|
211
|
+
[6, 30, 54, 78, 102, 126, 150],
|
|
212
|
+
[6, 24, 50, 76, 102, 128, 154],
|
|
213
|
+
[6, 28, 54, 80, 106, 132, 158],
|
|
214
|
+
[6, 32, 58, 84, 110, 136, 162],
|
|
215
|
+
[6, 26, 54, 82, 110, 138, 166],
|
|
216
|
+
[6, 30, 58, 86, 114, 142, 170]
|
|
217
|
+
],
|
|
218
|
+
G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,
|
|
219
|
+
G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
|
|
220
|
+
G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
|
|
221
|
+
getBCHTypeInfo: function(data) {
|
|
222
|
+
var d = data << 10;
|
|
223
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
|
|
224
|
+
d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
|
|
285
225
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
226
|
+
return (data << 10 | d) ^ QRUtil.G15_MASK;
|
|
227
|
+
},
|
|
228
|
+
getBCHTypeNumber: function(data) {
|
|
229
|
+
var d = data << 12;
|
|
230
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
|
|
231
|
+
d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
|
|
232
|
+
}
|
|
233
|
+
return data << 12 | d;
|
|
234
|
+
},
|
|
235
|
+
getBCHDigit: function(data) {
|
|
236
|
+
var digit = 0;
|
|
237
|
+
while (data !== 0) {
|
|
238
|
+
digit++;
|
|
239
|
+
data >>>= 1;
|
|
298
240
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
241
|
+
return digit;
|
|
242
|
+
},
|
|
243
|
+
getPatternPosition: function(typeNumber) {
|
|
244
|
+
return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
245
|
+
},
|
|
246
|
+
getMask: function(maskPattern, i, j) {
|
|
247
|
+
switch (maskPattern) {
|
|
248
|
+
case QRMaskPattern.PATTERN000:
|
|
249
|
+
return (i + j) % 2 === 0;
|
|
250
|
+
case QRMaskPattern.PATTERN001:
|
|
251
|
+
return i % 2 === 0;
|
|
252
|
+
case QRMaskPattern.PATTERN010:
|
|
253
|
+
return j % 3 === 0;
|
|
254
|
+
case QRMaskPattern.PATTERN011:
|
|
255
|
+
return (i + j) % 3 === 0;
|
|
256
|
+
case QRMaskPattern.PATTERN100:
|
|
257
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
258
|
+
case QRMaskPattern.PATTERN101:
|
|
259
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
260
|
+
case QRMaskPattern.PATTERN110:
|
|
261
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
262
|
+
case QRMaskPattern.PATTERN111:
|
|
263
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
309
264
|
default:
|
|
310
|
-
throw new Error("
|
|
265
|
+
throw new Error("bad maskPattern:" + maskPattern);
|
|
311
266
|
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
267
|
+
},
|
|
268
|
+
getErrorCorrectPolynomial: function(errorCorrectLength) {
|
|
269
|
+
var a = new QRPolynomial([1], 0);
|
|
270
|
+
for (var i = 0; i < errorCorrectLength; i++) {
|
|
271
|
+
a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
|
|
272
|
+
}
|
|
273
|
+
return a;
|
|
274
|
+
},
|
|
275
|
+
getLengthInBits: function(mode, type) {
|
|
276
|
+
if (1 <= type && type < 10) {
|
|
277
|
+
switch (mode) {
|
|
278
|
+
case QRMode.MODE_NUMBER:
|
|
279
|
+
return 10;
|
|
280
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
281
|
+
return 9;
|
|
282
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
283
|
+
return 8;
|
|
284
|
+
case QRMode.MODE_KANJI:
|
|
285
|
+
return 8;
|
|
286
|
+
default:
|
|
287
|
+
throw new Error("mode:" + mode);
|
|
288
|
+
}
|
|
289
|
+
} else if (type < 27) {
|
|
290
|
+
switch (mode) {
|
|
291
|
+
case QRMode.MODE_NUMBER:
|
|
292
|
+
return 12;
|
|
293
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
294
|
+
return 11;
|
|
295
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
296
|
+
return 16;
|
|
297
|
+
case QRMode.MODE_KANJI:
|
|
298
|
+
return 10;
|
|
299
|
+
default:
|
|
300
|
+
throw new Error("mode:" + mode);
|
|
301
|
+
}
|
|
302
|
+
} else if (type < 41) {
|
|
303
|
+
switch (mode) {
|
|
304
|
+
case QRMode.MODE_NUMBER:
|
|
305
|
+
return 14;
|
|
306
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
307
|
+
return 13;
|
|
308
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
309
|
+
return 16;
|
|
310
|
+
case QRMode.MODE_KANJI:
|
|
311
|
+
return 12;
|
|
312
|
+
default:
|
|
313
|
+
throw new Error("mode:" + mode);
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
throw new Error("type:" + type);
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
getLostPoint: function(qrCode) {
|
|
320
|
+
var moduleCount = qrCode.getModuleCount();
|
|
321
|
+
var lostPoint = 0;
|
|
322
|
+
var row = 0;
|
|
323
|
+
var col = 0;
|
|
324
|
+
for (row = 0; row < moduleCount; row++) {
|
|
325
|
+
for (col = 0; col < moduleCount; col++) {
|
|
326
|
+
var sameCount = 0;
|
|
327
|
+
var dark = qrCode.isDark(row, col);
|
|
328
|
+
for (var r = -1; r <= 1; r++) {
|
|
329
|
+
if (row + r < 0 || moduleCount <= row + r) {
|
|
334
330
|
continue;
|
|
335
331
|
}
|
|
336
|
-
|
|
337
|
-
|
|
332
|
+
for (var c = -1; c <= 1; c++) {
|
|
333
|
+
if (col + c < 0 || moduleCount <= col + c) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (r === 0 && c === 0) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (dark === qrCode.isDark(row + r, col + c)) {
|
|
340
|
+
sameCount++;
|
|
341
|
+
}
|
|
338
342
|
}
|
|
339
343
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
344
|
+
if (sameCount > 5) {
|
|
345
|
+
lostPoint += 3 + sameCount - 5;
|
|
346
|
+
}
|
|
343
347
|
}
|
|
344
348
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
count++;
|
|
351
|
-
|
|
352
|
-
count
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (qrCode.isDark(row + 1, col + 1))
|
|
356
|
-
count++;
|
|
357
|
-
if (count === 0 || count === 4) {
|
|
358
|
-
lostPoint += 3;
|
|
349
|
+
for (row = 0; row < moduleCount - 1; row++) {
|
|
350
|
+
for (col = 0; col < moduleCount - 1; col++) {
|
|
351
|
+
var count = 0;
|
|
352
|
+
if (qrCode.isDark(row, col)) count++;
|
|
353
|
+
if (qrCode.isDark(row + 1, col)) count++;
|
|
354
|
+
if (qrCode.isDark(row, col + 1)) count++;
|
|
355
|
+
if (qrCode.isDark(row + 1, col + 1)) count++;
|
|
356
|
+
if (count === 0 || count === 4) {
|
|
357
|
+
lostPoint += 3;
|
|
358
|
+
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
for (row = 0; row < moduleCount; row++) {
|
|
362
|
+
for (col = 0; col < moduleCount - 6; col++) {
|
|
363
|
+
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)) {
|
|
364
|
+
lostPoint += 40;
|
|
365
|
+
}
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
368
|
+
for (col = 0; col < moduleCount; col++) {
|
|
369
|
+
for (row = 0; row < moduleCount - 6; row++) {
|
|
370
|
+
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)) {
|
|
371
|
+
lostPoint += 40;
|
|
372
|
+
}
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
375
|
+
var darkCount = 0;
|
|
376
|
+
for (col = 0; col < moduleCount; col++) {
|
|
377
|
+
for (row = 0; row < moduleCount; row++) {
|
|
378
|
+
if (qrCode.isDark(row, col)) {
|
|
379
|
+
darkCount++;
|
|
380
|
+
}
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
|
+
var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
|
384
|
+
lostPoint += ratio * 10;
|
|
385
|
+
return lostPoint;
|
|
383
386
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
module.exports = QRUtil;
|
|
387
|
+
};
|
|
388
|
+
module.exports = QRUtil;
|
|
389
|
+
}
|
|
390
390
|
});
|
|
391
391
|
|
|
392
392
|
// node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js
|
|
393
|
-
var require_QRErrorCorrectLevel = __commonJS(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
393
|
+
var require_QRErrorCorrectLevel = __commonJS({
|
|
394
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js"(exports, module) {
|
|
395
|
+
module.exports = {
|
|
396
|
+
L: 1,
|
|
397
|
+
M: 0,
|
|
398
|
+
Q: 3,
|
|
399
|
+
H: 2
|
|
400
|
+
};
|
|
401
|
+
}
|
|
400
402
|
});
|
|
401
403
|
|
|
402
404
|
// node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js
|
|
403
|
-
var require_QRRSBlock = __commonJS(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
QRRSBlock.RS_BLOCK_TABLE = [
|
|
410
|
-
[1, 26, 19],
|
|
411
|
-
[1, 26, 16],
|
|
412
|
-
[1, 26, 13],
|
|
413
|
-
[1, 26, 9],
|
|
414
|
-
[1, 44, 34],
|
|
415
|
-
[1, 44, 28],
|
|
416
|
-
[1, 44, 22],
|
|
417
|
-
[1, 44, 16],
|
|
418
|
-
[1, 70, 55],
|
|
419
|
-
[1, 70, 44],
|
|
420
|
-
[2, 35, 17],
|
|
421
|
-
[2, 35, 13],
|
|
422
|
-
[1, 100, 80],
|
|
423
|
-
[2, 50, 32],
|
|
424
|
-
[2, 50, 24],
|
|
425
|
-
[4, 25, 9],
|
|
426
|
-
[1, 134, 108],
|
|
427
|
-
[2, 67, 43],
|
|
428
|
-
[2, 33, 15, 2, 34, 16],
|
|
429
|
-
[2, 33, 11, 2, 34, 12],
|
|
430
|
-
[2, 86, 68],
|
|
431
|
-
[4, 43, 27],
|
|
432
|
-
[4, 43, 19],
|
|
433
|
-
[4, 43, 15],
|
|
434
|
-
[2, 98, 78],
|
|
435
|
-
[4, 49, 31],
|
|
436
|
-
[2, 32, 14, 4, 33, 15],
|
|
437
|
-
[4, 39, 13, 1, 40, 14],
|
|
438
|
-
[2, 121, 97],
|
|
439
|
-
[2, 60, 38, 2, 61, 39],
|
|
440
|
-
[4, 40, 18, 2, 41, 19],
|
|
441
|
-
[4, 40, 14, 2, 41, 15],
|
|
442
|
-
[2, 146, 116],
|
|
443
|
-
[3, 58, 36, 2, 59, 37],
|
|
444
|
-
[4, 36, 16, 4, 37, 17],
|
|
445
|
-
[4, 36, 12, 4, 37, 13],
|
|
446
|
-
[2, 86, 68, 2, 87, 69],
|
|
447
|
-
[4, 69, 43, 1, 70, 44],
|
|
448
|
-
[6, 43, 19, 2, 44, 20],
|
|
449
|
-
[6, 43, 15, 2, 44, 16],
|
|
450
|
-
[4, 101, 81],
|
|
451
|
-
[1, 80, 50, 4, 81, 51],
|
|
452
|
-
[4, 50, 22, 4, 51, 23],
|
|
453
|
-
[3, 36, 12, 8, 37, 13],
|
|
454
|
-
[2, 116, 92, 2, 117, 93],
|
|
455
|
-
[6, 58, 36, 2, 59, 37],
|
|
456
|
-
[4, 46, 20, 6, 47, 21],
|
|
457
|
-
[7, 42, 14, 4, 43, 15],
|
|
458
|
-
[4, 133, 107],
|
|
459
|
-
[8, 59, 37, 1, 60, 38],
|
|
460
|
-
[8, 44, 20, 4, 45, 21],
|
|
461
|
-
[12, 33, 11, 4, 34, 12],
|
|
462
|
-
[3, 145, 115, 1, 146, 116],
|
|
463
|
-
[4, 64, 40, 5, 65, 41],
|
|
464
|
-
[11, 36, 16, 5, 37, 17],
|
|
465
|
-
[11, 36, 12, 5, 37, 13],
|
|
466
|
-
[5, 109, 87, 1, 110, 88],
|
|
467
|
-
[5, 65, 41, 5, 66, 42],
|
|
468
|
-
[5, 54, 24, 7, 55, 25],
|
|
469
|
-
[11, 36, 12],
|
|
470
|
-
[5, 122, 98, 1, 123, 99],
|
|
471
|
-
[7, 73, 45, 3, 74, 46],
|
|
472
|
-
[15, 43, 19, 2, 44, 20],
|
|
473
|
-
[3, 45, 15, 13, 46, 16],
|
|
474
|
-
[1, 135, 107, 5, 136, 108],
|
|
475
|
-
[10, 74, 46, 1, 75, 47],
|
|
476
|
-
[1, 50, 22, 15, 51, 23],
|
|
477
|
-
[2, 42, 14, 17, 43, 15],
|
|
478
|
-
[5, 150, 120, 1, 151, 121],
|
|
479
|
-
[9, 69, 43, 4, 70, 44],
|
|
480
|
-
[17, 50, 22, 1, 51, 23],
|
|
481
|
-
[2, 42, 14, 19, 43, 15],
|
|
482
|
-
[3, 141, 113, 4, 142, 114],
|
|
483
|
-
[3, 70, 44, 11, 71, 45],
|
|
484
|
-
[17, 47, 21, 4, 48, 22],
|
|
485
|
-
[9, 39, 13, 16, 40, 14],
|
|
486
|
-
[3, 135, 107, 5, 136, 108],
|
|
487
|
-
[3, 67, 41, 13, 68, 42],
|
|
488
|
-
[15, 54, 24, 5, 55, 25],
|
|
489
|
-
[15, 43, 15, 10, 44, 16],
|
|
490
|
-
[4, 144, 116, 4, 145, 117],
|
|
491
|
-
[17, 68, 42],
|
|
492
|
-
[17, 50, 22, 6, 51, 23],
|
|
493
|
-
[19, 46, 16, 6, 47, 17],
|
|
494
|
-
[2, 139, 111, 7, 140, 112],
|
|
495
|
-
[17, 74, 46],
|
|
496
|
-
[7, 54, 24, 16, 55, 25],
|
|
497
|
-
[34, 37, 13],
|
|
498
|
-
[4, 151, 121, 5, 152, 122],
|
|
499
|
-
[4, 75, 47, 14, 76, 48],
|
|
500
|
-
[11, 54, 24, 14, 55, 25],
|
|
501
|
-
[16, 45, 15, 14, 46, 16],
|
|
502
|
-
[6, 147, 117, 4, 148, 118],
|
|
503
|
-
[6, 73, 45, 14, 74, 46],
|
|
504
|
-
[11, 54, 24, 16, 55, 25],
|
|
505
|
-
[30, 46, 16, 2, 47, 17],
|
|
506
|
-
[8, 132, 106, 4, 133, 107],
|
|
507
|
-
[8, 75, 47, 13, 76, 48],
|
|
508
|
-
[7, 54, 24, 22, 55, 25],
|
|
509
|
-
[22, 45, 15, 13, 46, 16],
|
|
510
|
-
[10, 142, 114, 2, 143, 115],
|
|
511
|
-
[19, 74, 46, 4, 75, 47],
|
|
512
|
-
[28, 50, 22, 6, 51, 23],
|
|
513
|
-
[33, 46, 16, 4, 47, 17],
|
|
514
|
-
[8, 152, 122, 4, 153, 123],
|
|
515
|
-
[22, 73, 45, 3, 74, 46],
|
|
516
|
-
[8, 53, 23, 26, 54, 24],
|
|
517
|
-
[12, 45, 15, 28, 46, 16],
|
|
518
|
-
[3, 147, 117, 10, 148, 118],
|
|
519
|
-
[3, 73, 45, 23, 74, 46],
|
|
520
|
-
[4, 54, 24, 31, 55, 25],
|
|
521
|
-
[11, 45, 15, 31, 46, 16],
|
|
522
|
-
[7, 146, 116, 7, 147, 117],
|
|
523
|
-
[21, 73, 45, 7, 74, 46],
|
|
524
|
-
[1, 53, 23, 37, 54, 24],
|
|
525
|
-
[19, 45, 15, 26, 46, 16],
|
|
526
|
-
[5, 145, 115, 10, 146, 116],
|
|
527
|
-
[19, 75, 47, 10, 76, 48],
|
|
528
|
-
[15, 54, 24, 25, 55, 25],
|
|
529
|
-
[23, 45, 15, 25, 46, 16],
|
|
530
|
-
[13, 145, 115, 3, 146, 116],
|
|
531
|
-
[2, 74, 46, 29, 75, 47],
|
|
532
|
-
[42, 54, 24, 1, 55, 25],
|
|
533
|
-
[23, 45, 15, 28, 46, 16],
|
|
534
|
-
[17, 145, 115],
|
|
535
|
-
[10, 74, 46, 23, 75, 47],
|
|
536
|
-
[10, 54, 24, 35, 55, 25],
|
|
537
|
-
[19, 45, 15, 35, 46, 16],
|
|
538
|
-
[17, 145, 115, 1, 146, 116],
|
|
539
|
-
[14, 74, 46, 21, 75, 47],
|
|
540
|
-
[29, 54, 24, 19, 55, 25],
|
|
541
|
-
[11, 45, 15, 46, 46, 16],
|
|
542
|
-
[13, 145, 115, 6, 146, 116],
|
|
543
|
-
[14, 74, 46, 23, 75, 47],
|
|
544
|
-
[44, 54, 24, 7, 55, 25],
|
|
545
|
-
[59, 46, 16, 1, 47, 17],
|
|
546
|
-
[12, 151, 121, 7, 152, 122],
|
|
547
|
-
[12, 75, 47, 26, 76, 48],
|
|
548
|
-
[39, 54, 24, 14, 55, 25],
|
|
549
|
-
[22, 45, 15, 41, 46, 16],
|
|
550
|
-
[6, 151, 121, 14, 152, 122],
|
|
551
|
-
[6, 75, 47, 34, 76, 48],
|
|
552
|
-
[46, 54, 24, 10, 55, 25],
|
|
553
|
-
[2, 45, 15, 64, 46, 16],
|
|
554
|
-
[17, 152, 122, 4, 153, 123],
|
|
555
|
-
[29, 74, 46, 14, 75, 47],
|
|
556
|
-
[49, 54, 24, 10, 55, 25],
|
|
557
|
-
[24, 45, 15, 46, 46, 16],
|
|
558
|
-
[4, 152, 122, 18, 153, 123],
|
|
559
|
-
[13, 74, 46, 32, 75, 47],
|
|
560
|
-
[48, 54, 24, 14, 55, 25],
|
|
561
|
-
[42, 45, 15, 32, 46, 16],
|
|
562
|
-
[20, 147, 117, 4, 148, 118],
|
|
563
|
-
[40, 75, 47, 7, 76, 48],
|
|
564
|
-
[43, 54, 24, 22, 55, 25],
|
|
565
|
-
[10, 45, 15, 67, 46, 16],
|
|
566
|
-
[19, 148, 118, 6, 149, 119],
|
|
567
|
-
[18, 75, 47, 31, 76, 48],
|
|
568
|
-
[34, 54, 24, 34, 55, 25],
|
|
569
|
-
[20, 45, 15, 61, 46, 16]
|
|
570
|
-
];
|
|
571
|
-
QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
|
|
572
|
-
var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
|
|
573
|
-
if (rsBlock === undefined) {
|
|
574
|
-
throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
|
|
405
|
+
var require_QRRSBlock = __commonJS({
|
|
406
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js"(exports, module) {
|
|
407
|
+
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
408
|
+
function QRRSBlock(totalCount, dataCount) {
|
|
409
|
+
this.totalCount = totalCount;
|
|
410
|
+
this.dataCount = dataCount;
|
|
575
411
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
412
|
+
QRRSBlock.RS_BLOCK_TABLE = [
|
|
413
|
+
// L
|
|
414
|
+
// M
|
|
415
|
+
// Q
|
|
416
|
+
// H
|
|
417
|
+
// 1
|
|
418
|
+
[1, 26, 19],
|
|
419
|
+
[1, 26, 16],
|
|
420
|
+
[1, 26, 13],
|
|
421
|
+
[1, 26, 9],
|
|
422
|
+
// 2
|
|
423
|
+
[1, 44, 34],
|
|
424
|
+
[1, 44, 28],
|
|
425
|
+
[1, 44, 22],
|
|
426
|
+
[1, 44, 16],
|
|
427
|
+
// 3
|
|
428
|
+
[1, 70, 55],
|
|
429
|
+
[1, 70, 44],
|
|
430
|
+
[2, 35, 17],
|
|
431
|
+
[2, 35, 13],
|
|
432
|
+
// 4
|
|
433
|
+
[1, 100, 80],
|
|
434
|
+
[2, 50, 32],
|
|
435
|
+
[2, 50, 24],
|
|
436
|
+
[4, 25, 9],
|
|
437
|
+
// 5
|
|
438
|
+
[1, 134, 108],
|
|
439
|
+
[2, 67, 43],
|
|
440
|
+
[2, 33, 15, 2, 34, 16],
|
|
441
|
+
[2, 33, 11, 2, 34, 12],
|
|
442
|
+
// 6
|
|
443
|
+
[2, 86, 68],
|
|
444
|
+
[4, 43, 27],
|
|
445
|
+
[4, 43, 19],
|
|
446
|
+
[4, 43, 15],
|
|
447
|
+
// 7
|
|
448
|
+
[2, 98, 78],
|
|
449
|
+
[4, 49, 31],
|
|
450
|
+
[2, 32, 14, 4, 33, 15],
|
|
451
|
+
[4, 39, 13, 1, 40, 14],
|
|
452
|
+
// 8
|
|
453
|
+
[2, 121, 97],
|
|
454
|
+
[2, 60, 38, 2, 61, 39],
|
|
455
|
+
[4, 40, 18, 2, 41, 19],
|
|
456
|
+
[4, 40, 14, 2, 41, 15],
|
|
457
|
+
// 9
|
|
458
|
+
[2, 146, 116],
|
|
459
|
+
[3, 58, 36, 2, 59, 37],
|
|
460
|
+
[4, 36, 16, 4, 37, 17],
|
|
461
|
+
[4, 36, 12, 4, 37, 13],
|
|
462
|
+
// 10
|
|
463
|
+
[2, 86, 68, 2, 87, 69],
|
|
464
|
+
[4, 69, 43, 1, 70, 44],
|
|
465
|
+
[6, 43, 19, 2, 44, 20],
|
|
466
|
+
[6, 43, 15, 2, 44, 16],
|
|
467
|
+
// 11
|
|
468
|
+
[4, 101, 81],
|
|
469
|
+
[1, 80, 50, 4, 81, 51],
|
|
470
|
+
[4, 50, 22, 4, 51, 23],
|
|
471
|
+
[3, 36, 12, 8, 37, 13],
|
|
472
|
+
// 12
|
|
473
|
+
[2, 116, 92, 2, 117, 93],
|
|
474
|
+
[6, 58, 36, 2, 59, 37],
|
|
475
|
+
[4, 46, 20, 6, 47, 21],
|
|
476
|
+
[7, 42, 14, 4, 43, 15],
|
|
477
|
+
// 13
|
|
478
|
+
[4, 133, 107],
|
|
479
|
+
[8, 59, 37, 1, 60, 38],
|
|
480
|
+
[8, 44, 20, 4, 45, 21],
|
|
481
|
+
[12, 33, 11, 4, 34, 12],
|
|
482
|
+
// 14
|
|
483
|
+
[3, 145, 115, 1, 146, 116],
|
|
484
|
+
[4, 64, 40, 5, 65, 41],
|
|
485
|
+
[11, 36, 16, 5, 37, 17],
|
|
486
|
+
[11, 36, 12, 5, 37, 13],
|
|
487
|
+
// 15
|
|
488
|
+
[5, 109, 87, 1, 110, 88],
|
|
489
|
+
[5, 65, 41, 5, 66, 42],
|
|
490
|
+
[5, 54, 24, 7, 55, 25],
|
|
491
|
+
[11, 36, 12],
|
|
492
|
+
// 16
|
|
493
|
+
[5, 122, 98, 1, 123, 99],
|
|
494
|
+
[7, 73, 45, 3, 74, 46],
|
|
495
|
+
[15, 43, 19, 2, 44, 20],
|
|
496
|
+
[3, 45, 15, 13, 46, 16],
|
|
497
|
+
// 17
|
|
498
|
+
[1, 135, 107, 5, 136, 108],
|
|
499
|
+
[10, 74, 46, 1, 75, 47],
|
|
500
|
+
[1, 50, 22, 15, 51, 23],
|
|
501
|
+
[2, 42, 14, 17, 43, 15],
|
|
502
|
+
// 18
|
|
503
|
+
[5, 150, 120, 1, 151, 121],
|
|
504
|
+
[9, 69, 43, 4, 70, 44],
|
|
505
|
+
[17, 50, 22, 1, 51, 23],
|
|
506
|
+
[2, 42, 14, 19, 43, 15],
|
|
507
|
+
// 19
|
|
508
|
+
[3, 141, 113, 4, 142, 114],
|
|
509
|
+
[3, 70, 44, 11, 71, 45],
|
|
510
|
+
[17, 47, 21, 4, 48, 22],
|
|
511
|
+
[9, 39, 13, 16, 40, 14],
|
|
512
|
+
// 20
|
|
513
|
+
[3, 135, 107, 5, 136, 108],
|
|
514
|
+
[3, 67, 41, 13, 68, 42],
|
|
515
|
+
[15, 54, 24, 5, 55, 25],
|
|
516
|
+
[15, 43, 15, 10, 44, 16],
|
|
517
|
+
// 21
|
|
518
|
+
[4, 144, 116, 4, 145, 117],
|
|
519
|
+
[17, 68, 42],
|
|
520
|
+
[17, 50, 22, 6, 51, 23],
|
|
521
|
+
[19, 46, 16, 6, 47, 17],
|
|
522
|
+
// 22
|
|
523
|
+
[2, 139, 111, 7, 140, 112],
|
|
524
|
+
[17, 74, 46],
|
|
525
|
+
[7, 54, 24, 16, 55, 25],
|
|
526
|
+
[34, 37, 13],
|
|
527
|
+
// 23
|
|
528
|
+
[4, 151, 121, 5, 152, 122],
|
|
529
|
+
[4, 75, 47, 14, 76, 48],
|
|
530
|
+
[11, 54, 24, 14, 55, 25],
|
|
531
|
+
[16, 45, 15, 14, 46, 16],
|
|
532
|
+
// 24
|
|
533
|
+
[6, 147, 117, 4, 148, 118],
|
|
534
|
+
[6, 73, 45, 14, 74, 46],
|
|
535
|
+
[11, 54, 24, 16, 55, 25],
|
|
536
|
+
[30, 46, 16, 2, 47, 17],
|
|
537
|
+
// 25
|
|
538
|
+
[8, 132, 106, 4, 133, 107],
|
|
539
|
+
[8, 75, 47, 13, 76, 48],
|
|
540
|
+
[7, 54, 24, 22, 55, 25],
|
|
541
|
+
[22, 45, 15, 13, 46, 16],
|
|
542
|
+
// 26
|
|
543
|
+
[10, 142, 114, 2, 143, 115],
|
|
544
|
+
[19, 74, 46, 4, 75, 47],
|
|
545
|
+
[28, 50, 22, 6, 51, 23],
|
|
546
|
+
[33, 46, 16, 4, 47, 17],
|
|
547
|
+
// 27
|
|
548
|
+
[8, 152, 122, 4, 153, 123],
|
|
549
|
+
[22, 73, 45, 3, 74, 46],
|
|
550
|
+
[8, 53, 23, 26, 54, 24],
|
|
551
|
+
[12, 45, 15, 28, 46, 16],
|
|
552
|
+
// 28
|
|
553
|
+
[3, 147, 117, 10, 148, 118],
|
|
554
|
+
[3, 73, 45, 23, 74, 46],
|
|
555
|
+
[4, 54, 24, 31, 55, 25],
|
|
556
|
+
[11, 45, 15, 31, 46, 16],
|
|
557
|
+
// 29
|
|
558
|
+
[7, 146, 116, 7, 147, 117],
|
|
559
|
+
[21, 73, 45, 7, 74, 46],
|
|
560
|
+
[1, 53, 23, 37, 54, 24],
|
|
561
|
+
[19, 45, 15, 26, 46, 16],
|
|
562
|
+
// 30
|
|
563
|
+
[5, 145, 115, 10, 146, 116],
|
|
564
|
+
[19, 75, 47, 10, 76, 48],
|
|
565
|
+
[15, 54, 24, 25, 55, 25],
|
|
566
|
+
[23, 45, 15, 25, 46, 16],
|
|
567
|
+
// 31
|
|
568
|
+
[13, 145, 115, 3, 146, 116],
|
|
569
|
+
[2, 74, 46, 29, 75, 47],
|
|
570
|
+
[42, 54, 24, 1, 55, 25],
|
|
571
|
+
[23, 45, 15, 28, 46, 16],
|
|
572
|
+
// 32
|
|
573
|
+
[17, 145, 115],
|
|
574
|
+
[10, 74, 46, 23, 75, 47],
|
|
575
|
+
[10, 54, 24, 35, 55, 25],
|
|
576
|
+
[19, 45, 15, 35, 46, 16],
|
|
577
|
+
// 33
|
|
578
|
+
[17, 145, 115, 1, 146, 116],
|
|
579
|
+
[14, 74, 46, 21, 75, 47],
|
|
580
|
+
[29, 54, 24, 19, 55, 25],
|
|
581
|
+
[11, 45, 15, 46, 46, 16],
|
|
582
|
+
// 34
|
|
583
|
+
[13, 145, 115, 6, 146, 116],
|
|
584
|
+
[14, 74, 46, 23, 75, 47],
|
|
585
|
+
[44, 54, 24, 7, 55, 25],
|
|
586
|
+
[59, 46, 16, 1, 47, 17],
|
|
587
|
+
// 35
|
|
588
|
+
[12, 151, 121, 7, 152, 122],
|
|
589
|
+
[12, 75, 47, 26, 76, 48],
|
|
590
|
+
[39, 54, 24, 14, 55, 25],
|
|
591
|
+
[22, 45, 15, 41, 46, 16],
|
|
592
|
+
// 36
|
|
593
|
+
[6, 151, 121, 14, 152, 122],
|
|
594
|
+
[6, 75, 47, 34, 76, 48],
|
|
595
|
+
[46, 54, 24, 10, 55, 25],
|
|
596
|
+
[2, 45, 15, 64, 46, 16],
|
|
597
|
+
// 37
|
|
598
|
+
[17, 152, 122, 4, 153, 123],
|
|
599
|
+
[29, 74, 46, 14, 75, 47],
|
|
600
|
+
[49, 54, 24, 10, 55, 25],
|
|
601
|
+
[24, 45, 15, 46, 46, 16],
|
|
602
|
+
// 38
|
|
603
|
+
[4, 152, 122, 18, 153, 123],
|
|
604
|
+
[13, 74, 46, 32, 75, 47],
|
|
605
|
+
[48, 54, 24, 14, 55, 25],
|
|
606
|
+
[42, 45, 15, 32, 46, 16],
|
|
607
|
+
// 39
|
|
608
|
+
[20, 147, 117, 4, 148, 118],
|
|
609
|
+
[40, 75, 47, 7, 76, 48],
|
|
610
|
+
[43, 54, 24, 22, 55, 25],
|
|
611
|
+
[10, 45, 15, 67, 46, 16],
|
|
612
|
+
// 40
|
|
613
|
+
[19, 148, 118, 6, 149, 119],
|
|
614
|
+
[18, 75, 47, 31, 76, 48],
|
|
615
|
+
[34, 54, 24, 34, 55, 25],
|
|
616
|
+
[20, 45, 15, 61, 46, 16]
|
|
617
|
+
];
|
|
618
|
+
QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
|
|
619
|
+
var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
|
|
620
|
+
if (rsBlock === void 0) {
|
|
621
|
+
throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
|
|
584
622
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
623
|
+
var length = rsBlock.length / 3;
|
|
624
|
+
var list = [];
|
|
625
|
+
for (var i = 0; i < length; i++) {
|
|
626
|
+
var count = rsBlock[i * 3 + 0];
|
|
627
|
+
var totalCount = rsBlock[i * 3 + 1];
|
|
628
|
+
var dataCount = rsBlock[i * 3 + 2];
|
|
629
|
+
for (var j = 0; j < count; j++) {
|
|
630
|
+
list.push(new QRRSBlock(totalCount, dataCount));
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return list;
|
|
634
|
+
};
|
|
635
|
+
QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
|
|
636
|
+
switch (errorCorrectLevel) {
|
|
637
|
+
case QRErrorCorrectLevel.L:
|
|
638
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
|
639
|
+
case QRErrorCorrectLevel.M:
|
|
640
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
|
641
|
+
case QRErrorCorrectLevel.Q:
|
|
642
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
|
643
|
+
case QRErrorCorrectLevel.H:
|
|
644
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
|
645
|
+
default:
|
|
646
|
+
return void 0;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
module.exports = QRRSBlock;
|
|
650
|
+
}
|
|
603
651
|
});
|
|
604
652
|
|
|
605
653
|
// node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js
|
|
606
|
-
var require_QRBitBuffer = __commonJS(
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
QRBitBuffer.prototype = {
|
|
612
|
-
get: function(index) {
|
|
613
|
-
var bufIndex = Math.floor(index / 8);
|
|
614
|
-
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
|
|
615
|
-
},
|
|
616
|
-
put: function(num, length) {
|
|
617
|
-
for (var i = 0;i < length; i++) {
|
|
618
|
-
this.putBit((num >>> length - i - 1 & 1) == 1);
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
getLengthInBits: function() {
|
|
622
|
-
return this.length;
|
|
623
|
-
},
|
|
624
|
-
putBit: function(bit) {
|
|
625
|
-
var bufIndex = Math.floor(this.length / 8);
|
|
626
|
-
if (this.buffer.length <= bufIndex) {
|
|
627
|
-
this.buffer.push(0);
|
|
628
|
-
}
|
|
629
|
-
if (bit) {
|
|
630
|
-
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
631
|
-
}
|
|
632
|
-
this.length++;
|
|
654
|
+
var require_QRBitBuffer = __commonJS({
|
|
655
|
+
"node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js"(exports, module) {
|
|
656
|
+
function QRBitBuffer() {
|
|
657
|
+
this.buffer = [];
|
|
658
|
+
this.length = 0;
|
|
633
659
|
}
|
|
634
|
-
|
|
635
|
-
|
|
660
|
+
QRBitBuffer.prototype = {
|
|
661
|
+
get: function(index) {
|
|
662
|
+
var bufIndex = Math.floor(index / 8);
|
|
663
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
|
|
664
|
+
},
|
|
665
|
+
put: function(num, length) {
|
|
666
|
+
for (var i = 0; i < length; i++) {
|
|
667
|
+
this.putBit((num >>> length - i - 1 & 1) == 1);
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
getLengthInBits: function() {
|
|
671
|
+
return this.length;
|
|
672
|
+
},
|
|
673
|
+
putBit: function(bit) {
|
|
674
|
+
var bufIndex = Math.floor(this.length / 8);
|
|
675
|
+
if (this.buffer.length <= bufIndex) {
|
|
676
|
+
this.buffer.push(0);
|
|
677
|
+
}
|
|
678
|
+
if (bit) {
|
|
679
|
+
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
680
|
+
}
|
|
681
|
+
this.length++;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
module.exports = QRBitBuffer;
|
|
685
|
+
}
|
|
636
686
|
});
|
|
637
687
|
|
|
638
688
|
// node_modules/qrcode-terminal/vendor/QRCode/index.js
|
|
639
|
-
var require_QRCode = __commonJS(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
this.dataList = [];
|
|
652
|
-
}
|
|
653
|
-
QRCode.prototype = {
|
|
654
|
-
addData: function(data) {
|
|
655
|
-
var newData = new QR8bitByte(data);
|
|
656
|
-
this.dataList.push(newData);
|
|
689
|
+
var require_QRCode = __commonJS({
|
|
690
|
+
"node_modules/qrcode-terminal/vendor/QRCode/index.js"(exports, module) {
|
|
691
|
+
var QR8bitByte = require_QR8bitByte();
|
|
692
|
+
var QRUtil = require_QRUtil();
|
|
693
|
+
var QRPolynomial = require_QRPolynomial();
|
|
694
|
+
var QRRSBlock = require_QRRSBlock();
|
|
695
|
+
var QRBitBuffer = require_QRBitBuffer();
|
|
696
|
+
function QRCode(typeNumber, errorCorrectLevel) {
|
|
697
|
+
this.typeNumber = typeNumber;
|
|
698
|
+
this.errorCorrectLevel = errorCorrectLevel;
|
|
699
|
+
this.modules = null;
|
|
700
|
+
this.moduleCount = 0;
|
|
657
701
|
this.dataCache = null;
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
702
|
+
this.dataList = [];
|
|
703
|
+
}
|
|
704
|
+
QRCode.prototype = {
|
|
705
|
+
addData: function(data) {
|
|
706
|
+
var newData = new QR8bitByte(data);
|
|
707
|
+
this.dataList.push(newData);
|
|
708
|
+
this.dataCache = null;
|
|
709
|
+
},
|
|
710
|
+
isDark: function(row, col) {
|
|
711
|
+
if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
|
|
712
|
+
throw new Error(row + "," + col);
|
|
713
|
+
}
|
|
714
|
+
return this.modules[row][col];
|
|
715
|
+
},
|
|
716
|
+
getModuleCount: function() {
|
|
717
|
+
return this.moduleCount;
|
|
718
|
+
},
|
|
719
|
+
make: function() {
|
|
720
|
+
if (this.typeNumber < 1) {
|
|
721
|
+
var typeNumber = 1;
|
|
722
|
+
for (typeNumber = 1; typeNumber < 40; typeNumber++) {
|
|
723
|
+
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
|
|
724
|
+
var buffer = new QRBitBuffer();
|
|
725
|
+
var totalDataCount = 0;
|
|
726
|
+
for (var i = 0; i < rsBlocks.length; i++) {
|
|
727
|
+
totalDataCount += rsBlocks[i].dataCount;
|
|
728
|
+
}
|
|
729
|
+
for (var x = 0; x < this.dataList.length; x++) {
|
|
730
|
+
var data = this.dataList[x];
|
|
731
|
+
buffer.put(data.mode, 4);
|
|
732
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
|
|
733
|
+
data.write(buffer);
|
|
734
|
+
}
|
|
735
|
+
if (buffer.getLengthInBits() <= totalDataCount * 8)
|
|
736
|
+
break;
|
|
677
737
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
738
|
+
this.typeNumber = typeNumber;
|
|
739
|
+
}
|
|
740
|
+
this.makeImpl(false, this.getBestMaskPattern());
|
|
741
|
+
},
|
|
742
|
+
makeImpl: function(test, maskPattern) {
|
|
743
|
+
this.moduleCount = this.typeNumber * 4 + 17;
|
|
744
|
+
this.modules = new Array(this.moduleCount);
|
|
745
|
+
for (var row = 0; row < this.moduleCount; row++) {
|
|
746
|
+
this.modules[row] = new Array(this.moduleCount);
|
|
747
|
+
for (var col = 0; col < this.moduleCount; col++) {
|
|
748
|
+
this.modules[row][col] = null;
|
|
683
749
|
}
|
|
684
|
-
if (buffer.getLengthInBits() <= totalDataCount * 8)
|
|
685
|
-
break;
|
|
686
750
|
}
|
|
687
|
-
this.
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
this.modules[row] = new Array(this.moduleCount);
|
|
696
|
-
for (var col = 0;col < this.moduleCount; col++) {
|
|
697
|
-
this.modules[row][col] = null;
|
|
751
|
+
this.setupPositionProbePattern(0, 0);
|
|
752
|
+
this.setupPositionProbePattern(this.moduleCount - 7, 0);
|
|
753
|
+
this.setupPositionProbePattern(0, this.moduleCount - 7);
|
|
754
|
+
this.setupPositionAdjustPattern();
|
|
755
|
+
this.setupTimingPattern();
|
|
756
|
+
this.setupTypeInfo(test, maskPattern);
|
|
757
|
+
if (this.typeNumber >= 7) {
|
|
758
|
+
this.setupTypeNumber(test);
|
|
698
759
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
this.setupPositionProbePattern(this.moduleCount - 7, 0);
|
|
702
|
-
this.setupPositionProbePattern(0, this.moduleCount - 7);
|
|
703
|
-
this.setupPositionAdjustPattern();
|
|
704
|
-
this.setupTimingPattern();
|
|
705
|
-
this.setupTypeInfo(test, maskPattern);
|
|
706
|
-
if (this.typeNumber >= 7) {
|
|
707
|
-
this.setupTypeNumber(test);
|
|
708
|
-
}
|
|
709
|
-
if (this.dataCache === null) {
|
|
710
|
-
this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
|
|
711
|
-
}
|
|
712
|
-
this.mapData(this.dataCache, maskPattern);
|
|
713
|
-
},
|
|
714
|
-
setupPositionProbePattern: function(row, col) {
|
|
715
|
-
for (var r = -1;r <= 7; r++) {
|
|
716
|
-
if (row + r <= -1 || this.moduleCount <= row + r)
|
|
717
|
-
continue;
|
|
718
|
-
for (var c = -1;c <= 7; c++) {
|
|
719
|
-
if (col + c <= -1 || this.moduleCount <= col + c)
|
|
720
|
-
continue;
|
|
721
|
-
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) {
|
|
722
|
-
this.modules[row + r][col + c] = true;
|
|
723
|
-
} else {
|
|
724
|
-
this.modules[row + r][col + c] = false;
|
|
725
|
-
}
|
|
760
|
+
if (this.dataCache === null) {
|
|
761
|
+
this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
|
|
726
762
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
763
|
+
this.mapData(this.dataCache, maskPattern);
|
|
764
|
+
},
|
|
765
|
+
setupPositionProbePattern: function(row, col) {
|
|
766
|
+
for (var r = -1; r <= 7; r++) {
|
|
767
|
+
if (row + r <= -1 || this.moduleCount <= row + r) continue;
|
|
768
|
+
for (var c = -1; c <= 7; c++) {
|
|
769
|
+
if (col + c <= -1 || this.moduleCount <= col + c) continue;
|
|
770
|
+
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) {
|
|
771
|
+
this.modules[row + r][col + c] = true;
|
|
772
|
+
} else {
|
|
773
|
+
this.modules[row + r][col + c] = false;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
738
776
|
}
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
var x = col * cs;
|
|
750
|
-
var dark = this.modules[row][col];
|
|
751
|
-
if (dark) {
|
|
752
|
-
qr_mc.beginFill(0, 100);
|
|
753
|
-
qr_mc.moveTo(x, y);
|
|
754
|
-
qr_mc.lineTo(x + cs, y);
|
|
755
|
-
qr_mc.lineTo(x + cs, y + cs);
|
|
756
|
-
qr_mc.lineTo(x, y + cs);
|
|
757
|
-
qr_mc.endFill();
|
|
777
|
+
},
|
|
778
|
+
getBestMaskPattern: function() {
|
|
779
|
+
var minLostPoint = 0;
|
|
780
|
+
var pattern = 0;
|
|
781
|
+
for (var i = 0; i < 8; i++) {
|
|
782
|
+
this.makeImpl(true, i);
|
|
783
|
+
var lostPoint = QRUtil.getLostPoint(this);
|
|
784
|
+
if (i === 0 || minLostPoint > lostPoint) {
|
|
785
|
+
minLostPoint = lostPoint;
|
|
786
|
+
pattern = i;
|
|
758
787
|
}
|
|
759
788
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
789
|
+
return pattern;
|
|
790
|
+
},
|
|
791
|
+
createMovieClip: function(target_mc, instance_name, depth) {
|
|
792
|
+
var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
|
|
793
|
+
var cs = 1;
|
|
794
|
+
this.make();
|
|
795
|
+
for (var row = 0; row < this.modules.length; row++) {
|
|
796
|
+
var y = row * cs;
|
|
797
|
+
for (var col = 0; col < this.modules[row].length; col++) {
|
|
798
|
+
var x = col * cs;
|
|
799
|
+
var dark = this.modules[row][col];
|
|
800
|
+
if (dark) {
|
|
801
|
+
qr_mc.beginFill(0, 100);
|
|
802
|
+
qr_mc.moveTo(x, y);
|
|
803
|
+
qr_mc.lineTo(x + cs, y);
|
|
804
|
+
qr_mc.lineTo(x + cs, y + cs);
|
|
805
|
+
qr_mc.lineTo(x, y + cs);
|
|
806
|
+
qr_mc.endFill();
|
|
807
|
+
}
|
|
808
|
+
}
|
|
767
809
|
}
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
810
|
+
return qr_mc;
|
|
811
|
+
},
|
|
812
|
+
setupTimingPattern: function() {
|
|
813
|
+
for (var r = 8; r < this.moduleCount - 8; r++) {
|
|
814
|
+
if (this.modules[r][6] !== null) {
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
this.modules[r][6] = r % 2 === 0;
|
|
773
818
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
},
|
|
777
|
-
setupPositionAdjustPattern: function() {
|
|
778
|
-
var pos = QRUtil.getPatternPosition(this.typeNumber);
|
|
779
|
-
for (var i = 0;i < pos.length; i++) {
|
|
780
|
-
for (var j = 0;j < pos.length; j++) {
|
|
781
|
-
var row = pos[i];
|
|
782
|
-
var col = pos[j];
|
|
783
|
-
if (this.modules[row][col] !== null) {
|
|
819
|
+
for (var c = 8; c < this.moduleCount - 8; c++) {
|
|
820
|
+
if (this.modules[6][c] !== null) {
|
|
784
821
|
continue;
|
|
785
822
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
823
|
+
this.modules[6][c] = c % 2 === 0;
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
setupPositionAdjustPattern: function() {
|
|
827
|
+
var pos = QRUtil.getPatternPosition(this.typeNumber);
|
|
828
|
+
for (var i = 0; i < pos.length; i++) {
|
|
829
|
+
for (var j = 0; j < pos.length; j++) {
|
|
830
|
+
var row = pos[i];
|
|
831
|
+
var col = pos[j];
|
|
832
|
+
if (this.modules[row][col] !== null) {
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
for (var r = -2; r <= 2; r++) {
|
|
836
|
+
for (var c = -2; c <= 2; c++) {
|
|
837
|
+
if (Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0) {
|
|
838
|
+
this.modules[row + r][col + c] = true;
|
|
839
|
+
} else {
|
|
840
|
+
this.modules[row + r][col + c] = false;
|
|
841
|
+
}
|
|
792
842
|
}
|
|
793
843
|
}
|
|
794
844
|
}
|
|
795
845
|
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
|
|
804
|
-
}
|
|
805
|
-
for (var x = 0;x < 18; x++) {
|
|
806
|
-
mod = !test && (bits >> x & 1) === 1;
|
|
807
|
-
this.modules[x % 3 + this.moduleCount - 8 - 3][Math.floor(x / 3)] = mod;
|
|
808
|
-
}
|
|
809
|
-
},
|
|
810
|
-
setupTypeInfo: function(test, maskPattern) {
|
|
811
|
-
var data = this.errorCorrectLevel << 3 | maskPattern;
|
|
812
|
-
var bits = QRUtil.getBCHTypeInfo(data);
|
|
813
|
-
var mod;
|
|
814
|
-
for (var v = 0;v < 15; v++) {
|
|
815
|
-
mod = !test && (bits >> v & 1) === 1;
|
|
816
|
-
if (v < 6) {
|
|
817
|
-
this.modules[v][8] = mod;
|
|
818
|
-
} else if (v < 8) {
|
|
819
|
-
this.modules[v + 1][8] = mod;
|
|
820
|
-
} else {
|
|
821
|
-
this.modules[this.moduleCount - 15 + v][8] = mod;
|
|
846
|
+
},
|
|
847
|
+
setupTypeNumber: function(test) {
|
|
848
|
+
var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
|
|
849
|
+
var mod;
|
|
850
|
+
for (var i = 0; i < 18; i++) {
|
|
851
|
+
mod = !test && (bits >> i & 1) === 1;
|
|
852
|
+
this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
|
|
822
853
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
if (h < 8) {
|
|
827
|
-
this.modules[8][this.moduleCount - h - 1] = mod;
|
|
828
|
-
} else if (h < 9) {
|
|
829
|
-
this.modules[8][15 - h - 1 + 1] = mod;
|
|
830
|
-
} else {
|
|
831
|
-
this.modules[8][15 - h - 1] = mod;
|
|
854
|
+
for (var x = 0; x < 18; x++) {
|
|
855
|
+
mod = !test && (bits >> x & 1) === 1;
|
|
856
|
+
this.modules[x % 3 + this.moduleCount - 8 - 3][Math.floor(x / 3)] = mod;
|
|
832
857
|
}
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
858
|
+
},
|
|
859
|
+
setupTypeInfo: function(test, maskPattern) {
|
|
860
|
+
var data = this.errorCorrectLevel << 3 | maskPattern;
|
|
861
|
+
var bits = QRUtil.getBCHTypeInfo(data);
|
|
862
|
+
var mod;
|
|
863
|
+
for (var v = 0; v < 15; v++) {
|
|
864
|
+
mod = !test && (bits >> v & 1) === 1;
|
|
865
|
+
if (v < 6) {
|
|
866
|
+
this.modules[v][8] = mod;
|
|
867
|
+
} else if (v < 8) {
|
|
868
|
+
this.modules[v + 1][8] = mod;
|
|
869
|
+
} else {
|
|
870
|
+
this.modules[this.moduleCount - 15 + v][8] = mod;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
for (var h = 0; h < 15; h++) {
|
|
874
|
+
mod = !test && (bits >> h & 1) === 1;
|
|
875
|
+
if (h < 8) {
|
|
876
|
+
this.modules[8][this.moduleCount - h - 1] = mod;
|
|
877
|
+
} else if (h < 9) {
|
|
878
|
+
this.modules[8][15 - h - 1 + 1] = mod;
|
|
879
|
+
} else {
|
|
880
|
+
this.modules[8][15 - h - 1] = mod;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
this.modules[this.moduleCount - 8][8] = !test;
|
|
884
|
+
},
|
|
885
|
+
mapData: function(data, maskPattern) {
|
|
886
|
+
var inc = -1;
|
|
887
|
+
var row = this.moduleCount - 1;
|
|
888
|
+
var bitIndex = 7;
|
|
889
|
+
var byteIndex = 0;
|
|
890
|
+
for (var col = this.moduleCount - 1; col > 0; col -= 2) {
|
|
891
|
+
if (col === 6) col--;
|
|
892
|
+
while (true) {
|
|
893
|
+
for (var c = 0; c < 2; c++) {
|
|
894
|
+
if (this.modules[row][col - c] === null) {
|
|
895
|
+
var dark = false;
|
|
896
|
+
if (byteIndex < data.length) {
|
|
897
|
+
dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
898
|
+
}
|
|
899
|
+
var mask = QRUtil.getMask(maskPattern, row, col - c);
|
|
900
|
+
if (mask) {
|
|
901
|
+
dark = !dark;
|
|
902
|
+
}
|
|
903
|
+
this.modules[row][col - c] = dark;
|
|
904
|
+
bitIndex--;
|
|
905
|
+
if (bitIndex === -1) {
|
|
906
|
+
byteIndex++;
|
|
907
|
+
bitIndex = 7;
|
|
908
|
+
}
|
|
860
909
|
}
|
|
861
910
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
911
|
+
row += inc;
|
|
912
|
+
if (row < 0 || this.moduleCount <= row) {
|
|
913
|
+
row -= inc;
|
|
914
|
+
inc = -inc;
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
868
917
|
}
|
|
869
918
|
}
|
|
870
919
|
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
data.write(buffer);
|
|
883
|
-
}
|
|
884
|
-
var totalDataCount = 0;
|
|
885
|
-
for (var x = 0;x < rsBlocks.length; x++) {
|
|
886
|
-
totalDataCount += rsBlocks[x].dataCount;
|
|
887
|
-
}
|
|
888
|
-
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
889
|
-
throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
|
|
890
|
-
}
|
|
891
|
-
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
|
892
|
-
buffer.put(0, 4);
|
|
893
|
-
}
|
|
894
|
-
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
895
|
-
buffer.putBit(false);
|
|
896
|
-
}
|
|
897
|
-
while (true) {
|
|
898
|
-
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
899
|
-
break;
|
|
920
|
+
};
|
|
921
|
+
QRCode.PAD0 = 236;
|
|
922
|
+
QRCode.PAD1 = 17;
|
|
923
|
+
QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
|
|
924
|
+
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
|
|
925
|
+
var buffer = new QRBitBuffer();
|
|
926
|
+
for (var i = 0; i < dataList.length; i++) {
|
|
927
|
+
var data = dataList[i];
|
|
928
|
+
buffer.put(data.mode, 4);
|
|
929
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
|
|
930
|
+
data.write(buffer);
|
|
900
931
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
932
|
+
var totalDataCount = 0;
|
|
933
|
+
for (var x = 0; x < rsBlocks.length; x++) {
|
|
934
|
+
totalDataCount += rsBlocks[x].dataCount;
|
|
904
935
|
}
|
|
905
|
-
buffer.
|
|
906
|
-
|
|
907
|
-
return QRCode.createBytes(buffer, rsBlocks);
|
|
908
|
-
};
|
|
909
|
-
QRCode.createBytes = function(buffer, rsBlocks) {
|
|
910
|
-
var offset = 0;
|
|
911
|
-
var maxDcCount = 0;
|
|
912
|
-
var maxEcCount = 0;
|
|
913
|
-
var dcdata = new Array(rsBlocks.length);
|
|
914
|
-
var ecdata = new Array(rsBlocks.length);
|
|
915
|
-
for (var r = 0;r < rsBlocks.length; r++) {
|
|
916
|
-
var dcCount = rsBlocks[r].dataCount;
|
|
917
|
-
var ecCount = rsBlocks[r].totalCount - dcCount;
|
|
918
|
-
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
919
|
-
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
920
|
-
dcdata[r] = new Array(dcCount);
|
|
921
|
-
for (var i = 0;i < dcdata[r].length; i++) {
|
|
922
|
-
dcdata[r][i] = 255 & buffer.buffer[i + offset];
|
|
936
|
+
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
937
|
+
throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
|
|
923
938
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
|
927
|
-
var modPoly = rawPoly.mod(rsPoly);
|
|
928
|
-
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
929
|
-
for (var x = 0;x < ecdata[r].length; x++) {
|
|
930
|
-
var modIndex = x + modPoly.getLength() - ecdata[r].length;
|
|
931
|
-
ecdata[r][x] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
|
|
939
|
+
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
|
940
|
+
buffer.put(0, 4);
|
|
932
941
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
data[index++] = dcdata[s][z];
|
|
942
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
943
|
+
buffer.putBit(false);
|
|
944
|
+
}
|
|
945
|
+
while (true) {
|
|
946
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
buffer.put(QRCode.PAD0, 8);
|
|
950
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
951
|
+
break;
|
|
944
952
|
}
|
|
953
|
+
buffer.put(QRCode.PAD1, 8);
|
|
945
954
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
955
|
+
return QRCode.createBytes(buffer, rsBlocks);
|
|
956
|
+
};
|
|
957
|
+
QRCode.createBytes = function(buffer, rsBlocks) {
|
|
958
|
+
var offset = 0;
|
|
959
|
+
var maxDcCount = 0;
|
|
960
|
+
var maxEcCount = 0;
|
|
961
|
+
var dcdata = new Array(rsBlocks.length);
|
|
962
|
+
var ecdata = new Array(rsBlocks.length);
|
|
963
|
+
for (var r = 0; r < rsBlocks.length; r++) {
|
|
964
|
+
var dcCount = rsBlocks[r].dataCount;
|
|
965
|
+
var ecCount = rsBlocks[r].totalCount - dcCount;
|
|
966
|
+
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
967
|
+
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
968
|
+
dcdata[r] = new Array(dcCount);
|
|
969
|
+
for (var i = 0; i < dcdata[r].length; i++) {
|
|
970
|
+
dcdata[r][i] = 255 & buffer.buffer[i + offset];
|
|
971
|
+
}
|
|
972
|
+
offset += dcCount;
|
|
973
|
+
var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
974
|
+
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
|
975
|
+
var modPoly = rawPoly.mod(rsPoly);
|
|
976
|
+
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
977
|
+
for (var x = 0; x < ecdata[r].length; x++) {
|
|
978
|
+
var modIndex = x + modPoly.getLength() - ecdata[r].length;
|
|
979
|
+
ecdata[r][x] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
|
|
951
980
|
}
|
|
952
981
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
982
|
+
var totalCodeCount = 0;
|
|
983
|
+
for (var y = 0; y < rsBlocks.length; y++) {
|
|
984
|
+
totalCodeCount += rsBlocks[y].totalCount;
|
|
985
|
+
}
|
|
986
|
+
var data = new Array(totalCodeCount);
|
|
987
|
+
var index = 0;
|
|
988
|
+
for (var z = 0; z < maxDcCount; z++) {
|
|
989
|
+
for (var s = 0; s < rsBlocks.length; s++) {
|
|
990
|
+
if (z < dcdata[s].length) {
|
|
991
|
+
data[index++] = dcdata[s][z];
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
for (var xx = 0; xx < maxEcCount; xx++) {
|
|
996
|
+
for (var t = 0; t < rsBlocks.length; t++) {
|
|
997
|
+
if (xx < ecdata[t].length) {
|
|
998
|
+
data[index++] = ecdata[t][xx];
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return data;
|
|
1003
|
+
};
|
|
1004
|
+
module.exports = QRCode;
|
|
1005
|
+
}
|
|
957
1006
|
});
|
|
958
1007
|
|
|
959
1008
|
// node_modules/qrcode-terminal/lib/main.js
|
|
960
|
-
var require_main = __commonJS(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
var repeat = function(color) {
|
|
969
|
-
return {
|
|
970
|
-
times: function(count) {
|
|
971
|
-
return new Array(count).join(color);
|
|
972
|
-
}
|
|
1009
|
+
var require_main = __commonJS({
|
|
1010
|
+
"node_modules/qrcode-terminal/lib/main.js"(exports, module) {
|
|
1011
|
+
var QRCode = require_QRCode();
|
|
1012
|
+
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
1013
|
+
var black = "\x1B[40m \x1B[0m";
|
|
1014
|
+
var white = "\x1B[47m \x1B[0m";
|
|
1015
|
+
var toCell = function(isBlack) {
|
|
1016
|
+
return isBlack ? black : white;
|
|
973
1017
|
};
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
if (typeof opts === "function") {
|
|
986
|
-
cb = opts;
|
|
987
|
-
opts = {};
|
|
1018
|
+
var repeat = function(color) {
|
|
1019
|
+
return {
|
|
1020
|
+
times: function(count) {
|
|
1021
|
+
return new Array(count).join(color);
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
};
|
|
1025
|
+
var fill = function(length, value) {
|
|
1026
|
+
var arr = new Array(length);
|
|
1027
|
+
for (var i = 0; i < length; i++) {
|
|
1028
|
+
arr[i] = value;
|
|
988
1029
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
var oddRow = moduleCount % 2 === 1;
|
|
998
|
-
if (oddRow) {
|
|
999
|
-
moduleData.push(fill(moduleCount, WHITE));
|
|
1030
|
+
return arr;
|
|
1031
|
+
};
|
|
1032
|
+
module.exports = {
|
|
1033
|
+
error: QRErrorCorrectLevel.L,
|
|
1034
|
+
generate: function(input, opts, cb) {
|
|
1035
|
+
if (typeof opts === "function") {
|
|
1036
|
+
cb = opts;
|
|
1037
|
+
opts = {};
|
|
1000
1038
|
}
|
|
1001
|
-
var
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1039
|
+
var qrcode = new QRCode(-1, this.error);
|
|
1040
|
+
qrcode.addData(input);
|
|
1041
|
+
qrcode.make();
|
|
1042
|
+
var output = "";
|
|
1043
|
+
if (opts && opts.small) {
|
|
1044
|
+
var BLACK = true, WHITE = false;
|
|
1045
|
+
var moduleCount = qrcode.getModuleCount();
|
|
1046
|
+
var moduleData = qrcode.modules.slice();
|
|
1047
|
+
var oddRow = moduleCount % 2 === 1;
|
|
1048
|
+
if (oddRow) {
|
|
1049
|
+
moduleData.push(fill(moduleCount, WHITE));
|
|
1050
|
+
}
|
|
1051
|
+
var platte = {
|
|
1052
|
+
WHITE_ALL: "\u2588",
|
|
1053
|
+
WHITE_BLACK: "\u2580",
|
|
1054
|
+
BLACK_WHITE: "\u2584",
|
|
1055
|
+
BLACK_ALL: " "
|
|
1056
|
+
};
|
|
1057
|
+
var borderTop = repeat(platte.BLACK_WHITE).times(moduleCount + 3);
|
|
1058
|
+
var borderBottom = repeat(platte.WHITE_BLACK).times(moduleCount + 3);
|
|
1059
|
+
output += borderTop + "\n";
|
|
1060
|
+
for (var row = 0; row < moduleCount; row += 2) {
|
|
1061
|
+
output += platte.WHITE_ALL;
|
|
1062
|
+
for (var col = 0; col < moduleCount; col++) {
|
|
1063
|
+
if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === WHITE) {
|
|
1064
|
+
output += platte.WHITE_ALL;
|
|
1065
|
+
} else if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === BLACK) {
|
|
1066
|
+
output += platte.WHITE_BLACK;
|
|
1067
|
+
} else if (moduleData[row][col] === BLACK && moduleData[row + 1][col] === WHITE) {
|
|
1068
|
+
output += platte.BLACK_WHITE;
|
|
1069
|
+
} else {
|
|
1070
|
+
output += platte.BLACK_ALL;
|
|
1071
|
+
}
|
|
1022
1072
|
}
|
|
1073
|
+
output += platte.WHITE_ALL + "\n";
|
|
1023
1074
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1075
|
+
if (!oddRow) {
|
|
1076
|
+
output += borderBottom;
|
|
1077
|
+
}
|
|
1078
|
+
} else {
|
|
1079
|
+
var border = repeat(white).times(qrcode.getModuleCount() + 3);
|
|
1080
|
+
output += border + "\n";
|
|
1081
|
+
qrcode.modules.forEach(function(row2) {
|
|
1082
|
+
output += white;
|
|
1083
|
+
output += row2.map(toCell).join("");
|
|
1084
|
+
output += white + "\n";
|
|
1085
|
+
});
|
|
1086
|
+
output += border;
|
|
1029
1087
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
output += white;
|
|
1036
|
-
output += row2.map(toCell).join("");
|
|
1037
|
-
output += white + `
|
|
1038
|
-
`;
|
|
1039
|
-
});
|
|
1040
|
-
output += border;
|
|
1088
|
+
if (cb) cb(output);
|
|
1089
|
+
else console.log(output);
|
|
1090
|
+
},
|
|
1091
|
+
setErrorLevel: function(error) {
|
|
1092
|
+
this.error = QRErrorCorrectLevel[error] || this.error;
|
|
1041
1093
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
else
|
|
1045
|
-
console.log(output);
|
|
1046
|
-
},
|
|
1047
|
-
setErrorLevel: function(error) {
|
|
1048
|
-
this.error = QRErrorCorrectLevel[error] || this.error;
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1051
1096
|
});
|
|
1052
1097
|
|
|
1053
1098
|
// setup.ts
|
|
@@ -1075,29 +1120,34 @@ function saveCredentials(data) {
|
|
|
1075
1120
|
fs.writeFileSync(file, JSON.stringify(data, null, 2), "utf-8");
|
|
1076
1121
|
try {
|
|
1077
1122
|
fs.chmodSync(file, 384);
|
|
1078
|
-
} catch {
|
|
1123
|
+
} catch {
|
|
1124
|
+
}
|
|
1079
1125
|
}
|
|
1080
1126
|
async function fetchQRCode(baseUrl) {
|
|
1081
1127
|
const base = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
1082
|
-
const url = new URL(
|
|
1128
|
+
const url = new URL(
|
|
1129
|
+
`ilink/bot/get_bot_qrcode?bot_type=${encodeURIComponent(BOT_TYPE)}`,
|
|
1130
|
+
base
|
|
1131
|
+
);
|
|
1083
1132
|
const res = await fetch(url.toString());
|
|
1084
|
-
if (!res.ok)
|
|
1085
|
-
throw new Error(`QR fetch failed: ${res.status}`);
|
|
1133
|
+
if (!res.ok) throw new Error(`QR fetch failed: ${res.status}`);
|
|
1086
1134
|
return await res.json();
|
|
1087
1135
|
}
|
|
1088
1136
|
async function pollQRStatus(baseUrl, qrcode) {
|
|
1089
1137
|
const base = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
1090
|
-
const url = new URL(
|
|
1091
|
-
|
|
1092
|
-
|
|
1138
|
+
const url = new URL(
|
|
1139
|
+
`ilink/bot/get_qrcode_status?qrcode=${encodeURIComponent(qrcode)}`,
|
|
1140
|
+
base
|
|
1141
|
+
);
|
|
1142
|
+
const controller = new AbortController();
|
|
1143
|
+
const timer = setTimeout(() => controller.abort(), 35e3);
|
|
1093
1144
|
try {
|
|
1094
1145
|
const res = await fetch(url.toString(), {
|
|
1095
1146
|
headers: { "iLink-App-ClientVersion": "1" },
|
|
1096
1147
|
signal: controller.signal
|
|
1097
1148
|
});
|
|
1098
1149
|
clearTimeout(timer);
|
|
1099
|
-
if (!res.ok)
|
|
1100
|
-
throw new Error(`QR status failed: ${res.status}`);
|
|
1150
|
+
if (!res.ok) throw new Error(`QR status failed: ${res.status}`);
|
|
1101
1151
|
return await res.json();
|
|
1102
1152
|
} catch (err) {
|
|
1103
1153
|
clearTimeout(timer);
|
|
@@ -1114,8 +1164,8 @@ async function main() {
|
|
|
1114
1164
|
if (fs2.existsSync(CREDENTIALS_FILE)) {
|
|
1115
1165
|
try {
|
|
1116
1166
|
const existing = JSON.parse(fs2.readFileSync(CREDENTIALS_FILE, "utf-8"));
|
|
1117
|
-
console.log(
|
|
1118
|
-
console.log(
|
|
1167
|
+
console.log(`\u5DF2\u6709\u4FDD\u5B58\u7684\u8D26\u53F7: ${existing.accountId}`);
|
|
1168
|
+
console.log(`\u4FDD\u5B58\u65F6\u95F4: ${existing.savedAt}`);
|
|
1119
1169
|
console.log();
|
|
1120
1170
|
const readline = await import("node:readline");
|
|
1121
1171
|
const rl = readline.createInterface({
|
|
@@ -1123,35 +1173,37 @@ async function main() {
|
|
|
1123
1173
|
output: process.stdout
|
|
1124
1174
|
});
|
|
1125
1175
|
const answer = await new Promise((resolve) => {
|
|
1126
|
-
rl.question("
|
|
1176
|
+
rl.question("\u662F\u5426\u91CD\u65B0\u767B\u5F55\uFF1F(y/N) ", resolve);
|
|
1127
1177
|
});
|
|
1128
1178
|
rl.close();
|
|
1129
1179
|
if (answer.toLowerCase() !== "y") {
|
|
1130
|
-
console.log("
|
|
1180
|
+
console.log("\u4FDD\u6301\u73B0\u6709\u51ED\u636E\uFF0C\u9000\u51FA\u3002");
|
|
1131
1181
|
process.exit(0);
|
|
1132
1182
|
}
|
|
1133
1183
|
} catch (err) {
|
|
1134
|
-
console.error(
|
|
1184
|
+
console.error(`\u8BFB\u53D6\u5DF2\u6709\u51ED\u636E\u5931\u8D25: ${String(err)}`);
|
|
1135
1185
|
}
|
|
1136
1186
|
}
|
|
1137
|
-
console.log(
|
|
1138
|
-
`);
|
|
1187
|
+
console.log("\u6B63\u5728\u83B7\u53D6\u5FAE\u4FE1\u767B\u5F55\u4E8C\u7EF4\u7801...\n");
|
|
1139
1188
|
const qrResp = await fetchQRCode(DEFAULT_BASE_URL);
|
|
1140
1189
|
try {
|
|
1141
1190
|
const qrterm = await Promise.resolve().then(() => __toESM(require_main(), 1));
|
|
1142
1191
|
await new Promise((resolve) => {
|
|
1143
|
-
qrterm.default.generate(
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1192
|
+
qrterm.default.generate(
|
|
1193
|
+
qrResp.qrcode_img_content,
|
|
1194
|
+
{ small: true },
|
|
1195
|
+
(qr) => {
|
|
1196
|
+
console.log(qr);
|
|
1197
|
+
resolve();
|
|
1198
|
+
}
|
|
1199
|
+
);
|
|
1147
1200
|
});
|
|
1148
1201
|
} catch {
|
|
1149
|
-
console.log(
|
|
1202
|
+
console.log(`\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00\u6B64\u94FE\u63A5\u626B\u7801: ${qrResp.qrcode_img_content}
|
|
1150
1203
|
`);
|
|
1151
1204
|
}
|
|
1152
|
-
console.log(
|
|
1153
|
-
|
|
1154
|
-
const deadline = Date.now() + 480000;
|
|
1205
|
+
console.log("\u8BF7\u7528\u5FAE\u4FE1\u626B\u63CF\u4E0A\u65B9\u4E8C\u7EF4\u7801...\n");
|
|
1206
|
+
const deadline = Date.now() + 48e4;
|
|
1155
1207
|
let scannedPrinted = false;
|
|
1156
1208
|
while (Date.now() < deadline) {
|
|
1157
1209
|
const status = await pollQRStatus(DEFAULT_BASE_URL, qrResp.qrcode);
|
|
@@ -1161,20 +1213,17 @@ async function main() {
|
|
|
1161
1213
|
break;
|
|
1162
1214
|
case "scaned":
|
|
1163
1215
|
if (!scannedPrinted) {
|
|
1164
|
-
console.log(
|
|
1165
|
-
\uD83D\uDC40 已扫码,请在微信中确认...`);
|
|
1216
|
+
console.log("\n\u{1F440} \u5DF2\u626B\u7801\uFF0C\u8BF7\u5728\u5FAE\u4FE1\u4E2D\u786E\u8BA4...");
|
|
1166
1217
|
scannedPrinted = true;
|
|
1167
1218
|
}
|
|
1168
1219
|
break;
|
|
1169
1220
|
case "expired":
|
|
1170
|
-
console.log(
|
|
1171
|
-
二维码已过期,请重新运行 setup。`);
|
|
1221
|
+
console.log("\n\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C setup\u3002");
|
|
1172
1222
|
process.exit(1);
|
|
1173
1223
|
break;
|
|
1174
1224
|
case "confirmed": {
|
|
1175
1225
|
if (!status.ilink_bot_id || !status.bot_token) {
|
|
1176
|
-
console.error(
|
|
1177
|
-
登录失败:服务器未返回完整信息。`);
|
|
1226
|
+
console.error("\n\u767B\u5F55\u5931\u8D25\uFF1A\u670D\u52A1\u5668\u672A\u8FD4\u56DE\u5B8C\u6574\u4FE1\u606F\u3002");
|
|
1178
1227
|
process.exit(1);
|
|
1179
1228
|
}
|
|
1180
1229
|
const account = {
|
|
@@ -1182,27 +1231,28 @@ async function main() {
|
|
|
1182
1231
|
baseUrl: status.baseurl || DEFAULT_BASE_URL,
|
|
1183
1232
|
accountId: status.ilink_bot_id,
|
|
1184
1233
|
userId: status.ilink_user_id,
|
|
1185
|
-
savedAt: new Date().toISOString()
|
|
1234
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1186
1235
|
};
|
|
1187
1236
|
saveCredentials(account);
|
|
1188
1237
|
console.log(`
|
|
1189
|
-
|
|
1190
|
-
console.log(`
|
|
1191
|
-
console.log(`
|
|
1192
|
-
console.log(`
|
|
1238
|
+
\u2705 \u5FAE\u4FE1\u8FDE\u63A5\u6210\u529F\uFF01`);
|
|
1239
|
+
console.log(` \u8D26\u53F7 ID: ${account.accountId}`);
|
|
1240
|
+
console.log(` \u7528\u6237 ID: ${account.userId}`);
|
|
1241
|
+
console.log(` \u51ED\u636E\u4FDD\u5B58\u81F3: ${getCredentialsFile()}`);
|
|
1193
1242
|
console.log();
|
|
1194
|
-
console.log("
|
|
1195
|
-
console.log(
|
|
1243
|
+
console.log("\u73B0\u5728\u53EF\u4EE5\u542F\u52A8 Claude Code \u901A\u9053\uFF1A");
|
|
1244
|
+
console.log(
|
|
1245
|
+
" claude --dangerously-skip-permissions"
|
|
1246
|
+
);
|
|
1196
1247
|
process.exit(0);
|
|
1197
1248
|
}
|
|
1198
1249
|
}
|
|
1199
|
-
await new Promise((r) => setTimeout(r,
|
|
1250
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
1200
1251
|
}
|
|
1201
|
-
console.log(
|
|
1202
|
-
登录超时,请重新运行。`);
|
|
1252
|
+
console.log("\n\u767B\u5F55\u8D85\u65F6\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u3002");
|
|
1203
1253
|
process.exit(1);
|
|
1204
1254
|
}
|
|
1205
1255
|
main().catch((err) => {
|
|
1206
|
-
console.error(
|
|
1256
|
+
console.error(`\u9519\u8BEF: ${err}`);
|
|
1207
1257
|
process.exit(1);
|
|
1208
1258
|
});
|