@cbortech/cbor 0.25.7 → 0.25.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +83 -5
- package/README.md +83 -5
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/cbor.d.ts +48 -15
- package/dist/cdn/index.cjs +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/tokenizer.d.ts +3 -0
- package/dist/index.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +176 -16
- package/dist/index.js.map +1 -1
- package/dist/{mapEntries-C5S6uTIO.cjs → mapEntries-BkcJsv3C.cjs} +5 -5
- package/dist/mapEntries-BkcJsv3C.cjs.map +1 -0
- package/dist/{mapEntries-bvRWFfqX.js → mapEntries-I8f0WuwK.js} +122 -87
- package/dist/mapEntries-I8f0WuwK.js.map +1 -0
- package/dist/{tokenizer-BuRSmdyM.js → tokenizer-CETZf2NR.js} +5 -4
- package/dist/tokenizer-CETZf2NR.js.map +1 -0
- package/dist/{tokenizer-M2pf9ud0.cjs → tokenizer-CMK8MtYl.cjs} +4 -4
- package/dist/tokenizer-CMK8MtYl.cjs.map +1 -0
- package/dist/types.d.ts +4 -0
- package/package.json +3 -3
- package/dist/mapEntries-C5S6uTIO.cjs.map +0 -1
- package/dist/mapEntries-bvRWFfqX.js.map +0 -1
- package/dist/tokenizer-BuRSmdyM.js.map +0 -1
- package/dist/tokenizer-M2pf9ud0.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, t } from "./tokenizer-
|
|
1
|
+
import { n as e, t } from "./tokenizer-CETZf2NR.js";
|
|
2
2
|
//#region src/tag.ts
|
|
3
3
|
var n = Symbol.for("cbor.tag"), r = class {
|
|
4
4
|
valueOf() {
|
|
@@ -93,7 +93,7 @@ var u = class {
|
|
|
93
93
|
static get(t) {
|
|
94
94
|
return t instanceof e ? t.value : void 0;
|
|
95
95
|
}
|
|
96
|
-
}, p = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), m = new Int8Array(128).fill(-1);
|
|
96
|
+
}, p = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), m = (/* @__PURE__ */ new Int8Array(128)).fill(-1);
|
|
97
97
|
for (let e = 0; e < 16; e++) m["0123456789abcdef".charCodeAt(e)] = e, m["0123456789ABCDEF".charCodeAt(e)] = e;
|
|
98
98
|
var h = typeof Uint8Array.prototype.toHex == "function", g = typeof Uint8Array.fromHex == "function", ee = 256;
|
|
99
99
|
function te(e) {
|
|
@@ -161,7 +161,7 @@ function le(e, t = !1) {
|
|
|
161
161
|
colSep: t ? ":" : ": "
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
var ue = typeof new Uint8Array().toBase64 == "function";
|
|
164
|
+
var ue = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
|
|
165
165
|
function de(e) {
|
|
166
166
|
if (ue) return e.toBase64({ omitPadding: !0 });
|
|
167
167
|
let t = "";
|
|
@@ -989,7 +989,7 @@ var L = class e extends D {
|
|
|
989
989
|
}, Ke = 2n, qe = 3n, Je = 18446744073709551615n, Ye = -18446744073709551616n;
|
|
990
990
|
function Xe(e) {
|
|
991
991
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
992
|
-
if (e === 0n) return new Uint8Array();
|
|
992
|
+
if (e === 0n) return /* @__PURE__ */ new Uint8Array();
|
|
993
993
|
let t = e.toString(16);
|
|
994
994
|
t.length % 2 != 0 && (t = "0" + t);
|
|
995
995
|
let n = new Uint8Array(t.length / 2);
|
|
@@ -1027,7 +1027,10 @@ var Qe = class extends j {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
}, et = new TextEncoder(), tt = new TextDecoder("utf-8", { fatal: !0 }), nt = new TextDecoder("utf-8", { fatal: !1 });
|
|
1029
1029
|
function rt(e, n) {
|
|
1030
|
-
let r = new t(e, {
|
|
1030
|
+
let r = new t(e, {
|
|
1031
|
+
offset: n?.offset,
|
|
1032
|
+
skipRS: n?._skipRS
|
|
1033
|
+
}), i = new ht(r, n ?? {}).parse();
|
|
1031
1034
|
return n?.preserveComments && ct(i, r.comments, e), i;
|
|
1032
1035
|
}
|
|
1033
1036
|
function it(e) {
|
|
@@ -1164,7 +1167,7 @@ function dt(e) {
|
|
|
1164
1167
|
return a + 1;
|
|
1165
1168
|
};
|
|
1166
1169
|
}
|
|
1167
|
-
var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, pt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, mt = new Map([
|
|
1170
|
+
var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, pt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, mt = /* @__PURE__ */ new Map([
|
|
1168
1171
|
["b32", ft("b32")],
|
|
1169
1172
|
["h32", ft("h32")],
|
|
1170
1173
|
["float", ft("float")],
|
|
@@ -1182,7 +1185,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1182
1185
|
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1183
1186
|
constructor(t, n) {
|
|
1184
1187
|
this.t = t, this._options = n, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = n.unresolvedExtension ?? "cpa999";
|
|
1185
|
-
for (let e of [...
|
|
1188
|
+
for (let e of [...Z, ...n.extensions ?? []]) {
|
|
1186
1189
|
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1187
1190
|
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1188
1191
|
}
|
|
@@ -1271,7 +1274,12 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1271
1274
|
case "APP_SEQUENCE": {
|
|
1272
1275
|
this.t.consume();
|
|
1273
1276
|
let t = [];
|
|
1274
|
-
for (; this.t.peek().type !== "GT_GT"
|
|
1277
|
+
for (; this.t.peek().type !== "GT_GT";) {
|
|
1278
|
+
if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), t.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1279
|
+
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1280
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1281
|
+
t.push(this.parseValue());
|
|
1282
|
+
}
|
|
1275
1283
|
this.expect("GT_GT");
|
|
1276
1284
|
let n, r;
|
|
1277
1285
|
this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
|
|
@@ -1406,7 +1414,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1406
1414
|
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: et.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1407
1415
|
}
|
|
1408
1416
|
if (!r) {
|
|
1409
|
-
let e = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
|
|
1417
|
+
let e = i.map((e) => "bytes" in e ? e.bytes : /* @__PURE__ */ new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
|
|
1410
1418
|
return new M(t, n === void 0 ? void 0 : { encodingWidth: n });
|
|
1411
1419
|
}
|
|
1412
1420
|
let a = [], o = [], s = () => {
|
|
@@ -1458,7 +1466,12 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1458
1466
|
parseEmbeddedCBOR() {
|
|
1459
1467
|
this.t.consume();
|
|
1460
1468
|
let e = [];
|
|
1461
|
-
for (; this.t.peek().type !== "GT_GT"
|
|
1469
|
+
for (; this.t.peek().type !== "GT_GT";) {
|
|
1470
|
+
if (e.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1471
|
+
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1472
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1473
|
+
e.push(this.parseValue());
|
|
1474
|
+
}
|
|
1462
1475
|
this.expect("GT_GT");
|
|
1463
1476
|
let t;
|
|
1464
1477
|
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
@@ -1472,7 +1485,12 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1472
1485
|
let e = !1, t, n;
|
|
1473
1486
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1474
1487
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
1475
|
-
for (; this.t.peek().type !== "RBRACKET"
|
|
1488
|
+
for (; this.t.peek().type !== "RBRACKET";) {
|
|
1489
|
+
if (i.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1490
|
+
if (this.t.consume(), this.t.peek().type === "RBRACKET") break;
|
|
1491
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("array items must be separated by \",\" or whitespace", this.t.peek());
|
|
1492
|
+
i.push(this.parseValue());
|
|
1493
|
+
}
|
|
1476
1494
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1477
1495
|
let a = new F(i, {
|
|
1478
1496
|
indefiniteLength: e,
|
|
@@ -1485,7 +1503,10 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1485
1503
|
let e = !1, t, n;
|
|
1486
1504
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1487
1505
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
1488
|
-
for (; this.t.peek().type !== "RBRACE"
|
|
1506
|
+
for (; this.t.peek().type !== "RBRACE";) {
|
|
1507
|
+
if (i.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1508
|
+
if (this.t.consume(), this.t.peek().type === "RBRACE") break;
|
|
1509
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("map entries must be separated by \",\" or whitespace", this.t.peek());
|
|
1489
1510
|
let e = this.parseValue();
|
|
1490
1511
|
this.expect("COLON");
|
|
1491
1512
|
let t = this.parseValue();
|
|
@@ -1508,7 +1529,12 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1508
1529
|
this._warnOrFail(t, e);
|
|
1509
1530
|
} else e.type !== "RPAREN" && this._warnOrFail("indefinite string group is missing _ after (; interpreting as (_ ...)", e);
|
|
1510
1531
|
let t = this._pendingWarnings.splice(0), n = [];
|
|
1511
|
-
for (; this.t.peek().type !== "RPAREN"
|
|
1532
|
+
for (; this.t.peek().type !== "RPAREN";) {
|
|
1533
|
+
if (n.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1534
|
+
if (this.t.consume(), this.t.peek().type === "RPAREN") break;
|
|
1535
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("indefinite string chunks must be separated by \",\" or whitespace", this.t.peek());
|
|
1536
|
+
n.push(this.parseValue());
|
|
1537
|
+
}
|
|
1512
1538
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1513
1539
|
let r = n[0];
|
|
1514
1540
|
if (r instanceof M) {
|
|
@@ -1781,12 +1807,12 @@ function Ct(e) {
|
|
|
1781
1807
|
}
|
|
1782
1808
|
return t;
|
|
1783
1809
|
}
|
|
1784
|
-
var wt = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Tt = new Set([
|
|
1810
|
+
var wt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Tt = /* @__PURE__ */ new Set([
|
|
1785
1811
|
"LBRACKET",
|
|
1786
1812
|
"LBRACE",
|
|
1787
1813
|
"LPAREN",
|
|
1788
1814
|
"LT_LT"
|
|
1789
|
-
]), Et = new Set([
|
|
1815
|
+
]), Et = /* @__PURE__ */ new Set([
|
|
1790
1816
|
"RBRACKET",
|
|
1791
1817
|
"RBRACE",
|
|
1792
1818
|
"RPAREN",
|
|
@@ -1934,7 +1960,7 @@ var Vt = Bt(), Ht = Bt({ jsDate: !0 });
|
|
|
1934
1960
|
function Ut(e) {
|
|
1935
1961
|
let t = e.split(".");
|
|
1936
1962
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
1937
|
-
let n = new Uint8Array(4);
|
|
1963
|
+
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
1938
1964
|
for (let e = 0; e < 4; e++) {
|
|
1939
1965
|
let r = t[e];
|
|
1940
1966
|
if (!/^\d+$/.test(r) || r.length > 1 && r[0] === "0") throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);
|
|
@@ -1945,7 +1971,7 @@ function Ut(e) {
|
|
|
1945
1971
|
return n;
|
|
1946
1972
|
}
|
|
1947
1973
|
function Wt(e) {
|
|
1948
|
-
let t = new Uint8Array(16);
|
|
1974
|
+
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
1949
1975
|
if (e === "::") return t;
|
|
1950
1976
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1951
1977
|
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Ut(i[2]));
|
|
@@ -2094,7 +2120,7 @@ var on = {
|
|
|
2094
2120
|
}
|
|
2095
2121
|
}
|
|
2096
2122
|
}
|
|
2097
|
-
}, un = "cri", dn = "CRI", fn = 99n, pn = new Map([
|
|
2123
|
+
}, un = "cri", dn = "CRI", fn = 99n, pn = /* @__PURE__ */ new Map([
|
|
2098
2124
|
["coap", -1n],
|
|
2099
2125
|
["coaps", -2n],
|
|
2100
2126
|
["http", -3n],
|
|
@@ -2398,30 +2424,30 @@ function Rn(e, t, n) {
|
|
|
2398
2424
|
if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
|
|
2399
2425
|
return r;
|
|
2400
2426
|
}
|
|
2401
|
-
function
|
|
2427
|
+
function zn(e, t) {
|
|
2402
2428
|
e.warnings ??= [], e.warnings.push(t);
|
|
2403
2429
|
}
|
|
2404
|
-
function
|
|
2430
|
+
function Bn(e) {
|
|
2405
2431
|
let t = "";
|
|
2406
2432
|
for (let n of e) t += n.toString(16).padStart(2, "0");
|
|
2407
2433
|
return t;
|
|
2408
2434
|
}
|
|
2409
|
-
function
|
|
2435
|
+
function J(e) {
|
|
2410
2436
|
if (e instanceof O) return ["u", String(e.value)];
|
|
2411
2437
|
if (e instanceof k) return ["n", String(e.value)];
|
|
2412
2438
|
if (e instanceof z) return ["t", e.value];
|
|
2413
2439
|
if (e instanceof P) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2414
|
-
if (e instanceof M) return ["b",
|
|
2440
|
+
if (e instanceof M) return ["b", Bn(e.value)];
|
|
2415
2441
|
if (e instanceof N) {
|
|
2416
2442
|
let t = "";
|
|
2417
|
-
for (let n of e.chunks) t +=
|
|
2443
|
+
for (let n of e.chunks) t += Bn(n.value);
|
|
2418
2444
|
return ["b", t];
|
|
2419
2445
|
}
|
|
2420
2446
|
if (e instanceof A) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2421
2447
|
if (e instanceof L) return ["s", e.value];
|
|
2422
|
-
if (e instanceof F) return ["A", e.items.map(
|
|
2448
|
+
if (e instanceof F) return ["A", e.items.map(J)];
|
|
2423
2449
|
if (e instanceof I) {
|
|
2424
|
-
let t = e.entries.map(([e, t]) => [
|
|
2450
|
+
let t = e.entries.map(([e, t]) => [J(e), J(t)]);
|
|
2425
2451
|
if (t.length <= 1) return ["M", t];
|
|
2426
2452
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2427
2453
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
@@ -2429,13 +2455,13 @@ function Y(e) {
|
|
|
2429
2455
|
if (e instanceof j) return [
|
|
2430
2456
|
"G",
|
|
2431
2457
|
String(e.tag),
|
|
2432
|
-
|
|
2458
|
+
J(e.content)
|
|
2433
2459
|
];
|
|
2434
2460
|
let t = e.toCBOR(), n = "";
|
|
2435
2461
|
for (let e of t) n += e.toString(16).padStart(2, "0");
|
|
2436
2462
|
return ["c", n];
|
|
2437
2463
|
}
|
|
2438
|
-
function
|
|
2464
|
+
function Vn(e) {
|
|
2439
2465
|
if (e instanceof O) return "u" + e.value;
|
|
2440
2466
|
if (e instanceof k) return "n" + e.value;
|
|
2441
2467
|
if (e instanceof z) return "t" + e.value;
|
|
@@ -2444,17 +2470,25 @@ function Bn(e) {
|
|
|
2444
2470
|
for (let n of e.chunks) t += n.value;
|
|
2445
2471
|
return t;
|
|
2446
2472
|
}
|
|
2447
|
-
if (e instanceof M) return "b" +
|
|
2473
|
+
if (e instanceof M) return "b" + Bn(e.value);
|
|
2448
2474
|
if (e instanceof N) {
|
|
2449
2475
|
let t = "b";
|
|
2450
|
-
for (let n of e.chunks) t +=
|
|
2476
|
+
for (let n of e.chunks) t += Bn(n.value);
|
|
2451
2477
|
return t;
|
|
2452
2478
|
}
|
|
2453
|
-
return e instanceof A ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof L ? "s" + e.value : JSON.stringify(
|
|
2479
|
+
return e instanceof A ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof L ? "s" + e.value : JSON.stringify(J(e));
|
|
2480
|
+
}
|
|
2481
|
+
var Hn = Array.from({ length: 24 }, (e, t) => BigInt(t)), Un;
|
|
2482
|
+
function Wn() {
|
|
2483
|
+
return Un ??= Z.filter((e) => e.parseTag !== void 0);
|
|
2454
2484
|
}
|
|
2455
|
-
function
|
|
2485
|
+
function Gn(e, t) {
|
|
2486
|
+
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
2487
|
+
return String.fromCharCode.apply(null, e);
|
|
2488
|
+
}
|
|
2489
|
+
function Y(e, t, n) {
|
|
2456
2490
|
if (n <= 23) return {
|
|
2457
|
-
value:
|
|
2491
|
+
value: Hn[n],
|
|
2458
2492
|
nextOffset: t
|
|
2459
2493
|
};
|
|
2460
2494
|
switch (n) {
|
|
@@ -2477,14 +2511,14 @@ function X(e, t, n) {
|
|
|
2477
2511
|
default: q(`reserved additional info value: ${n}`);
|
|
2478
2512
|
}
|
|
2479
2513
|
}
|
|
2480
|
-
function
|
|
2514
|
+
function Kn(e, t, n, r, i, a) {
|
|
2481
2515
|
let o = [], s = t;
|
|
2482
2516
|
for (;;) {
|
|
2483
2517
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
2484
2518
|
s++;
|
|
2485
2519
|
break;
|
|
2486
2520
|
}
|
|
2487
|
-
let t =
|
|
2521
|
+
let t = X(e, s, n, r);
|
|
2488
2522
|
a(t.value) || q(`indefinite-length ${i} chunk must be a definite ${i}`), o.push(t.value), s = t.nextOffset;
|
|
2489
2523
|
}
|
|
2490
2524
|
return {
|
|
@@ -2492,27 +2526,27 @@ function Vn(e, t, n, r, i, a) {
|
|
|
2492
2526
|
nextOffset: s
|
|
2493
2527
|
};
|
|
2494
2528
|
}
|
|
2495
|
-
function
|
|
2496
|
-
let i =
|
|
2529
|
+
function qn(e, t, n, r) {
|
|
2530
|
+
let i = Vn(e);
|
|
2497
2531
|
t.has(i) && n.push(Rn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2498
2532
|
}
|
|
2499
|
-
function
|
|
2500
|
-
let i = t, a =
|
|
2533
|
+
function X(e, t, n, r) {
|
|
2534
|
+
let i = t, a = Jn(e, t, n, r);
|
|
2501
2535
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2502
2536
|
}
|
|
2503
|
-
function
|
|
2537
|
+
function Jn(e, t, n, r) {
|
|
2504
2538
|
t >= e.byteLength && q("unexpected end of input");
|
|
2505
2539
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2506
2540
|
switch (a) {
|
|
2507
2541
|
case 0: {
|
|
2508
|
-
let { value: n, nextOffset: r } =
|
|
2542
|
+
let { value: n, nextOffset: r } = Y(e, t, o);
|
|
2509
2543
|
return {
|
|
2510
2544
|
value: new O(n, { encodingWidth: K(o, n) }),
|
|
2511
2545
|
nextOffset: r
|
|
2512
2546
|
};
|
|
2513
2547
|
}
|
|
2514
2548
|
case 1: {
|
|
2515
|
-
let { value: n, nextOffset: r } =
|
|
2549
|
+
let { value: n, nextOffset: r } = Y(e, t, o), i = K(o, n);
|
|
2516
2550
|
return {
|
|
2517
2551
|
value: new k(-1n - n, { encodingWidth: i }),
|
|
2518
2552
|
nextOffset: r
|
|
@@ -2520,13 +2554,13 @@ function Un(e, t, n, r) {
|
|
|
2520
2554
|
}
|
|
2521
2555
|
case 2: {
|
|
2522
2556
|
if (o === 31) {
|
|
2523
|
-
let { chunks: i, nextOffset: a } =
|
|
2557
|
+
let { chunks: i, nextOffset: a } = Kn(e, t, n, r, "byte string", (e) => e instanceof M);
|
|
2524
2558
|
return {
|
|
2525
2559
|
value: new N(i),
|
|
2526
2560
|
nextOffset: a
|
|
2527
2561
|
};
|
|
2528
2562
|
}
|
|
2529
|
-
let { value: i, nextOffset: a } =
|
|
2563
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i);
|
|
2530
2564
|
return a + s > e.byteLength && q("byte string extends beyond input"), {
|
|
2531
2565
|
value: new M(new Uint8Array(e.buffer, e.byteOffset + a, s).slice(), { encodingWidth: c }),
|
|
2532
2566
|
nextOffset: a + s
|
|
@@ -2534,23 +2568,24 @@ function Un(e, t, n, r) {
|
|
|
2534
2568
|
}
|
|
2535
2569
|
case 3: {
|
|
2536
2570
|
if (o === 31) {
|
|
2537
|
-
let { chunks: i, nextOffset: a } =
|
|
2571
|
+
let { chunks: i, nextOffset: a } = Kn(e, t, n, r, "text string", (e) => e instanceof z);
|
|
2538
2572
|
return {
|
|
2539
2573
|
value: new P(i),
|
|
2540
2574
|
nextOffset: a
|
|
2541
2575
|
};
|
|
2542
2576
|
}
|
|
2543
|
-
let { value: i, nextOffset: a } =
|
|
2577
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i);
|
|
2544
2578
|
a + s > e.byteLength && q("text string extends beyond input");
|
|
2545
|
-
let l = new Uint8Array(e.buffer, e.byteOffset + a, s), u, d;
|
|
2546
|
-
|
|
2579
|
+
let l = new Uint8Array(e.buffer, e.byteOffset + a, s), u, d, f = s < 64 ? Gn(l, s) : void 0;
|
|
2580
|
+
if (f !== void 0) u = f;
|
|
2581
|
+
else try {
|
|
2547
2582
|
u = In.decode(l);
|
|
2548
2583
|
} catch {
|
|
2549
2584
|
d = Rn("invalid UTF-8 sequence in text string", a, n), u = Ln.decode(l);
|
|
2550
2585
|
}
|
|
2551
|
-
let
|
|
2552
|
-
return d &&
|
|
2553
|
-
value:
|
|
2586
|
+
let p = new z(u, { encodingWidth: c });
|
|
2587
|
+
return d && zn(p, d), {
|
|
2588
|
+
value: p,
|
|
2554
2589
|
nextOffset: a + s
|
|
2555
2590
|
};
|
|
2556
2591
|
}
|
|
@@ -2562,7 +2597,7 @@ function Un(e, t, n, r) {
|
|
|
2562
2597
|
a++;
|
|
2563
2598
|
break;
|
|
2564
2599
|
}
|
|
2565
|
-
let t =
|
|
2600
|
+
let t = X(e, a, n, r);
|
|
2566
2601
|
i.push(t.value), a = t.nextOffset;
|
|
2567
2602
|
}
|
|
2568
2603
|
return {
|
|
@@ -2570,9 +2605,9 @@ function Un(e, t, n, r) {
|
|
|
2570
2605
|
nextOffset: a
|
|
2571
2606
|
};
|
|
2572
2607
|
}
|
|
2573
|
-
let { value: i, nextOffset: a } =
|
|
2608
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i), l = [], u = a;
|
|
2574
2609
|
for (let t = 0; t < s; t++) {
|
|
2575
|
-
let t =
|
|
2610
|
+
let t = X(e, u, n, r);
|
|
2576
2611
|
l.push(t.value), u = t.nextOffset;
|
|
2577
2612
|
}
|
|
2578
2613
|
return {
|
|
@@ -2588,27 +2623,27 @@ function Un(e, t, n, r) {
|
|
|
2588
2623
|
s++;
|
|
2589
2624
|
break;
|
|
2590
2625
|
}
|
|
2591
|
-
let t =
|
|
2592
|
-
|
|
2593
|
-
let c =
|
|
2626
|
+
let t = X(e, s, n, r);
|
|
2627
|
+
qn(t.value, a, o, n), s = t.nextOffset;
|
|
2628
|
+
let c = X(e, s, n, r);
|
|
2594
2629
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2595
2630
|
}
|
|
2596
2631
|
let c = new I(i, { indefiniteLength: !0 });
|
|
2597
|
-
for (let e of o)
|
|
2632
|
+
for (let e of o) zn(c, e);
|
|
2598
2633
|
return {
|
|
2599
2634
|
value: c,
|
|
2600
2635
|
nextOffset: s
|
|
2601
2636
|
};
|
|
2602
2637
|
}
|
|
2603
|
-
let { value: i, nextOffset: a } =
|
|
2638
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i), l = [], u = /* @__PURE__ */ new Set(), d = [], f = a;
|
|
2604
2639
|
for (let t = 0; t < s; t++) {
|
|
2605
|
-
let t =
|
|
2606
|
-
|
|
2607
|
-
let i =
|
|
2640
|
+
let t = X(e, f, n, r);
|
|
2641
|
+
qn(t.value, u, d, n), f = t.nextOffset;
|
|
2642
|
+
let i = X(e, f, n, r);
|
|
2608
2643
|
f = i.nextOffset, l.push([t.value, i.value]);
|
|
2609
2644
|
}
|
|
2610
2645
|
let p = new I(l, { encodingWidth: c });
|
|
2611
|
-
for (let e of d)
|
|
2646
|
+
for (let e of d) zn(p, e);
|
|
2612
2647
|
return {
|
|
2613
2648
|
value: p,
|
|
2614
2649
|
nextOffset: f
|
|
@@ -2616,7 +2651,7 @@ function Un(e, t, n, r) {
|
|
|
2616
2651
|
}
|
|
2617
2652
|
case 6: {
|
|
2618
2653
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2619
|
-
let { value: i, nextOffset: a } =
|
|
2654
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = K(o, i), c = X(e, a, n, r);
|
|
2620
2655
|
for (let e of r) {
|
|
2621
2656
|
let t = e.parseTag(i, c.value, n);
|
|
2622
2657
|
if (t !== void 0) return t instanceof j && s !== void 0 && (t.encodingWidth = s), {
|
|
@@ -2655,7 +2690,7 @@ function Un(e, t, n, r) {
|
|
|
2655
2690
|
let r = e.getUint8(t);
|
|
2656
2691
|
if (r < 32) {
|
|
2657
2692
|
let e = Rn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new L(r);
|
|
2658
|
-
return
|
|
2693
|
+
return zn(i, e), {
|
|
2659
2694
|
value: i,
|
|
2660
2695
|
nextOffset: t + 1
|
|
2661
2696
|
};
|
|
@@ -2678,34 +2713,34 @@ function Un(e, t, n, r) {
|
|
|
2678
2713
|
}
|
|
2679
2714
|
return q(`unknown major type: ${a}`);
|
|
2680
2715
|
}
|
|
2681
|
-
function
|
|
2716
|
+
function Yn(e) {
|
|
2682
2717
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2683
2718
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2684
2719
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2685
2720
|
}
|
|
2686
|
-
function
|
|
2687
|
-
let n =
|
|
2721
|
+
function Xn(e, t) {
|
|
2722
|
+
let n = Yn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2688
2723
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
2689
|
-
let a =
|
|
2724
|
+
let a = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...Wn()] : Wn(), { value: o, nextOffset: s } = X(r, i, t, a);
|
|
2690
2725
|
if (!t?.allowTrailing && s !== r.byteLength) {
|
|
2691
|
-
|
|
2726
|
+
zn(o, Rn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
|
|
2692
2727
|
let e = {
|
|
2693
2728
|
strict: !1,
|
|
2694
2729
|
silent: !0
|
|
2695
2730
|
}, n = s;
|
|
2696
|
-
for (; n < r.byteLength;) ({nextOffset: n} =
|
|
2731
|
+
for (; n < r.byteLength;) ({nextOffset: n} = X(r, n, e, a));
|
|
2697
2732
|
}
|
|
2698
2733
|
return o;
|
|
2699
2734
|
}
|
|
2700
2735
|
//#endregion
|
|
2701
2736
|
//#region src/extensions/cbordata.ts
|
|
2702
|
-
var
|
|
2737
|
+
var Zn = 24n, Z = [
|
|
2703
2738
|
Vt,
|
|
2704
2739
|
on,
|
|
2705
2740
|
ln,
|
|
2706
2741
|
Fn,
|
|
2707
2742
|
{
|
|
2708
|
-
tagNumbers: [
|
|
2743
|
+
tagNumbers: [Zn],
|
|
2709
2744
|
parseTag(e, t, n) {
|
|
2710
2745
|
if (e !== 24n || !(t instanceof M)) return;
|
|
2711
2746
|
let r = n ? {
|
|
@@ -2715,7 +2750,7 @@ var Kn = 24n, qn = [
|
|
|
2715
2750
|
silent: n.silent
|
|
2716
2751
|
} : void 0;
|
|
2717
2752
|
try {
|
|
2718
|
-
return new j(
|
|
2753
|
+
return new j(Zn, new Ve([Xn(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2719
2754
|
} catch (e) {
|
|
2720
2755
|
if (r?.strict !== !1) throw e;
|
|
2721
2756
|
return;
|
|
@@ -2727,19 +2762,19 @@ var Kn = 24n, qn = [
|
|
|
2727
2762
|
//#region src/js/fromJS.ts
|
|
2728
2763
|
function Q(e, t) {
|
|
2729
2764
|
if (t?.replacer) {
|
|
2730
|
-
let { replacer: n, ...r } = t, i =
|
|
2765
|
+
let { replacer: n, ...r } = t, i = er(e, n, r.extensions, r.undefinedOmits);
|
|
2731
2766
|
return i === d ? L.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2732
2767
|
}
|
|
2733
|
-
return
|
|
2768
|
+
return Qn(e, t, !0);
|
|
2734
2769
|
}
|
|
2735
|
-
function
|
|
2736
|
-
for (let n of [...t?.extensions ?? [], ...
|
|
2770
|
+
function Qn(e, t, n) {
|
|
2771
|
+
for (let n of [...t?.extensions ?? [], ...Z]) if (n.fromJS) {
|
|
2737
2772
|
let r = n.fromJS(e, t ?? {});
|
|
2738
2773
|
if (r !== void 0) return r;
|
|
2739
2774
|
}
|
|
2740
2775
|
if (n && typeof e == "object" && e && u.symbol in e) {
|
|
2741
|
-
let n = e[u.symbol], r =
|
|
2742
|
-
for (let e of [...t?.extensions ?? [], ...
|
|
2776
|
+
let n = e[u.symbol], r = Qn(e, t, !1);
|
|
2777
|
+
for (let e of [...t?.extensions ?? [], ...Z]) if (e.parseTag) {
|
|
2743
2778
|
let t = e.parseTag(n, r);
|
|
2744
2779
|
if (t !== void 0) return t;
|
|
2745
2780
|
}
|
|
@@ -2755,7 +2790,7 @@ function Jn(e, t, n) {
|
|
|
2755
2790
|
if (typeof e == "bigint") return e > 18446744073709551615n ? new Qe(e) : e < -18446744073709551616n ? new $e(e) : e >= 0n ? new O(e) : new k(e);
|
|
2756
2791
|
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new O(BigInt(e)) : new k(BigInt(e)) : new A(e);
|
|
2757
2792
|
if (typeof e == "string") return new z(e);
|
|
2758
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return
|
|
2793
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Qn(e.valueOf(), t, !1);
|
|
2759
2794
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new M(new Uint8Array(e));
|
|
2760
2795
|
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new F(Array.from(e, (e) => new O(BigInt(e)))) : new M(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
2761
2796
|
if (e instanceof $) return new I([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
@@ -2767,11 +2802,11 @@ function Jn(e, t, n) {
|
|
|
2767
2802
|
}
|
|
2768
2803
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2769
2804
|
}
|
|
2770
|
-
function
|
|
2805
|
+
function $n(e) {
|
|
2771
2806
|
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof u.Null || e instanceof u.Undefined || e instanceof f;
|
|
2772
2807
|
}
|
|
2773
|
-
function
|
|
2774
|
-
let i = [...n ?? [], ...
|
|
2808
|
+
function er(e, t, n, r) {
|
|
2809
|
+
let i = [...n ?? [], ...Z];
|
|
2775
2810
|
function a(e) {
|
|
2776
2811
|
return e === d || r === !0 && e === void 0;
|
|
2777
2812
|
}
|
|
@@ -2781,7 +2816,7 @@ function Xn(e, t, n, r) {
|
|
|
2781
2816
|
if (typeof e != "object" || !e) return e;
|
|
2782
2817
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
2783
2818
|
if (Array.isArray(e)) return e.map(r);
|
|
2784
|
-
if (u.symbol in e ||
|
|
2819
|
+
if (u.symbol in e || $n(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
2785
2820
|
let t = Object.getPrototypeOf(e);
|
|
2786
2821
|
if (t === Object.prototype || t === null) {
|
|
2787
2822
|
let t = e.toJSON;
|
|
@@ -2816,7 +2851,7 @@ function Xn(e, t, n, r) {
|
|
|
2816
2851
|
let r = s(t, String(n), e);
|
|
2817
2852
|
return a(r) ? null : r;
|
|
2818
2853
|
});
|
|
2819
|
-
if (
|
|
2854
|
+
if ($n(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
2820
2855
|
let t = {};
|
|
2821
2856
|
for (let n of Object.keys(e)) {
|
|
2822
2857
|
let r = s(e[n], n, e);
|
|
@@ -2846,6 +2881,6 @@ var $ = class extends Array {
|
|
|
2846
2881
|
}
|
|
2847
2882
|
};
|
|
2848
2883
|
//#endregion
|
|
2849
|
-
export { i as A, x as C, n as D, d as E, r as O, S, f as T, j as _, Ht as a, O as b, $e as c, L as d, I as f, M as g, N as h,
|
|
2884
|
+
export { i as A, x as C, n as D, d as E, r as O, S, f as T, j as _, Ht as a, O as b, $e as c, L as d, I as f, M as g, N as h, Xn as i, u as k, Qe as l, P as m, er as n, z as o, F as p, Q as r, rt as s, $ as t, Ve as u, A as v, ne as w, D as x, k as y };
|
|
2850
2885
|
|
|
2851
|
-
//# sourceMappingURL=mapEntries-
|
|
2886
|
+
//# sourceMappingURL=mapEntries-I8f0WuwK.js.map
|