@atooyu/uxto-ui 1.1.34 → 1.1.35
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/index.js +398 -190
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +398 -190
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +4 -4
- package/package.json +1 -1
- package/src/components/u-qrcode/u-qrcode.vue +490 -241
package/dist/index.js
CHANGED
|
@@ -5051,254 +5051,464 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5051
5051
|
if (moduleCount.value === 0) return 0;
|
|
5052
5052
|
return props.size / moduleCount.value;
|
|
5053
5053
|
});
|
|
5054
|
-
const
|
|
5055
|
-
const
|
|
5056
|
-
[
|
|
5057
|
-
|
|
5058
|
-
[
|
|
5059
|
-
|
|
5060
|
-
[
|
|
5061
|
-
[
|
|
5062
|
-
[
|
|
5063
|
-
[
|
|
5064
|
-
[
|
|
5065
|
-
[
|
|
5066
|
-
[
|
|
5067
|
-
[
|
|
5068
|
-
[
|
|
5069
|
-
[
|
|
5070
|
-
[
|
|
5071
|
-
[
|
|
5072
|
-
[
|
|
5073
|
-
[
|
|
5074
|
-
[
|
|
5075
|
-
[
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
[
|
|
5082
|
-
[
|
|
5083
|
-
|
|
5084
|
-
[
|
|
5085
|
-
[
|
|
5086
|
-
[
|
|
5087
|
-
[
|
|
5088
|
-
|
|
5089
|
-
[
|
|
5090
|
-
[
|
|
5091
|
-
[
|
|
5092
|
-
[
|
|
5093
|
-
|
|
5094
|
-
[
|
|
5095
|
-
[
|
|
5096
|
-
[
|
|
5097
|
-
[
|
|
5098
|
-
|
|
5099
|
-
[
|
|
5100
|
-
[
|
|
5101
|
-
[
|
|
5054
|
+
const ECL = { L: 1, M: 0, Q: 3, H: 2 };
|
|
5055
|
+
const ALIGNMENT_PATTERNS = {
|
|
5056
|
+
1: [],
|
|
5057
|
+
2: [6, 18],
|
|
5058
|
+
3: [6, 22],
|
|
5059
|
+
4: [6, 26],
|
|
5060
|
+
5: [6, 30],
|
|
5061
|
+
6: [6, 34],
|
|
5062
|
+
7: [6, 22, 38],
|
|
5063
|
+
8: [6, 24, 42],
|
|
5064
|
+
9: [6, 26, 46],
|
|
5065
|
+
10: [6, 28, 50],
|
|
5066
|
+
11: [6, 30, 54],
|
|
5067
|
+
12: [6, 32, 58],
|
|
5068
|
+
13: [6, 34, 62],
|
|
5069
|
+
14: [6, 26, 46, 66],
|
|
5070
|
+
15: [6, 26, 48, 70],
|
|
5071
|
+
16: [6, 26, 50, 74],
|
|
5072
|
+
17: [6, 30, 54, 78],
|
|
5073
|
+
18: [6, 30, 56, 82],
|
|
5074
|
+
19: [6, 30, 58, 86],
|
|
5075
|
+
20: [6, 34, 62, 90]
|
|
5076
|
+
};
|
|
5077
|
+
const RS_BLOCK_TABLE = [
|
|
5078
|
+
// Version 1
|
|
5079
|
+
[1, 26, 19],
|
|
5080
|
+
[1, 26, 16],
|
|
5081
|
+
[1, 26, 13],
|
|
5082
|
+
[1, 26, 9],
|
|
5083
|
+
// Version 2
|
|
5084
|
+
[1, 44, 34],
|
|
5085
|
+
[1, 44, 28],
|
|
5086
|
+
[1, 44, 22],
|
|
5087
|
+
[1, 44, 16],
|
|
5088
|
+
// Version 3
|
|
5089
|
+
[1, 70, 55],
|
|
5090
|
+
[1, 70, 44],
|
|
5091
|
+
[2, 35, 17],
|
|
5092
|
+
[2, 35, 13],
|
|
5093
|
+
// Version 4
|
|
5094
|
+
[1, 100, 80],
|
|
5095
|
+
[2, 50, 32],
|
|
5096
|
+
[2, 50, 24],
|
|
5097
|
+
[4, 25, 9],
|
|
5098
|
+
// Version 5
|
|
5099
|
+
[1, 134, 108],
|
|
5100
|
+
[2, 67, 43],
|
|
5101
|
+
[2, 33, 15, 2, 34, 16],
|
|
5102
|
+
[2, 33, 11, 2, 34, 12],
|
|
5103
|
+
// Version 6
|
|
5104
|
+
[2, 86, 68],
|
|
5105
|
+
[4, 43, 27],
|
|
5106
|
+
[4, 43, 19],
|
|
5107
|
+
[4, 43, 15],
|
|
5108
|
+
// Version 7
|
|
5109
|
+
[2, 98, 78],
|
|
5110
|
+
[4, 49, 31],
|
|
5111
|
+
[2, 32, 14, 4, 33, 15],
|
|
5112
|
+
[4, 39, 13, 1, 40, 14],
|
|
5113
|
+
// Version 8
|
|
5114
|
+
[2, 121, 97],
|
|
5115
|
+
[2, 60, 38, 2, 61, 39],
|
|
5116
|
+
[4, 40, 18, 2, 41, 19],
|
|
5117
|
+
[4, 40, 14, 2, 41, 15],
|
|
5118
|
+
// Version 9
|
|
5119
|
+
[2, 146, 116],
|
|
5120
|
+
[3, 58, 36, 2, 59, 37],
|
|
5121
|
+
[4, 36, 16, 4, 37, 17],
|
|
5122
|
+
[4, 36, 12, 4, 37, 13],
|
|
5123
|
+
// Version 10
|
|
5124
|
+
[2, 86, 68, 2, 87, 69],
|
|
5125
|
+
[4, 69, 43, 1, 70, 44],
|
|
5126
|
+
[6, 43, 19, 2, 44, 20],
|
|
5127
|
+
[6, 43, 15, 2, 44, 16],
|
|
5128
|
+
// Version 11
|
|
5129
|
+
[4, 101, 81],
|
|
5130
|
+
[1, 80, 50, 4, 81, 51],
|
|
5131
|
+
[4, 50, 22, 4, 51, 23],
|
|
5132
|
+
[3, 36, 12, 8, 37, 13],
|
|
5133
|
+
// Version 12
|
|
5134
|
+
[2, 116, 92, 2, 117, 93],
|
|
5135
|
+
[6, 58, 36, 2, 59, 37],
|
|
5136
|
+
[4, 46, 20, 6, 47, 21],
|
|
5137
|
+
[7, 42, 14, 4, 43, 15],
|
|
5138
|
+
// Version 13
|
|
5139
|
+
[4, 133, 107],
|
|
5140
|
+
[8, 59, 37, 1, 60, 38],
|
|
5141
|
+
[8, 44, 20, 4, 45, 21],
|
|
5142
|
+
[12, 33, 11, 4, 34, 12],
|
|
5143
|
+
// Version 14
|
|
5144
|
+
[3, 145, 115, 1, 146, 116],
|
|
5145
|
+
[4, 64, 40, 5, 65, 41],
|
|
5146
|
+
[11, 36, 16, 5, 37, 17],
|
|
5147
|
+
[11, 36, 12, 5, 37, 13],
|
|
5148
|
+
// Version 15
|
|
5149
|
+
[5, 109, 87, 1, 110, 88],
|
|
5150
|
+
[5, 65, 41, 5, 66, 42],
|
|
5151
|
+
[5, 54, 24, 7, 55, 25],
|
|
5152
|
+
[11, 36, 12, 7, 37, 13],
|
|
5153
|
+
// Version 16
|
|
5154
|
+
[5, 122, 98, 1, 123, 99],
|
|
5155
|
+
[7, 73, 45, 3, 74, 46],
|
|
5156
|
+
[15, 43, 19, 2, 44, 20],
|
|
5157
|
+
[3, 45, 15, 13, 46, 16],
|
|
5158
|
+
// Version 17
|
|
5159
|
+
[1, 135, 107, 5, 136, 108],
|
|
5160
|
+
[10, 74, 46, 1, 75, 47],
|
|
5161
|
+
[1, 50, 22, 15, 51, 23],
|
|
5162
|
+
[2, 42, 14, 17, 43, 15],
|
|
5163
|
+
// Version 18
|
|
5164
|
+
[5, 150, 120, 1, 151, 121],
|
|
5165
|
+
[9, 69, 43, 4, 70, 44],
|
|
5166
|
+
[17, 50, 22, 1, 51, 23],
|
|
5167
|
+
[2, 42, 14, 19, 43, 15],
|
|
5168
|
+
// Version 19
|
|
5169
|
+
[3, 141, 113, 4, 142, 114],
|
|
5170
|
+
[3, 70, 44, 11, 71, 45],
|
|
5171
|
+
[17, 47, 21, 4, 48, 22],
|
|
5172
|
+
[9, 39, 13, 16, 40, 14],
|
|
5173
|
+
// Version 20
|
|
5174
|
+
[3, 135, 107, 5, 136, 108],
|
|
5175
|
+
[3, 67, 41, 13, 68, 42],
|
|
5176
|
+
[15, 54, 24, 5, 55, 25],
|
|
5177
|
+
[15, 43, 15, 10, 44, 16]
|
|
5102
5178
|
];
|
|
5103
5179
|
const GF_EXP = new Array(512);
|
|
5104
5180
|
const GF_LOG = new Array(256);
|
|
5105
|
-
let
|
|
5106
|
-
for (let
|
|
5107
|
-
GF_EXP[
|
|
5108
|
-
GF_LOG[
|
|
5109
|
-
|
|
5110
|
-
if (
|
|
5181
|
+
let gfX = 1;
|
|
5182
|
+
for (let gfI = 0; gfI < 255; gfI++) {
|
|
5183
|
+
GF_EXP[gfI] = gfX;
|
|
5184
|
+
GF_LOG[gfX] = gfI;
|
|
5185
|
+
gfX <<= 1;
|
|
5186
|
+
if (gfX & 256) {
|
|
5187
|
+
gfX ^= 285;
|
|
5188
|
+
}
|
|
5111
5189
|
}
|
|
5112
|
-
for (let
|
|
5113
|
-
GF_EXP[
|
|
5190
|
+
for (let gfI = 255; gfI < 512; gfI++) {
|
|
5191
|
+
GF_EXP[gfI] = GF_EXP[gfI - 255];
|
|
5114
5192
|
}
|
|
5115
5193
|
function gfMul(a, b) {
|
|
5116
5194
|
if (a === 0 || b === 0) return 0;
|
|
5117
5195
|
return GF_EXP[GF_LOG[a] + GF_LOG[b]];
|
|
5118
5196
|
}
|
|
5119
|
-
function
|
|
5197
|
+
function getRSBlocks(version, ecl) {
|
|
5198
|
+
const index = (version - 1) * 4 + ecl;
|
|
5199
|
+
const blockData = RS_BLOCK_TABLE[index];
|
|
5200
|
+
const blocks = [];
|
|
5201
|
+
if (blockData.length === 3) {
|
|
5202
|
+
const count = blockData[0];
|
|
5203
|
+
const total = blockData[1];
|
|
5204
|
+
const data = blockData[2];
|
|
5205
|
+
for (let i = 0; i < count; i++) {
|
|
5206
|
+
blocks.push({ totalCount: total, dataCount: data });
|
|
5207
|
+
}
|
|
5208
|
+
} else if (blockData.length === 6) {
|
|
5209
|
+
const count1 = blockData[0];
|
|
5210
|
+
const total1 = blockData[1];
|
|
5211
|
+
const data1 = blockData[2];
|
|
5212
|
+
for (let i = 0; i < count1; i++) {
|
|
5213
|
+
blocks.push({ totalCount: total1, dataCount: data1 });
|
|
5214
|
+
}
|
|
5215
|
+
const count2 = blockData[3];
|
|
5216
|
+
const total2 = blockData[4];
|
|
5217
|
+
const data2 = blockData[5];
|
|
5218
|
+
for (let i = 0; i < count2; i++) {
|
|
5219
|
+
blocks.push({ totalCount: total2, dataCount: data2 });
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5222
|
+
return blocks;
|
|
5223
|
+
}
|
|
5224
|
+
function getECCodewords(data, ecCount) {
|
|
5120
5225
|
let gen = [1];
|
|
5121
|
-
for (let i = 0; i <
|
|
5122
|
-
const
|
|
5226
|
+
for (let i = 0; i < ecCount; i++) {
|
|
5227
|
+
const temp = new Array(gen.length + 1).fill(0);
|
|
5123
5228
|
for (let j = 0; j < gen.length; j++) {
|
|
5124
|
-
|
|
5125
|
-
|
|
5229
|
+
temp[j] ^= gen[j];
|
|
5230
|
+
temp[j + 1] ^= gfMul(gen[j], GF_EXP[i]);
|
|
5126
5231
|
}
|
|
5127
|
-
gen =
|
|
5232
|
+
gen = temp;
|
|
5128
5233
|
}
|
|
5129
|
-
const ecc = new Array(
|
|
5234
|
+
const ecc = new Array(ecCount).fill(0);
|
|
5130
5235
|
for (const byte of data) {
|
|
5131
5236
|
const factor = byte ^ ecc[0];
|
|
5132
5237
|
ecc.shift();
|
|
5133
5238
|
ecc.push(0);
|
|
5134
|
-
for (let i = 0; i <
|
|
5135
|
-
ecc[i] ^= gfMul(gen[i], factor);
|
|
5239
|
+
for (let i = 0; i < ecCount; i++) {
|
|
5240
|
+
ecc[i] ^= gfMul(gen[i + 1], factor);
|
|
5136
5241
|
}
|
|
5137
5242
|
}
|
|
5138
5243
|
return ecc;
|
|
5139
5244
|
}
|
|
5140
|
-
function
|
|
5245
|
+
function createData(text, version, ecl) {
|
|
5246
|
+
const rsBlocks = getRSBlocks(version, ecl);
|
|
5247
|
+
let totalDataCount = 0;
|
|
5248
|
+
for (const block of rsBlocks) {
|
|
5249
|
+
totalDataCount += block.dataCount;
|
|
5250
|
+
}
|
|
5251
|
+
const buffer = [];
|
|
5252
|
+
buffer.push(0, 1, 0, 0);
|
|
5253
|
+
const cciBits = version <= 9 ? 8 : 16;
|
|
5254
|
+
for (let i = cciBits - 1; i >= 0; i--) {
|
|
5255
|
+
buffer.push(text.length >>> i & 1);
|
|
5256
|
+
}
|
|
5257
|
+
for (const char of text) {
|
|
5258
|
+
const code2 = char.charCodeAt(0);
|
|
5259
|
+
for (let i = 7; i >= 0; i--) {
|
|
5260
|
+
buffer.push(code2 >>> i & 1);
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
const totalBits = totalDataCount * 8;
|
|
5264
|
+
const termLen = Math.min(4, totalBits - buffer.length);
|
|
5265
|
+
for (let i = 0; i < termLen; i++) {
|
|
5266
|
+
buffer.push(0);
|
|
5267
|
+
}
|
|
5268
|
+
while (buffer.length % 8 !== 0) {
|
|
5269
|
+
buffer.push(0);
|
|
5270
|
+
}
|
|
5271
|
+
let padIdx = 0;
|
|
5272
|
+
const pads = [236, 17];
|
|
5273
|
+
while (buffer.length < totalBits) {
|
|
5274
|
+
const pad = pads[padIdx];
|
|
5275
|
+
for (let i = 7; i >= 0; i--) {
|
|
5276
|
+
buffer.push(pad >>> i & 1);
|
|
5277
|
+
}
|
|
5278
|
+
padIdx = (padIdx + 1) % 2;
|
|
5279
|
+
}
|
|
5280
|
+
const dataBytes = [];
|
|
5281
|
+
for (let i = 0; i < buffer.length; i += 8) {
|
|
5282
|
+
let byte = 0;
|
|
5283
|
+
for (let j = 0; j < 8; j++) {
|
|
5284
|
+
byte = byte << 1 | (buffer[i + j] || 0);
|
|
5285
|
+
}
|
|
5286
|
+
dataBytes.push(byte);
|
|
5287
|
+
}
|
|
5288
|
+
let dataIndex = 0;
|
|
5289
|
+
const ecData = [];
|
|
5290
|
+
const dcData = [];
|
|
5291
|
+
for (const block of rsBlocks) {
|
|
5292
|
+
const dc = dataBytes.slice(dataIndex, dataIndex + block.dataCount);
|
|
5293
|
+
dataIndex += block.dataCount;
|
|
5294
|
+
dcData.push(dc);
|
|
5295
|
+
const ecCount = block.totalCount - block.dataCount;
|
|
5296
|
+
ecData.push(getECCodewords(dc, ecCount));
|
|
5297
|
+
}
|
|
5298
|
+
const result = [];
|
|
5299
|
+
let maxDcCount = 0;
|
|
5300
|
+
let maxEcCount = 0;
|
|
5301
|
+
for (const block of rsBlocks) {
|
|
5302
|
+
maxDcCount = Math.max(maxDcCount, block.dataCount);
|
|
5303
|
+
maxEcCount = Math.max(maxEcCount, block.totalCount - block.dataCount);
|
|
5304
|
+
}
|
|
5305
|
+
for (let i = 0; i < maxDcCount; i++) {
|
|
5306
|
+
for (let j = 0; j < dcData.length; j++) {
|
|
5307
|
+
if (i < dcData[j].length) {
|
|
5308
|
+
result.push(dcData[j][i]);
|
|
5309
|
+
}
|
|
5310
|
+
}
|
|
5311
|
+
}
|
|
5312
|
+
for (let i = 0; i < maxEcCount; i++) {
|
|
5313
|
+
for (let j = 0; j < ecData.length; j++) {
|
|
5314
|
+
if (i < ecData[j].length) {
|
|
5315
|
+
result.push(ecData[j][i]);
|
|
5316
|
+
}
|
|
5317
|
+
}
|
|
5318
|
+
}
|
|
5319
|
+
return result;
|
|
5320
|
+
}
|
|
5321
|
+
function getMinVersion(text) {
|
|
5322
|
+
const CAPACITIES = [
|
|
5323
|
+
0,
|
|
5324
|
+
14,
|
|
5325
|
+
26,
|
|
5326
|
+
42,
|
|
5327
|
+
62,
|
|
5328
|
+
84,
|
|
5329
|
+
106,
|
|
5330
|
+
122,
|
|
5331
|
+
152,
|
|
5332
|
+
180,
|
|
5333
|
+
213,
|
|
5334
|
+
251,
|
|
5335
|
+
287,
|
|
5336
|
+
331,
|
|
5337
|
+
362,
|
|
5338
|
+
412,
|
|
5339
|
+
450,
|
|
5340
|
+
504,
|
|
5341
|
+
560,
|
|
5342
|
+
624,
|
|
5343
|
+
666
|
|
5344
|
+
];
|
|
5141
5345
|
for (let v = 1; v <= 20; v++) {
|
|
5142
|
-
if (
|
|
5346
|
+
if (text.length <= CAPACITIES[v]) return v;
|
|
5143
5347
|
}
|
|
5144
5348
|
return 20;
|
|
5145
5349
|
}
|
|
5146
|
-
function
|
|
5147
|
-
|
|
5148
|
-
const
|
|
5149
|
-
const size = version * 4 + 17;
|
|
5150
|
-
const step = Math.ceil((size - 13) / (intervals + 1));
|
|
5151
|
-
const positions = [6];
|
|
5152
|
-
let pos = size - 7;
|
|
5153
|
-
while (pos > 6) {
|
|
5154
|
-
positions.unshift(pos);
|
|
5155
|
-
pos -= step;
|
|
5156
|
-
}
|
|
5157
|
-
return positions;
|
|
5158
|
-
}
|
|
5159
|
-
function generateQR(text, errorCorrectionLevel) {
|
|
5160
|
-
const eclIdx = ECL_INDEX[errorCorrectionLevel] ?? 1;
|
|
5161
|
-
const version = getVersion(text.length, eclIdx);
|
|
5350
|
+
function createQRCode(text, errorLevel) {
|
|
5351
|
+
const ecl = ECL[errorLevel] ?? 0;
|
|
5352
|
+
const version = getMinVersion(text);
|
|
5162
5353
|
const size = version * 4 + 17;
|
|
5163
|
-
const
|
|
5354
|
+
const mod = [];
|
|
5164
5355
|
for (let i = 0; i < size; i++) {
|
|
5165
|
-
|
|
5356
|
+
mod[i] = new Array(size).fill(-1);
|
|
5166
5357
|
}
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5358
|
+
const setModule = (row, col, value) => {
|
|
5359
|
+
if (row >= 0 && row < size && col >= 0 && col < size) {
|
|
5360
|
+
mod[row][col] = value;
|
|
5361
|
+
}
|
|
5362
|
+
};
|
|
5363
|
+
const isSet = (row, col) => {
|
|
5364
|
+
return row >= 0 && row < size && col >= 0 && col < size && mod[row][col] !== -1;
|
|
5365
|
+
};
|
|
5366
|
+
const addFinderPattern = (baseRow, baseCol) => {
|
|
5367
|
+
for (let r = -1; r <= 7; r++) {
|
|
5368
|
+
for (let c = -1; c <= 7; c++) {
|
|
5369
|
+
const nr = baseRow + r;
|
|
5370
|
+
const nc = baseCol + c;
|
|
5172
5371
|
if (nr < 0 || nr >= size || nc < 0 || nc >= size) continue;
|
|
5173
|
-
if (
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5372
|
+
if (r >= 0 && r <= 6 && c >= 0 && c <= 6) {
|
|
5373
|
+
if (r === 0 || r === 6 || c === 0 || c === 6 || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
|
|
5374
|
+
setModule(nr, nc, 1);
|
|
5375
|
+
} else {
|
|
5376
|
+
setModule(nr, nc, 0);
|
|
5377
|
+
}
|
|
5179
5378
|
} else {
|
|
5180
|
-
|
|
5379
|
+
setModule(nr, nc, 0);
|
|
5181
5380
|
}
|
|
5182
5381
|
}
|
|
5183
5382
|
}
|
|
5184
|
-
}
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
for (const c of alignPos) {
|
|
5196
|
-
if (matrix[r][c] !== -1) continue;
|
|
5197
|
-
for (let dr = -2; dr <= 2; dr++) {
|
|
5198
|
-
for (let dc = -2; dc <= 2; dc++) {
|
|
5199
|
-
const nr = r + dr;
|
|
5200
|
-
const nc = c + dc;
|
|
5201
|
-
if (nr >= 0 && nr < size && nc >= 0 && nc < size && matrix[nr][nc] === -1) {
|
|
5202
|
-
matrix[nr][nc] = Math.abs(dr) === 2 || Math.abs(dc) === 2 || dr === 0 && dc === 0 ? 1 : 0;
|
|
5203
|
-
}
|
|
5204
|
-
}
|
|
5383
|
+
};
|
|
5384
|
+
addFinderPattern(0, 0);
|
|
5385
|
+
addFinderPattern(size - 7, 0);
|
|
5386
|
+
addFinderPattern(0, size - 7);
|
|
5387
|
+
const addAlignmentPattern = (row, col) => {
|
|
5388
|
+
for (let r = -2; r <= 2; r++) {
|
|
5389
|
+
for (let c = -2; c <= 2; c++) {
|
|
5390
|
+
if (Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0) {
|
|
5391
|
+
setModule(row + r, col + c, 1);
|
|
5392
|
+
} else {
|
|
5393
|
+
setModule(row + r, col + c, 0);
|
|
5205
5394
|
}
|
|
5206
5395
|
}
|
|
5207
5396
|
}
|
|
5397
|
+
};
|
|
5398
|
+
const alignPositions = ALIGNMENT_PATTERNS[version] || [];
|
|
5399
|
+
for (const r of alignPositions) {
|
|
5400
|
+
for (const c of alignPositions) {
|
|
5401
|
+
if (isSet(r, c)) continue;
|
|
5402
|
+
addAlignmentPattern(r, c);
|
|
5403
|
+
}
|
|
5208
5404
|
}
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
if (matrix[i][8] === -1) matrix[i][8] = 0;
|
|
5405
|
+
for (let i = 8; i < size - 8; i++) {
|
|
5406
|
+
setModule(6, i, i % 2 === 0 ? 1 : 0);
|
|
5407
|
+
setModule(i, 6, i % 2 === 0 ? 1 : 0);
|
|
5213
5408
|
}
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5409
|
+
setModule(size - 8, 8, 1);
|
|
5410
|
+
const reserved = [];
|
|
5411
|
+
for (let i = 0; i < size; i++) {
|
|
5412
|
+
reserved[i] = new Array(size).fill(false);
|
|
5217
5413
|
}
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
bits.push(text.length >> i & 1);
|
|
5414
|
+
for (let r = 0; r < 9; r++) {
|
|
5415
|
+
for (let c = 0; c < 9; c++) {
|
|
5416
|
+
reserved[r][c] = true;
|
|
5417
|
+
}
|
|
5223
5418
|
}
|
|
5224
|
-
for (
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
bits.push(code2 >> i & 1);
|
|
5419
|
+
for (let r = 0; r < 9; r++) {
|
|
5420
|
+
for (let c = size - 8; c < size; c++) {
|
|
5421
|
+
reserved[r][c] = true;
|
|
5228
5422
|
}
|
|
5229
5423
|
}
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
while (bits.length % 8 !== 0) bits.push(0);
|
|
5234
|
-
const pads = [236, 17];
|
|
5235
|
-
let padIdx = 0;
|
|
5236
|
-
while (bits.length < dataCapacity * 8) {
|
|
5237
|
-
const pad = pads[padIdx];
|
|
5238
|
-
for (let i = 7; i >= 0; i--) {
|
|
5239
|
-
bits.push(pad >> i & 1);
|
|
5424
|
+
for (let r = size - 8; r < size; r++) {
|
|
5425
|
+
for (let c = 0; c < 9; c++) {
|
|
5426
|
+
reserved[r][c] = true;
|
|
5240
5427
|
}
|
|
5241
|
-
padIdx = (padIdx + 1) % 2;
|
|
5242
5428
|
}
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5429
|
+
for (let i = 0; i < size; i++) {
|
|
5430
|
+
reserved[6][i] = true;
|
|
5431
|
+
reserved[i][6] = true;
|
|
5432
|
+
}
|
|
5433
|
+
for (const r of alignPositions) {
|
|
5434
|
+
for (const c of alignPositions) {
|
|
5435
|
+
for (let dr = -2; dr <= 2; dr++) {
|
|
5436
|
+
for (let dc = -2; dc <= 2; dc++) {
|
|
5437
|
+
const nr = r + dr;
|
|
5438
|
+
const nc = c + dc;
|
|
5439
|
+
if (nr >= 0 && nr < size && nc >= 0 && nc < size) {
|
|
5440
|
+
reserved[nr][nc] = true;
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
}
|
|
5248
5444
|
}
|
|
5249
|
-
dataBytes.push(b);
|
|
5250
5445
|
}
|
|
5251
|
-
|
|
5252
|
-
const
|
|
5253
|
-
|
|
5254
|
-
let
|
|
5255
|
-
let upward = true;
|
|
5446
|
+
reserved[size - 8][8] = true;
|
|
5447
|
+
const dataBytes = createData(text, version, ecl);
|
|
5448
|
+
let bitIndex = 0;
|
|
5449
|
+
let direction = -1;
|
|
5256
5450
|
for (let col = size - 1; col >= 0; col -= 2) {
|
|
5257
5451
|
if (col === 6) col = 5;
|
|
5258
|
-
for (let row =
|
|
5452
|
+
for (let row = direction === -1 ? size - 1 : 0; direction === -1 ? row >= 0 : row < size; row += direction) {
|
|
5259
5453
|
for (let c = 0; c < 2; c++) {
|
|
5260
5454
|
const tc = col - c;
|
|
5261
|
-
if (tc
|
|
5262
|
-
let
|
|
5263
|
-
if (
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
bit = bit === 1 ? 0 : 1;
|
|
5455
|
+
if (!reserved[row][tc] && mod[row][tc] === -1) {
|
|
5456
|
+
let dark = false;
|
|
5457
|
+
if (bitIndex < dataBytes.length * 8) {
|
|
5458
|
+
const byteIndex = Math.floor(bitIndex / 8);
|
|
5459
|
+
const bitPos = 7 - bitIndex % 8;
|
|
5460
|
+
dark = (dataBytes[byteIndex] >>> bitPos & 1) === 1;
|
|
5268
5461
|
}
|
|
5269
|
-
|
|
5270
|
-
|
|
5462
|
+
setModule(row, tc, dark ? 1 : 0);
|
|
5463
|
+
bitIndex++;
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5467
|
+
direction = -direction;
|
|
5468
|
+
}
|
|
5469
|
+
const maskPattern = 0;
|
|
5470
|
+
for (let row = 0; row < size; row++) {
|
|
5471
|
+
for (let col = 0; col < size; col++) {
|
|
5472
|
+
if (!reserved[row][col] && mod[row][col] !== -1) {
|
|
5473
|
+
if ((row + col) % 2 === 0) {
|
|
5474
|
+
mod[row][col] = mod[row][col] === 1 ? 0 : 1;
|
|
5271
5475
|
}
|
|
5272
5476
|
}
|
|
5273
5477
|
}
|
|
5274
|
-
upward = !upward;
|
|
5275
5478
|
}
|
|
5276
|
-
const
|
|
5277
|
-
const formatData = eclBits << 3 | 0;
|
|
5479
|
+
const formatData = ecl << 3 | maskPattern;
|
|
5278
5480
|
let rem = formatData;
|
|
5279
5481
|
for (let i = 0; i < 10; i++) {
|
|
5280
|
-
rem = rem << 1 ^ (rem
|
|
5482
|
+
rem = rem << 1 ^ (rem >>> 9) * 1335;
|
|
5281
5483
|
}
|
|
5282
|
-
const
|
|
5283
|
-
const
|
|
5484
|
+
const format = (formatData << 10 | rem & 1023) ^ 21522;
|
|
5485
|
+
const formatBits = [];
|
|
5284
5486
|
for (let i = 14; i >= 0; i--) {
|
|
5285
|
-
|
|
5286
|
-
}
|
|
5287
|
-
for (let i = 0; i < 6; i++)
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
for (let i =
|
|
5487
|
+
formatBits.push(format >>> i & 1);
|
|
5488
|
+
}
|
|
5489
|
+
for (let i = 0; i < 6; i++) {
|
|
5490
|
+
mod[8][i] = formatBits[i];
|
|
5491
|
+
}
|
|
5492
|
+
mod[8][7] = formatBits[6];
|
|
5493
|
+
mod[8][8] = formatBits[7];
|
|
5494
|
+
mod[7][8] = formatBits[8];
|
|
5495
|
+
for (let i = 9; i < 15; i++) {
|
|
5496
|
+
mod[14 - i][8] = formatBits[i];
|
|
5497
|
+
}
|
|
5498
|
+
for (let i = 0; i < 8; i++) {
|
|
5499
|
+
mod[8][size - 1 - i] = formatBits[14 - i];
|
|
5500
|
+
}
|
|
5501
|
+
for (let i = 7; i < 15; i++) {
|
|
5502
|
+
mod[size - 1 - (14 - i)][8] = formatBits[14 - i];
|
|
5503
|
+
}
|
|
5294
5504
|
const result = [];
|
|
5295
5505
|
for (let r = 0; r < size; r++) {
|
|
5296
5506
|
result[r] = [];
|
|
5297
5507
|
for (let c = 0; c < size; c++) {
|
|
5298
|
-
result[r][c] =
|
|
5508
|
+
result[r][c] = mod[r][c] === 1;
|
|
5299
5509
|
}
|
|
5300
5510
|
}
|
|
5301
|
-
return result;
|
|
5511
|
+
return { modules: result, moduleCount: size };
|
|
5302
5512
|
}
|
|
5303
5513
|
const generate = () => {
|
|
5304
5514
|
if (!props.value) {
|
|
@@ -5307,9 +5517,9 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5307
5517
|
return;
|
|
5308
5518
|
}
|
|
5309
5519
|
try {
|
|
5310
|
-
const
|
|
5311
|
-
modules.value =
|
|
5312
|
-
moduleCount.value =
|
|
5520
|
+
const qr = createQRCode(props.value, props.errorCorrectLevel);
|
|
5521
|
+
modules.value = qr.modules;
|
|
5522
|
+
moduleCount.value = qr.moduleCount;
|
|
5313
5523
|
} catch (e) {
|
|
5314
5524
|
console.error("QR Code generation failed:", e);
|
|
5315
5525
|
modules.value = [];
|
|
@@ -5318,9 +5528,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5318
5528
|
};
|
|
5319
5529
|
vue.watch(() => props.value, generate);
|
|
5320
5530
|
vue.watch(() => props.errorCorrectLevel, generate);
|
|
5321
|
-
vue.onMounted(
|
|
5322
|
-
generate();
|
|
5323
|
-
});
|
|
5531
|
+
vue.onMounted(generate);
|
|
5324
5532
|
return (_ctx, _cache) => {
|
|
5325
5533
|
return vue.openBlock(), vue.createElementBlock("view", {
|
|
5326
5534
|
class: "u-qrcode",
|
|
@@ -5353,7 +5561,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5353
5561
|
};
|
|
5354
5562
|
}
|
|
5355
5563
|
});
|
|
5356
|
-
const uQrcode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
5564
|
+
const uQrcode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-97271d75"]]);
|
|
5357
5565
|
const _hoisted_1 = { class: "u-barcode" };
|
|
5358
5566
|
const _hoisted_2 = ["canvas-id"];
|
|
5359
5567
|
const _hoisted_3 = ["src"];
|