@learncard/vpqr-plugin 1.0.11 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/vpqr-plugin.cjs.development.js +982 -1080
- package/dist/vpqr-plugin.cjs.development.js.map +4 -4
- package/dist/vpqr-plugin.cjs.production.min.js +9 -3
- package/dist/vpqr-plugin.cjs.production.min.js.map +4 -4
- package/dist/vpqr-plugin.esm.js +981 -1080
- package/dist/vpqr-plugin.esm.js.map +4 -4
- package/package.json +3 -3
@@ -1,3 +1,4 @@
|
|
1
|
+
"use strict";
|
1
2
|
var __create = Object.create;
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -20,7 +21,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
20
21
|
}
|
21
22
|
return to;
|
22
23
|
};
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
24
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
25
29
|
|
26
30
|
// ../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js
|
@@ -81,7 +85,7 @@ __export(src_exports, {
|
|
81
85
|
});
|
82
86
|
module.exports = __toCommonJS(src_exports);
|
83
87
|
|
84
|
-
// ../../../node_modules/.pnpm/cborg@
|
88
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/is.js
|
85
89
|
var typeofs = [
|
86
90
|
"string",
|
87
91
|
"number",
|
@@ -167,7 +171,7 @@ function getObjectType(value) {
|
|
167
171
|
}
|
168
172
|
__name(getObjectType, "getObjectType");
|
169
173
|
|
170
|
-
// ../../../node_modules/.pnpm/cborg@
|
174
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/token.js
|
171
175
|
var Type = class {
|
172
176
|
constructor(major, name, terminal) {
|
173
177
|
this.major = major;
|
@@ -210,7 +214,7 @@ var Token = class {
|
|
210
214
|
};
|
211
215
|
__name(Token, "Token");
|
212
216
|
|
213
|
-
// ../../../node_modules/.pnpm/cborg@
|
217
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/byte-utils.js
|
214
218
|
var useBuffer = globalThis.process && !globalThis.process.browser && globalThis.Buffer && typeof globalThis.Buffer.isBuffer === "function";
|
215
219
|
var textDecoder = new TextDecoder();
|
216
220
|
var textEncoder = new TextEncoder();
|
@@ -279,60 +283,29 @@ function compare(b1, b2) {
|
|
279
283
|
return 0;
|
280
284
|
}
|
281
285
|
__name(compare, "compare");
|
282
|
-
function utf8ToBytes(
|
283
|
-
|
284
|
-
|
285
|
-
let
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
if (
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
continue;
|
299
|
-
}
|
300
|
-
leadSurrogate = codePoint;
|
301
|
-
continue;
|
302
|
-
}
|
303
|
-
if (codePoint < 56320) {
|
304
|
-
if ((units -= 3) > -1)
|
305
|
-
bytes.push(239, 191, 189);
|
306
|
-
leadSurrogate = codePoint;
|
307
|
-
continue;
|
308
|
-
}
|
309
|
-
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
310
|
-
} else if (leadSurrogate) {
|
311
|
-
if ((units -= 3) > -1)
|
312
|
-
bytes.push(239, 191, 189);
|
313
|
-
}
|
314
|
-
leadSurrogate = null;
|
315
|
-
if (codePoint < 128) {
|
316
|
-
if ((units -= 1) < 0)
|
317
|
-
break;
|
318
|
-
bytes.push(codePoint);
|
319
|
-
} else if (codePoint < 2048) {
|
320
|
-
if ((units -= 2) < 0)
|
321
|
-
break;
|
322
|
-
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
|
323
|
-
} else if (codePoint < 65536) {
|
324
|
-
if ((units -= 3) < 0)
|
325
|
-
break;
|
326
|
-
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
327
|
-
} else if (codePoint < 1114112) {
|
328
|
-
if ((units -= 4) < 0)
|
329
|
-
break;
|
330
|
-
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
286
|
+
function utf8ToBytes(str) {
|
287
|
+
const out = [];
|
288
|
+
let p = 0;
|
289
|
+
for (let i = 0; i < str.length; i++) {
|
290
|
+
let c = str.charCodeAt(i);
|
291
|
+
if (c < 128) {
|
292
|
+
out[p++] = c;
|
293
|
+
} else if (c < 2048) {
|
294
|
+
out[p++] = c >> 6 | 192;
|
295
|
+
out[p++] = c & 63 | 128;
|
296
|
+
} else if ((c & 64512) === 55296 && i + 1 < str.length && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
297
|
+
c = 65536 + ((c & 1023) << 10) + (str.charCodeAt(++i) & 1023);
|
298
|
+
out[p++] = c >> 18 | 240;
|
299
|
+
out[p++] = c >> 12 & 63 | 128;
|
300
|
+
out[p++] = c >> 6 & 63 | 128;
|
301
|
+
out[p++] = c & 63 | 128;
|
331
302
|
} else {
|
332
|
-
|
303
|
+
out[p++] = c >> 12 | 224;
|
304
|
+
out[p++] = c >> 6 & 63 | 128;
|
305
|
+
out[p++] = c & 63 | 128;
|
333
306
|
}
|
334
307
|
}
|
335
|
-
return
|
308
|
+
return out;
|
336
309
|
}
|
337
310
|
__name(utf8ToBytes, "utf8ToBytes");
|
338
311
|
function utf8Slice(buf2, offset, end) {
|
@@ -403,13 +376,16 @@ function decodeCodePointsArray(codePoints) {
|
|
403
376
|
let res = "";
|
404
377
|
let i = 0;
|
405
378
|
while (i < len) {
|
406
|
-
res += String.fromCharCode.apply(
|
379
|
+
res += String.fromCharCode.apply(
|
380
|
+
String,
|
381
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
382
|
+
);
|
407
383
|
}
|
408
384
|
return res;
|
409
385
|
}
|
410
386
|
__name(decodeCodePointsArray, "decodeCodePointsArray");
|
411
387
|
|
412
|
-
// ../../../node_modules/.pnpm/cborg@
|
388
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/bl.js
|
413
389
|
var defaultChunkSize = 256;
|
414
390
|
var Bl = class {
|
415
391
|
constructor(chunkSize = defaultChunkSize) {
|
@@ -481,7 +457,7 @@ var Bl = class {
|
|
481
457
|
};
|
482
458
|
__name(Bl, "Bl");
|
483
459
|
|
484
|
-
// ../../../node_modules/.pnpm/cborg@
|
460
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/common.js
|
485
461
|
var decodeErrPrefix = "CBOR decode error:";
|
486
462
|
var encodeErrPrefix = "CBOR encode error:";
|
487
463
|
var uintMinorPrefixBytes = [];
|
@@ -497,14 +473,8 @@ function assertEnoughData(data, pos, need) {
|
|
497
473
|
}
|
498
474
|
__name(assertEnoughData, "assertEnoughData");
|
499
475
|
|
500
|
-
// ../../../node_modules/.pnpm/cborg@
|
501
|
-
var uintBoundaries = [
|
502
|
-
24,
|
503
|
-
256,
|
504
|
-
65536,
|
505
|
-
4294967296,
|
506
|
-
BigInt("18446744073709551616")
|
507
|
-
];
|
476
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/0uint.js
|
477
|
+
var uintBoundaries = [24, 256, 65536, 4294967296, BigInt("18446744073709551616")];
|
508
478
|
function readUint8(data, offset, options) {
|
509
479
|
assertEnoughData(data, offset, 1);
|
510
480
|
const value = data[offset];
|
@@ -575,39 +545,17 @@ function encodeUintValue(buf2, major, uint) {
|
|
575
545
|
buf2.push([major | nuint]);
|
576
546
|
} else if (uint < uintBoundaries[1]) {
|
577
547
|
const nuint = Number(uint);
|
578
|
-
buf2.push([
|
579
|
-
major | 24,
|
580
|
-
nuint
|
581
|
-
]);
|
548
|
+
buf2.push([major | 24, nuint]);
|
582
549
|
} else if (uint < uintBoundaries[2]) {
|
583
550
|
const nuint = Number(uint);
|
584
|
-
buf2.push([
|
585
|
-
major | 25,
|
586
|
-
nuint >>> 8,
|
587
|
-
nuint & 255
|
588
|
-
]);
|
551
|
+
buf2.push([major | 25, nuint >>> 8, nuint & 255]);
|
589
552
|
} else if (uint < uintBoundaries[3]) {
|
590
553
|
const nuint = Number(uint);
|
591
|
-
buf2.push([
|
592
|
-
major | 26,
|
593
|
-
nuint >>> 24 & 255,
|
594
|
-
nuint >>> 16 & 255,
|
595
|
-
nuint >>> 8 & 255,
|
596
|
-
nuint & 255
|
597
|
-
]);
|
554
|
+
buf2.push([major | 26, nuint >>> 24 & 255, nuint >>> 16 & 255, nuint >>> 8 & 255, nuint & 255]);
|
598
555
|
} else {
|
599
556
|
const buint = BigInt(uint);
|
600
557
|
if (buint < uintBoundaries[4]) {
|
601
|
-
const set = [
|
602
|
-
major | 27,
|
603
|
-
0,
|
604
|
-
0,
|
605
|
-
0,
|
606
|
-
0,
|
607
|
-
0,
|
608
|
-
0,
|
609
|
-
0
|
610
|
-
];
|
558
|
+
const set = [major | 27, 0, 0, 0, 0, 0, 0, 0];
|
611
559
|
let lo = Number(buint & BigInt(4294967295));
|
612
560
|
let hi = Number(buint >> BigInt(32) & BigInt(4294967295));
|
613
561
|
set[8] = lo & 255;
|
@@ -653,7 +601,7 @@ encodeUint.compareTokens = /* @__PURE__ */ __name(function compareTokens(tok1, t
|
|
653
601
|
return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : 0;
|
654
602
|
}, "compareTokens");
|
655
603
|
|
656
|
-
// ../../../node_modules/.pnpm/cborg@
|
604
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/1negint.js
|
657
605
|
function decodeNegint8(data, pos, _minor, options) {
|
658
606
|
return new Token(Type.negint, -1 - readUint8(data, pos + 1, options), 2);
|
659
607
|
}
|
@@ -709,7 +657,7 @@ encodeNegint.compareTokens = /* @__PURE__ */ __name(function compareTokens2(tok1
|
|
709
657
|
return tok1.value < tok2.value ? 1 : tok1.value > tok2.value ? -1 : 0;
|
710
658
|
}, "compareTokens");
|
711
659
|
|
712
|
-
// ../../../node_modules/.pnpm/cborg@
|
660
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/2bytes.js
|
713
661
|
function toToken(data, pos, prefix, length) {
|
714
662
|
assertEnoughData(data, pos, prefix + length);
|
715
663
|
const buf2 = slice(data, pos + prefix, pos + prefix + length);
|
@@ -765,7 +713,7 @@ function compareBytes(b1, b2) {
|
|
765
713
|
}
|
766
714
|
__name(compareBytes, "compareBytes");
|
767
715
|
|
768
|
-
// ../../../node_modules/.pnpm/cborg@
|
716
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/3string.js
|
769
717
|
function toToken2(data, pos, prefix, length, options) {
|
770
718
|
const totLength = prefix + length;
|
771
719
|
assertEnoughData(data, pos, totLength);
|
@@ -802,7 +750,7 @@ function decodeString64(data, pos, _minor, options) {
|
|
802
750
|
__name(decodeString64, "decodeString64");
|
803
751
|
var encodeString = encodeBytes;
|
804
752
|
|
805
|
-
// ../../../node_modules/.pnpm/cborg@
|
753
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/4array.js
|
806
754
|
function toToken3(_data, _pos, prefix, length) {
|
807
755
|
return new Token(Type.array, length, prefix);
|
808
756
|
}
|
@@ -847,7 +795,7 @@ encodeArray.encodedSize = /* @__PURE__ */ __name(function encodedSize5(token) {
|
|
847
795
|
return encodeUintValue.encodedSize(token.value);
|
848
796
|
}, "encodedSize");
|
849
797
|
|
850
|
-
// ../../../node_modules/.pnpm/cborg@
|
798
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/5map.js
|
851
799
|
function toToken4(_data, _pos, prefix, length) {
|
852
800
|
return new Token(Type.map, length, prefix);
|
853
801
|
}
|
@@ -892,7 +840,7 @@ encodeMap.encodedSize = /* @__PURE__ */ __name(function encodedSize6(token) {
|
|
892
840
|
return encodeUintValue.encodedSize(token.value);
|
893
841
|
}, "encodedSize");
|
894
842
|
|
895
|
-
// ../../../node_modules/.pnpm/cborg@
|
843
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/6tag.js
|
896
844
|
function decodeTagCompact(_data, _pos, minor, _options) {
|
897
845
|
return new Token(Type.tag, minor, 1);
|
898
846
|
}
|
@@ -922,7 +870,7 @@ encodeTag.encodedSize = /* @__PURE__ */ __name(function encodedSize7(token) {
|
|
922
870
|
return encodeUintValue.encodedSize(token.value);
|
923
871
|
}, "encodedSize");
|
924
872
|
|
925
|
-
// ../../../node_modules/.pnpm/cborg@
|
873
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/7float.js
|
926
874
|
var MINOR_FALSE = 20;
|
927
875
|
var MINOR_TRUE = 21;
|
928
876
|
var MINOR_NULL = 22;
|
@@ -1110,7 +1058,7 @@ function readFloat64(ui8a2, pos) {
|
|
1110
1058
|
__name(readFloat64, "readFloat64");
|
1111
1059
|
encodeFloat.compareTokens = encodeUint.compareTokens;
|
1112
1060
|
|
1113
|
-
// ../../../node_modules/.pnpm/cborg@
|
1061
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/jump.js
|
1114
1062
|
function invalidMinor(data, pos, minor) {
|
1115
1063
|
throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`);
|
1116
1064
|
}
|
@@ -1269,7 +1217,7 @@ function quickEncodeToken(token) {
|
|
1269
1217
|
}
|
1270
1218
|
__name(quickEncodeToken, "quickEncodeToken");
|
1271
1219
|
|
1272
|
-
// ../../../node_modules/.pnpm/cborg@
|
1220
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/encode.js
|
1273
1221
|
var defaultEncodeOptions = {
|
1274
1222
|
float64: false,
|
1275
1223
|
mapSorter,
|
@@ -1361,10 +1309,7 @@ var typeEncoders = {
|
|
1361
1309
|
Array(obj, _typ, options, refStack) {
|
1362
1310
|
if (!obj.length) {
|
1363
1311
|
if (options.addBreakTokens === true) {
|
1364
|
-
return [
|
1365
|
-
simpleTokens.emptyArray,
|
1366
|
-
new Token(Type.break)
|
1367
|
-
];
|
1312
|
+
return [simpleTokens.emptyArray, new Token(Type.break)];
|
1368
1313
|
}
|
1369
1314
|
return simpleTokens.emptyArray;
|
1370
1315
|
}
|
@@ -1375,16 +1320,9 @@ var typeEncoders = {
|
|
1375
1320
|
entries[i++] = objectToTokens(e, options, refStack);
|
1376
1321
|
}
|
1377
1322
|
if (options.addBreakTokens) {
|
1378
|
-
return [
|
1379
|
-
new Token(Type.array, obj.length),
|
1380
|
-
entries,
|
1381
|
-
new Token(Type.break)
|
1382
|
-
];
|
1323
|
+
return [new Token(Type.array, obj.length), entries, new Token(Type.break)];
|
1383
1324
|
}
|
1384
|
-
return [
|
1385
|
-
new Token(Type.array, obj.length),
|
1386
|
-
entries
|
1387
|
-
];
|
1325
|
+
return [new Token(Type.array, obj.length), entries];
|
1388
1326
|
},
|
1389
1327
|
Object(obj, typ, options, refStack) {
|
1390
1328
|
const isMap = typ !== "Object";
|
@@ -1392,10 +1330,7 @@ var typeEncoders = {
|
|
1392
1330
|
const length = isMap ? obj.size : keys.length;
|
1393
1331
|
if (!length) {
|
1394
1332
|
if (options.addBreakTokens === true) {
|
1395
|
-
return [
|
1396
|
-
simpleTokens.emptyMap,
|
1397
|
-
new Token(Type.break)
|
1398
|
-
];
|
1333
|
+
return [simpleTokens.emptyMap, new Token(Type.break)];
|
1399
1334
|
}
|
1400
1335
|
return simpleTokens.emptyMap;
|
1401
1336
|
}
|
@@ -1410,16 +1345,9 @@ var typeEncoders = {
|
|
1410
1345
|
}
|
1411
1346
|
sortMapEntries(entries, options);
|
1412
1347
|
if (options.addBreakTokens) {
|
1413
|
-
return [
|
1414
|
-
new Token(Type.map, length),
|
1415
|
-
entries,
|
1416
|
-
new Token(Type.break)
|
1417
|
-
];
|
1348
|
+
return [new Token(Type.map, length), entries, new Token(Type.break)];
|
1418
1349
|
}
|
1419
|
-
return [
|
1420
|
-
new Token(Type.map, length),
|
1421
|
-
entries
|
1422
|
-
];
|
1350
|
+
return [new Token(Type.map, length), entries];
|
1423
1351
|
}
|
1424
1352
|
};
|
1425
1353
|
typeEncoders.Map = typeEncoders.Object;
|
@@ -1502,7 +1430,7 @@ function encode(data, options) {
|
|
1502
1430
|
}
|
1503
1431
|
__name(encode, "encode");
|
1504
1432
|
|
1505
|
-
// ../../../node_modules/.pnpm/cborg@
|
1433
|
+
// ../../../node_modules/.pnpm/cborg@4.2.4/node_modules/cborg/lib/decode.js
|
1506
1434
|
var defaultDecodeOptions = {
|
1507
1435
|
strict: false,
|
1508
1436
|
allowIndefinite: true,
|
@@ -1511,15 +1439,18 @@ var defaultDecodeOptions = {
|
|
1511
1439
|
};
|
1512
1440
|
var Tokeniser = class {
|
1513
1441
|
constructor(data, options = {}) {
|
1514
|
-
this.
|
1442
|
+
this._pos = 0;
|
1515
1443
|
this.data = data;
|
1516
1444
|
this.options = options;
|
1517
1445
|
}
|
1446
|
+
pos() {
|
1447
|
+
return this._pos;
|
1448
|
+
}
|
1518
1449
|
done() {
|
1519
|
-
return this.
|
1450
|
+
return this._pos >= this.data.length;
|
1520
1451
|
}
|
1521
1452
|
next() {
|
1522
|
-
const byt = this.data[this.
|
1453
|
+
const byt = this.data[this._pos];
|
1523
1454
|
let token = quick[byt];
|
1524
1455
|
if (token === void 0) {
|
1525
1456
|
const decoder = jump[byt];
|
@@ -1527,9 +1458,9 @@ var Tokeniser = class {
|
|
1527
1458
|
throw new Error(`${decodeErrPrefix} no decoder for major type ${byt >>> 5} (byte 0x${byt.toString(16).padStart(2, "0")})`);
|
1528
1459
|
}
|
1529
1460
|
const minor = byt & 31;
|
1530
|
-
token = decoder(this.data, this.
|
1461
|
+
token = decoder(this.data, this._pos, minor, this.options);
|
1531
1462
|
}
|
1532
|
-
this.
|
1463
|
+
this._pos += token.encodedLength;
|
1533
1464
|
return token;
|
1534
1465
|
}
|
1535
1466
|
};
|
@@ -1617,7 +1548,7 @@ function tokensToObject(tokeniser, options) {
|
|
1617
1548
|
throw new Error("unsupported");
|
1618
1549
|
}
|
1619
1550
|
__name(tokensToObject, "tokensToObject");
|
1620
|
-
function
|
1551
|
+
function decodeFirst(data, options) {
|
1621
1552
|
if (!(data instanceof Uint8Array)) {
|
1622
1553
|
throw new Error(`${decodeErrPrefix} data to decode must be a Uint8Array`);
|
1623
1554
|
}
|
@@ -1630,14 +1561,19 @@ function decode(data, options) {
|
|
1630
1561
|
if (decoded === BREAK) {
|
1631
1562
|
throw new Error(`${decodeErrPrefix} got unexpected break`);
|
1632
1563
|
}
|
1633
|
-
|
1564
|
+
return [decoded, data.subarray(tokeniser.pos())];
|
1565
|
+
}
|
1566
|
+
__name(decodeFirst, "decodeFirst");
|
1567
|
+
function decode(data, options) {
|
1568
|
+
const [decoded, remainder] = decodeFirst(data, options);
|
1569
|
+
if (remainder.length > 0) {
|
1634
1570
|
throw new Error(`${decodeErrPrefix} too many terminals, data makes no sense`);
|
1635
1571
|
}
|
1636
1572
|
return decoded;
|
1637
1573
|
}
|
1638
1574
|
__name(decode, "decode");
|
1639
1575
|
|
1640
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
1576
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/CborldError.js
|
1641
1577
|
var CborldError = class extends Error {
|
1642
1578
|
constructor(value, message) {
|
1643
1579
|
super();
|
@@ -1649,7 +1585,39 @@ var CborldError = class extends Error {
|
|
1649
1585
|
};
|
1650
1586
|
__name(CborldError, "CborldError");
|
1651
1587
|
|
1652
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
1588
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/keywords.js
|
1589
|
+
var KEYWORDS = /* @__PURE__ */ new Map([
|
1590
|
+
["@context", 0],
|
1591
|
+
["@type", 2],
|
1592
|
+
["@id", 4],
|
1593
|
+
["@value", 6],
|
1594
|
+
["@direction", 8],
|
1595
|
+
["@graph", 10],
|
1596
|
+
["@included", 12],
|
1597
|
+
["@index", 14],
|
1598
|
+
["@json", 16],
|
1599
|
+
["@language", 18],
|
1600
|
+
["@list", 20],
|
1601
|
+
["@nest", 22],
|
1602
|
+
["@reverse", 24],
|
1603
|
+
["@base", 26],
|
1604
|
+
["@container", 28],
|
1605
|
+
["@default", 30],
|
1606
|
+
["@embed", 32],
|
1607
|
+
["@explicit", 34],
|
1608
|
+
["@none", 36],
|
1609
|
+
["@omitDefault", 38],
|
1610
|
+
["@prefix", 40],
|
1611
|
+
["@preserve", 42],
|
1612
|
+
["@protected", 44],
|
1613
|
+
["@requireAll", 46],
|
1614
|
+
["@set", 48],
|
1615
|
+
["@version", 50],
|
1616
|
+
["@vocab", 52]
|
1617
|
+
]);
|
1618
|
+
var FIRST_CUSTOM_TERM_ID = 100;
|
1619
|
+
|
1620
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/CborldDecoder.js
|
1653
1621
|
var CborldDecoder = class {
|
1654
1622
|
decode({ value } = {}) {
|
1655
1623
|
throw new Error("Must be implemented by derived class.");
|
@@ -1660,7 +1628,7 @@ var CborldDecoder = class {
|
|
1660
1628
|
};
|
1661
1629
|
__name(CborldDecoder, "CborldDecoder");
|
1662
1630
|
|
1663
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
1631
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/registeredContexts.js
|
1664
1632
|
var ID_TO_URL = /* @__PURE__ */ new Map();
|
1665
1633
|
var URL_TO_ID = /* @__PURE__ */ new Map();
|
1666
1634
|
_addRegistration(16, "https://www.w3.org/ns/activitystreams");
|
@@ -1678,15 +1646,19 @@ _addRegistration(27, "https://w3id.org/security/suites/hmac-2019/v1");
|
|
1678
1646
|
_addRegistration(28, "https://w3id.org/security/suites/aes-2019/v1");
|
1679
1647
|
_addRegistration(29, "https://w3id.org/vaccination/v1");
|
1680
1648
|
_addRegistration(30, "https://w3id.org/vc-revocation-list-2020/v1");
|
1681
|
-
_addRegistration(31, "https://w3id.org/dcc/
|
1649
|
+
_addRegistration(31, "https://w3id.org/dcc/v1");
|
1682
1650
|
_addRegistration(32, "https://w3id.org/vc/status-list/v1");
|
1651
|
+
_addRegistration(48, "https://w3id.org/security/data-integrity/v1");
|
1652
|
+
_addRegistration(49, "https://w3id.org/security/multikey/v1");
|
1653
|
+
_addRegistration(50, "https://purl.imsglobal.org/spec/ob/v3p0/context.json");
|
1654
|
+
_addRegistration(51, "https://w3id.org/security/data-integrity/v2");
|
1683
1655
|
function _addRegistration(id, url) {
|
1684
1656
|
URL_TO_ID.set(url, id);
|
1685
1657
|
ID_TO_URL.set(id, url);
|
1686
1658
|
}
|
1687
1659
|
__name(_addRegistration, "_addRegistration");
|
1688
1660
|
|
1689
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
1661
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/ContextDecoder.js
|
1690
1662
|
var ContextDecoder = class extends CborldDecoder {
|
1691
1663
|
constructor({ reverseAppContextMap } = {}) {
|
1692
1664
|
super();
|
@@ -1698,7 +1670,10 @@ var ContextDecoder = class extends CborldDecoder {
|
|
1698
1670
|
}
|
1699
1671
|
const url = ID_TO_URL.get(value) || this.reverseAppContextMap.get(value);
|
1700
1672
|
if (url === void 0) {
|
1701
|
-
throw new CborldError(
|
1673
|
+
throw new CborldError(
|
1674
|
+
"ERR_UNDEFINED_COMPRESSED_CONTEXT",
|
1675
|
+
`Undefined compressed context "${value}".`
|
1676
|
+
);
|
1702
1677
|
}
|
1703
1678
|
return url;
|
1704
1679
|
}
|
@@ -1723,11 +1698,15 @@ function _mapToObject(map) {
|
|
1723
1698
|
}
|
1724
1699
|
__name(_mapToObject, "_mapToObject");
|
1725
1700
|
|
1726
|
-
// ../../../node_modules/.pnpm
|
1727
|
-
|
1701
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/util-browser.js
|
1702
|
+
function inspect(data, options) {
|
1703
|
+
return JSON.stringify(data, null, 2);
|
1704
|
+
}
|
1705
|
+
__name(inspect, "inspect");
|
1706
|
+
|
1707
|
+
// ../../../node_modules/.pnpm/js-base64@3.7.7/node_modules/js-base64/base64.mjs
|
1708
|
+
var version = "3.7.7";
|
1728
1709
|
var VERSION = version;
|
1729
|
-
var _hasatob = typeof atob === "function";
|
1730
|
-
var _hasbtoa = typeof btoa === "function";
|
1731
1710
|
var _hasBuffer = typeof Buffer === "function";
|
1732
1711
|
var _TD = typeof TextDecoder === "function" ? new TextDecoder() : void 0;
|
1733
1712
|
var _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
|
@@ -1754,7 +1733,7 @@ var btoaPolyfill = /* @__PURE__ */ __name((bin) => {
|
|
1754
1733
|
}
|
1755
1734
|
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
1756
1735
|
}, "btoaPolyfill");
|
1757
|
-
var _btoa =
|
1736
|
+
var _btoa = typeof btoa === "function" ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
|
1758
1737
|
var _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
|
1759
1738
|
const maxargs = 4096;
|
1760
1739
|
let strs = [];
|
@@ -1803,7 +1782,7 @@ var atobPolyfill = /* @__PURE__ */ __name((asc) => {
|
|
1803
1782
|
}
|
1804
1783
|
return bin;
|
1805
1784
|
}, "atobPolyfill");
|
1806
|
-
var _atob =
|
1785
|
+
var _atob = typeof atob === "function" ? (asc) => atob(_tidyB64(asc)) : _hasBuffer ? (asc) => Buffer.from(asc, "base64").toString("binary") : atobPolyfill;
|
1807
1786
|
var _toUint8Array = _hasBuffer ? (a) => _U8Afrom(Buffer.from(a, "base64")) : (a) => _U8Afrom(_atob(a).split("").map((c) => c.charCodeAt(0)));
|
1808
1787
|
var toUint8Array = /* @__PURE__ */ __name((a) => _toUint8Array(_unURI(a)), "toUint8Array");
|
1809
1788
|
var _decode = _hasBuffer ? (a) => Buffer.from(a, "base64").toString("utf8") : _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
|
@@ -1980,7 +1959,7 @@ function decode4(input) {
|
|
1980
1959
|
}
|
1981
1960
|
__name(decode4, "decode");
|
1982
1961
|
|
1983
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
1962
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/MultibaseDecoder.js
|
1984
1963
|
var MultibaseDecoder = class extends CborldDecoder {
|
1985
1964
|
decode({ value } = {}) {
|
1986
1965
|
const { buffer: buffer2, byteOffset, length } = value;
|
@@ -2004,39 +1983,7 @@ var MultibaseDecoder = class extends CborldDecoder {
|
|
2004
1983
|
};
|
2005
1984
|
__name(MultibaseDecoder, "MultibaseDecoder");
|
2006
1985
|
|
2007
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2008
|
-
var KEYWORDS = /* @__PURE__ */ new Map([
|
2009
|
-
["@context", 0],
|
2010
|
-
["@type", 2],
|
2011
|
-
["@id", 4],
|
2012
|
-
["@value", 6],
|
2013
|
-
["@direction", 8],
|
2014
|
-
["@graph", 10],
|
2015
|
-
["@included", 12],
|
2016
|
-
["@index", 14],
|
2017
|
-
["@json", 16],
|
2018
|
-
["@language", 18],
|
2019
|
-
["@list", 20],
|
2020
|
-
["@nest", 22],
|
2021
|
-
["@reverse", 24],
|
2022
|
-
["@base", 26],
|
2023
|
-
["@container", 28],
|
2024
|
-
["@default", 30],
|
2025
|
-
["@embed", 32],
|
2026
|
-
["@explicit", 34],
|
2027
|
-
["@none", 36],
|
2028
|
-
["@omitDefault", 38],
|
2029
|
-
["@prefix", 40],
|
2030
|
-
["@preserve", 42],
|
2031
|
-
["@protected", 44],
|
2032
|
-
["@requireAll", 46],
|
2033
|
-
["@set", 48],
|
2034
|
-
["@version", 50],
|
2035
|
-
["@vocab", 52]
|
2036
|
-
]);
|
2037
|
-
var FIRST_CUSTOM_TERM_ID = 100;
|
2038
|
-
|
2039
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.0.0/node_modules/@digitalbazaar/cborld/lib/Transformer.js
|
1986
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/Transformer.js
|
2040
1987
|
var Transformer = class {
|
2041
1988
|
constructor({ appContextMap, documentLoader } = {}) {
|
2042
1989
|
this.appContextMap = appContextMap;
|
@@ -2056,7 +2003,9 @@ var Transformer = class {
|
|
2056
2003
|
this._beforeTypeScopedContexts({ activeCtx, obj, transformMap });
|
2057
2004
|
activeCtx = await this._applyTypeScopedContexts({ obj, contextStack });
|
2058
2005
|
const { aliases, scopedContextMap, termMap } = activeCtx;
|
2059
|
-
const termEntries = this._getEntries(
|
2006
|
+
const termEntries = this._getEntries(
|
2007
|
+
{ obj, transformMap, transformer: this, termMap }
|
2008
|
+
);
|
2060
2009
|
for (const [termInfo, value] of termEntries) {
|
2061
2010
|
const { term } = termInfo;
|
2062
2011
|
if (term === "@id" || aliases.id.has(term)) {
|
@@ -2078,7 +2027,9 @@ var Transformer = class {
|
|
2078
2027
|
propertyContextStack = contextStack.slice();
|
2079
2028
|
}
|
2080
2029
|
const { plural, def } = termInfo;
|
2081
|
-
const termType = this._getTermType(
|
2030
|
+
const termType = this._getTermType(
|
2031
|
+
{ activeCtx: newActiveCtx || activeCtx, def }
|
2032
|
+
);
|
2082
2033
|
const values = plural ? value : [value];
|
2083
2034
|
const entries = [];
|
2084
2035
|
for (const value2 of values) {
|
@@ -2094,7 +2045,9 @@ var Transformer = class {
|
|
2094
2045
|
continue;
|
2095
2046
|
}
|
2096
2047
|
if (Array.isArray(value2)) {
|
2097
|
-
await this._transformArray(
|
2048
|
+
await this._transformArray(
|
2049
|
+
{ entries, contextStack: propertyContextStack, value: value2 }
|
2050
|
+
);
|
2098
2051
|
continue;
|
2099
2052
|
}
|
2100
2053
|
await this._transformObject({
|
@@ -2235,8 +2188,12 @@ var Transformer = class {
|
|
2235
2188
|
if (importUrl) {
|
2236
2189
|
let importEntry = contextMap.get(importUrl);
|
2237
2190
|
if (!importEntry) {
|
2238
|
-
const { "@context": importCtx } = await this._getDocument(
|
2239
|
-
|
2191
|
+
const { "@context": importCtx } = await this._getDocument(
|
2192
|
+
{ url: importUrl }
|
2193
|
+
);
|
2194
|
+
importEntry = await this._addContext(
|
2195
|
+
{ context: importCtx, contextUrl: importUrl }
|
2196
|
+
);
|
2240
2197
|
}
|
2241
2198
|
context = { ...importEntry.context, ...context };
|
2242
2199
|
}
|
@@ -2300,14 +2257,20 @@ var Transformer = class {
|
|
2300
2257
|
return prefixDef + suffix.join(":");
|
2301
2258
|
}
|
2302
2259
|
if (!(typeof prefixDef === "object" && typeof prefixDef["@id"] === "string")) {
|
2303
|
-
throw new CborldError(
|
2260
|
+
throw new CborldError(
|
2261
|
+
"ERR_INVALID_TERM_DEFINITION",
|
2262
|
+
'JSON-LD term definitions must be strings or objects with "@id".'
|
2263
|
+
);
|
2304
2264
|
}
|
2305
2265
|
return prefixDef["@id"] + suffix.join(":");
|
2306
2266
|
}
|
2307
2267
|
_getIdForTerm({ term, plural }) {
|
2308
2268
|
const id = this.termToId.get(term);
|
2309
2269
|
if (id === void 0) {
|
2310
|
-
throw new CborldError(
|
2270
|
+
throw new CborldError(
|
2271
|
+
"ERR_UNDEFINED_TERM",
|
2272
|
+
"CBOR-LD compression requires all terms to be defined in a JSON-LD context."
|
2273
|
+
);
|
2311
2274
|
}
|
2312
2275
|
return plural ? id + 1 : id;
|
2313
2276
|
}
|
@@ -2319,7 +2282,7 @@ var Transformer = class {
|
|
2319
2282
|
};
|
2320
2283
|
__name(Transformer, "Transformer");
|
2321
2284
|
|
2322
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2285
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/Base58DidUrlDecoder.js
|
2323
2286
|
var ID_TO_SCHEME = /* @__PURE__ */ new Map([
|
2324
2287
|
[1024, "did:v1:nym:"],
|
2325
2288
|
[1025, "did:key:"]
|
@@ -2353,7 +2316,7 @@ var Base58DidUrlDecoder = class extends CborldDecoder {
|
|
2353
2316
|
};
|
2354
2317
|
__name(Base58DidUrlDecoder, "Base58DidUrlDecoder");
|
2355
2318
|
|
2356
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2319
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/HttpUrlDecoder.js
|
2357
2320
|
var HttpUrlDecoder = class extends CborldDecoder {
|
2358
2321
|
constructor({ secure } = {}) {
|
2359
2322
|
super();
|
@@ -2372,25 +2335,27 @@ var HttpUrlDecoder = class extends CborldDecoder {
|
|
2372
2335
|
};
|
2373
2336
|
__name(HttpUrlDecoder, "HttpUrlDecoder");
|
2374
2337
|
|
2375
|
-
// ../../../node_modules/.pnpm/uuid@
|
2338
|
+
// ../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/regex.js
|
2376
2339
|
var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
2377
2340
|
|
2378
|
-
// ../../../node_modules/.pnpm/uuid@
|
2341
|
+
// ../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/validate.js
|
2379
2342
|
function validate(uuid) {
|
2380
2343
|
return typeof uuid === "string" && regex_default.test(uuid);
|
2381
2344
|
}
|
2382
2345
|
__name(validate, "validate");
|
2383
2346
|
var validate_default = validate;
|
2384
2347
|
|
2385
|
-
// ../../../node_modules/.pnpm/uuid@
|
2348
|
+
// ../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/stringify.js
|
2386
2349
|
var byteToHex = [];
|
2387
|
-
for (i = 0; i < 256; ++i) {
|
2388
|
-
byteToHex.push((i + 256).toString(16).
|
2350
|
+
for (let i = 0; i < 256; ++i) {
|
2351
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
2389
2352
|
}
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2353
|
+
function unsafeStringify(arr, offset = 0) {
|
2354
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
2355
|
+
}
|
2356
|
+
__name(unsafeStringify, "unsafeStringify");
|
2357
|
+
function stringify(arr, offset = 0) {
|
2358
|
+
const uuid = unsafeStringify(arr, offset);
|
2394
2359
|
if (!validate_default(uuid)) {
|
2395
2360
|
throw TypeError("Stringified UUID is invalid");
|
2396
2361
|
}
|
@@ -2399,13 +2364,13 @@ function stringify(arr) {
|
|
2399
2364
|
__name(stringify, "stringify");
|
2400
2365
|
var stringify_default = stringify;
|
2401
2366
|
|
2402
|
-
// ../../../node_modules/.pnpm/uuid@
|
2367
|
+
// ../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/parse.js
|
2403
2368
|
function parse(uuid) {
|
2404
2369
|
if (!validate_default(uuid)) {
|
2405
2370
|
throw TypeError("Invalid UUID");
|
2406
2371
|
}
|
2407
|
-
|
2408
|
-
|
2372
|
+
let v;
|
2373
|
+
const arr = new Uint8Array(16);
|
2409
2374
|
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
2410
2375
|
arr[1] = v >>> 16 & 255;
|
2411
2376
|
arr[2] = v >>> 8 & 255;
|
@@ -2427,7 +2392,7 @@ function parse(uuid) {
|
|
2427
2392
|
__name(parse, "parse");
|
2428
2393
|
var parse_default = parse;
|
2429
2394
|
|
2430
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2395
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/UuidUrnDecoder.js
|
2431
2396
|
var UuidUrnDecoder = class extends CborldDecoder {
|
2432
2397
|
decode({ value } = {}) {
|
2433
2398
|
const uuid = typeof value[1] === "string" ? value[1] : stringify_default(value[1]);
|
@@ -2441,7 +2406,7 @@ var UuidUrnDecoder = class extends CborldDecoder {
|
|
2441
2406
|
};
|
2442
2407
|
__name(UuidUrnDecoder, "UuidUrnDecoder");
|
2443
2408
|
|
2444
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2409
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/UriDecoder.js
|
2445
2410
|
var SCHEME_ID_TO_DECODER = /* @__PURE__ */ new Map([
|
2446
2411
|
[1, HttpUrlDecoder],
|
2447
2412
|
[2, HttpUrlDecoder],
|
@@ -2460,7 +2425,7 @@ var UriDecoder = class extends CborldDecoder {
|
|
2460
2425
|
};
|
2461
2426
|
__name(UriDecoder, "UriDecoder");
|
2462
2427
|
|
2463
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2428
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/VocabTermDecoder.js
|
2464
2429
|
var VocabTermDecoder = class extends CborldDecoder {
|
2465
2430
|
constructor({ term } = {}) {
|
2466
2431
|
super();
|
@@ -2481,7 +2446,7 @@ var VocabTermDecoder = class extends CborldDecoder {
|
|
2481
2446
|
};
|
2482
2447
|
__name(VocabTermDecoder, "VocabTermDecoder");
|
2483
2448
|
|
2484
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2449
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/XsdDateDecoder.js
|
2485
2450
|
var XsdDateDecoder = class extends CborldDecoder {
|
2486
2451
|
decode({ value } = {}) {
|
2487
2452
|
const dateString = new Date(value * 1e3).toISOString();
|
@@ -2495,7 +2460,7 @@ var XsdDateDecoder = class extends CborldDecoder {
|
|
2495
2460
|
};
|
2496
2461
|
__name(XsdDateDecoder, "XsdDateDecoder");
|
2497
2462
|
|
2498
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2463
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/XsdDateTimeDecoder.js
|
2499
2464
|
var XsdDateTimeDecoder = class extends CborldDecoder {
|
2500
2465
|
constructor({ value } = {}) {
|
2501
2466
|
super();
|
@@ -2518,13 +2483,7 @@ var XsdDateTimeDecoder = class extends CborldDecoder {
|
|
2518
2483
|
};
|
2519
2484
|
__name(XsdDateTimeDecoder, "XsdDateTimeDecoder");
|
2520
2485
|
|
2521
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2522
|
-
function inspect(data, options) {
|
2523
|
-
return JSON.stringify(data, null, 2);
|
2524
|
-
}
|
2525
|
-
__name(inspect, "inspect");
|
2526
|
-
|
2527
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.0.0/node_modules/@digitalbazaar/cborld/lib/Decompressor.js
|
2486
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/Decompressor.js
|
2528
2487
|
var TYPE_DECODERS = /* @__PURE__ */ new Map([
|
2529
2488
|
["@id", UriDecoder],
|
2530
2489
|
["@vocab", VocabTermDecoder],
|
@@ -2570,20 +2529,30 @@ var Decompressor = class extends Transformer {
|
|
2570
2529
|
_beforeObjectContexts({ obj, transformMap }) {
|
2571
2530
|
const encodedContext = transformMap.get(CONTEXT_TERM_ID);
|
2572
2531
|
if (encodedContext) {
|
2573
|
-
const decoder = ContextDecoder.createDecoder(
|
2532
|
+
const decoder = ContextDecoder.createDecoder(
|
2533
|
+
{ value: encodedContext, transformer: this }
|
2534
|
+
);
|
2574
2535
|
obj["@context"] = decoder ? decoder.decode({ value: encodedContext }) : encodedContext;
|
2575
2536
|
}
|
2576
2537
|
const encodedContexts = transformMap.get(CONTEXT_TERM_ID_PLURAL);
|
2577
2538
|
if (encodedContexts) {
|
2578
2539
|
if (encodedContext) {
|
2579
|
-
throw new CborldError(
|
2540
|
+
throw new CborldError(
|
2541
|
+
"ERR_INVALID_ENCODED_CONTEXT",
|
2542
|
+
"Both singular and plural context IDs were found in the CBOR-LD input."
|
2543
|
+
);
|
2580
2544
|
}
|
2581
2545
|
if (!Array.isArray(encodedContexts)) {
|
2582
|
-
throw new CborldError(
|
2546
|
+
throw new CborldError(
|
2547
|
+
"ERR_INVALID_ENCODED_CONTEXT",
|
2548
|
+
"Encoded plural context value must be an array."
|
2549
|
+
);
|
2583
2550
|
}
|
2584
2551
|
const entries = [];
|
2585
2552
|
for (const value of encodedContexts) {
|
2586
|
-
const decoder = ContextDecoder.createDecoder(
|
2553
|
+
const decoder = ContextDecoder.createDecoder(
|
2554
|
+
{ value, transformer: this }
|
2555
|
+
);
|
2587
2556
|
entries.push(decoder ? decoder.decode({ value }) : value);
|
2588
2557
|
}
|
2589
2558
|
obj["@context"] = entries;
|
@@ -2601,11 +2570,15 @@ var Decompressor = class extends Transformer {
|
|
2601
2570
|
if (value !== void 0) {
|
2602
2571
|
if (Array.isArray(value)) {
|
2603
2572
|
obj[term] = value.map((value2) => {
|
2604
|
-
const decoder = VocabTermDecoder.createDecoder(
|
2573
|
+
const decoder = VocabTermDecoder.createDecoder(
|
2574
|
+
{ value: value2, transformer: this }
|
2575
|
+
);
|
2605
2576
|
return decoder ? decoder.decode({ value: value2 }) : value2;
|
2606
2577
|
});
|
2607
2578
|
} else {
|
2608
|
-
const decoder = VocabTermDecoder.createDecoder(
|
2579
|
+
const decoder = VocabTermDecoder.createDecoder(
|
2580
|
+
{ value, transformer: this }
|
2581
|
+
);
|
2609
2582
|
obj[term] = decoder ? decoder.decode({ value }) : value;
|
2610
2583
|
}
|
2611
2584
|
}
|
@@ -2619,11 +2592,17 @@ var Decompressor = class extends Transformer {
|
|
2619
2592
|
}
|
2620
2593
|
const { term, plural } = this._getTermForId({ id: key });
|
2621
2594
|
if (term === void 0) {
|
2622
|
-
throw new CborldError(
|
2595
|
+
throw new CborldError(
|
2596
|
+
"ERR_UNKNOWN_CBORLD_TERM_ID",
|
2597
|
+
`Unknown term ID '${key}' was detected in the CBOR-LD input.`
|
2598
|
+
);
|
2623
2599
|
}
|
2624
2600
|
const def = termMap.get(term);
|
2625
2601
|
if (def === void 0 && !(term.startsWith("@") && KEYWORDS.has(term))) {
|
2626
|
-
throw new CborldError(
|
2602
|
+
throw new CborldError(
|
2603
|
+
"ERR_UNKNOWN_CBORLD_TERM",
|
2604
|
+
`Unknown term "${term}" was detected in the CBOR-LD input.`
|
2605
|
+
);
|
2627
2606
|
}
|
2628
2607
|
entries.push([{ term, termId: key, plural, def }, value]);
|
2629
2608
|
}
|
@@ -2632,11 +2611,17 @@ var Decompressor = class extends Transformer {
|
|
2632
2611
|
_getTermInfo({ termMap, key }) {
|
2633
2612
|
const { term, plural } = this._getTermForId({ id: key });
|
2634
2613
|
if (term === void 0) {
|
2635
|
-
throw new CborldError(
|
2614
|
+
throw new CborldError(
|
2615
|
+
"ERR_UNKNOWN_CBORLD_TERM_ID",
|
2616
|
+
`Unknown term ID '${key}' was detected in the CBOR-LD input.`
|
2617
|
+
);
|
2636
2618
|
}
|
2637
2619
|
const def = termMap.get(term);
|
2638
2620
|
if (def === void 0 && !(term.startsWith("@") && KEYWORDS.has(term))) {
|
2639
|
-
throw new CborldError(
|
2621
|
+
throw new CborldError(
|
2622
|
+
"ERR_UNKNOWN_CBORLD_TERM",
|
2623
|
+
`Unknown term "${term}" was detected in the CBOR-LD input.`
|
2624
|
+
);
|
2640
2625
|
}
|
2641
2626
|
return { term, termId: key, plural, def };
|
2642
2627
|
}
|
@@ -2649,14 +2634,18 @@ var Decompressor = class extends Transformer {
|
|
2649
2634
|
const values = plural ? value : [value];
|
2650
2635
|
const entries = [];
|
2651
2636
|
for (const value2 of values) {
|
2652
|
-
const decoder = VocabTermDecoder.createDecoder(
|
2637
|
+
const decoder = VocabTermDecoder.createDecoder(
|
2638
|
+
{ value: value2, transformer: this }
|
2639
|
+
);
|
2653
2640
|
entries.push(decoder ? decoder.decode({ value: value2 }) : value2);
|
2654
2641
|
}
|
2655
2642
|
obj[term] = plural ? entries : entries[0];
|
2656
2643
|
}
|
2657
2644
|
_transformTypedValue({ entries, termType, value }) {
|
2658
2645
|
const DecoderClass = TYPE_DECODERS.get(termType);
|
2659
|
-
const decoder = DecoderClass && DecoderClass.createDecoder(
|
2646
|
+
const decoder = DecoderClass && DecoderClass.createDecoder(
|
2647
|
+
{ value, transformer: this }
|
2648
|
+
);
|
2660
2649
|
if (decoder) {
|
2661
2650
|
entries.push(decoder.decode({ value }));
|
2662
2651
|
return true;
|
@@ -2687,7 +2676,7 @@ function _sortEntriesByTerm([{ term: t1 }], [{ term: t2 }]) {
|
|
2687
2676
|
}
|
2688
2677
|
__name(_sortEntriesByTerm, "_sortEntriesByTerm");
|
2689
2678
|
|
2690
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2679
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/decode.js
|
2691
2680
|
async function decode5({
|
2692
2681
|
cborldBytes,
|
2693
2682
|
documentLoader,
|
@@ -2699,17 +2688,29 @@ async function decode5({
|
|
2699
2688
|
}
|
2700
2689
|
let index = 0;
|
2701
2690
|
if (cborldBytes[index++] !== 217) {
|
2702
|
-
throw new CborldError(
|
2691
|
+
throw new CborldError(
|
2692
|
+
"ERR_NOT_CBORLD",
|
2693
|
+
'CBOR-LD must start with a CBOR major type "Tag" header of `0xd9`.'
|
2694
|
+
);
|
2703
2695
|
}
|
2704
2696
|
if (cborldBytes[index++] !== 5) {
|
2705
|
-
throw new CborldError(
|
2697
|
+
throw new CborldError(
|
2698
|
+
"ERR_NOT_CBORLD",
|
2699
|
+
"CBOR-LD 16-bit tag must start with `0x05`."
|
2700
|
+
);
|
2706
2701
|
}
|
2707
2702
|
const compressionMode = cborldBytes[index];
|
2708
2703
|
if (compressionMode === void 0) {
|
2709
|
-
throw new CborldError(
|
2704
|
+
throw new CborldError(
|
2705
|
+
"ERR_NOT_CBORLD",
|
2706
|
+
"Truncated CBOR-LD 16-bit tag."
|
2707
|
+
);
|
2710
2708
|
}
|
2711
2709
|
if (!(compressionMode === 0 || compressionMode === 1)) {
|
2712
|
-
throw new CborldError(
|
2710
|
+
throw new CborldError(
|
2711
|
+
"ERR_NOT_CBORLD",
|
2712
|
+
`Unsupported CBOR-LD compression mode "${compressionMode}".`
|
2713
|
+
);
|
2713
2714
|
}
|
2714
2715
|
index++;
|
2715
2716
|
const { buffer: buffer2, byteOffset, length } = cborldBytes;
|
@@ -2718,7 +2719,9 @@ async function decode5({
|
|
2718
2719
|
return decode(suffix, { useMaps: false });
|
2719
2720
|
}
|
2720
2721
|
const decompressor = new Decompressor({ documentLoader, appContextMap });
|
2721
|
-
const result = await decompressor.decompress(
|
2722
|
+
const result = await decompressor.decompress(
|
2723
|
+
{ compressedBytes: suffix, diagnose }
|
2724
|
+
);
|
2722
2725
|
if (diagnose) {
|
2723
2726
|
diagnose("Diagnostic JSON-LD result:");
|
2724
2727
|
diagnose(inspect(result, { depth: null, colors: true }));
|
@@ -2727,7 +2730,7 @@ async function decode5({
|
|
2727
2730
|
}
|
2728
2731
|
__name(decode5, "decode");
|
2729
2732
|
|
2730
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2733
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/CborldEncoder.js
|
2731
2734
|
var CborldEncoder = class {
|
2732
2735
|
encode() {
|
2733
2736
|
throw new Error("Must be implemented by derived class.");
|
@@ -2738,7 +2741,7 @@ var CborldEncoder = class {
|
|
2738
2741
|
};
|
2739
2742
|
__name(CborldEncoder, "CborldEncoder");
|
2740
2743
|
|
2741
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2744
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/ContextEncoder.js
|
2742
2745
|
var ContextEncoder = class extends CborldEncoder {
|
2743
2746
|
constructor({ context, appContextMap } = {}) {
|
2744
2747
|
super();
|
@@ -2763,7 +2766,7 @@ var ContextEncoder = class extends CborldEncoder {
|
|
2763
2766
|
};
|
2764
2767
|
__name(ContextEncoder, "ContextEncoder");
|
2765
2768
|
|
2766
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2769
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/MultibaseEncoder.js
|
2767
2770
|
var MultibaseEncoder = class extends CborldEncoder {
|
2768
2771
|
constructor({ value } = {}) {
|
2769
2772
|
super();
|
@@ -2796,7 +2799,7 @@ var MultibaseEncoder = class extends CborldEncoder {
|
|
2796
2799
|
};
|
2797
2800
|
__name(MultibaseEncoder, "MultibaseEncoder");
|
2798
2801
|
|
2799
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2802
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/Base58DidUrlEncoder.js
|
2800
2803
|
var SCHEME_TO_ID = /* @__PURE__ */ new Map([
|
2801
2804
|
["did:v1:nym:", 1024],
|
2802
2805
|
["did:key:", 1025]
|
@@ -2841,7 +2844,7 @@ function _multibase58ToToken(str) {
|
|
2841
2844
|
}
|
2842
2845
|
__name(_multibase58ToToken, "_multibase58ToToken");
|
2843
2846
|
|
2844
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2847
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/HttpUrlEncoder.js
|
2845
2848
|
var HttpUrlEncoder = class extends CborldEncoder {
|
2846
2849
|
constructor({ value, secure } = {}) {
|
2847
2850
|
super();
|
@@ -2868,7 +2871,7 @@ var HttpUrlEncoder = class extends CborldEncoder {
|
|
2868
2871
|
};
|
2869
2872
|
__name(HttpUrlEncoder, "HttpUrlEncoder");
|
2870
2873
|
|
2871
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2874
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/UuidUrnEncoder.js
|
2872
2875
|
var UuidUrnEncoder = class extends CborldEncoder {
|
2873
2876
|
constructor({ value } = {}) {
|
2874
2877
|
super();
|
@@ -2894,7 +2897,7 @@ var UuidUrnEncoder = class extends CborldEncoder {
|
|
2894
2897
|
};
|
2895
2898
|
__name(UuidUrnEncoder, "UuidUrnEncoder");
|
2896
2899
|
|
2897
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2900
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/UriEncoder.js
|
2898
2901
|
var SCHEME_TO_ENCODER = /* @__PURE__ */ new Map([
|
2899
2902
|
["http", HttpUrlEncoder],
|
2900
2903
|
["https", HttpUrlEncoder],
|
@@ -2926,7 +2929,7 @@ var UriEncoder = class extends CborldEncoder {
|
|
2926
2929
|
};
|
2927
2930
|
__name(UriEncoder, "UriEncoder");
|
2928
2931
|
|
2929
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2932
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/VocabTermEncoder.js
|
2930
2933
|
var VocabTermEncoder = class extends CborldEncoder {
|
2931
2934
|
constructor({ termId } = {}) {
|
2932
2935
|
super();
|
@@ -2946,7 +2949,7 @@ var VocabTermEncoder = class extends CborldEncoder {
|
|
2946
2949
|
};
|
2947
2950
|
__name(VocabTermEncoder, "VocabTermEncoder");
|
2948
2951
|
|
2949
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2952
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/XsdDateEncoder.js
|
2950
2953
|
var XsdDateEncoder = class extends CborldEncoder {
|
2951
2954
|
constructor({ value, parsed } = {}) {
|
2952
2955
|
super();
|
@@ -2976,7 +2979,7 @@ var XsdDateEncoder = class extends CborldEncoder {
|
|
2976
2979
|
};
|
2977
2980
|
__name(XsdDateEncoder, "XsdDateEncoder");
|
2978
2981
|
|
2979
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
2982
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/codecs/XsdDateTimeEncoder.js
|
2980
2983
|
var XsdDateTimeEncoder = class extends CborldEncoder {
|
2981
2984
|
constructor({ value, parsed } = {}) {
|
2982
2985
|
super();
|
@@ -2989,14 +2992,18 @@ var XsdDateTimeEncoder = class extends CborldEncoder {
|
|
2989
2992
|
const secondsToken = new Token(Type.uint, secondsSinceEpoch);
|
2990
2993
|
const millisecondIndex = value.indexOf(".");
|
2991
2994
|
if (millisecondIndex === -1) {
|
2992
|
-
const expectedDate2 = new Date(
|
2995
|
+
const expectedDate2 = new Date(
|
2996
|
+
secondsSinceEpoch * 1e3
|
2997
|
+
).toISOString().replace(".000Z", "Z");
|
2993
2998
|
if (value !== expectedDate2) {
|
2994
2999
|
return new Token(Type.string, value);
|
2995
3000
|
}
|
2996
3001
|
return secondsToken;
|
2997
3002
|
}
|
2998
3003
|
const milliseconds = parseInt(value.substr(millisecondIndex + 1), 10);
|
2999
|
-
const expectedDate = new Date(
|
3004
|
+
const expectedDate = new Date(
|
3005
|
+
secondsSinceEpoch * 1e3 + milliseconds
|
3006
|
+
).toISOString();
|
3000
3007
|
if (value !== expectedDate) {
|
3001
3008
|
return new Token(Type.string, value);
|
3002
3009
|
}
|
@@ -3019,7 +3026,7 @@ var XsdDateTimeEncoder = class extends CborldEncoder {
|
|
3019
3026
|
};
|
3020
3027
|
__name(XsdDateTimeEncoder, "XsdDateTimeEncoder");
|
3021
3028
|
|
3022
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
3029
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/Compressor.js
|
3023
3030
|
var TYPE_ENCODERS = /* @__PURE__ */ new Map([
|
3024
3031
|
["@id", UriEncoder],
|
3025
3032
|
["@vocab", VocabTermEncoder],
|
@@ -3071,7 +3078,9 @@ var Compressor = class extends Transformer {
|
|
3071
3078
|
const isArray = Array.isArray(context);
|
3072
3079
|
const contexts = isArray ? context : [context];
|
3073
3080
|
for (const value of contexts) {
|
3074
|
-
const encoder = ContextEncoder.createEncoder(
|
3081
|
+
const encoder = ContextEncoder.createEncoder(
|
3082
|
+
{ value, transformer: this }
|
3083
|
+
);
|
3075
3084
|
entries.push(encoder || value);
|
3076
3085
|
}
|
3077
3086
|
const id = isArray ? CONTEXT_TERM_ID_PLURAL2 : CONTEXT_TERM_ID2;
|
@@ -3086,7 +3095,10 @@ var Compressor = class extends Transformer {
|
|
3086
3095
|
}
|
3087
3096
|
const def = termMap.get(key);
|
3088
3097
|
if (def === void 0 && !(key.startsWith("@") && KEYWORDS.has(key))) {
|
3089
|
-
throw new CborldError(
|
3098
|
+
throw new CborldError(
|
3099
|
+
"ERR_UNKNOWN_CBORLD_TERM",
|
3100
|
+
`Unknown term '${key}' was detected in the JSON-LD input.`
|
3101
|
+
);
|
3090
3102
|
}
|
3091
3103
|
const value = obj[key];
|
3092
3104
|
const plural = Array.isArray(value);
|
@@ -3097,7 +3109,9 @@ var Compressor = class extends Transformer {
|
|
3097
3109
|
}
|
3098
3110
|
_transformObjectId({ transformMap, termInfo, value }) {
|
3099
3111
|
const { termId } = termInfo;
|
3100
|
-
const encoder = UriEncoder.createEncoder(
|
3112
|
+
const encoder = UriEncoder.createEncoder(
|
3113
|
+
{ value, transformer: this, termInfo }
|
3114
|
+
);
|
3101
3115
|
transformMap.set(termId, encoder || value);
|
3102
3116
|
}
|
3103
3117
|
_transformObjectType({ transformMap, termInfo, value }) {
|
@@ -3105,14 +3119,18 @@ var Compressor = class extends Transformer {
|
|
3105
3119
|
const values = plural ? value : [value];
|
3106
3120
|
const entries = [];
|
3107
3121
|
for (const value2 of values) {
|
3108
|
-
const encoder = VocabTermEncoder.createEncoder(
|
3122
|
+
const encoder = VocabTermEncoder.createEncoder(
|
3123
|
+
{ value: value2, transformer: this, termInfo }
|
3124
|
+
);
|
3109
3125
|
entries.push(encoder || value2);
|
3110
3126
|
}
|
3111
3127
|
transformMap.set(termId, plural ? entries : entries[0]);
|
3112
3128
|
}
|
3113
3129
|
_transformTypedValue({ entries, termType, value, termInfo }) {
|
3114
3130
|
const EncoderClass = TYPE_ENCODERS.get(termType);
|
3115
|
-
const encoder = EncoderClass && EncoderClass.createEncoder(
|
3131
|
+
const encoder = EncoderClass && EncoderClass.createEncoder(
|
3132
|
+
{ value, transformer: this, termInfo }
|
3133
|
+
);
|
3116
3134
|
if (encoder) {
|
3117
3135
|
entries.push(encoder);
|
3118
3136
|
return true;
|
@@ -3139,7 +3157,7 @@ var Compressor = class extends Transformer {
|
|
3139
3157
|
};
|
3140
3158
|
__name(Compressor, "Compressor");
|
3141
3159
|
|
3142
|
-
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.
|
3160
|
+
// ../../../node_modules/.pnpm/@digitalbazaar+cborld@5.2.0/node_modules/@digitalbazaar/cborld/lib/encode.js
|
3143
3161
|
async function encode5({
|
3144
3162
|
jsonldDocument,
|
3145
3163
|
documentLoader,
|
@@ -3148,7 +3166,9 @@ async function encode5({
|
|
3148
3166
|
diagnose
|
3149
3167
|
} = {}) {
|
3150
3168
|
if (!(compressionMode === 0 || compressionMode === 1)) {
|
3151
|
-
throw new TypeError(
|
3169
|
+
throw new TypeError(
|
3170
|
+
'"compressionMode" must be "0" (no compression) or "1" for compression mode version 1.'
|
3171
|
+
);
|
3152
3172
|
}
|
3153
3173
|
const prefix = new Uint8Array([217, 5, compressionMode]);
|
3154
3174
|
let suffix;
|
@@ -3234,7 +3254,7 @@ __name(base32Encode, "base32Encode");
|
|
3234
3254
|
// ../../../node_modules/.pnpm/@digitalbazaar+vpqr@3.0.0/node_modules/@digitalbazaar/vpqr/lib/vpqr.js
|
3235
3255
|
var import_base32_decode = __toESM(require_base32_decode(), 1);
|
3236
3256
|
|
3237
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3257
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/common/Mode.js
|
3238
3258
|
var Mode;
|
3239
3259
|
(function(Mode2) {
|
3240
3260
|
Mode2[Mode2["Terminator"] = 0] = "Terminator";
|
@@ -3246,43 +3266,19 @@ var Mode;
|
|
3246
3266
|
Mode2[Mode2["ECI"] = 7] = "ECI";
|
3247
3267
|
})(Mode || (Mode = {}));
|
3248
3268
|
|
3249
|
-
// ../../../node_modules/.pnpm
|
3250
|
-
var
|
3251
|
-
|
3252
|
-
d2.__proto__ = b2;
|
3253
|
-
} || function(d2, b2) {
|
3254
|
-
for (var p in b2)
|
3255
|
-
if (Object.prototype.hasOwnProperty.call(b2, p))
|
3256
|
-
d2[p] = b2[p];
|
3257
|
-
};
|
3258
|
-
return extendStatics(d, b);
|
3259
|
-
}, "extendStatics");
|
3260
|
-
function __extends(d, b) {
|
3261
|
-
if (typeof b !== "function" && b !== null)
|
3262
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
3263
|
-
extendStatics(d, b);
|
3264
|
-
function __() {
|
3265
|
-
this.constructor = d;
|
3266
|
-
}
|
3267
|
-
__name(__, "__");
|
3268
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
3269
|
-
}
|
3270
|
-
__name(__extends, "__extends");
|
3271
|
-
|
3272
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.3.5/node_modules/@nuintun/qrcode/esm/qrcode/encoder/QRData.js
|
3273
|
-
var QRData = /* @__PURE__ */ function() {
|
3274
|
-
function QRData2(mode, data) {
|
3269
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/QRData.js
|
3270
|
+
var QRData = class {
|
3271
|
+
constructor(mode, data) {
|
3275
3272
|
this.bytes = [];
|
3276
3273
|
this.mode = mode;
|
3277
3274
|
this.data = data;
|
3278
3275
|
}
|
3279
|
-
|
3280
|
-
QRData2.prototype.getLength = function() {
|
3276
|
+
getLength() {
|
3281
3277
|
return this.bytes.length;
|
3282
|
-
}
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3278
|
+
}
|
3279
|
+
getLengthInBits(version2) {
|
3280
|
+
const mode = this.mode;
|
3281
|
+
const error = new Error(`illegal mode: ${mode}`);
|
3286
3282
|
if (1 <= version2 && version2 < 10) {
|
3287
3283
|
switch (mode) {
|
3288
3284
|
case Mode.Numeric:
|
@@ -3323,19 +3319,19 @@ var QRData = /* @__PURE__ */ function() {
|
|
3323
3319
|
throw error;
|
3324
3320
|
}
|
3325
3321
|
} else {
|
3326
|
-
throw new Error(
|
3322
|
+
throw new Error(`illegal version: ${version2}`);
|
3327
3323
|
}
|
3328
|
-
}
|
3329
|
-
|
3330
|
-
|
3324
|
+
}
|
3325
|
+
};
|
3326
|
+
__name(QRData, "QRData");
|
3331
3327
|
|
3332
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3328
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/encoding/UTF8.js
|
3333
3329
|
function encode6(text) {
|
3334
|
-
|
3335
|
-
|
3336
|
-
|
3337
|
-
for (
|
3338
|
-
|
3330
|
+
let pos = 0;
|
3331
|
+
const { length } = text;
|
3332
|
+
const bytes = [];
|
3333
|
+
for (let i = 0; i < length; i++) {
|
3334
|
+
let code = text.charCodeAt(i);
|
3339
3335
|
if (code < 128) {
|
3340
3336
|
bytes[pos++] = code;
|
3341
3337
|
} else if (code < 2048) {
|
@@ -3357,48 +3353,42 @@ function encode6(text) {
|
|
3357
3353
|
}
|
3358
3354
|
__name(encode6, "encode");
|
3359
3355
|
|
3360
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3361
|
-
var QRByte =
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
_this.encoding = -1;
|
3356
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/QRByte.js
|
3357
|
+
var QRByte = class extends QRData {
|
3358
|
+
constructor(data, encode$1) {
|
3359
|
+
super(Mode.Byte, data);
|
3360
|
+
this.encoding = -1;
|
3366
3361
|
if (typeof encode$1 === "function") {
|
3367
|
-
|
3368
|
-
|
3369
|
-
|
3362
|
+
const { encoding, bytes } = encode$1(data);
|
3363
|
+
this.bytes = bytes;
|
3364
|
+
this.encoding = encoding;
|
3370
3365
|
} else {
|
3371
|
-
|
3372
|
-
|
3366
|
+
this.bytes = encode6(data);
|
3367
|
+
this.encoding = 26;
|
3373
3368
|
}
|
3374
|
-
return _this;
|
3375
3369
|
}
|
3376
|
-
|
3377
|
-
|
3378
|
-
|
3379
|
-
for (var _i = 0, bytes_1 = bytes; _i < bytes_1.length; _i++) {
|
3380
|
-
var byte = bytes_1[_i];
|
3370
|
+
writeTo(buffer2) {
|
3371
|
+
const { bytes } = this;
|
3372
|
+
for (const byte of bytes) {
|
3381
3373
|
buffer2.put(byte, 8);
|
3382
3374
|
}
|
3383
|
-
}
|
3384
|
-
|
3385
|
-
|
3375
|
+
}
|
3376
|
+
};
|
3377
|
+
__name(QRByte, "QRByte");
|
3386
3378
|
|
3387
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3379
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/QRMath.js
|
3388
3380
|
var EXP_TABLE = [];
|
3389
3381
|
var LOG_TABLE = [];
|
3390
|
-
for (i = 0; i < 256; i++) {
|
3382
|
+
for (let i = 0; i < 256; i++) {
|
3391
3383
|
LOG_TABLE[i] = 0;
|
3392
3384
|
EXP_TABLE[i] = i < 8 ? 1 << i : EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
|
3393
3385
|
}
|
3394
|
-
|
3395
|
-
for (i = 0; i < 255; i++) {
|
3386
|
+
for (let i = 0; i < 255; i++) {
|
3396
3387
|
LOG_TABLE[EXP_TABLE[i]] = i;
|
3397
3388
|
}
|
3398
|
-
var i;
|
3399
3389
|
function glog(n) {
|
3400
3390
|
if (n < 1) {
|
3401
|
-
throw new Error(
|
3391
|
+
throw new Error(`illegal log: ${n}`);
|
3402
3392
|
}
|
3403
3393
|
return LOG_TABLE[n];
|
3404
3394
|
}
|
@@ -3414,69 +3404,65 @@ function gexp(n) {
|
|
3414
3404
|
}
|
3415
3405
|
__name(gexp, "gexp");
|
3416
3406
|
|
3417
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3418
|
-
var Polynomial =
|
3419
|
-
|
3420
|
-
|
3421
|
-
|
3422
|
-
}
|
3423
|
-
var offset = 0;
|
3424
|
-
var length = num.length;
|
3407
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/Polynomial.js
|
3408
|
+
var Polynomial = class {
|
3409
|
+
constructor(num, shift = 0) {
|
3410
|
+
let offset = 0;
|
3411
|
+
let { length } = num;
|
3425
3412
|
while (offset < length && num[offset] === 0) {
|
3426
3413
|
offset++;
|
3427
3414
|
}
|
3428
3415
|
length -= offset;
|
3429
|
-
|
3430
|
-
for (
|
3416
|
+
const numbers = [];
|
3417
|
+
for (let i = 0; i < length; i++) {
|
3431
3418
|
numbers.push(num[offset + i]);
|
3432
3419
|
}
|
3433
|
-
for (
|
3420
|
+
for (let i = 0; i < shift; i++) {
|
3434
3421
|
numbers.push(0);
|
3435
3422
|
}
|
3436
3423
|
this.num = numbers;
|
3437
3424
|
}
|
3438
|
-
|
3439
|
-
Polynomial2.prototype.getAt = function(index) {
|
3425
|
+
getAt(index) {
|
3440
3426
|
return this.num[index];
|
3441
|
-
}
|
3442
|
-
|
3427
|
+
}
|
3428
|
+
getLength() {
|
3443
3429
|
return this.num.length;
|
3444
|
-
}
|
3445
|
-
|
3446
|
-
|
3447
|
-
|
3448
|
-
|
3449
|
-
|
3450
|
-
for (
|
3430
|
+
}
|
3431
|
+
multiply(e) {
|
3432
|
+
const num = [];
|
3433
|
+
const eLength = e.getLength();
|
3434
|
+
const tLength = this.getLength();
|
3435
|
+
const dLength = tLength + eLength - 1;
|
3436
|
+
for (let i = 0; i < dLength; i++) {
|
3451
3437
|
num.push(0);
|
3452
3438
|
}
|
3453
|
-
for (
|
3454
|
-
for (
|
3439
|
+
for (let i = 0; i < tLength; i++) {
|
3440
|
+
for (let j = 0; j < eLength; j++) {
|
3455
3441
|
num[i + j] ^= gexp(glog(this.getAt(i)) + glog(e.getAt(j)));
|
3456
3442
|
}
|
3457
3443
|
}
|
3458
|
-
return new
|
3459
|
-
}
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3444
|
+
return new Polynomial(num);
|
3445
|
+
}
|
3446
|
+
mod(e) {
|
3447
|
+
const eLength = e.getLength();
|
3448
|
+
const tLength = this.getLength();
|
3463
3449
|
if (tLength - eLength < 0) {
|
3464
3450
|
return this;
|
3465
3451
|
}
|
3466
|
-
|
3467
|
-
|
3468
|
-
for (
|
3452
|
+
const ratio = glog(this.getAt(0)) - glog(e.getAt(0));
|
3453
|
+
const num = [];
|
3454
|
+
for (let i = 0; i < tLength; i++) {
|
3469
3455
|
num.push(this.getAt(i));
|
3470
3456
|
}
|
3471
|
-
for (
|
3457
|
+
for (let i = 0; i < eLength; i++) {
|
3472
3458
|
num[i] ^= gexp(glog(e.getAt(i)) + ratio);
|
3473
3459
|
}
|
3474
|
-
return new
|
3475
|
-
}
|
3476
|
-
|
3477
|
-
|
3460
|
+
return new Polynomial(num).mod(e);
|
3461
|
+
}
|
3462
|
+
};
|
3463
|
+
__name(Polynomial, "Polynomial");
|
3478
3464
|
|
3479
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3465
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/QRUtil.js
|
3480
3466
|
var N1 = 3;
|
3481
3467
|
var N2 = 3;
|
3482
3468
|
var N3 = 40;
|
@@ -3531,15 +3517,15 @@ function getAlignmentPattern(version2) {
|
|
3531
3517
|
}
|
3532
3518
|
__name(getAlignmentPattern, "getAlignmentPattern");
|
3533
3519
|
function getErrorCorrectionPolynomial(errorCorrectionLength) {
|
3534
|
-
|
3535
|
-
for (
|
3520
|
+
let e = new Polynomial([1]);
|
3521
|
+
for (let i = 0; i < errorCorrectionLength; i++) {
|
3536
3522
|
e = e.multiply(new Polynomial([1, gexp(i)]));
|
3537
3523
|
}
|
3538
3524
|
return e;
|
3539
3525
|
}
|
3540
3526
|
__name(getErrorCorrectionPolynomial, "getErrorCorrectionPolynomial");
|
3541
3527
|
function getBCHDigit(data) {
|
3542
|
-
|
3528
|
+
let digit = 0;
|
3543
3529
|
while (data !== 0) {
|
3544
3530
|
digit++;
|
3545
3531
|
data >>>= 1;
|
@@ -3549,7 +3535,7 @@ function getBCHDigit(data) {
|
|
3549
3535
|
__name(getBCHDigit, "getBCHDigit");
|
3550
3536
|
var G18_BCH = getBCHDigit(G18);
|
3551
3537
|
function getBCHVersion(data) {
|
3552
|
-
|
3538
|
+
let offset = data << 12;
|
3553
3539
|
while (getBCHDigit(offset) - G18_BCH >= 0) {
|
3554
3540
|
offset ^= G18 << getBCHDigit(offset) - G18_BCH;
|
3555
3541
|
}
|
@@ -3558,7 +3544,7 @@ function getBCHVersion(data) {
|
|
3558
3544
|
__name(getBCHVersion, "getBCHVersion");
|
3559
3545
|
var G15_BCH = getBCHDigit(G15);
|
3560
3546
|
function getBCHVersionInfo(data) {
|
3561
|
-
|
3547
|
+
let offset = data << 10;
|
3562
3548
|
while (getBCHDigit(offset) - G15_BCH >= 0) {
|
3563
3549
|
offset ^= G15 << getBCHDigit(offset) - G15_BCH;
|
3564
3550
|
}
|
@@ -3566,13 +3552,13 @@ function getBCHVersionInfo(data) {
|
|
3566
3552
|
}
|
3567
3553
|
__name(getBCHVersionInfo, "getBCHVersionInfo");
|
3568
3554
|
function applyMaskPenaltyRule1Internal(qrcode, isHorizontal) {
|
3569
|
-
|
3570
|
-
|
3571
|
-
for (
|
3572
|
-
|
3573
|
-
|
3574
|
-
for (
|
3575
|
-
|
3555
|
+
const matrixSize = qrcode.getMatrixSize();
|
3556
|
+
let penalty = 0;
|
3557
|
+
for (let i = 0; i < matrixSize; i++) {
|
3558
|
+
let prevBit = false;
|
3559
|
+
let numSameBitCells = 0;
|
3560
|
+
for (let j = 0; j < matrixSize; j++) {
|
3561
|
+
const bit = isHorizontal ? qrcode.isDark(i, j) : qrcode.isDark(j, i);
|
3576
3562
|
if (bit === prevBit) {
|
3577
3563
|
numSameBitCells++;
|
3578
3564
|
if (numSameBitCells === 5) {
|
@@ -3594,11 +3580,11 @@ function applyMaskPenaltyRule1(qrcode) {
|
|
3594
3580
|
}
|
3595
3581
|
__name(applyMaskPenaltyRule1, "applyMaskPenaltyRule1");
|
3596
3582
|
function applyMaskPenaltyRule2(qrcode) {
|
3597
|
-
|
3598
|
-
|
3599
|
-
for (
|
3600
|
-
for (
|
3601
|
-
|
3583
|
+
const matrixSize = qrcode.getMatrixSize();
|
3584
|
+
let penalty = 0;
|
3585
|
+
for (let y = 0; y < matrixSize - 1; y++) {
|
3586
|
+
for (let x = 0; x < matrixSize - 1; x++) {
|
3587
|
+
const value = qrcode.isDark(y, x);
|
3602
3588
|
if (value === qrcode.isDark(y, x + 1) && value === qrcode.isDark(y + 1, x) && value === qrcode.isDark(y + 1, x + 1)) {
|
3603
3589
|
penalty += N2;
|
3604
3590
|
}
|
@@ -3610,8 +3596,8 @@ __name(applyMaskPenaltyRule2, "applyMaskPenaltyRule2");
|
|
3610
3596
|
function isFourWhite(qrcode, rangeIndex, from, to, isHorizontal) {
|
3611
3597
|
from = Math.max(from, 0);
|
3612
3598
|
to = Math.min(to, qrcode.getMatrixSize());
|
3613
|
-
for (
|
3614
|
-
|
3599
|
+
for (let i = from; i < to; i++) {
|
3600
|
+
const value = isHorizontal ? qrcode.isDark(rangeIndex, i) : qrcode.isDark(i, rangeIndex);
|
3615
3601
|
if (value) {
|
3616
3602
|
return false;
|
3617
3603
|
}
|
@@ -3620,10 +3606,10 @@ function isFourWhite(qrcode, rangeIndex, from, to, isHorizontal) {
|
|
3620
3606
|
}
|
3621
3607
|
__name(isFourWhite, "isFourWhite");
|
3622
3608
|
function applyMaskPenaltyRule3(qrcode) {
|
3623
|
-
|
3624
|
-
|
3625
|
-
for (
|
3626
|
-
for (
|
3609
|
+
const matrixSize = qrcode.getMatrixSize();
|
3610
|
+
let penalty = 0;
|
3611
|
+
for (let y = 0; y < matrixSize; y++) {
|
3612
|
+
for (let x = 0; x < matrixSize; x++) {
|
3627
3613
|
if (x + 6 < matrixSize && qrcode.isDark(y, x) && !qrcode.isDark(y, x + 1) && qrcode.isDark(y, x + 2) && qrcode.isDark(y, x + 3) && qrcode.isDark(y, x + 4) && !qrcode.isDark(y, x + 5) && qrcode.isDark(y, x + 6) && (isFourWhite(qrcode, y, x - 4, x, true) || isFourWhite(qrcode, y, x + 7, x + 11, true))) {
|
3628
3614
|
penalty += N3;
|
3629
3615
|
}
|
@@ -3636,17 +3622,17 @@ function applyMaskPenaltyRule3(qrcode) {
|
|
3636
3622
|
}
|
3637
3623
|
__name(applyMaskPenaltyRule3, "applyMaskPenaltyRule3");
|
3638
3624
|
function applyMaskPenaltyRule4(qrcode) {
|
3639
|
-
|
3640
|
-
|
3641
|
-
for (
|
3642
|
-
for (
|
3625
|
+
const matrixSize = qrcode.getMatrixSize();
|
3626
|
+
let numDarkCells = 0;
|
3627
|
+
for (let y = 0; y < matrixSize; y++) {
|
3628
|
+
for (let x = 0; x < matrixSize; x++) {
|
3643
3629
|
if (qrcode.isDark(y, x)) {
|
3644
3630
|
numDarkCells++;
|
3645
3631
|
}
|
3646
3632
|
}
|
3647
3633
|
}
|
3648
|
-
|
3649
|
-
|
3634
|
+
const numTotalCells = matrixSize * matrixSize;
|
3635
|
+
const fivePercentVariances = Math.floor(Math.abs(numDarkCells * 20 - numTotalCells * 10) / numTotalCells);
|
3650
3636
|
return fivePercentVariances * N4;
|
3651
3637
|
}
|
3652
3638
|
__name(applyMaskPenaltyRule4, "applyMaskPenaltyRule4");
|
@@ -3655,7 +3641,7 @@ function calculateMaskPenalty(qrcode) {
|
|
3655
3641
|
}
|
3656
3642
|
__name(calculateMaskPenalty, "calculateMaskPenalty");
|
3657
3643
|
|
3658
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3644
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/common/ErrorCorrectionLevel.js
|
3659
3645
|
var ErrorCorrectionLevel;
|
3660
3646
|
(function(ErrorCorrectionLevel2) {
|
3661
3647
|
ErrorCorrectionLevel2[ErrorCorrectionLevel2["L"] = 1] = "L";
|
@@ -3664,235 +3650,233 @@ var ErrorCorrectionLevel;
|
|
3664
3650
|
ErrorCorrectionLevel2[ErrorCorrectionLevel2["H"] = 2] = "H";
|
3665
3651
|
})(ErrorCorrectionLevel || (ErrorCorrectionLevel = {}));
|
3666
3652
|
|
3667
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3668
|
-
var RSBlock =
|
3669
|
-
|
3653
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/RSBlock.js
|
3654
|
+
var RSBlock = class {
|
3655
|
+
constructor(totalCount, dataCount) {
|
3670
3656
|
this.dataCount = dataCount;
|
3671
3657
|
this.totalCount = totalCount;
|
3672
3658
|
}
|
3673
|
-
|
3674
|
-
RSBlock2.prototype.getDataCount = function() {
|
3659
|
+
getDataCount() {
|
3675
3660
|
return this.dataCount;
|
3676
|
-
}
|
3677
|
-
|
3661
|
+
}
|
3662
|
+
getTotalCount() {
|
3678
3663
|
return this.totalCount;
|
3679
|
-
}
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
for (
|
3685
|
-
|
3686
|
-
|
3687
|
-
|
3688
|
-
for (
|
3689
|
-
rsBlocks.push(new
|
3664
|
+
}
|
3665
|
+
static getRSBlocks(version2, errorCorrectionLevel) {
|
3666
|
+
const rsBlocks = [];
|
3667
|
+
const rsBlock = RSBlock.getRSBlockTable(version2, errorCorrectionLevel);
|
3668
|
+
const length = rsBlock.length / 3;
|
3669
|
+
for (let i = 0; i < length; i++) {
|
3670
|
+
const count = rsBlock[i * 3 + 0];
|
3671
|
+
const totalCount = rsBlock[i * 3 + 1];
|
3672
|
+
const dataCount = rsBlock[i * 3 + 2];
|
3673
|
+
for (let j = 0; j < count; j++) {
|
3674
|
+
rsBlocks.push(new RSBlock(totalCount, dataCount));
|
3690
3675
|
}
|
3691
3676
|
}
|
3692
3677
|
return rsBlocks;
|
3693
|
-
}
|
3694
|
-
|
3678
|
+
}
|
3679
|
+
static getRSBlockTable(version2, errorCorrectionLevel) {
|
3695
3680
|
switch (errorCorrectionLevel) {
|
3696
3681
|
case ErrorCorrectionLevel.L:
|
3697
|
-
return
|
3682
|
+
return RSBlock.RS_BLOCK_TABLE[(version2 - 1) * 4 + 0];
|
3698
3683
|
case ErrorCorrectionLevel.M:
|
3699
|
-
return
|
3684
|
+
return RSBlock.RS_BLOCK_TABLE[(version2 - 1) * 4 + 1];
|
3700
3685
|
case ErrorCorrectionLevel.Q:
|
3701
|
-
return
|
3686
|
+
return RSBlock.RS_BLOCK_TABLE[(version2 - 1) * 4 + 2];
|
3702
3687
|
case ErrorCorrectionLevel.H:
|
3703
|
-
return
|
3688
|
+
return RSBlock.RS_BLOCK_TABLE[(version2 - 1) * 4 + 3];
|
3704
3689
|
default:
|
3705
|
-
throw new Error(
|
3690
|
+
throw new Error(`illegal error correction level: ${errorCorrectionLevel}`);
|
3706
3691
|
}
|
3707
|
-
}
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
|
3726
|
-
|
3727
|
-
|
3728
|
-
|
3729
|
-
|
3730
|
-
|
3731
|
-
|
3732
|
-
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
|
3737
|
-
|
3738
|
-
|
3739
|
-
|
3740
|
-
|
3741
|
-
|
3742
|
-
|
3743
|
-
|
3744
|
-
|
3745
|
-
|
3746
|
-
|
3747
|
-
|
3748
|
-
|
3749
|
-
|
3750
|
-
|
3751
|
-
|
3752
|
-
|
3753
|
-
|
3754
|
-
|
3755
|
-
|
3756
|
-
|
3757
|
-
|
3758
|
-
|
3759
|
-
|
3760
|
-
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3764
|
-
|
3765
|
-
|
3766
|
-
|
3767
|
-
|
3768
|
-
|
3769
|
-
|
3770
|
-
|
3771
|
-
|
3772
|
-
|
3773
|
-
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3777
|
-
|
3778
|
-
|
3779
|
-
|
3780
|
-
|
3781
|
-
|
3782
|
-
|
3783
|
-
|
3784
|
-
|
3785
|
-
|
3786
|
-
|
3787
|
-
|
3788
|
-
|
3789
|
-
|
3790
|
-
|
3791
|
-
|
3792
|
-
|
3793
|
-
|
3794
|
-
|
3795
|
-
|
3796
|
-
|
3797
|
-
|
3798
|
-
|
3799
|
-
|
3800
|
-
|
3801
|
-
|
3802
|
-
|
3803
|
-
|
3804
|
-
|
3805
|
-
|
3806
|
-
|
3807
|
-
|
3808
|
-
|
3809
|
-
|
3810
|
-
|
3811
|
-
|
3812
|
-
|
3813
|
-
|
3814
|
-
|
3815
|
-
|
3816
|
-
|
3817
|
-
|
3818
|
-
|
3819
|
-
|
3820
|
-
|
3821
|
-
|
3822
|
-
|
3823
|
-
|
3824
|
-
|
3825
|
-
|
3826
|
-
|
3827
|
-
|
3828
|
-
|
3829
|
-
|
3830
|
-
|
3831
|
-
|
3832
|
-
|
3833
|
-
|
3834
|
-
|
3835
|
-
|
3836
|
-
|
3837
|
-
|
3838
|
-
|
3839
|
-
|
3840
|
-
|
3841
|
-
|
3842
|
-
|
3843
|
-
|
3844
|
-
|
3845
|
-
|
3846
|
-
|
3847
|
-
|
3848
|
-
|
3849
|
-
|
3850
|
-
|
3851
|
-
|
3852
|
-
|
3853
|
-
|
3854
|
-
|
3855
|
-
|
3856
|
-
|
3857
|
-
|
3858
|
-
|
3859
|
-
|
3860
|
-
|
3861
|
-
|
3862
|
-
|
3863
|
-
|
3864
|
-
|
3865
|
-
|
3866
|
-
|
3867
|
-
|
3868
|
-
|
3869
|
-
]
|
3870
|
-
|
3871
|
-
|
3692
|
+
}
|
3693
|
+
};
|
3694
|
+
__name(RSBlock, "RSBlock");
|
3695
|
+
RSBlock.RS_BLOCK_TABLE = [
|
3696
|
+
[1, 26, 19],
|
3697
|
+
[1, 26, 16],
|
3698
|
+
[1, 26, 13],
|
3699
|
+
[1, 26, 9],
|
3700
|
+
[1, 44, 34],
|
3701
|
+
[1, 44, 28],
|
3702
|
+
[1, 44, 22],
|
3703
|
+
[1, 44, 16],
|
3704
|
+
[1, 70, 55],
|
3705
|
+
[1, 70, 44],
|
3706
|
+
[2, 35, 17],
|
3707
|
+
[2, 35, 13],
|
3708
|
+
[1, 100, 80],
|
3709
|
+
[2, 50, 32],
|
3710
|
+
[2, 50, 24],
|
3711
|
+
[4, 25, 9],
|
3712
|
+
[1, 134, 108],
|
3713
|
+
[2, 67, 43],
|
3714
|
+
[2, 33, 15, 2, 34, 16],
|
3715
|
+
[2, 33, 11, 2, 34, 12],
|
3716
|
+
[2, 86, 68],
|
3717
|
+
[4, 43, 27],
|
3718
|
+
[4, 43, 19],
|
3719
|
+
[4, 43, 15],
|
3720
|
+
[2, 98, 78],
|
3721
|
+
[4, 49, 31],
|
3722
|
+
[2, 32, 14, 4, 33, 15],
|
3723
|
+
[4, 39, 13, 1, 40, 14],
|
3724
|
+
[2, 121, 97],
|
3725
|
+
[2, 60, 38, 2, 61, 39],
|
3726
|
+
[4, 40, 18, 2, 41, 19],
|
3727
|
+
[4, 40, 14, 2, 41, 15],
|
3728
|
+
[2, 146, 116],
|
3729
|
+
[3, 58, 36, 2, 59, 37],
|
3730
|
+
[4, 36, 16, 4, 37, 17],
|
3731
|
+
[4, 36, 12, 4, 37, 13],
|
3732
|
+
[2, 86, 68, 2, 87, 69],
|
3733
|
+
[4, 69, 43, 1, 70, 44],
|
3734
|
+
[6, 43, 19, 2, 44, 20],
|
3735
|
+
[6, 43, 15, 2, 44, 16],
|
3736
|
+
[4, 101, 81],
|
3737
|
+
[1, 80, 50, 4, 81, 51],
|
3738
|
+
[4, 50, 22, 4, 51, 23],
|
3739
|
+
[3, 36, 12, 8, 37, 13],
|
3740
|
+
[2, 116, 92, 2, 117, 93],
|
3741
|
+
[6, 58, 36, 2, 59, 37],
|
3742
|
+
[4, 46, 20, 6, 47, 21],
|
3743
|
+
[7, 42, 14, 4, 43, 15],
|
3744
|
+
[4, 133, 107],
|
3745
|
+
[8, 59, 37, 1, 60, 38],
|
3746
|
+
[8, 44, 20, 4, 45, 21],
|
3747
|
+
[12, 33, 11, 4, 34, 12],
|
3748
|
+
[3, 145, 115, 1, 146, 116],
|
3749
|
+
[4, 64, 40, 5, 65, 41],
|
3750
|
+
[11, 36, 16, 5, 37, 17],
|
3751
|
+
[11, 36, 12, 5, 37, 13],
|
3752
|
+
[5, 109, 87, 1, 110, 88],
|
3753
|
+
[5, 65, 41, 5, 66, 42],
|
3754
|
+
[5, 54, 24, 7, 55, 25],
|
3755
|
+
[11, 36, 12, 7, 37, 13],
|
3756
|
+
[5, 122, 98, 1, 123, 99],
|
3757
|
+
[7, 73, 45, 3, 74, 46],
|
3758
|
+
[15, 43, 19, 2, 44, 20],
|
3759
|
+
[3, 45, 15, 13, 46, 16],
|
3760
|
+
[1, 135, 107, 5, 136, 108],
|
3761
|
+
[10, 74, 46, 1, 75, 47],
|
3762
|
+
[1, 50, 22, 15, 51, 23],
|
3763
|
+
[2, 42, 14, 17, 43, 15],
|
3764
|
+
[5, 150, 120, 1, 151, 121],
|
3765
|
+
[9, 69, 43, 4, 70, 44],
|
3766
|
+
[17, 50, 22, 1, 51, 23],
|
3767
|
+
[2, 42, 14, 19, 43, 15],
|
3768
|
+
[3, 141, 113, 4, 142, 114],
|
3769
|
+
[3, 70, 44, 11, 71, 45],
|
3770
|
+
[17, 47, 21, 4, 48, 22],
|
3771
|
+
[9, 39, 13, 16, 40, 14],
|
3772
|
+
[3, 135, 107, 5, 136, 108],
|
3773
|
+
[3, 67, 41, 13, 68, 42],
|
3774
|
+
[15, 54, 24, 5, 55, 25],
|
3775
|
+
[15, 43, 15, 10, 44, 16],
|
3776
|
+
[4, 144, 116, 4, 145, 117],
|
3777
|
+
[17, 68, 42],
|
3778
|
+
[17, 50, 22, 6, 51, 23],
|
3779
|
+
[19, 46, 16, 6, 47, 17],
|
3780
|
+
[2, 139, 111, 7, 140, 112],
|
3781
|
+
[17, 74, 46],
|
3782
|
+
[7, 54, 24, 16, 55, 25],
|
3783
|
+
[34, 37, 13],
|
3784
|
+
[4, 151, 121, 5, 152, 122],
|
3785
|
+
[4, 75, 47, 14, 76, 48],
|
3786
|
+
[11, 54, 24, 14, 55, 25],
|
3787
|
+
[16, 45, 15, 14, 46, 16],
|
3788
|
+
[6, 147, 117, 4, 148, 118],
|
3789
|
+
[6, 73, 45, 14, 74, 46],
|
3790
|
+
[11, 54, 24, 16, 55, 25],
|
3791
|
+
[30, 46, 16, 2, 47, 17],
|
3792
|
+
[8, 132, 106, 4, 133, 107],
|
3793
|
+
[8, 75, 47, 13, 76, 48],
|
3794
|
+
[7, 54, 24, 22, 55, 25],
|
3795
|
+
[22, 45, 15, 13, 46, 16],
|
3796
|
+
[10, 142, 114, 2, 143, 115],
|
3797
|
+
[19, 74, 46, 4, 75, 47],
|
3798
|
+
[28, 50, 22, 6, 51, 23],
|
3799
|
+
[33, 46, 16, 4, 47, 17],
|
3800
|
+
[8, 152, 122, 4, 153, 123],
|
3801
|
+
[22, 73, 45, 3, 74, 46],
|
3802
|
+
[8, 53, 23, 26, 54, 24],
|
3803
|
+
[12, 45, 15, 28, 46, 16],
|
3804
|
+
[3, 147, 117, 10, 148, 118],
|
3805
|
+
[3, 73, 45, 23, 74, 46],
|
3806
|
+
[4, 54, 24, 31, 55, 25],
|
3807
|
+
[11, 45, 15, 31, 46, 16],
|
3808
|
+
[7, 146, 116, 7, 147, 117],
|
3809
|
+
[21, 73, 45, 7, 74, 46],
|
3810
|
+
[1, 53, 23, 37, 54, 24],
|
3811
|
+
[19, 45, 15, 26, 46, 16],
|
3812
|
+
[5, 145, 115, 10, 146, 116],
|
3813
|
+
[19, 75, 47, 10, 76, 48],
|
3814
|
+
[15, 54, 24, 25, 55, 25],
|
3815
|
+
[23, 45, 15, 25, 46, 16],
|
3816
|
+
[13, 145, 115, 3, 146, 116],
|
3817
|
+
[2, 74, 46, 29, 75, 47],
|
3818
|
+
[42, 54, 24, 1, 55, 25],
|
3819
|
+
[23, 45, 15, 28, 46, 16],
|
3820
|
+
[17, 145, 115],
|
3821
|
+
[10, 74, 46, 23, 75, 47],
|
3822
|
+
[10, 54, 24, 35, 55, 25],
|
3823
|
+
[19, 45, 15, 35, 46, 16],
|
3824
|
+
[17, 145, 115, 1, 146, 116],
|
3825
|
+
[14, 74, 46, 21, 75, 47],
|
3826
|
+
[29, 54, 24, 19, 55, 25],
|
3827
|
+
[11, 45, 15, 46, 46, 16],
|
3828
|
+
[13, 145, 115, 6, 146, 116],
|
3829
|
+
[14, 74, 46, 23, 75, 47],
|
3830
|
+
[44, 54, 24, 7, 55, 25],
|
3831
|
+
[59, 46, 16, 1, 47, 17],
|
3832
|
+
[12, 151, 121, 7, 152, 122],
|
3833
|
+
[12, 75, 47, 26, 76, 48],
|
3834
|
+
[39, 54, 24, 14, 55, 25],
|
3835
|
+
[22, 45, 15, 41, 46, 16],
|
3836
|
+
[6, 151, 121, 14, 152, 122],
|
3837
|
+
[6, 75, 47, 34, 76, 48],
|
3838
|
+
[46, 54, 24, 10, 55, 25],
|
3839
|
+
[2, 45, 15, 64, 46, 16],
|
3840
|
+
[17, 152, 122, 4, 153, 123],
|
3841
|
+
[29, 74, 46, 14, 75, 47],
|
3842
|
+
[49, 54, 24, 10, 55, 25],
|
3843
|
+
[24, 45, 15, 46, 46, 16],
|
3844
|
+
[4, 152, 122, 18, 153, 123],
|
3845
|
+
[13, 74, 46, 32, 75, 47],
|
3846
|
+
[48, 54, 24, 14, 55, 25],
|
3847
|
+
[42, 45, 15, 32, 46, 16],
|
3848
|
+
[20, 147, 117, 4, 148, 118],
|
3849
|
+
[40, 75, 47, 7, 76, 48],
|
3850
|
+
[43, 54, 24, 22, 55, 25],
|
3851
|
+
[10, 45, 15, 67, 46, 16],
|
3852
|
+
[19, 148, 118, 6, 149, 119],
|
3853
|
+
[18, 75, 47, 31, 76, 48],
|
3854
|
+
[34, 54, 24, 34, 55, 25],
|
3855
|
+
[20, 45, 15, 61, 46, 16]
|
3856
|
+
];
|
3872
3857
|
|
3873
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3874
|
-
var BitBuffer =
|
3875
|
-
|
3858
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/BitBuffer.js
|
3859
|
+
var BitBuffer = class {
|
3860
|
+
constructor() {
|
3876
3861
|
this.length = 0;
|
3877
3862
|
this.buffer = [];
|
3878
3863
|
}
|
3879
|
-
|
3880
|
-
BitBuffer2.prototype.getBuffer = function() {
|
3864
|
+
getBuffer() {
|
3881
3865
|
return this.buffer;
|
3882
|
-
}
|
3883
|
-
|
3866
|
+
}
|
3867
|
+
getLengthInBits() {
|
3884
3868
|
return this.length;
|
3885
|
-
}
|
3886
|
-
|
3869
|
+
}
|
3870
|
+
getBit(index) {
|
3887
3871
|
return (this.buffer[index / 8 >> 0] >>> 7 - index % 8 & 1) === 1;
|
3888
|
-
}
|
3889
|
-
|
3890
|
-
for (
|
3872
|
+
}
|
3873
|
+
put(num, length) {
|
3874
|
+
for (let i = 0; i < length; i++) {
|
3891
3875
|
this.putBit((num >>> length - i - 1 & 1) === 1);
|
3892
3876
|
}
|
3893
|
-
}
|
3894
|
-
|
3895
|
-
|
3877
|
+
}
|
3878
|
+
putBit(bit) {
|
3879
|
+
const { buffer: buffer2 } = this;
|
3896
3880
|
if (this.length === buffer2.length * 8) {
|
3897
3881
|
buffer2.push(0);
|
3898
3882
|
}
|
@@ -3900,351 +3884,279 @@ var BitBuffer = /* @__PURE__ */ function() {
|
|
3900
3884
|
buffer2[this.length / 8 >> 0] |= 128 >>> this.length % 8;
|
3901
3885
|
}
|
3902
3886
|
this.length++;
|
3903
|
-
}
|
3904
|
-
|
3905
|
-
|
3887
|
+
}
|
3888
|
+
};
|
3889
|
+
__name(BitBuffer, "BitBuffer");
|
3906
3890
|
|
3907
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3908
|
-
var
|
3909
|
-
|
3891
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/image/lzw/Dict.js
|
3892
|
+
var MAX_CODE = (1 << 12) - 1;
|
3893
|
+
var Dict = class {
|
3894
|
+
constructor(depth) {
|
3895
|
+
const bof = 1 << depth;
|
3896
|
+
const eof = bof + 1;
|
3897
|
+
this.bof = bof;
|
3898
|
+
this.eof = eof;
|
3899
|
+
this.depth = depth;
|
3900
|
+
this.reset();
|
3910
3901
|
}
|
3911
|
-
|
3912
|
-
|
3913
|
-
|
3914
|
-
|
3902
|
+
reset() {
|
3903
|
+
const bits = this.depth + 1;
|
3904
|
+
this.bits = bits;
|
3905
|
+
this.size = 1 << bits;
|
3906
|
+
this.codes = /* @__PURE__ */ new Map();
|
3907
|
+
this.unused = this.eof + 1;
|
3908
|
+
}
|
3909
|
+
add(code, index) {
|
3910
|
+
let { unused } = this;
|
3911
|
+
if (unused > MAX_CODE) {
|
3912
|
+
return false;
|
3915
3913
|
}
|
3916
|
-
|
3917
|
-
|
3914
|
+
this.codes.set(code << 8 | index, unused++);
|
3915
|
+
let { bits, size } = this;
|
3916
|
+
if (unused > size) {
|
3917
|
+
size = 1 << ++bits;
|
3918
3918
|
}
|
3919
|
-
|
3920
|
-
|
3919
|
+
this.bits = bits;
|
3920
|
+
this.size = size;
|
3921
|
+
this.unused = unused;
|
3922
|
+
return true;
|
3923
|
+
}
|
3924
|
+
get(code, index) {
|
3925
|
+
return this.codes.get(code << 8 | index);
|
3926
|
+
}
|
3927
|
+
};
|
3928
|
+
__name(Dict, "Dict");
|
3929
|
+
|
3930
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/image/lzw/DictStream.js
|
3931
|
+
var DictStream = class {
|
3932
|
+
constructor(dict) {
|
3933
|
+
this.bits = 0;
|
3934
|
+
this.buffer = 0;
|
3935
|
+
this.bytes = [];
|
3936
|
+
this.dict = dict;
|
3937
|
+
}
|
3938
|
+
write(code) {
|
3939
|
+
let { bits } = this;
|
3940
|
+
let buffer2 = this.buffer | code << bits;
|
3941
|
+
bits += this.dict.bits;
|
3942
|
+
const { bytes } = this;
|
3943
|
+
while (bits >= 8) {
|
3944
|
+
bytes.push(buffer2 & 255);
|
3945
|
+
buffer2 >>= 8;
|
3946
|
+
bits -= 8;
|
3947
|
+
}
|
3948
|
+
this.bits = bits;
|
3949
|
+
this.buffer = buffer2;
|
3950
|
+
}
|
3951
|
+
pipe(stream) {
|
3952
|
+
const { bytes } = this;
|
3953
|
+
if (this.bits > 0) {
|
3954
|
+
bytes.push(this.buffer);
|
3955
|
+
}
|
3956
|
+
stream.writeByte(this.dict.depth);
|
3957
|
+
const { length } = bytes;
|
3958
|
+
for (let i = 0; i < length; ) {
|
3959
|
+
const remain = length - i;
|
3960
|
+
if (remain >= 255) {
|
3961
|
+
stream.writeByte(255);
|
3962
|
+
stream.writeBytes(bytes, i, 255);
|
3963
|
+
i += 255;
|
3964
|
+
} else {
|
3965
|
+
stream.writeByte(remain);
|
3966
|
+
stream.writeBytes(bytes, i, remain);
|
3967
|
+
i = length;
|
3968
|
+
}
|
3921
3969
|
}
|
3922
|
-
|
3923
|
-
|
3924
|
-
|
3925
|
-
|
3926
|
-
this.flush();
|
3927
|
-
};
|
3928
|
-
return OutputStream2;
|
3929
|
-
}();
|
3970
|
+
stream.writeByte(0);
|
3971
|
+
}
|
3972
|
+
};
|
3973
|
+
__name(DictStream, "DictStream");
|
3930
3974
|
|
3931
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3932
|
-
|
3933
|
-
|
3934
|
-
|
3935
|
-
|
3936
|
-
|
3937
|
-
|
3938
|
-
|
3939
|
-
|
3940
|
-
|
3941
|
-
|
3942
|
-
|
3943
|
-
|
3944
|
-
|
3945
|
-
|
3946
|
-
|
3947
|
-
|
3948
|
-
|
3949
|
-
|
3950
|
-
|
3975
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/image/lzw/index.js
|
3976
|
+
function compress(pixels, depth, stream) {
|
3977
|
+
const dict = new Dict(depth);
|
3978
|
+
const buffer2 = new DictStream(dict);
|
3979
|
+
buffer2.write(dict.bof);
|
3980
|
+
if (pixels.length > 0) {
|
3981
|
+
let code = pixels[0];
|
3982
|
+
const { length } = pixels;
|
3983
|
+
for (let i = 1; i < length; i++) {
|
3984
|
+
const pixelIndex = pixels[i];
|
3985
|
+
const nextCode = dict.get(code, pixelIndex);
|
3986
|
+
if (nextCode != null) {
|
3987
|
+
code = nextCode;
|
3988
|
+
} else {
|
3989
|
+
buffer2.write(code);
|
3990
|
+
if (!dict.add(code, pixelIndex)) {
|
3991
|
+
buffer2.write(dict.bof);
|
3992
|
+
dict.reset();
|
3993
|
+
}
|
3994
|
+
code = pixelIndex;
|
3995
|
+
}
|
3996
|
+
}
|
3997
|
+
buffer2.write(code);
|
3998
|
+
}
|
3999
|
+
buffer2.write(dict.eof);
|
4000
|
+
buffer2.pipe(stream);
|
4001
|
+
}
|
4002
|
+
__name(compress, "compress");
|
4003
|
+
|
4004
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/image/ByteStream.js
|
4005
|
+
var ByteStream = class {
|
4006
|
+
constructor() {
|
4007
|
+
this.bytes = [];
|
4008
|
+
}
|
4009
|
+
writeByte(value) {
|
4010
|
+
this.bytes.push(value & 255);
|
4011
|
+
}
|
4012
|
+
writeInt16(value) {
|
4013
|
+
this.bytes.push(value & 255, value >> 8 & 255);
|
4014
|
+
}
|
4015
|
+
writeBytes(bytes, offset = 0, length = bytes.length) {
|
4016
|
+
const buffer2 = this.bytes;
|
4017
|
+
for (let i = 0; i < length; i++) {
|
4018
|
+
buffer2.push(bytes[offset + i] & 255);
|
4019
|
+
}
|
4020
|
+
}
|
4021
|
+
};
|
4022
|
+
__name(ByteStream, "ByteStream");
|
3951
4023
|
|
3952
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
3953
|
-
|
3954
|
-
|
3955
|
-
|
3956
|
-
|
3957
|
-
|
3958
|
-
return
|
3959
|
-
} else if (
|
3960
|
-
return
|
3961
|
-
} else if (
|
4024
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/image/Base64Stream.js
|
4025
|
+
var { fromCharCode } = String;
|
4026
|
+
function encode7(byte) {
|
4027
|
+
byte &= 63;
|
4028
|
+
if (byte >= 0) {
|
4029
|
+
if (byte < 26) {
|
4030
|
+
return 65 + byte;
|
4031
|
+
} else if (byte < 52) {
|
4032
|
+
return 97 + (byte - 26);
|
4033
|
+
} else if (byte < 62) {
|
4034
|
+
return 48 + (byte - 52);
|
4035
|
+
} else if (byte === 62) {
|
3962
4036
|
return 43;
|
3963
|
-
} else if (
|
4037
|
+
} else if (byte === 63) {
|
3964
4038
|
return 47;
|
3965
4039
|
}
|
3966
4040
|
}
|
3967
|
-
throw new Error(
|
4041
|
+
throw new Error(`illegal char: ${fromCharCode(byte)}`);
|
3968
4042
|
}
|
3969
4043
|
__name(encode7, "encode");
|
3970
|
-
var
|
3971
|
-
|
3972
|
-
|
3973
|
-
|
3974
|
-
|
3975
|
-
|
3976
|
-
|
3977
|
-
|
3978
|
-
return
|
3979
|
-
}
|
3980
|
-
|
3981
|
-
|
3982
|
-
|
3983
|
-
this.
|
3984
|
-
|
3985
|
-
|
3986
|
-
|
3987
|
-
this.bufLength -= 6;
|
4044
|
+
var Base64Stream = class {
|
4045
|
+
constructor() {
|
4046
|
+
this.bits = 0;
|
4047
|
+
this.buffer = 0;
|
4048
|
+
this.length = 0;
|
4049
|
+
this.stream = new ByteStream();
|
4050
|
+
}
|
4051
|
+
get bytes() {
|
4052
|
+
return this.stream.bytes;
|
4053
|
+
}
|
4054
|
+
write(byte) {
|
4055
|
+
let bits = this.bits + 8;
|
4056
|
+
const { stream } = this;
|
4057
|
+
const buffer2 = this.buffer << 8 | byte & 255;
|
4058
|
+
while (bits >= 6) {
|
4059
|
+
stream.writeByte(encode7(buffer2 >>> bits - 6));
|
4060
|
+
bits -= 6;
|
3988
4061
|
}
|
3989
|
-
|
3990
|
-
|
3991
|
-
|
3992
|
-
|
4062
|
+
this.length++;
|
4063
|
+
this.bits = bits;
|
4064
|
+
this.buffer = buffer2;
|
4065
|
+
}
|
4066
|
+
close() {
|
4067
|
+
const { bits, stream, length } = this;
|
4068
|
+
if (bits > 0) {
|
4069
|
+
stream.writeByte(encode7(this.buffer << 6 - bits));
|
4070
|
+
this.bits = 0;
|
3993
4071
|
this.buffer = 0;
|
3994
|
-
this.bufLength = 0;
|
3995
4072
|
}
|
3996
|
-
|
3997
|
-
|
3998
|
-
|
3999
|
-
for (var i = 0; i < pad; i++) {
|
4073
|
+
if (length % 3 != 0) {
|
4074
|
+
const pad = 3 - length % 3;
|
4075
|
+
for (let i = 0; i < pad; i++) {
|
4000
4076
|
stream.writeByte(61);
|
4001
4077
|
}
|
4002
4078
|
}
|
4003
|
-
}
|
4004
|
-
|
4005
|
-
|
4006
|
-
};
|
4007
|
-
return Base64EncodeOutputStream2;
|
4008
|
-
}(OutputStream);
|
4079
|
+
}
|
4080
|
+
};
|
4081
|
+
__name(Base64Stream, "Base64Stream");
|
4009
4082
|
|
4010
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4014
|
-
stream.writeBytes(data);
|
4015
|
-
stream.close();
|
4016
|
-
output.close();
|
4017
|
-
return output.toByteArray();
|
4018
|
-
}
|
4019
|
-
__name(encodeToBase64, "encodeToBase64");
|
4020
|
-
var LZWTable = /* @__PURE__ */ function() {
|
4021
|
-
function LZWTable2() {
|
4022
|
-
this.size = 0;
|
4023
|
-
this.map = {};
|
4024
|
-
}
|
4025
|
-
__name(LZWTable2, "LZWTable");
|
4026
|
-
LZWTable2.prototype.add = function(key) {
|
4027
|
-
if (!this.contains(key)) {
|
4028
|
-
this.map[key] = this.size++;
|
4029
|
-
}
|
4030
|
-
};
|
4031
|
-
LZWTable2.prototype.getSize = function() {
|
4032
|
-
return this.size;
|
4033
|
-
};
|
4034
|
-
LZWTable2.prototype.indexOf = function(key) {
|
4035
|
-
return this.map[key];
|
4036
|
-
};
|
4037
|
-
LZWTable2.prototype.contains = function(key) {
|
4038
|
-
return this.map[key] >= 0;
|
4039
|
-
};
|
4040
|
-
return LZWTable2;
|
4041
|
-
}();
|
4042
|
-
var BitOutputStream = /* @__PURE__ */ function() {
|
4043
|
-
function BitOutputStream2(output) {
|
4044
|
-
this.output = output;
|
4045
|
-
this.bitLength = 0;
|
4046
|
-
this.bitBuffer = 0;
|
4047
|
-
}
|
4048
|
-
__name(BitOutputStream2, "BitOutputStream");
|
4049
|
-
BitOutputStream2.prototype.write = function(data, length) {
|
4050
|
-
if (data >>> length !== 0) {
|
4051
|
-
throw new Error("length overflow");
|
4052
|
-
}
|
4053
|
-
var output = this.output;
|
4054
|
-
while (this.bitLength + length >= 8) {
|
4055
|
-
output.writeByte(255 & (data << this.bitLength | this.bitBuffer));
|
4056
|
-
length -= 8 - this.bitLength;
|
4057
|
-
data >>>= 8 - this.bitLength;
|
4058
|
-
this.bitBuffer = 0;
|
4059
|
-
this.bitLength = 0;
|
4060
|
-
}
|
4061
|
-
this.bitBuffer = data << this.bitLength | this.bitBuffer;
|
4062
|
-
this.bitLength = this.bitLength + length;
|
4063
|
-
};
|
4064
|
-
BitOutputStream2.prototype.flush = function() {
|
4065
|
-
var output = this.output;
|
4066
|
-
if (this.bitLength > 0) {
|
4067
|
-
output.writeByte(this.bitBuffer);
|
4068
|
-
}
|
4069
|
-
output.flush();
|
4070
|
-
};
|
4071
|
-
BitOutputStream2.prototype.close = function() {
|
4072
|
-
this.flush();
|
4073
|
-
this.output.close();
|
4074
|
-
};
|
4075
|
-
return BitOutputStream2;
|
4076
|
-
}();
|
4077
|
-
var GIFImage = /* @__PURE__ */ function() {
|
4078
|
-
function GIFImage2(width, height) {
|
4079
|
-
this.data = [];
|
4083
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/image/GIFImage.js
|
4084
|
+
var GIFImage = class {
|
4085
|
+
constructor(width, height, { foreground = [0, 0, 0], background = [255, 255, 255] } = {}) {
|
4086
|
+
this.pixels = [];
|
4080
4087
|
this.width = width;
|
4081
4088
|
this.height = height;
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4087
|
-
|
4088
|
-
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
|
4109
|
-
|
4110
|
-
|
4111
|
-
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
|
4117
|
-
|
4118
|
-
table.add(words + char);
|
4119
|
-
}
|
4120
|
-
words = char;
|
4121
|
-
}
|
4122
|
-
}
|
4123
|
-
bitOutput.write(table.indexOf(words), bitLength);
|
4124
|
-
bitOutput.write(endCode, bitLength);
|
4125
|
-
} finally {
|
4126
|
-
bitOutput.close();
|
4127
|
-
}
|
4128
|
-
return byteOutput.toByteArray();
|
4129
|
-
};
|
4130
|
-
GIFImage2.prototype.setPixel = function(x, y, pixel) {
|
4131
|
-
var _a = this, width = _a.width, height = _a.height;
|
4132
|
-
if (x < 0 || width <= x)
|
4133
|
-
throw new Error("illegal x axis: ".concat(x));
|
4134
|
-
if (y < 0 || height <= y)
|
4135
|
-
throw new Error("illegal y axis: ".concat(y));
|
4136
|
-
this.data[y * width + x] = pixel;
|
4137
|
-
};
|
4138
|
-
GIFImage2.prototype.getPixel = function(x, y) {
|
4139
|
-
var _a = this, width = _a.width, height = _a.height;
|
4140
|
-
if (x < 0 || width <= x)
|
4141
|
-
throw new Error("illegal x axis: ".concat(x));
|
4142
|
-
if (y < 0 || height <= y)
|
4143
|
-
throw new Error("illegal y axis: ".concat(y));
|
4144
|
-
return this.data[y * width + x];
|
4145
|
-
};
|
4146
|
-
GIFImage2.prototype.write = function(output) {
|
4147
|
-
var _a = this, width = _a.width, height = _a.height;
|
4148
|
-
output.writeByte(71);
|
4149
|
-
output.writeByte(73);
|
4150
|
-
output.writeByte(70);
|
4151
|
-
output.writeByte(56);
|
4152
|
-
output.writeByte(55);
|
4153
|
-
output.writeByte(97);
|
4154
|
-
output.writeInt16(width);
|
4155
|
-
output.writeInt16(height);
|
4156
|
-
output.writeByte(128);
|
4157
|
-
output.writeByte(0);
|
4158
|
-
output.writeByte(0);
|
4159
|
-
output.writeByte(0);
|
4160
|
-
output.writeByte(0);
|
4161
|
-
output.writeByte(0);
|
4162
|
-
output.writeByte(255);
|
4163
|
-
output.writeByte(255);
|
4164
|
-
output.writeByte(255);
|
4165
|
-
output.writeByte(44);
|
4166
|
-
output.writeInt16(0);
|
4167
|
-
output.writeInt16(0);
|
4168
|
-
output.writeInt16(width);
|
4169
|
-
output.writeInt16(height);
|
4170
|
-
output.writeByte(0);
|
4171
|
-
var lzwMinCodeSize = 2;
|
4172
|
-
var raster = this.getLZWRaster(lzwMinCodeSize);
|
4173
|
-
var raLength = raster.length;
|
4174
|
-
output.writeByte(lzwMinCodeSize);
|
4175
|
-
var offset = 0;
|
4176
|
-
while (raLength - offset > 255) {
|
4177
|
-
output.writeByte(255);
|
4178
|
-
output.writeBytes(raster, offset, 255);
|
4179
|
-
offset += 255;
|
4180
|
-
}
|
4181
|
-
var length = raLength - offset;
|
4182
|
-
output.writeByte(length);
|
4183
|
-
output.writeBytes(raster, offset, length);
|
4184
|
-
output.writeByte(0);
|
4185
|
-
output.writeByte(59);
|
4186
|
-
};
|
4187
|
-
GIFImage2.prototype.toDataURL = function() {
|
4188
|
-
var output = new ByteArrayOutputStream();
|
4189
|
-
this.write(output);
|
4190
|
-
var bytes = encodeToBase64(output.toByteArray());
|
4191
|
-
output.close();
|
4192
|
-
var length = bytes.length;
|
4193
|
-
var fromCharCode = String.fromCharCode;
|
4194
|
-
var url = "data:image/gif;base64,";
|
4195
|
-
for (var i = 0; i < length; i++) {
|
4196
|
-
url += fromCharCode(bytes[i]);
|
4089
|
+
this.foreground = foreground;
|
4090
|
+
this.background = background;
|
4091
|
+
}
|
4092
|
+
encodeImpl() {
|
4093
|
+
const stream = new ByteStream();
|
4094
|
+
const { width, height, background, foreground } = this;
|
4095
|
+
stream.writeBytes([71, 73, 70, 56, 57, 97]);
|
4096
|
+
stream.writeInt16(width);
|
4097
|
+
stream.writeInt16(height);
|
4098
|
+
stream.writeBytes([128, 0, 0]);
|
4099
|
+
stream.writeBytes([background[0], background[1], background[2]]);
|
4100
|
+
stream.writeBytes([foreground[0], foreground[1], foreground[2]]);
|
4101
|
+
stream.writeByte(44);
|
4102
|
+
stream.writeInt16(0);
|
4103
|
+
stream.writeInt16(0);
|
4104
|
+
stream.writeInt16(width);
|
4105
|
+
stream.writeInt16(height);
|
4106
|
+
stream.writeByte(0);
|
4107
|
+
compress(this.pixels, 2, stream);
|
4108
|
+
stream.writeByte(59);
|
4109
|
+
return stream.bytes;
|
4110
|
+
}
|
4111
|
+
set(x, y, color) {
|
4112
|
+
this.pixels[y * this.width + x] = color;
|
4113
|
+
}
|
4114
|
+
toDataURL() {
|
4115
|
+
const bytes = this.encodeImpl();
|
4116
|
+
const stream = new Base64Stream();
|
4117
|
+
for (const byte of bytes) {
|
4118
|
+
stream.write(byte);
|
4119
|
+
}
|
4120
|
+
stream.close();
|
4121
|
+
const base64 = stream.bytes;
|
4122
|
+
let url = "data:image/gif;base64,";
|
4123
|
+
for (const byte of base64) {
|
4124
|
+
url += fromCharCode(byte);
|
4197
4125
|
}
|
4198
4126
|
return url;
|
4199
|
-
}
|
4200
|
-
|
4201
|
-
|
4127
|
+
}
|
4128
|
+
};
|
4129
|
+
__name(GIFImage, "GIFImage");
|
4202
4130
|
|
4203
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
4131
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/common/MaskPattern.js
|
4204
4132
|
function getMaskFunc(maskPattern) {
|
4205
4133
|
switch (maskPattern) {
|
4206
4134
|
case 0:
|
4207
|
-
return
|
4208
|
-
return (x + y & 1) === 0;
|
4209
|
-
};
|
4135
|
+
return (x, y) => (x + y & 1) === 0;
|
4210
4136
|
case 1:
|
4211
|
-
return
|
4212
|
-
return (y & 1) === 0;
|
4213
|
-
};
|
4137
|
+
return (_x, y) => (y & 1) === 0;
|
4214
4138
|
case 2:
|
4215
|
-
return
|
4216
|
-
return x % 3 === 0;
|
4217
|
-
};
|
4139
|
+
return (x, _y) => x % 3 === 0;
|
4218
4140
|
case 3:
|
4219
|
-
return
|
4220
|
-
return (x + y) % 3 === 0;
|
4221
|
-
};
|
4141
|
+
return (x, y) => (x + y) % 3 === 0;
|
4222
4142
|
case 4:
|
4223
|
-
return
|
4224
|
-
return ((x / 3 >> 0) + (y / 2 >> 0) & 1) === 0;
|
4225
|
-
};
|
4143
|
+
return (x, y) => ((x / 3 >> 0) + (y / 2 >> 0) & 1) === 0;
|
4226
4144
|
case 5:
|
4227
|
-
return
|
4228
|
-
return (x * y & 1) + x * y % 3 === 0;
|
4229
|
-
};
|
4145
|
+
return (x, y) => (x * y & 1) + x * y % 3 === 0;
|
4230
4146
|
case 6:
|
4231
|
-
return
|
4232
|
-
return ((x * y & 1) + x * y % 3 & 1) === 0;
|
4233
|
-
};
|
4147
|
+
return (x, y) => ((x * y & 1) + x * y % 3 & 1) === 0;
|
4234
4148
|
case 7:
|
4235
|
-
return
|
4236
|
-
return (x * y % 3 + (x + y & 1) & 1) === 0;
|
4237
|
-
};
|
4149
|
+
return (x, y) => (x * y % 3 + (x + y & 1) & 1) === 0;
|
4238
4150
|
default:
|
4239
|
-
throw new Error(
|
4151
|
+
throw new Error(`illegal mask: ${maskPattern}`);
|
4240
4152
|
}
|
4241
4153
|
}
|
4242
4154
|
__name(getMaskFunc, "getMaskFunc");
|
4243
4155
|
|
4244
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
4156
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/Writer.js
|
4245
4157
|
var PAD0 = 236;
|
4246
4158
|
var PAD1 = 17;
|
4247
|
-
var toString2 = Object.prototype
|
4159
|
+
var { toString: toString2 } = Object.prototype;
|
4248
4160
|
function appendECI(encoding, buffer2) {
|
4249
4161
|
if (encoding < 0 || encoding >= 1e6) {
|
4250
4162
|
throw new Error("byte mode encoding hint out of range");
|
@@ -4262,11 +4174,10 @@ function appendECI(encoding, buffer2) {
|
|
4262
4174
|
}
|
4263
4175
|
__name(appendECI, "appendECI");
|
4264
4176
|
function prepareData(version2, errorCorrectionLevel, encodingHint, chunks) {
|
4265
|
-
|
4266
|
-
|
4267
|
-
for (
|
4268
|
-
|
4269
|
-
var mode = data.mode;
|
4177
|
+
const buffer2 = new BitBuffer();
|
4178
|
+
const rsBlocks = RSBlock.getRSBlocks(version2, errorCorrectionLevel);
|
4179
|
+
for (const data of chunks) {
|
4180
|
+
const mode = data.mode;
|
4270
4181
|
if (encodingHint && mode === Mode.Byte) {
|
4271
4182
|
appendECI(data.encoding, buffer2);
|
4272
4183
|
}
|
@@ -4274,9 +4185,8 @@ function prepareData(version2, errorCorrectionLevel, encodingHint, chunks) {
|
|
4274
4185
|
buffer2.put(data.getLength(), data.getLengthInBits(version2));
|
4275
4186
|
data.writeTo(buffer2);
|
4276
4187
|
}
|
4277
|
-
|
4278
|
-
for (
|
4279
|
-
var rsBlock = rsBlocks_1[_a];
|
4188
|
+
let maxDataCount = 0;
|
4189
|
+
for (const rsBlock of rsBlocks) {
|
4280
4190
|
maxDataCount += rsBlock.getDataCount();
|
4281
4191
|
}
|
4282
4192
|
maxDataCount *= 8;
|
@@ -4284,45 +4194,45 @@ function prepareData(version2, errorCorrectionLevel, encodingHint, chunks) {
|
|
4284
4194
|
}
|
4285
4195
|
__name(prepareData, "prepareData");
|
4286
4196
|
function createBytes(buffer2, rsBlocks) {
|
4287
|
-
|
4288
|
-
|
4289
|
-
|
4290
|
-
|
4291
|
-
|
4292
|
-
|
4293
|
-
|
4294
|
-
for (
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4197
|
+
let offset = 0;
|
4198
|
+
let maxDcCount = 0;
|
4199
|
+
let maxEcCount = 0;
|
4200
|
+
const dcData = [];
|
4201
|
+
const ecData = [];
|
4202
|
+
const rsLength = rsBlocks.length;
|
4203
|
+
const bufferData = buffer2.getBuffer();
|
4204
|
+
for (let r = 0; r < rsLength; r++) {
|
4205
|
+
const rsBlock = rsBlocks[r];
|
4206
|
+
const dcCount = rsBlock.getDataCount();
|
4207
|
+
const ecCount = rsBlock.getTotalCount() - dcCount;
|
4298
4208
|
maxDcCount = Math.max(maxDcCount, dcCount);
|
4299
4209
|
maxEcCount = Math.max(maxEcCount, ecCount);
|
4300
4210
|
dcData[r] = [];
|
4301
|
-
for (
|
4211
|
+
for (let i = 0; i < dcCount; i++) {
|
4302
4212
|
dcData[r][i] = 255 & bufferData[i + offset];
|
4303
4213
|
}
|
4304
4214
|
offset += dcCount;
|
4305
|
-
|
4306
|
-
|
4307
|
-
|
4308
|
-
|
4309
|
-
|
4215
|
+
const rsPoly = getErrorCorrectionPolynomial(ecCount);
|
4216
|
+
const ecLength = rsPoly.getLength() - 1;
|
4217
|
+
const rawPoly = new Polynomial(dcData[r], ecLength);
|
4218
|
+
const modPoly = rawPoly.mod(rsPoly);
|
4219
|
+
const mpLength = modPoly.getLength();
|
4310
4220
|
ecData[r] = [];
|
4311
|
-
for (
|
4312
|
-
|
4221
|
+
for (let i = 0; i < ecLength; i++) {
|
4222
|
+
const modIndex = i + mpLength - ecLength;
|
4313
4223
|
ecData[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
|
4314
4224
|
}
|
4315
4225
|
}
|
4316
4226
|
buffer2 = new BitBuffer();
|
4317
|
-
for (
|
4318
|
-
for (
|
4227
|
+
for (let i = 0; i < maxDcCount; i++) {
|
4228
|
+
for (let r = 0; r < rsLength; r++) {
|
4319
4229
|
if (i < dcData[r].length) {
|
4320
4230
|
buffer2.put(dcData[r][i], 8);
|
4321
4231
|
}
|
4322
4232
|
}
|
4323
4233
|
}
|
4324
|
-
for (
|
4325
|
-
for (
|
4234
|
+
for (let i = 0; i < maxEcCount; i++) {
|
4235
|
+
for (let r = 0; r < rsLength; r++) {
|
4326
4236
|
if (i < ecData[r].length) {
|
4327
4237
|
buffer2.put(ecData[r][i], 8);
|
4328
4238
|
}
|
@@ -4351,38 +4261,34 @@ function createData(buffer2, rsBlocks, maxDataCount) {
|
|
4351
4261
|
return createBytes(buffer2, rsBlocks);
|
4352
4262
|
}
|
4353
4263
|
__name(createData, "createData");
|
4354
|
-
var Encoder =
|
4355
|
-
|
4356
|
-
if (options === void 0) {
|
4357
|
-
options = {};
|
4358
|
-
}
|
4264
|
+
var Encoder = class {
|
4265
|
+
constructor(options = {}) {
|
4359
4266
|
this.matrixSize = 0;
|
4360
4267
|
this.chunks = [];
|
4361
4268
|
this.matrix = [];
|
4362
|
-
|
4269
|
+
const { version: version2 = 0, encodingHint = false, errorCorrectionLevel = ErrorCorrectionLevel.L } = options;
|
4363
4270
|
this.setVersion(version2);
|
4364
4271
|
this.setEncodingHint(encodingHint);
|
4365
4272
|
this.setErrorCorrectionLevel(errorCorrectionLevel);
|
4366
4273
|
}
|
4367
|
-
|
4368
|
-
Encoder2.prototype.getMatrix = function() {
|
4274
|
+
getMatrix() {
|
4369
4275
|
return this.matrix;
|
4370
|
-
}
|
4371
|
-
|
4276
|
+
}
|
4277
|
+
getMatrixSize() {
|
4372
4278
|
return this.matrixSize;
|
4373
|
-
}
|
4374
|
-
|
4279
|
+
}
|
4280
|
+
getVersion() {
|
4375
4281
|
return this.version;
|
4376
|
-
}
|
4377
|
-
|
4282
|
+
}
|
4283
|
+
setVersion(version2) {
|
4378
4284
|
this.version = Math.min(40, Math.max(0, version2 >> 0));
|
4379
4285
|
this.auto = this.version === 0;
|
4380
4286
|
return this;
|
4381
|
-
}
|
4382
|
-
|
4287
|
+
}
|
4288
|
+
getErrorCorrectionLevel() {
|
4383
4289
|
return this.errorCorrectionLevel;
|
4384
|
-
}
|
4385
|
-
|
4290
|
+
}
|
4291
|
+
setErrorCorrectionLevel(errorCorrectionLevel) {
|
4386
4292
|
switch (errorCorrectionLevel) {
|
4387
4293
|
case ErrorCorrectionLevel.L:
|
4388
4294
|
case ErrorCorrectionLevel.M:
|
@@ -4391,36 +4297,36 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4391
4297
|
this.errorCorrectionLevel = errorCorrectionLevel;
|
4392
4298
|
}
|
4393
4299
|
return this;
|
4394
|
-
}
|
4395
|
-
|
4300
|
+
}
|
4301
|
+
getEncodingHint() {
|
4396
4302
|
return this.encodingHint;
|
4397
|
-
}
|
4398
|
-
|
4303
|
+
}
|
4304
|
+
setEncodingHint(encodingHint) {
|
4399
4305
|
this.encodingHint = encodingHint;
|
4400
4306
|
return this;
|
4401
|
-
}
|
4402
|
-
|
4403
|
-
|
4307
|
+
}
|
4308
|
+
write(data) {
|
4309
|
+
const { chunks } = this;
|
4404
4310
|
if (data instanceof QRData) {
|
4405
4311
|
chunks.push(data);
|
4406
4312
|
} else {
|
4407
|
-
|
4313
|
+
const type = toString2.call(data);
|
4408
4314
|
if (type === "[object String]") {
|
4409
4315
|
chunks.push(new QRByte(data));
|
4410
4316
|
} else {
|
4411
|
-
throw new Error(
|
4317
|
+
throw new Error(`illegal data: ${data}`);
|
4412
4318
|
}
|
4413
4319
|
}
|
4414
4320
|
return this;
|
4415
|
-
}
|
4416
|
-
|
4321
|
+
}
|
4322
|
+
isDark(row, col) {
|
4417
4323
|
return this.matrix[row][col] === true;
|
4418
|
-
}
|
4419
|
-
|
4420
|
-
|
4421
|
-
|
4422
|
-
for (
|
4423
|
-
for (
|
4324
|
+
}
|
4325
|
+
setupFinderPattern(row, col) {
|
4326
|
+
const { matrix } = this;
|
4327
|
+
const matrixSize = this.matrixSize;
|
4328
|
+
for (let r = -1; r <= 7; r++) {
|
4329
|
+
for (let c = -1; c <= 7; c++) {
|
4424
4330
|
if (row + r <= -1 || matrixSize <= row + r || col + c <= -1 || matrixSize <= col + c) {
|
4425
4331
|
continue;
|
4426
4332
|
}
|
@@ -4431,20 +4337,20 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4431
4337
|
}
|
4432
4338
|
}
|
4433
4339
|
}
|
4434
|
-
}
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
|
4439
|
-
for (
|
4440
|
-
for (
|
4441
|
-
|
4442
|
-
|
4340
|
+
}
|
4341
|
+
setupAlignmentPattern() {
|
4342
|
+
const { matrix } = this;
|
4343
|
+
const pos = getAlignmentPattern(this.version);
|
4344
|
+
const { length } = pos;
|
4345
|
+
for (let i = 0; i < length; i++) {
|
4346
|
+
for (let j = 0; j < length; j++) {
|
4347
|
+
const row = pos[i];
|
4348
|
+
const col = pos[j];
|
4443
4349
|
if (matrix[row][col] !== null) {
|
4444
4350
|
continue;
|
4445
4351
|
}
|
4446
|
-
for (
|
4447
|
-
for (
|
4352
|
+
for (let r = -2; r <= 2; r++) {
|
4353
|
+
for (let c = -2; c <= 2; c++) {
|
4448
4354
|
if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) {
|
4449
4355
|
matrix[row + r][col + c] = true;
|
4450
4356
|
} else {
|
@@ -4454,12 +4360,12 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4454
4360
|
}
|
4455
4361
|
}
|
4456
4362
|
}
|
4457
|
-
}
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
for (
|
4462
|
-
|
4363
|
+
}
|
4364
|
+
setupTimingPattern() {
|
4365
|
+
const { matrix } = this;
|
4366
|
+
const count = this.matrixSize - 8;
|
4367
|
+
for (let i = 8; i < count; i++) {
|
4368
|
+
const bit = i % 2 === 0;
|
4463
4369
|
if (matrix[i][6] === null) {
|
4464
4370
|
matrix[i][6] = bit;
|
4465
4371
|
}
|
@@ -4467,14 +4373,14 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4467
4373
|
matrix[6][i] = bit;
|
4468
4374
|
}
|
4469
4375
|
}
|
4470
|
-
}
|
4471
|
-
|
4472
|
-
|
4473
|
-
|
4474
|
-
|
4475
|
-
|
4476
|
-
for (
|
4477
|
-
|
4376
|
+
}
|
4377
|
+
setupFormatInfo(maskPattern) {
|
4378
|
+
const { matrix } = this;
|
4379
|
+
const data = this.errorCorrectionLevel << 3 | maskPattern;
|
4380
|
+
const bits = getBCHVersionInfo(data);
|
4381
|
+
const matrixSize = this.matrixSize;
|
4382
|
+
for (let i = 0; i < 15; i++) {
|
4383
|
+
const bit = (bits >> i & 1) === 1;
|
4478
4384
|
if (i < 6) {
|
4479
4385
|
matrix[i][8] = bit;
|
4480
4386
|
} else if (i < 8) {
|
@@ -4491,42 +4397,42 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4491
4397
|
}
|
4492
4398
|
}
|
4493
4399
|
matrix[matrixSize - 8][8] = true;
|
4494
|
-
}
|
4495
|
-
|
4400
|
+
}
|
4401
|
+
setupVersionInfo() {
|
4496
4402
|
if (this.version >= 7) {
|
4497
|
-
|
4498
|
-
|
4499
|
-
|
4500
|
-
for (
|
4501
|
-
|
4403
|
+
const { matrix } = this;
|
4404
|
+
const matrixSize = this.matrixSize;
|
4405
|
+
const bits = getBCHVersion(this.version);
|
4406
|
+
for (let i = 0; i < 18; i++) {
|
4407
|
+
const bit = (bits >> i & 1) === 1;
|
4502
4408
|
matrix[i / 3 >> 0][i % 3 + matrixSize - 8 - 3] = bit;
|
4503
4409
|
matrix[i % 3 + matrixSize - 8 - 3][i / 3 >> 0] = bit;
|
4504
4410
|
}
|
4505
4411
|
}
|
4506
|
-
}
|
4507
|
-
|
4508
|
-
|
4509
|
-
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
for (
|
4412
|
+
}
|
4413
|
+
setupCodewords(data, maskPattern) {
|
4414
|
+
const { matrix } = this;
|
4415
|
+
const matrixSize = this.matrixSize;
|
4416
|
+
const bitLength = data.getLengthInBits();
|
4417
|
+
const maskFunc = getMaskFunc(maskPattern);
|
4418
|
+
let bitIndex = 0;
|
4419
|
+
for (let right = matrixSize - 1; right >= 1; right -= 2) {
|
4514
4420
|
if (right === 6) {
|
4515
4421
|
right = 5;
|
4516
4422
|
}
|
4517
|
-
for (
|
4518
|
-
for (
|
4519
|
-
|
4520
|
-
|
4521
|
-
|
4423
|
+
for (let vert = 0; vert < matrixSize; vert++) {
|
4424
|
+
for (let j = 0; j < 2; j++) {
|
4425
|
+
const x = right - j;
|
4426
|
+
const upward = (right + 1 & 2) === 0;
|
4427
|
+
const y = upward ? matrixSize - 1 - vert : vert;
|
4522
4428
|
if (matrix[y][x] !== null) {
|
4523
4429
|
continue;
|
4524
4430
|
}
|
4525
|
-
|
4431
|
+
let bit = false;
|
4526
4432
|
if (bitIndex < bitLength) {
|
4527
4433
|
bit = data.getBit(bitIndex++);
|
4528
4434
|
}
|
4529
|
-
|
4435
|
+
const invert = maskFunc(x, y);
|
4530
4436
|
if (invert) {
|
4531
4437
|
bit = !bit;
|
4532
4438
|
}
|
@@ -4534,13 +4440,13 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4534
4440
|
}
|
4535
4441
|
}
|
4536
4442
|
}
|
4537
|
-
}
|
4538
|
-
|
4539
|
-
|
4540
|
-
|
4541
|
-
for (
|
4443
|
+
}
|
4444
|
+
buildMatrix(data, maskPattern) {
|
4445
|
+
const matrix = [];
|
4446
|
+
const matrixSize = this.matrixSize;
|
4447
|
+
for (let row = 0; row < matrixSize; row++) {
|
4542
4448
|
matrix[row] = [];
|
4543
|
-
for (
|
4449
|
+
for (let col = 0; col < matrixSize; col++) {
|
4544
4450
|
matrix[row][col] = null;
|
4545
4451
|
}
|
4546
4452
|
}
|
@@ -4553,37 +4459,36 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4553
4459
|
this.setupFormatInfo(maskPattern);
|
4554
4460
|
this.setupVersionInfo();
|
4555
4461
|
this.setupCodewords(data, maskPattern);
|
4556
|
-
}
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4562
|
-
var _c = this, chunks = _c.chunks, errorCorrectionLevel = _c.errorCorrectionLevel;
|
4462
|
+
}
|
4463
|
+
make() {
|
4464
|
+
let buffer2;
|
4465
|
+
let rsBlocks;
|
4466
|
+
let maxDataCount;
|
4467
|
+
const { chunks, errorCorrectionLevel } = this;
|
4563
4468
|
if (this.auto) {
|
4564
|
-
|
4469
|
+
let version2 = 1;
|
4565
4470
|
for (; version2 <= 40; version2++) {
|
4566
|
-
|
4471
|
+
[buffer2, rsBlocks, maxDataCount] = prepareData(version2, errorCorrectionLevel, this.encodingHint, chunks);
|
4567
4472
|
if (buffer2.getLengthInBits() <= maxDataCount)
|
4568
4473
|
break;
|
4569
4474
|
}
|
4570
|
-
|
4475
|
+
const dataLengthInBits = buffer2.getLengthInBits();
|
4571
4476
|
if (dataLengthInBits > maxDataCount) {
|
4572
|
-
throw new Error(
|
4477
|
+
throw new Error(`data overflow: ${dataLengthInBits} > ${maxDataCount}`);
|
4573
4478
|
}
|
4574
4479
|
this.version = version2;
|
4575
4480
|
} else {
|
4576
|
-
|
4481
|
+
[buffer2, rsBlocks, maxDataCount] = prepareData(this.version, errorCorrectionLevel, this.encodingHint, chunks);
|
4577
4482
|
}
|
4578
4483
|
this.matrixSize = this.version * 4 + 17;
|
4579
|
-
|
4580
|
-
|
4581
|
-
|
4582
|
-
|
4583
|
-
for (
|
4484
|
+
const matrices = [];
|
4485
|
+
const data = createData(buffer2, rsBlocks, maxDataCount);
|
4486
|
+
let bestMaskPattern = -1;
|
4487
|
+
let minPenalty = Number.MAX_VALUE;
|
4488
|
+
for (let maskPattern = 0; maskPattern < 8; maskPattern++) {
|
4584
4489
|
this.buildMatrix(data, maskPattern);
|
4585
4490
|
matrices.push(this.matrix);
|
4586
|
-
|
4491
|
+
const penalty = calculateMaskPenalty(this);
|
4587
4492
|
if (penalty < minPenalty) {
|
4588
4493
|
minPenalty = penalty;
|
4589
4494
|
bestMaskPattern = maskPattern;
|
@@ -4591,52 +4496,46 @@ var Encoder = /* @__PURE__ */ function() {
|
|
4591
4496
|
}
|
4592
4497
|
this.matrix = matrices[bestMaskPattern];
|
4593
4498
|
return this;
|
4594
|
-
}
|
4595
|
-
|
4596
|
-
if (moduleSize === void 0) {
|
4597
|
-
moduleSize = 2;
|
4598
|
-
}
|
4599
|
-
if (margin === void 0) {
|
4600
|
-
margin = moduleSize * 4;
|
4601
|
-
}
|
4499
|
+
}
|
4500
|
+
toDataURL(moduleSize = 2, margin = moduleSize * 4, colors) {
|
4602
4501
|
moduleSize = Math.max(1, moduleSize >> 0);
|
4603
4502
|
margin = Math.max(0, margin >> 0);
|
4604
|
-
|
4605
|
-
|
4606
|
-
|
4607
|
-
|
4608
|
-
|
4609
|
-
for (
|
4610
|
-
for (
|
4503
|
+
const matrixSize = this.matrixSize;
|
4504
|
+
const size = moduleSize * matrixSize + margin * 2;
|
4505
|
+
const min = margin;
|
4506
|
+
const max = size - margin;
|
4507
|
+
const gif = new GIFImage(size, size, colors);
|
4508
|
+
for (let y = 0; y < size; y++) {
|
4509
|
+
for (let x = 0; x < size; x++) {
|
4611
4510
|
if (min <= x && x < max && min <= y && y < max) {
|
4612
|
-
|
4613
|
-
|
4614
|
-
gif.
|
4511
|
+
const row = (y - min) / moduleSize >> 0;
|
4512
|
+
const col = (x - min) / moduleSize >> 0;
|
4513
|
+
gif.set(x, y, this.isDark(row, col) ? 1 : 0);
|
4615
4514
|
} else {
|
4616
|
-
gif.
|
4515
|
+
gif.set(x, y, 0);
|
4617
4516
|
}
|
4618
4517
|
}
|
4619
4518
|
}
|
4620
4519
|
return gif.toDataURL();
|
4621
|
-
}
|
4622
|
-
|
4520
|
+
}
|
4521
|
+
clear() {
|
4623
4522
|
this.chunks = [];
|
4624
|
-
}
|
4625
|
-
|
4626
|
-
|
4523
|
+
}
|
4524
|
+
};
|
4525
|
+
__name(Encoder, "Encoder");
|
4627
4526
|
|
4628
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
4527
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/encoding/UTF16.js
|
4629
4528
|
function encode8(text) {
|
4630
|
-
|
4631
|
-
|
4632
|
-
for (
|
4529
|
+
const { length } = text;
|
4530
|
+
const bytes = [];
|
4531
|
+
for (let i = 0; i < length; i++) {
|
4633
4532
|
bytes.push(text.charCodeAt(i));
|
4634
4533
|
}
|
4635
4534
|
return bytes;
|
4636
4535
|
}
|
4637
4536
|
__name(encode8, "encode");
|
4638
4537
|
|
4639
|
-
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.
|
4538
|
+
// ../../../node_modules/.pnpm/@nuintun+qrcode@3.4.0/node_modules/@nuintun/qrcode/esm/qrcode/encoder/QRAlphanumeric.js
|
4640
4539
|
function getByte(byte) {
|
4641
4540
|
if (48 <= byte && byte <= 57) {
|
4642
4541
|
return byte - 48;
|
@@ -4663,23 +4562,20 @@ function getByte(byte) {
|
|
4663
4562
|
case 58:
|
4664
4563
|
return 44;
|
4665
4564
|
default:
|
4666
|
-
throw new Error(
|
4565
|
+
throw new Error(`illegal char: ${String.fromCharCode(byte)}`);
|
4667
4566
|
}
|
4668
4567
|
}
|
4669
4568
|
}
|
4670
4569
|
__name(getByte, "getByte");
|
4671
|
-
var QRAlphanumeric =
|
4672
|
-
|
4673
|
-
|
4674
|
-
|
4675
|
-
|
4676
|
-
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
var i = 0;
|
4681
|
-
var bytes = this.bytes;
|
4682
|
-
var length = bytes.length;
|
4570
|
+
var QRAlphanumeric = class extends QRData {
|
4571
|
+
constructor(data) {
|
4572
|
+
super(Mode.Alphanumeric, data);
|
4573
|
+
this.bytes = encode8(data);
|
4574
|
+
}
|
4575
|
+
writeTo(buffer2) {
|
4576
|
+
let i = 0;
|
4577
|
+
const { bytes } = this;
|
4578
|
+
const { length } = bytes;
|
4683
4579
|
while (i + 1 < length) {
|
4684
4580
|
buffer2.put(getByte(bytes[i]) * 45 + getByte(bytes[i + 1]), 11);
|
4685
4581
|
i += 2;
|
@@ -4687,9 +4583,9 @@ var QRAlphanumeric = /* @__PURE__ */ function(_super) {
|
|
4687
4583
|
if (i < length) {
|
4688
4584
|
buffer2.put(getByte(bytes[i]), 6);
|
4689
4585
|
}
|
4690
|
-
}
|
4691
|
-
|
4692
|
-
|
4586
|
+
}
|
4587
|
+
};
|
4588
|
+
__name(QRAlphanumeric, "QRAlphanumeric");
|
4693
4589
|
|
4694
4590
|
// ../../../node_modules/.pnpm/@digitalbazaar+vpqr@3.0.0/node_modules/@digitalbazaar/vpqr/lib/vpqr.js
|
4695
4591
|
var VP_QR_VERSION = "VP1";
|
@@ -4797,14 +4693,20 @@ var getVpqrPlugin = /* @__PURE__ */ __name((learnCard) => {
|
|
4797
4693
|
/*!
|
4798
4694
|
* Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
|
4799
4695
|
*/
|
4696
|
+
/*!
|
4697
|
+
* Copyright (c) 2020-2023 Digital Bazaar, Inc. All rights reserved.
|
4698
|
+
*/
|
4800
4699
|
/*!
|
4801
4700
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
4802
4701
|
*/
|
4702
|
+
/*!
|
4703
|
+
* Copyright (c) 2021-2023 Digital Bazaar, Inc. All rights reserved.
|
4704
|
+
*/
|
4803
4705
|
/**
|
4804
4706
|
* @module QRCode
|
4805
4707
|
* @package @nuintun/qrcode
|
4806
4708
|
* @license MIT
|
4807
|
-
* @version 3.
|
4709
|
+
* @version 3.4.0
|
4808
4710
|
* @author nuintun <nuintun@qq.com>
|
4809
4711
|
* @description A pure JavaScript QRCode encode and decode library.
|
4810
4712
|
* @see https://github.com/nuintun/qrcode#readme
|