@cbortech/cbor 0.25.7 → 0.25.8
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-BQYXoTz7.cjs} +4 -4
- package/dist/mapEntries-BQYXoTz7.cjs.map +1 -0
- package/dist/{mapEntries-bvRWFfqX.js → mapEntries-Cc4If3gy.js} +44 -18
- package/dist/mapEntries-Cc4If3gy.js.map +1 -0
- package/dist/{tokenizer-M2pf9ud0.cjs → tokenizer-Cg5EIl83.cjs} +3 -3
- package/dist/tokenizer-Cg5EIl83.cjs.map +1 -0
- package/dist/{tokenizer-BuRSmdyM.js → tokenizer-IDqJN0Dw.js} +4 -3
- package/dist/tokenizer-IDqJN0Dw.js.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-IDqJN0Dw.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")],
|
|
@@ -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],
|
|
@@ -2848,4 +2874,4 @@ var $ = class extends Array {
|
|
|
2848
2874
|
//#endregion
|
|
2849
2875
|
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, Gn as i, u as k, Qe as l, P as m, Xn 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
2876
|
|
|
2851
|
-
//# sourceMappingURL=mapEntries-
|
|
2877
|
+
//# sourceMappingURL=mapEntries-Cc4If3gy.js.map
|