@cbortech/cbor 0.26.5 → 0.26.6
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 +95 -34
- package/README.md +99 -38
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/cbor.d.ts +8 -0
- package/dist/cddl/ast.d.ts +196 -0
- package/dist/cddl/controls.d.ts +28 -0
- package/dist/cddl/equal.d.ts +19 -0
- package/dist/cddl/errors.d.ts +91 -0
- package/dist/cddl/index.cjs +3 -0
- package/dist/cddl/index.cjs.map +1 -0
- package/dist/cddl/index.d.ts +52 -0
- package/dist/cddl/index.js +67 -0
- package/dist/cddl/index.js.map +1 -0
- package/dist/cddl/parser.d.ts +13 -0
- package/dist/cddl/position.d.ts +13 -0
- package/dist/cddl/prelude.d.ts +5 -0
- package/dist/cddl/schema.d.ts +90 -0
- package/dist/cddl/tokenizer.d.ts +138 -0
- package/dist/cddl/validator.d.ts +30 -0
- package/dist/cddl/writer.d.ts +23 -0
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +104 -77
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-BhMlCwYo.cjs +15 -0
- package/dist/mapEntries-BhMlCwYo.cjs.map +1 -0
- package/dist/{mapEntries-Clr-oNtQ.js → mapEntries-Czxt-cmd.js} +427 -422
- package/dist/mapEntries-Czxt-cmd.js.map +1 -0
- package/dist/schema-BmGsaEaW.cjs +63 -0
- package/dist/schema-BmGsaEaW.cjs.map +1 -0
- package/dist/schema-BxkgvUY6.js +1977 -0
- package/dist/schema-BxkgvUY6.js.map +1 -0
- package/dist/types.d.ts +89 -0
- package/dist/utils/base64.d.ts +12 -0
- package/package.json +23 -6
- package/dist/mapEntries-6hy7UgeN.cjs +0 -15
- package/dist/mapEntries-6hy7UgeN.cjs.map +0 -1
- package/dist/mapEntries-Clr-oNtQ.js.map +0 -1
|
@@ -437,12 +437,12 @@ function Fe(e) {
|
|
|
437
437
|
function Ie(e) {
|
|
438
438
|
return Pe.setFloat32(0, e, !1), Object.is(Pe.getFloat32(0, !1), e);
|
|
439
439
|
}
|
|
440
|
-
function
|
|
440
|
+
function k(e) {
|
|
441
441
|
return Fe(e) ? "half" : Ie(e) ? "single" : "double";
|
|
442
442
|
}
|
|
443
443
|
//#endregion
|
|
444
444
|
//#region src/ast/CborItem.ts
|
|
445
|
-
var
|
|
445
|
+
var A = class e {
|
|
446
446
|
start;
|
|
447
447
|
end;
|
|
448
448
|
comments;
|
|
@@ -513,7 +513,7 @@ var k = class e {
|
|
|
513
513
|
comment: this._toCDN(n, 0)
|
|
514
514
|
}];
|
|
515
515
|
}
|
|
516
|
-
},
|
|
516
|
+
}, j = class extends A {
|
|
517
517
|
value;
|
|
518
518
|
encodingWidth;
|
|
519
519
|
constructor(e, t) {
|
|
@@ -537,7 +537,7 @@ var k = class e {
|
|
|
537
537
|
let t = e?.integerAs ?? "auto";
|
|
538
538
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
539
539
|
}
|
|
540
|
-
},
|
|
540
|
+
}, M = class extends A {
|
|
541
541
|
argument;
|
|
542
542
|
encodingWidth;
|
|
543
543
|
constructor(e, t) {
|
|
@@ -566,8 +566,8 @@ var k = class e {
|
|
|
566
566
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
567
567
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
568
568
|
}
|
|
569
|
-
},
|
|
570
|
-
function
|
|
569
|
+
}, Le = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
570
|
+
function Re(e) {
|
|
571
571
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
572
572
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
573
573
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -585,20 +585,20 @@ function ze(e) {
|
|
|
585
585
|
let l = c * 2 ** o;
|
|
586
586
|
return t ? -l : l;
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function ze(e) {
|
|
589
589
|
if (isNaN(e)) return "NaN";
|
|
590
590
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
591
591
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
592
592
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
593
|
-
|
|
594
|
-
let r =
|
|
593
|
+
Le.setFloat64(0, n, !1);
|
|
594
|
+
let r = Le.getUint32(0, !1), i = Le.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
|
|
595
595
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
596
596
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
597
597
|
return t ? `-${p}` : p;
|
|
598
598
|
}
|
|
599
599
|
//#endregion
|
|
600
600
|
//#region src/ast/CborFloat.ts
|
|
601
|
-
var
|
|
601
|
+
var N = class extends A {
|
|
602
602
|
value;
|
|
603
603
|
precision;
|
|
604
604
|
ednSource;
|
|
@@ -607,7 +607,7 @@ var M = class extends k {
|
|
|
607
607
|
super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits;
|
|
608
608
|
}
|
|
609
609
|
_encodeTo(e, t) {
|
|
610
|
-
let n = this.precision ??
|
|
610
|
+
let n = this.precision ?? k(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
|
|
611
611
|
n === "half" ? (e.writeByte(249), r?.length === 2 ? e.writeBytes(r) : e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), r?.length === 4 ? e.writeBytes(r) : e.writeFloat32(this.value)) : (e.writeByte(251), r?.length === 8 ? e.writeBytes(r) : e.writeFloat64(this.value));
|
|
612
612
|
}
|
|
613
613
|
_toCDN(e, t) {
|
|
@@ -617,18 +617,18 @@ var M = class extends k {
|
|
|
617
617
|
if (n === "never") return e.replace(/_[0-3i]$/, "");
|
|
618
618
|
if (n === "always") {
|
|
619
619
|
if (/_[0-3i]$/.test(e)) return e;
|
|
620
|
-
let t = this.precision ??
|
|
620
|
+
let t = this.precision ?? k(this.value);
|
|
621
621
|
return e + (t === "half" ? "_1" : t === "single" ? "_2" : "_3");
|
|
622
622
|
}
|
|
623
623
|
return e;
|
|
624
624
|
}
|
|
625
|
-
let r =
|
|
626
|
-
return (e?.floatFormat === "hex" ?
|
|
625
|
+
let r = k(this.value);
|
|
626
|
+
return (e?.floatFormat === "hex" ? ze(this.value) : be(this.value)) + xe(this.value, this.precision, r, n);
|
|
627
627
|
}
|
|
628
628
|
_toJS(e) {
|
|
629
629
|
return this.value;
|
|
630
630
|
}
|
|
631
|
-
},
|
|
631
|
+
}, P = class extends A {
|
|
632
632
|
tag;
|
|
633
633
|
content;
|
|
634
634
|
encodingWidth;
|
|
@@ -661,7 +661,7 @@ var M = class extends k {
|
|
|
661
661
|
let t = this.content._toJS(e);
|
|
662
662
|
return e?.stripTags ? t : m.set(t, this.tag);
|
|
663
663
|
}
|
|
664
|
-
},
|
|
664
|
+
}, F = class extends A {
|
|
665
665
|
indefiniteLength = !1;
|
|
666
666
|
value;
|
|
667
667
|
ednEncoding;
|
|
@@ -693,7 +693,7 @@ var M = class extends k {
|
|
|
693
693
|
_toJS(e) {
|
|
694
694
|
return this.value;
|
|
695
695
|
}
|
|
696
|
-
},
|
|
696
|
+
}, I = class extends A {
|
|
697
697
|
indefiniteLength = !0;
|
|
698
698
|
chunks;
|
|
699
699
|
constructor(e) {
|
|
@@ -708,7 +708,7 @@ var M = class extends k {
|
|
|
708
708
|
if ((e?.encodingIndicators ?? "auto") === "never") {
|
|
709
709
|
let n = this.chunks.reduce((e, t) => e + t.value.length, 0), r = new Uint8Array(n), i = 0;
|
|
710
710
|
for (let e of this.chunks) r.set(e.value, i), i += e.value.length;
|
|
711
|
-
return new
|
|
711
|
+
return new F(r)._toCDN(e, t);
|
|
712
712
|
}
|
|
713
713
|
return this.chunks.length === 0 ? "''_" : x({
|
|
714
714
|
node: this,
|
|
@@ -743,7 +743,7 @@ var M = class extends k {
|
|
|
743
743
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
744
744
|
return n;
|
|
745
745
|
}
|
|
746
|
-
},
|
|
746
|
+
}, L = class extends A {
|
|
747
747
|
indefiniteLength = !0;
|
|
748
748
|
chunks;
|
|
749
749
|
constructor(e) {
|
|
@@ -755,7 +755,7 @@ var M = class extends k {
|
|
|
755
755
|
e.writeByte(255);
|
|
756
756
|
}
|
|
757
757
|
_toCDN(e, t) {
|
|
758
|
-
return (e?.encodingIndicators ?? "auto") === "never" ? new
|
|
758
|
+
return (e?.encodingIndicators ?? "auto") === "never" ? new U(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : x({
|
|
759
759
|
node: this,
|
|
760
760
|
options: e,
|
|
761
761
|
depth: t,
|
|
@@ -786,7 +786,7 @@ var M = class extends k {
|
|
|
786
786
|
_toJS(e) {
|
|
787
787
|
return this.chunks.map((e) => e.value).join("");
|
|
788
788
|
}
|
|
789
|
-
},
|
|
789
|
+
}, R = class extends A {
|
|
790
790
|
items;
|
|
791
791
|
indefiniteLength;
|
|
792
792
|
encodingWidth;
|
|
@@ -858,7 +858,7 @@ var M = class extends k {
|
|
|
858
858
|
}
|
|
859
859
|
return r;
|
|
860
860
|
}
|
|
861
|
-
},
|
|
861
|
+
}, z = class extends A {
|
|
862
862
|
entries;
|
|
863
863
|
indefiniteLength;
|
|
864
864
|
encodingWidth;
|
|
@@ -900,7 +900,7 @@ var M = class extends k {
|
|
|
900
900
|
entryLeadingNode: (e) => this.entries[e][0],
|
|
901
901
|
entryTrailing: (e, t) => {
|
|
902
902
|
let [n, r] = this.entries[e];
|
|
903
|
-
return
|
|
903
|
+
return Be([
|
|
904
904
|
...n.comments?.trailing ?? [],
|
|
905
905
|
...r.comments?.leading ?? [],
|
|
906
906
|
...r.comments?.trailing ?? []
|
|
@@ -941,13 +941,13 @@ var M = class extends k {
|
|
|
941
941
|
}
|
|
942
942
|
return n;
|
|
943
943
|
};
|
|
944
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
944
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof U) ? (() => {
|
|
945
945
|
let n = e ? {
|
|
946
946
|
...e,
|
|
947
947
|
reviver: void 0
|
|
948
948
|
} : void 0, r = {};
|
|
949
949
|
for (let [e, t] of this.entries) {
|
|
950
|
-
let i = e instanceof
|
|
950
|
+
let i = e instanceof U ? e.value : e.toCDN(), a = t._toJS(n);
|
|
951
951
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
952
952
|
value: a,
|
|
953
953
|
writable: !0,
|
|
@@ -959,10 +959,10 @@ var M = class extends k {
|
|
|
959
959
|
let i = /* @__PURE__ */ new Map();
|
|
960
960
|
for (let e = 0; e < this.entries.length; e++) {
|
|
961
961
|
let [t] = this.entries[e];
|
|
962
|
-
i.set(t instanceof
|
|
962
|
+
i.set(t instanceof U ? t.value : t.toCDN(), e);
|
|
963
963
|
}
|
|
964
964
|
for (let n = 0; n < this.entries.length; n++) {
|
|
965
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
965
|
+
let [a, o] = this.entries[n], s = a instanceof U ? a.value : a.toCDN();
|
|
966
966
|
if (i.get(s) !== n) continue;
|
|
967
967
|
let c = o._toJS(e), l = t.call(r, s, c);
|
|
968
968
|
l === h || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
@@ -976,12 +976,12 @@ var M = class extends k {
|
|
|
976
976
|
})() : n();
|
|
977
977
|
}
|
|
978
978
|
};
|
|
979
|
-
function
|
|
979
|
+
function Be(e, t) {
|
|
980
980
|
return e.length === 0 ? "" : " " + e.map((e) => b(e, t).trimEnd()).join(" ");
|
|
981
981
|
}
|
|
982
982
|
//#endregion
|
|
983
983
|
//#region src/ast/CborSimple.ts
|
|
984
|
-
var
|
|
984
|
+
var B = class e extends A {
|
|
985
985
|
value;
|
|
986
986
|
constructor(e) {
|
|
987
987
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
@@ -1016,7 +1016,7 @@ var z = class e extends k {
|
|
|
1016
1016
|
default: return new g(this.value);
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
|
-
},
|
|
1019
|
+
}, Ve = class extends A {
|
|
1020
1020
|
items;
|
|
1021
1021
|
encodingWidth;
|
|
1022
1022
|
constructor(e, t) {
|
|
@@ -1054,17 +1054,59 @@ var z = class e extends k {
|
|
|
1054
1054
|
_toJS(e) {
|
|
1055
1055
|
return this._content();
|
|
1056
1056
|
}
|
|
1057
|
-
}
|
|
1057
|
+
};
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region src/utils/base64.ts
|
|
1060
|
+
function He(e, t) {
|
|
1061
|
+
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1062
|
+
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1063
|
+
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
1064
|
+
throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`);
|
|
1065
|
+
}
|
|
1066
|
+
if (i && !/^=+$/.test(i)) throw SyntaxError("invalid character after base64 '=' padding");
|
|
1067
|
+
let a = r.length % 4;
|
|
1068
|
+
if (a === 1) throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);
|
|
1069
|
+
let o = a === 0 ? 0 : 4 - a;
|
|
1070
|
+
if (i.length > o) {
|
|
1071
|
+
let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but the data length (${r.length}) requires at most ${o}`;
|
|
1072
|
+
if (t) t(e);
|
|
1073
|
+
else throw SyntaxError(e);
|
|
1074
|
+
}
|
|
1075
|
+
if (i.length > 0 && i.length < o) {
|
|
1076
|
+
let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but needs exactly ${o} — use full padding or no padding at all`;
|
|
1077
|
+
if (t) t(e);
|
|
1078
|
+
else throw SyntaxError(e);
|
|
1079
|
+
}
|
|
1080
|
+
if (a !== 0 && r.length > 0) {
|
|
1081
|
+
let e = r[r.length - 1].replace("-", "+").replace("_", "/"), n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e);
|
|
1082
|
+
if (n >= 0 && n & (a === 2 ? 15 : 3)) {
|
|
1083
|
+
let e = "base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)";
|
|
1084
|
+
if (t) t(e);
|
|
1085
|
+
else throw SyntaxError(e);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
let s = r.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat(o);
|
|
1089
|
+
if (typeof Uint8Array.fromBase64 == "function") return Uint8Array.fromBase64(s, {
|
|
1090
|
+
alphabet: "base64",
|
|
1091
|
+
lastChunkHandling: "loose"
|
|
1092
|
+
});
|
|
1093
|
+
let c = atob(s), l = new Uint8Array(c.length);
|
|
1094
|
+
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1095
|
+
return l;
|
|
1096
|
+
}
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region src/ast/CborUnresolvedAppExt.ts
|
|
1099
|
+
var Ue = 999n, We = class extends P {
|
|
1058
1100
|
constructor(e, t) {
|
|
1059
|
-
let n = t.length === 1 && t[0] instanceof
|
|
1060
|
-
super(Ue, new
|
|
1101
|
+
let n = t.length === 1 && t[0] instanceof U ? t[0] : new R(t);
|
|
1102
|
+
super(Ue, new R([new U(e), n]));
|
|
1061
1103
|
}
|
|
1062
1104
|
_toCDN(e, t) {
|
|
1063
1105
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1064
1106
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1065
|
-
return i instanceof
|
|
1107
|
+
return i instanceof U ? `${r}${ve(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1066
1108
|
}
|
|
1067
|
-
}, Ge = class extends
|
|
1109
|
+
}, Ge = class extends A {
|
|
1068
1110
|
inner;
|
|
1069
1111
|
ednSource;
|
|
1070
1112
|
constructor(e, t) {
|
|
@@ -1083,14 +1125,14 @@ var z = class e extends k {
|
|
|
1083
1125
|
_toJS(e) {
|
|
1084
1126
|
return this.inner._toJS(e);
|
|
1085
1127
|
}
|
|
1086
|
-
}, Ke = 888n,
|
|
1128
|
+
}, Ke = 888n, V = class extends P {
|
|
1087
1129
|
constructor(e) {
|
|
1088
|
-
e === void 0 ? super(Ke,
|
|
1130
|
+
e === void 0 ? super(Ke, B.NULL) : super(Ke, new R(e));
|
|
1089
1131
|
}
|
|
1090
1132
|
_toCDN(e, t) {
|
|
1091
1133
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1092
|
-
if (this.content instanceof
|
|
1093
|
-
if (this.content instanceof
|
|
1134
|
+
if (this.content instanceof B) return "...";
|
|
1135
|
+
if (this.content instanceof R) {
|
|
1094
1136
|
let n = this.content.items.map((n) => n._toCDN(e, t));
|
|
1095
1137
|
return n.length === 0 ? "" : ee(n, _(e), t);
|
|
1096
1138
|
}
|
|
@@ -1111,11 +1153,11 @@ function Qe(e) {
|
|
|
1111
1153
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1112
1154
|
return t;
|
|
1113
1155
|
}
|
|
1114
|
-
var $e = class extends
|
|
1156
|
+
var $e = class extends P {
|
|
1115
1157
|
bigValue;
|
|
1116
1158
|
constructor(e) {
|
|
1117
1159
|
if (e <= Ye) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1118
|
-
super(qe, new
|
|
1160
|
+
super(qe, new F(Ze(e))), this.bigValue = e;
|
|
1119
1161
|
}
|
|
1120
1162
|
_toCDN(e, t) {
|
|
1121
1163
|
return this.bigValue.toString();
|
|
@@ -1123,11 +1165,11 @@ var $e = class extends N {
|
|
|
1123
1165
|
_toJS(e) {
|
|
1124
1166
|
return this.bigValue;
|
|
1125
1167
|
}
|
|
1126
|
-
}, et = class extends
|
|
1168
|
+
}, et = class extends P {
|
|
1127
1169
|
bigValue;
|
|
1128
1170
|
constructor(e) {
|
|
1129
1171
|
if (e >= Xe) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1130
|
-
super(Je, new
|
|
1172
|
+
super(Je, new F(Ze(-1n - e))), this.bigValue = e;
|
|
1131
1173
|
}
|
|
1132
1174
|
_toCDN(e, t) {
|
|
1133
1175
|
return this.bigValue.toString();
|
|
@@ -1140,8 +1182,8 @@ function it(e, t) {
|
|
|
1140
1182
|
let n = new a(e, {
|
|
1141
1183
|
offset: t?.offset,
|
|
1142
1184
|
skipRS: t?._skipRS
|
|
1143
|
-
}), r = new
|
|
1144
|
-
return t?.preserveComments &&
|
|
1185
|
+
}), r = new ht(n, t ?? {}).parse();
|
|
1186
|
+
return t?.preserveComments && ct(r, n.comments, e), r;
|
|
1145
1187
|
}
|
|
1146
1188
|
function at(e) {
|
|
1147
1189
|
let t = e, n;
|
|
@@ -1177,53 +1219,16 @@ function st(e, t) {
|
|
|
1177
1219
|
};
|
|
1178
1220
|
let n = e, r;
|
|
1179
1221
|
return e.endsWith("_1") ? (r = "half", n = e.slice(0, -2)) : e.endsWith("_2") ? (r = "single", n = e.slice(0, -2)) : e.endsWith("_3") && (r = "double", n = e.slice(0, -2)), /^-?0[xX]/.test(n) ? {
|
|
1180
|
-
value:
|
|
1222
|
+
value: Re(n),
|
|
1181
1223
|
precision: r
|
|
1182
1224
|
} : {
|
|
1183
1225
|
value: parseFloat(n),
|
|
1184
1226
|
precision: r
|
|
1185
1227
|
};
|
|
1186
1228
|
}
|
|
1187
|
-
function ct(e, t) {
|
|
1188
|
-
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1189
|
-
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1190
|
-
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
1191
|
-
throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`);
|
|
1192
|
-
}
|
|
1193
|
-
if (i && !/^=+$/.test(i)) throw SyntaxError("invalid character after base64 '=' padding");
|
|
1194
|
-
let a = r.length % 4;
|
|
1195
|
-
if (a === 1) throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);
|
|
1196
|
-
let o = a === 0 ? 0 : 4 - a;
|
|
1197
|
-
if (i.length > o) {
|
|
1198
|
-
let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but the data length (${r.length}) requires at most ${o}`;
|
|
1199
|
-
if (t) t(e);
|
|
1200
|
-
else throw SyntaxError(e);
|
|
1201
|
-
}
|
|
1202
|
-
if (i.length > 0 && i.length < o) {
|
|
1203
|
-
let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but needs exactly ${o} — use full padding or no padding at all`;
|
|
1204
|
-
if (t) t(e);
|
|
1205
|
-
else throw SyntaxError(e);
|
|
1206
|
-
}
|
|
1207
|
-
if (a !== 0 && r.length > 0) {
|
|
1208
|
-
let e = r[r.length - 1].replace("-", "+").replace("_", "/"), n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e);
|
|
1209
|
-
if (n >= 0 && n & (a === 2 ? 15 : 3)) {
|
|
1210
|
-
let e = "base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)";
|
|
1211
|
-
if (t) t(e);
|
|
1212
|
-
else throw SyntaxError(e);
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
let s = r.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat(o);
|
|
1216
|
-
if (typeof Uint8Array.fromBase64 == "function") return Uint8Array.fromBase64(s, {
|
|
1217
|
-
alphabet: "base64",
|
|
1218
|
-
lastChunkHandling: "loose"
|
|
1219
|
-
});
|
|
1220
|
-
let c = atob(s), l = new Uint8Array(c.length);
|
|
1221
|
-
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1222
|
-
return l;
|
|
1223
|
-
}
|
|
1224
|
-
function lt(e, t, n) {
|
|
1229
|
+
function ct(e, t, n) {
|
|
1225
1230
|
if (t.length === 0) return;
|
|
1226
|
-
let r =
|
|
1231
|
+
let r = lt(e), i = dt(n), a = [...r].sort((e, t) => e.start - t.start || t.end - e.end), o = [...r].sort((e, t) => e.end - t.end || e.start - t.start), s = [...t].sort((e, t) => e.start - t.start), c = [], l = 0;
|
|
1227
1232
|
for (let t of s) {
|
|
1228
1233
|
let r = { ...t }, s = 0, u = o.length;
|
|
1229
1234
|
for (; s < u;) {
|
|
@@ -1232,7 +1237,7 @@ function lt(e, t, n) {
|
|
|
1232
1237
|
}
|
|
1233
1238
|
let d = s > 0 ? o[s - 1] : void 0, f = d ? n.slice(d.end, t.start) : "";
|
|
1234
1239
|
if (d && i(d.end) === t.line && !f.includes(":")) {
|
|
1235
|
-
|
|
1240
|
+
ut(d.node, "trailing", r);
|
|
1236
1241
|
continue;
|
|
1237
1242
|
}
|
|
1238
1243
|
for (; l < a.length && a[l].start < t.start;) {
|
|
@@ -1248,38 +1253,38 @@ function lt(e, t, n) {
|
|
|
1248
1253
|
}
|
|
1249
1254
|
let m = s < a.length ? a[s] : void 0;
|
|
1250
1255
|
if ((!p || m && m.end <= p.end) && m) {
|
|
1251
|
-
|
|
1256
|
+
ut(m.node, "leading", r);
|
|
1252
1257
|
continue;
|
|
1253
1258
|
}
|
|
1254
|
-
|
|
1259
|
+
ut(p?.node ?? e, "dangling", r);
|
|
1255
1260
|
}
|
|
1256
1261
|
}
|
|
1257
|
-
function
|
|
1262
|
+
function lt(e) {
|
|
1258
1263
|
let t = [], n = (e) => {
|
|
1259
1264
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1260
1265
|
node: e,
|
|
1261
1266
|
start: e.start,
|
|
1262
1267
|
end: e.end
|
|
1263
|
-
}), e instanceof
|
|
1268
|
+
}), e instanceof R || e instanceof Ve) {
|
|
1264
1269
|
for (let t of e.items) n(t);
|
|
1265
1270
|
return;
|
|
1266
1271
|
}
|
|
1267
|
-
if (e instanceof
|
|
1272
|
+
if (e instanceof z) {
|
|
1268
1273
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1269
1274
|
return;
|
|
1270
1275
|
}
|
|
1271
|
-
if (e instanceof
|
|
1276
|
+
if (e instanceof I || e instanceof L) {
|
|
1272
1277
|
for (let t of e.chunks) n(t);
|
|
1273
1278
|
return;
|
|
1274
1279
|
}
|
|
1275
|
-
e instanceof
|
|
1280
|
+
e instanceof P && n(e.content);
|
|
1276
1281
|
};
|
|
1277
1282
|
return n(e), t;
|
|
1278
1283
|
}
|
|
1279
|
-
function
|
|
1284
|
+
function ut(e, t, n) {
|
|
1280
1285
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1281
1286
|
}
|
|
1282
|
-
function
|
|
1287
|
+
function dt(e) {
|
|
1283
1288
|
let t = [0];
|
|
1284
1289
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1285
1290
|
return (n) => {
|
|
@@ -1293,25 +1298,25 @@ function ft(e) {
|
|
|
1293
1298
|
return a + 1;
|
|
1294
1299
|
};
|
|
1295
1300
|
}
|
|
1296
|
-
var
|
|
1297
|
-
["b32",
|
|
1298
|
-
["h32",
|
|
1299
|
-
["same",
|
|
1300
|
-
["hash",
|
|
1301
|
-
["uuid",
|
|
1302
|
-
["UUID",
|
|
1303
|
-
["dt",
|
|
1304
|
-
["DT",
|
|
1305
|
-
["ip",
|
|
1306
|
-
["IP",
|
|
1307
|
-
["cri",
|
|
1308
|
-
["CRI",
|
|
1309
|
-
["t1",
|
|
1310
|
-
["b1",
|
|
1311
|
-
["ilbs",
|
|
1312
|
-
["ilts",
|
|
1313
|
-
["float",
|
|
1314
|
-
]),
|
|
1301
|
+
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}])`, H = (e) => `'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`, mt = /* @__PURE__ */ new Map([
|
|
1302
|
+
["b32", ft("b32")],
|
|
1303
|
+
["h32", ft("h32")],
|
|
1304
|
+
["same", ft("same")],
|
|
1305
|
+
["hash", pt("hash", "@cbortech/hash-extension")],
|
|
1306
|
+
["uuid", pt("uuid", "@cbortech/uuid-extension")],
|
|
1307
|
+
["UUID", pt("uuid", "@cbortech/uuid-extension")],
|
|
1308
|
+
["dt", H("dt")],
|
|
1309
|
+
["DT", H("dt")],
|
|
1310
|
+
["ip", H("ip")],
|
|
1311
|
+
["IP", H("ip")],
|
|
1312
|
+
["cri", H("cri")],
|
|
1313
|
+
["CRI", H("cri")],
|
|
1314
|
+
["t1", H("t1")],
|
|
1315
|
+
["b1", H("b1")],
|
|
1316
|
+
["ilbs", H("ilbs")],
|
|
1317
|
+
["ilts", H("ilts")],
|
|
1318
|
+
["float", H("float")]
|
|
1319
|
+
]), ht = class {
|
|
1315
1320
|
t;
|
|
1316
1321
|
_options;
|
|
1317
1322
|
extByPrefix;
|
|
@@ -1372,12 +1377,12 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1372
1377
|
case "BYTES_HEX":
|
|
1373
1378
|
case "SQSTR":
|
|
1374
1379
|
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1375
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1376
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1377
|
-
case "TRUE": return this.t.consume(), new
|
|
1378
|
-
case "FALSE": return this.t.consume(), new
|
|
1379
|
-
case "NULL": return this.t.consume(), new
|
|
1380
|
-
case "UNDEFINED": return this.t.consume(), new
|
|
1380
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new I([]);
|
|
1381
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new L([]);
|
|
1382
|
+
case "TRUE": return this.t.consume(), new B(21);
|
|
1383
|
+
case "FALSE": return this.t.consume(), new B(20);
|
|
1384
|
+
case "NULL": return this.t.consume(), new B(22);
|
|
1385
|
+
case "UNDEFINED": return this.t.consume(), new B(23);
|
|
1381
1386
|
case "SIMPLE": return this.parseSimple();
|
|
1382
1387
|
case "LBRACKET": return this.parseArray();
|
|
1383
1388
|
case "LBRACE": return this.parseMap();
|
|
@@ -1392,21 +1397,21 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1392
1397
|
}
|
|
1393
1398
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1394
1399
|
if (!r?.parseAppString) {
|
|
1395
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, [new
|
|
1400
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, [new U(e.value)]);
|
|
1396
1401
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1397
1402
|
}
|
|
1398
1403
|
{
|
|
1399
1404
|
let i = this._pendingWarnings.length;
|
|
1400
1405
|
try {
|
|
1401
1406
|
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1402
|
-
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof
|
|
1407
|
+
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof F && Object.getPrototypeOf(i) === F.prototype && i.ednSource === void 0 ? new F(i.value, {
|
|
1403
1408
|
ednEncoding: i.ednEncoding,
|
|
1404
1409
|
encodingWidth: i.encodingWidth,
|
|
1405
1410
|
ednSource: e.raw + n
|
|
1406
|
-
}) : (i instanceof
|
|
1411
|
+
}) : (i instanceof N && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1407
1412
|
} catch (t) {
|
|
1408
1413
|
if (this._options.strict !== !1) throw t;
|
|
1409
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new We(e.appPrefix, [new
|
|
1414
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new We(e.appPrefix, [new U(e.value)]);
|
|
1410
1415
|
}
|
|
1411
1416
|
}
|
|
1412
1417
|
}
|
|
@@ -1434,7 +1439,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1434
1439
|
let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
|
|
1435
1440
|
n !== void 0 && this._applyEiToResult(a, n, r ?? e);
|
|
1436
1441
|
let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1437
|
-
if (a instanceof
|
|
1442
|
+
if (a instanceof N) a.ednSource === void 0 && (a.ednSource = o);
|
|
1438
1443
|
else if (i.preserveAppSeqSource) return new Ge(a, o);
|
|
1439
1444
|
return a;
|
|
1440
1445
|
} catch (n) {
|
|
@@ -1444,10 +1449,10 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1444
1449
|
}
|
|
1445
1450
|
}
|
|
1446
1451
|
case "ELLIPSIS": {
|
|
1447
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1448
|
-
let e = [new
|
|
1452
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new V();
|
|
1453
|
+
let e = [new V()];
|
|
1449
1454
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1450
|
-
return new
|
|
1455
|
+
return new V(e);
|
|
1451
1456
|
}
|
|
1452
1457
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1453
1458
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
@@ -1461,17 +1466,17 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1461
1466
|
let t = i >= 0n ? i : -(i + 1n);
|
|
1462
1467
|
r = this._validateEncodingFit(t, r, e);
|
|
1463
1468
|
}
|
|
1464
|
-
let a = i >= 0n ? new
|
|
1469
|
+
let a = i >= 0n ? new j(i, r === void 0 ? void 0 : { encodingWidth: r }) : new M(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1465
1470
|
if (this.t.peek().type === "LPAREN") {
|
|
1466
|
-
a instanceof
|
|
1471
|
+
a instanceof j || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1467
1472
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
1468
1473
|
this.expect("RPAREN");
|
|
1469
1474
|
let i = a.value, o = this.extByTag.get(i);
|
|
1470
1475
|
if (o?.parseTag) {
|
|
1471
1476
|
let e = o.parseTag(i, n);
|
|
1472
|
-
if (e !== void 0) return e instanceof
|
|
1477
|
+
if (e !== void 0) return e instanceof P && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
|
|
1473
1478
|
}
|
|
1474
|
-
let s = new
|
|
1479
|
+
let s = new P(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1475
1480
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
1476
1481
|
}
|
|
1477
1482
|
return a;
|
|
@@ -1482,16 +1487,16 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1482
1487
|
let e = r === "half" ? E(T(n)) : Math.fround(n);
|
|
1483
1488
|
Object.is(n, e) || isNaN(n) && isNaN(e) || t(`${n} cannot be exactly represented as ${r === "half" ? "f16 (_1)" : "f32 (_2)"}; use _3 or remove the indicator`);
|
|
1484
1489
|
}
|
|
1485
|
-
return new
|
|
1490
|
+
return new N(n, r === void 0 ? void 0 : { precision: r });
|
|
1486
1491
|
}
|
|
1487
1492
|
parseString() {
|
|
1488
1493
|
let e = this.t.consume();
|
|
1489
1494
|
if (this.t.peek().type !== "PLUS") {
|
|
1490
1495
|
let t = this.consumeEncodingIndicator(() => BigInt(tt.encode(e.value).length));
|
|
1491
|
-
return e.type === "RAWSTRING" ? new
|
|
1496
|
+
return e.type === "RAWSTRING" ? new U(e.value, {
|
|
1492
1497
|
ednSource: e.raw,
|
|
1493
1498
|
...t === void 0 ? {} : { encodingWidth: t }
|
|
1494
|
-
}) : new
|
|
1499
|
+
}) : new U(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1495
1500
|
}
|
|
1496
1501
|
let t = !1, n = [e.type === "RAWSTRING" ? {
|
|
1497
1502
|
text: e.value,
|
|
@@ -1507,7 +1512,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1507
1512
|
}
|
|
1508
1513
|
if (!t) {
|
|
1509
1514
|
let e = n.map((e) => "text" in e ? e.text : ""), t = n.map((e) => "text" in e ? e.source : void 0), r = e.join(""), i = this.consumeEncodingIndicator(() => BigInt(tt.encode(r).length));
|
|
1510
|
-
return new
|
|
1515
|
+
return new U(r, {
|
|
1511
1516
|
ednParts: e,
|
|
1512
1517
|
...t.some((e) => e !== void 0) ? { ednPartSources: t } : {},
|
|
1513
1518
|
...i === void 0 ? {} : { encodingWidth: i }
|
|
@@ -1517,15 +1522,15 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1517
1522
|
let e = i.map((e) => e.text), t = e.join("");
|
|
1518
1523
|
if (t !== "") {
|
|
1519
1524
|
let n = i.map((e) => e.source);
|
|
1520
|
-
r.push(new
|
|
1525
|
+
r.push(new U(t, {
|
|
1521
1526
|
ednParts: e,
|
|
1522
1527
|
...n.some((e) => e !== void 0) ? { ednPartSources: n } : {}
|
|
1523
1528
|
}));
|
|
1524
1529
|
}
|
|
1525
1530
|
i.length = 0;
|
|
1526
1531
|
};
|
|
1527
|
-
for (let e of n) "ellipsis" in e ? (a(), r.push(new
|
|
1528
|
-
return a(), new
|
|
1532
|
+
for (let e of n) "ellipsis" in e ? (a(), r.push(new V())) : i.push(e);
|
|
1533
|
+
return a(), new V(r);
|
|
1529
1534
|
}
|
|
1530
1535
|
_isBytesToken(e) {
|
|
1531
1536
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
@@ -1547,7 +1552,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1547
1552
|
}
|
|
1548
1553
|
case "BYTES_HEX": return this._hexToBytes(e.value, e);
|
|
1549
1554
|
case "BYTES_B64": try {
|
|
1550
|
-
return
|
|
1555
|
+
return He(e.value, t);
|
|
1551
1556
|
} catch (t) {
|
|
1552
1557
|
if (t instanceof r || !(t instanceof SyntaxError)) throw t;
|
|
1553
1558
|
this._fail(t.message, e);
|
|
@@ -1569,7 +1574,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1569
1574
|
_parseBytesConcat(e, t, n) {
|
|
1570
1575
|
if (this.t.peek().type !== "PLUS") {
|
|
1571
1576
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1572
|
-
return new
|
|
1577
|
+
return new F(e, {
|
|
1573
1578
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1574
1579
|
ednSource: n,
|
|
1575
1580
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
@@ -1586,7 +1591,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1586
1591
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1587
1592
|
this.t.consume();
|
|
1588
1593
|
let t = this._buildBytesElidedItems(e.value, e);
|
|
1589
|
-
for (let e of t) e instanceof
|
|
1594
|
+
for (let e of t) e instanceof V ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof F && i.push({ bytes: e.value });
|
|
1590
1595
|
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
|
|
1591
1596
|
bytes: this._decodeBytesToken(e),
|
|
1592
1597
|
source: e.raw
|
|
@@ -1594,24 +1599,24 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1594
1599
|
}
|
|
1595
1600
|
if (!r) {
|
|
1596
1601
|
let e = i.map((e) => "bytes" in e ? e : { bytes: /* @__PURE__ */ new Uint8Array() }), n = this._concatBytes(e.map((e) => e.bytes)), r = this.consumeEncodingIndicator(() => BigInt(n.length));
|
|
1597
|
-
return new
|
|
1602
|
+
return new F(n, {
|
|
1598
1603
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1599
1604
|
ednParts: e,
|
|
1600
1605
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
1601
1606
|
});
|
|
1602
1607
|
}
|
|
1603
1608
|
let a = [], o = [], s = () => {
|
|
1604
|
-
o.length > 0 && (a.push(new
|
|
1609
|
+
o.length > 0 && (a.push(new F(this._concatBytes([...o]))), o.length = 0);
|
|
1605
1610
|
};
|
|
1606
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
1607
|
-
return s(), new
|
|
1611
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new V())) : o.push(e.bytes);
|
|
1612
|
+
return s(), new V(a);
|
|
1608
1613
|
}
|
|
1609
1614
|
_parseHexElidedConcat(e) {
|
|
1610
1615
|
let t = this._buildBytesElidedItems(e.value, e);
|
|
1611
1616
|
for (; this.t.peek().type === "PLUS";) {
|
|
1612
1617
|
this.t.consume();
|
|
1613
1618
|
let e = this.t.peek();
|
|
1614
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
1619
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new V());
|
|
1615
1620
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1616
1621
|
this.t.consume();
|
|
1617
1622
|
let n = this._buildBytesElidedItems(e.value, e);
|
|
@@ -1619,20 +1624,20 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1619
1624
|
} else if (this._isBytesToken(e.type)) {
|
|
1620
1625
|
this.t.consume();
|
|
1621
1626
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
1622
|
-
r instanceof
|
|
1627
|
+
r instanceof F ? t[t.length - 1] = new F(this._concatBytes([r.value, n])) : t.push(new F(n));
|
|
1623
1628
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1624
1629
|
}
|
|
1625
|
-
return new
|
|
1630
|
+
return new V(t);
|
|
1626
1631
|
}
|
|
1627
1632
|
_buildBytesElidedItems(e, t) {
|
|
1628
1633
|
let n = e.split("..."), r = [];
|
|
1629
|
-
for (let e = 0; e < n.length; e++) e > 0 && r.push(new
|
|
1634
|
+
for (let e = 0; e < n.length; e++) e > 0 && r.push(new V()), n[e].length > 0 && r.push(new F(this._hexToBytes(n[e], t)));
|
|
1630
1635
|
return r;
|
|
1631
1636
|
}
|
|
1632
1637
|
_mergeFirstBytesItem(e, t) {
|
|
1633
1638
|
if (t.length === 0) return;
|
|
1634
1639
|
let n = e[e.length - 1], r = t[0];
|
|
1635
|
-
n instanceof
|
|
1640
|
+
n instanceof F && r instanceof F ? (e[e.length - 1] = new F(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
1636
1641
|
}
|
|
1637
1642
|
_concatBytes(e) {
|
|
1638
1643
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1644,7 +1649,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1644
1649
|
let e = this.t.peek();
|
|
1645
1650
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1646
1651
|
let { numStr: t } = at(e.value), n = Number(ot(t));
|
|
1647
|
-
return this.expect("RPAREN"), new
|
|
1652
|
+
return this.expect("RPAREN"), new B(n);
|
|
1648
1653
|
}
|
|
1649
1654
|
parseEmbeddedCBOR() {
|
|
1650
1655
|
this.t.consume();
|
|
@@ -1661,7 +1666,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1661
1666
|
let e = this.t.consume();
|
|
1662
1667
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1663
1668
|
}
|
|
1664
|
-
return new
|
|
1669
|
+
return new Ve(e, { encodingWidth: t });
|
|
1665
1670
|
}
|
|
1666
1671
|
parseArray() {
|
|
1667
1672
|
this.t.consume();
|
|
@@ -1675,7 +1680,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1675
1680
|
i.push(this.parseValue());
|
|
1676
1681
|
}
|
|
1677
1682
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1678
|
-
let a = new
|
|
1683
|
+
let a = new R(i, {
|
|
1679
1684
|
indefiniteLength: e,
|
|
1680
1685
|
encodingWidth: t
|
|
1681
1686
|
});
|
|
@@ -1696,7 +1701,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1696
1701
|
i.push([e, t]);
|
|
1697
1702
|
}
|
|
1698
1703
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1699
|
-
let a = new
|
|
1704
|
+
let a = new z(i, {
|
|
1700
1705
|
indefiniteLength: e,
|
|
1701
1706
|
encodingWidth: t
|
|
1702
1707
|
});
|
|
@@ -1720,16 +1725,16 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1720
1725
|
}
|
|
1721
1726
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1722
1727
|
let r = n[0];
|
|
1723
|
-
if (r instanceof
|
|
1724
|
-
let e = new
|
|
1725
|
-
if (e instanceof
|
|
1728
|
+
if (r instanceof F) {
|
|
1729
|
+
let e = new I(n.map((e, t) => {
|
|
1730
|
+
if (e instanceof F) return e;
|
|
1726
1731
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1727
1732
|
}));
|
|
1728
1733
|
return t.length > 0 && (e.warnings = t), e;
|
|
1729
1734
|
}
|
|
1730
|
-
if (r instanceof
|
|
1731
|
-
let e = new
|
|
1732
|
-
if (e instanceof
|
|
1735
|
+
if (r instanceof U) {
|
|
1736
|
+
let e = new L(n.map((e, t) => {
|
|
1737
|
+
if (e instanceof U) return e;
|
|
1733
1738
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1734
1739
|
}));
|
|
1735
1740
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -1747,7 +1752,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1747
1752
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1748
1753
|
}
|
|
1749
1754
|
_applyEiToResult(e, t, n) {
|
|
1750
|
-
if (e instanceof
|
|
1755
|
+
if (e instanceof N) {
|
|
1751
1756
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1752
1757
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1753
1758
|
else if (e.precision !== r) {
|
|
@@ -1757,37 +1762,37 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1757
1762
|
}
|
|
1758
1763
|
e.precision = r;
|
|
1759
1764
|
}
|
|
1760
|
-
} else if (e instanceof
|
|
1765
|
+
} else if (e instanceof j) {
|
|
1761
1766
|
if (e.encodingWidth === void 0) {
|
|
1762
1767
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
1763
1768
|
r !== void 0 && (e.encodingWidth = r);
|
|
1764
1769
|
}
|
|
1765
|
-
} else if (e instanceof
|
|
1770
|
+
} else if (e instanceof M) {
|
|
1766
1771
|
if (e.encodingWidth === void 0) {
|
|
1767
1772
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1768
1773
|
r !== void 0 && (e.encodingWidth = r);
|
|
1769
1774
|
}
|
|
1770
|
-
} else if (e instanceof
|
|
1775
|
+
} else if (e instanceof F) {
|
|
1771
1776
|
if (e.encodingWidth === void 0) {
|
|
1772
1777
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1773
1778
|
r !== void 0 && (e.encodingWidth = r);
|
|
1774
1779
|
}
|
|
1775
|
-
} else if (e instanceof
|
|
1780
|
+
} else if (e instanceof U) {
|
|
1776
1781
|
if (e.encodingWidth === void 0) {
|
|
1777
1782
|
let r = this._validateEncodingFit(BigInt(tt.encode(e.value).length), t, n);
|
|
1778
1783
|
r !== void 0 && (e.encodingWidth = r);
|
|
1779
1784
|
}
|
|
1780
|
-
} else if (e instanceof
|
|
1785
|
+
} else if (e instanceof R) {
|
|
1781
1786
|
if (e.encodingWidth === void 0) {
|
|
1782
1787
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1783
1788
|
r !== void 0 && (e.encodingWidth = r);
|
|
1784
1789
|
}
|
|
1785
|
-
} else if (e instanceof
|
|
1790
|
+
} else if (e instanceof z) {
|
|
1786
1791
|
if (e.encodingWidth === void 0) {
|
|
1787
1792
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1788
1793
|
r !== void 0 && (e.encodingWidth = r);
|
|
1789
1794
|
}
|
|
1790
|
-
} else if (e instanceof
|
|
1795
|
+
} else if (e instanceof P) {
|
|
1791
1796
|
if (e.encodingWidth === void 0) {
|
|
1792
1797
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1793
1798
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -1819,29 +1824,29 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1819
1824
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1820
1825
|
}
|
|
1821
1826
|
_hintMissingExtension(e, t) {
|
|
1822
|
-
let n =
|
|
1827
|
+
let n = mt.get(e);
|
|
1823
1828
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1824
1829
|
this._hintedPrefixes.add(e);
|
|
1825
1830
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
1826
1831
|
this._options.onWarning ? this._options.onWarning({
|
|
1827
1832
|
message: r,
|
|
1828
|
-
...
|
|
1833
|
+
...gt(t),
|
|
1829
1834
|
hint: !0
|
|
1830
1835
|
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
1831
1836
|
}
|
|
1832
1837
|
_warn(e, t) {
|
|
1833
1838
|
let n = { message: e };
|
|
1834
|
-
if (t !== void 0 && Object.assign(n,
|
|
1839
|
+
if (t !== void 0 && Object.assign(n, gt(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
|
|
1835
1840
|
else if (!this._options.silent) {
|
|
1836
1841
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
1837
1842
|
console.warn(`CDN strict violation${n}: ${e}`);
|
|
1838
1843
|
}
|
|
1839
1844
|
}
|
|
1840
1845
|
_fail(e, t) {
|
|
1841
|
-
throw new r(e, t ?
|
|
1846
|
+
throw new r(e, t ? gt(t) : void 0);
|
|
1842
1847
|
}
|
|
1843
1848
|
};
|
|
1844
|
-
function
|
|
1849
|
+
function gt(e) {
|
|
1845
1850
|
return {
|
|
1846
1851
|
offset: e.offset,
|
|
1847
1852
|
line: e.line,
|
|
@@ -1851,7 +1856,7 @@ function _t(e) {
|
|
|
1851
1856
|
}
|
|
1852
1857
|
//#endregion
|
|
1853
1858
|
//#region src/ast/CborTextString.ts
|
|
1854
|
-
var
|
|
1859
|
+
var _t = new TextEncoder(), vt = !1, U = class extends A {
|
|
1855
1860
|
indefiniteLength = !1;
|
|
1856
1861
|
value;
|
|
1857
1862
|
encodingWidth;
|
|
@@ -1865,20 +1870,20 @@ var vt = new TextEncoder(), yt = !1, H = class extends k {
|
|
|
1865
1870
|
e.writeTextString(3, this.value, this.encodingWidth);
|
|
1866
1871
|
}
|
|
1867
1872
|
_toCDN(e, t) {
|
|
1868
|
-
let n = w(e, this.encodingWidth, () => C(BigInt(
|
|
1869
|
-
return
|
|
1873
|
+
let n = w(e, this.encodingWidth, () => C(BigInt(_t.encode(this.value).length)));
|
|
1874
|
+
return yt(this.value, n, e, t, this.ednParts, this.ednSource, this.ednPartSources);
|
|
1870
1875
|
}
|
|
1871
1876
|
_toJS(e) {
|
|
1872
1877
|
return this.value;
|
|
1873
1878
|
}
|
|
1874
1879
|
};
|
|
1875
|
-
function
|
|
1880
|
+
function yt(e, t, n, r, i, a, o) {
|
|
1876
1881
|
let s = _(n);
|
|
1877
1882
|
if (n?.preserveRawString && a !== void 0 && (s !== null || !/[\r\n]/.test(a))) return a + t;
|
|
1878
1883
|
if (s === null) return ye(e) + t;
|
|
1879
|
-
let c = n?.preserveRawString ? o : void 0, l = c?.some((e) => e !== void 0) ?? !1, { cdn: u, newline: d } =
|
|
1884
|
+
let c = n?.preserveRawString ? o : void 0, l = c?.some((e) => e !== void 0) ?? !1, { cdn: u, newline: d } = xt(n), f = n?.preserveConcatenation && i !== void 0 && (i.length > 1 || l) ? i : void 0;
|
|
1880
1885
|
if (!u && !d && f === void 0) return ye(e) + t;
|
|
1881
|
-
let p = u ?
|
|
1886
|
+
let p = u ? wt(e) : null;
|
|
1882
1887
|
if (f !== void 0 && (p === null || l)) {
|
|
1883
1888
|
let e = [];
|
|
1884
1889
|
for (let [t, n] of f.entries()) {
|
|
@@ -1890,25 +1895,25 @@ function bt(e, t, n, r, i, a, o) {
|
|
|
1890
1895
|
});
|
|
1891
1896
|
else if (d) {
|
|
1892
1897
|
let t = /* @__PURE__ */ new Map();
|
|
1893
|
-
for (let { point: e, contentDepth: r } of
|
|
1894
|
-
e.push(...
|
|
1898
|
+
for (let { point: e, contentDepth: r } of Ct(n, 0)) t.set(e, r);
|
|
1899
|
+
e.push(...Mt(n, t));
|
|
1895
1900
|
} else e.push({
|
|
1896
1901
|
text: n,
|
|
1897
1902
|
contentDepth: 0
|
|
1898
1903
|
});
|
|
1899
1904
|
}
|
|
1900
|
-
return
|
|
1905
|
+
return bt(e, t, s, r);
|
|
1901
1906
|
}
|
|
1902
1907
|
let m = /* @__PURE__ */ new Map();
|
|
1903
1908
|
if (p !== null) for (let { point: e, contentDepth: t } of p) m.set(e, t);
|
|
1904
1909
|
if (d) {
|
|
1905
|
-
let t = p === null ?
|
|
1910
|
+
let t = p === null ? Ct(e, 0) : Tt(e);
|
|
1906
1911
|
for (let { point: e, contentDepth: n } of t) m.has(e) || m.set(e, n);
|
|
1907
1912
|
}
|
|
1908
|
-
let h =
|
|
1909
|
-
return h.length <= 1 ? ye(e) + t :
|
|
1913
|
+
let h = Mt(e, m);
|
|
1914
|
+
return h.length <= 1 ? ye(e) + t : bt(h, t, s, r);
|
|
1910
1915
|
}
|
|
1911
|
-
function
|
|
1916
|
+
function bt(e, t, n, r) {
|
|
1912
1917
|
let i = e.map(({ text: n, source: r }, i) => {
|
|
1913
1918
|
let a = r ?? ye(n);
|
|
1914
1919
|
return i === e.length - 1 ? a + t : a;
|
|
@@ -1919,17 +1924,17 @@ function xt(e, t, n, r) {
|
|
|
1919
1924
|
}
|
|
1920
1925
|
return a;
|
|
1921
1926
|
}
|
|
1922
|
-
function
|
|
1923
|
-
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ?
|
|
1927
|
+
function xt(e) {
|
|
1928
|
+
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? St(e?.textStringFormat ?? []) : [];
|
|
1924
1929
|
return {
|
|
1925
1930
|
cdn: e?.splitCdn ?? t.includes("cdn"),
|
|
1926
1931
|
newline: e?.splitNewline ?? t.includes("newline")
|
|
1927
1932
|
};
|
|
1928
1933
|
}
|
|
1929
|
-
function
|
|
1930
|
-
return e.map((e) => e === "cboredn" ? (
|
|
1934
|
+
function St(e) {
|
|
1935
|
+
return e.map((e) => e === "cboredn" ? (vt || (vt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1931
1936
|
}
|
|
1932
|
-
function
|
|
1937
|
+
function Ct(e, t) {
|
|
1933
1938
|
let n = [];
|
|
1934
1939
|
for (let r = 0; r < e.length; r++) {
|
|
1935
1940
|
let i = e[r];
|
|
@@ -1946,7 +1951,7 @@ function wt(e, t) {
|
|
|
1946
1951
|
}
|
|
1947
1952
|
return n;
|
|
1948
1953
|
}
|
|
1949
|
-
function
|
|
1954
|
+
function wt(e) {
|
|
1950
1955
|
try {
|
|
1951
1956
|
it(e);
|
|
1952
1957
|
} catch {
|
|
@@ -1957,24 +1962,24 @@ function Tt(e) {
|
|
|
1957
1962
|
let a = n.consume();
|
|
1958
1963
|
if (a.type === "EOF") break;
|
|
1959
1964
|
let c = !1;
|
|
1960
|
-
if (o || (o = !0, a.offset > 0 &&
|
|
1965
|
+
if (o || (o = !0, a.offset > 0 && At(n.comments, 0, a.offset) && t.push({
|
|
1961
1966
|
point: a.offset,
|
|
1962
1967
|
contentDepth: r
|
|
1963
1968
|
})), i !== null) {
|
|
1964
|
-
if (i.kind === "opener" &&
|
|
1969
|
+
if (i.kind === "opener" && Dt.has(a.type)) {
|
|
1965
1970
|
i.point = a.endOffset, s = a.endOffset;
|
|
1966
1971
|
continue;
|
|
1967
|
-
} else i.kind === "opener" &&
|
|
1972
|
+
} else i.kind === "opener" && kt.has(a.type) && jt(e, i.point, a.offset) ? c = !0 : t.push({
|
|
1968
1973
|
point: a.offset,
|
|
1969
1974
|
contentDepth: i.contentDepth
|
|
1970
1975
|
});
|
|
1971
1976
|
i = null;
|
|
1972
1977
|
}
|
|
1973
|
-
|
|
1978
|
+
Ot.has(a.type) ? (r++, i = {
|
|
1974
1979
|
point: a.endOffset,
|
|
1975
1980
|
contentDepth: r,
|
|
1976
1981
|
kind: "opener"
|
|
1977
|
-
}) :
|
|
1982
|
+
}) : kt.has(a.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
1978
1983
|
point: a.offset,
|
|
1979
1984
|
contentDepth: r
|
|
1980
1985
|
})) : a.type === "COMMA" && (i = {
|
|
@@ -1989,23 +1994,23 @@ function Tt(e) {
|
|
|
1989
1994
|
contentDepth: r
|
|
1990
1995
|
}), t;
|
|
1991
1996
|
}
|
|
1992
|
-
function
|
|
1997
|
+
function Tt(e) {
|
|
1993
1998
|
let t = [], n = new a(e), r = 0;
|
|
1994
1999
|
for (;;) {
|
|
1995
2000
|
let i = n.consume();
|
|
1996
2001
|
if (i.type === "EOF") break;
|
|
1997
|
-
if (
|
|
1998
|
-
else if (
|
|
2002
|
+
if (Ot.has(i.type)) r++;
|
|
2003
|
+
else if (kt.has(i.type)) r = Math.max(0, r - 1);
|
|
1999
2004
|
else if (i.type !== "COMMA") {
|
|
2000
2005
|
if (i.type === "TSTR") {
|
|
2001
2006
|
let n = e.slice(i.offset, i.endOffset);
|
|
2002
|
-
for (let e of
|
|
2007
|
+
for (let e of Et(n)) t.push({
|
|
2003
2008
|
point: i.offset + e,
|
|
2004
2009
|
contentDepth: r + 1
|
|
2005
2010
|
});
|
|
2006
2011
|
} else if (i.type === "RAWSTRING") {
|
|
2007
2012
|
let n = e.slice(i.offset, i.endOffset);
|
|
2008
|
-
for (let { point: e } of
|
|
2013
|
+
for (let { point: e } of Ct(n, 0)) t.push({
|
|
2009
2014
|
point: i.offset + e,
|
|
2010
2015
|
contentDepth: r + 1
|
|
2011
2016
|
});
|
|
@@ -2014,7 +2019,7 @@ function Et(e) {
|
|
|
2014
2019
|
}
|
|
2015
2020
|
return t;
|
|
2016
2021
|
}
|
|
2017
|
-
function
|
|
2022
|
+
function Et(e) {
|
|
2018
2023
|
let t = [], n = 1, r = e.length - 1;
|
|
2019
2024
|
for (; n < r;) {
|
|
2020
2025
|
let r = e[n];
|
|
@@ -2030,24 +2035,24 @@ function Dt(e) {
|
|
|
2030
2035
|
}
|
|
2031
2036
|
return t;
|
|
2032
2037
|
}
|
|
2033
|
-
var
|
|
2038
|
+
var Dt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Ot = /* @__PURE__ */ new Set([
|
|
2034
2039
|
"LBRACKET",
|
|
2035
2040
|
"LBRACE",
|
|
2036
2041
|
"LPAREN",
|
|
2037
2042
|
"LT_LT"
|
|
2038
|
-
]),
|
|
2043
|
+
]), kt = /* @__PURE__ */ new Set([
|
|
2039
2044
|
"RBRACKET",
|
|
2040
2045
|
"RBRACE",
|
|
2041
2046
|
"RPAREN",
|
|
2042
2047
|
"GT_GT"
|
|
2043
2048
|
]);
|
|
2044
|
-
function
|
|
2049
|
+
function At(e, t, n) {
|
|
2045
2050
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
2046
2051
|
}
|
|
2047
|
-
function
|
|
2052
|
+
function jt(e, t, n) {
|
|
2048
2053
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
2049
2054
|
}
|
|
2050
|
-
function
|
|
2055
|
+
function Mt(e, t) {
|
|
2051
2056
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2052
2057
|
if (n.length === 0) return [{
|
|
2053
2058
|
text: e,
|
|
@@ -2065,7 +2070,7 @@ function Nt(e, t) {
|
|
|
2065
2070
|
}
|
|
2066
2071
|
//#endregion
|
|
2067
2072
|
//#region src/extensions/dt.ts
|
|
2068
|
-
function
|
|
2073
|
+
function W(e) {
|
|
2069
2074
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2070
2075
|
let t = Math.round(e * 1e3);
|
|
2071
2076
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -2073,17 +2078,17 @@ function U(e) {
|
|
|
2073
2078
|
for (; s.length < 3;) s += "0";
|
|
2074
2079
|
return `${i}.${s}Z`;
|
|
2075
2080
|
}
|
|
2076
|
-
var
|
|
2077
|
-
function
|
|
2081
|
+
var Nt = new TextDecoder("utf-8", { fatal: !0 });
|
|
2082
|
+
function Pt(e) {
|
|
2078
2083
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2079
2084
|
let t = e[0];
|
|
2080
|
-
if (t instanceof
|
|
2081
|
-
if (t instanceof
|
|
2085
|
+
if (t instanceof U) return t.value;
|
|
2086
|
+
if (t instanceof F) return Nt.decode(t.value);
|
|
2082
2087
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2083
2088
|
}
|
|
2084
|
-
var
|
|
2085
|
-
function
|
|
2086
|
-
if (!
|
|
2089
|
+
var Ft = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
2090
|
+
function It(e, t) {
|
|
2091
|
+
if (!Ft.test(e)) {
|
|
2087
2092
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
2088
2093
|
if (t) t(n);
|
|
2089
2094
|
else throw SyntaxError(n);
|
|
@@ -2094,93 +2099,93 @@ function Lt(e, t) {
|
|
|
2094
2099
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2095
2100
|
if (i === void 0) {
|
|
2096
2101
|
let e = a / 1e3;
|
|
2097
|
-
return e >= 0 ? new
|
|
2102
|
+
return e >= 0 ? new Rt(BigInt(e)) : new zt(BigInt(e));
|
|
2098
2103
|
}
|
|
2099
|
-
return new
|
|
2104
|
+
return new Bt(a / 1e3 + i);
|
|
2100
2105
|
}
|
|
2101
|
-
var
|
|
2106
|
+
var Lt = 1n, Rt = class extends j {
|
|
2102
2107
|
constructor(e, t) {
|
|
2103
2108
|
super(e, t);
|
|
2104
2109
|
}
|
|
2105
2110
|
_toCDN(e, t) {
|
|
2106
2111
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2107
2112
|
let n = w(e, this.encodingWidth, () => C(this.value));
|
|
2108
|
-
return `dt'${
|
|
2113
|
+
return `dt'${W(Number(this.value))}'${n}`;
|
|
2109
2114
|
}
|
|
2110
|
-
},
|
|
2115
|
+
}, zt = class extends M {
|
|
2111
2116
|
constructor(e, t) {
|
|
2112
2117
|
super(e, t);
|
|
2113
2118
|
}
|
|
2114
2119
|
_toCDN(e, t) {
|
|
2115
2120
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2116
2121
|
let n = w(e, this.encodingWidth, () => C(this.argument));
|
|
2117
|
-
return `dt'${
|
|
2122
|
+
return `dt'${W(Number(this.value))}'${n}`;
|
|
2118
2123
|
}
|
|
2119
|
-
},
|
|
2124
|
+
}, Bt = class extends N {
|
|
2120
2125
|
constructor(e, t) {
|
|
2121
2126
|
super(e, t);
|
|
2122
2127
|
}
|
|
2123
2128
|
_toCDN(e, t) {
|
|
2124
2129
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2125
|
-
let n =
|
|
2126
|
-
return `dt'${
|
|
2130
|
+
let n = k(this.value), r = xe(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
2131
|
+
return `dt'${W(this.value)}'${r}`;
|
|
2127
2132
|
}
|
|
2128
|
-
},
|
|
2133
|
+
}, Vt = class extends P {
|
|
2129
2134
|
constructor(e, t) {
|
|
2130
|
-
super(
|
|
2135
|
+
super(Lt, typeof e == "string" ? It(e) : e, t);
|
|
2131
2136
|
}
|
|
2132
2137
|
_toCDN(e, t) {
|
|
2133
2138
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2134
2139
|
let n = this.content;
|
|
2135
|
-
if (n instanceof
|
|
2140
|
+
if (n instanceof N ? n.precision !== void 0 && n.precision !== k(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
2136
2141
|
...e,
|
|
2137
2142
|
appStrings: !1
|
|
2138
2143
|
}, t);
|
|
2139
|
-
let r = n instanceof
|
|
2140
|
-
return `DT'${
|
|
2144
|
+
let r = n instanceof N ? n.value : Number(n.value), i = w(e, this.encodingWidth, () => C(Lt));
|
|
2145
|
+
return `DT'${W(r)}'${i}`;
|
|
2141
2146
|
}
|
|
2142
|
-
},
|
|
2147
|
+
}, Ht = class extends Vt {
|
|
2143
2148
|
constructor(e, t) {
|
|
2144
2149
|
super(e, t);
|
|
2145
2150
|
}
|
|
2146
2151
|
_toJS(e) {
|
|
2147
|
-
let t = this.content, n = t instanceof
|
|
2152
|
+
let t = this.content, n = t instanceof N ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2148
2153
|
return new Date(n);
|
|
2149
2154
|
}
|
|
2150
2155
|
};
|
|
2151
|
-
function
|
|
2156
|
+
function Ut(e) {
|
|
2152
2157
|
let t = e?.jsDate ?? !1;
|
|
2153
2158
|
function n(e) {
|
|
2154
|
-
return t ? new
|
|
2159
|
+
return t ? new Ht(e) : new Vt(e);
|
|
2155
2160
|
}
|
|
2156
2161
|
let r = {
|
|
2157
2162
|
appStringPrefixes: ["dt", "DT"],
|
|
2158
|
-
tagNumbers: [
|
|
2163
|
+
tagNumbers: [Lt],
|
|
2159
2164
|
parseAppString(e, t, r) {
|
|
2160
|
-
return e === "DT" ? n(t) :
|
|
2165
|
+
return e === "DT" ? n(t) : It(t, r);
|
|
2161
2166
|
},
|
|
2162
2167
|
parseAppSequence(e, t, r) {
|
|
2163
|
-
let i =
|
|
2164
|
-
return e === "DT" ? n(i) :
|
|
2168
|
+
let i = Pt(t);
|
|
2169
|
+
return e === "DT" ? n(i) : It(i, r);
|
|
2165
2170
|
},
|
|
2166
2171
|
parseTag(e, n) {
|
|
2167
2172
|
if (e !== 1n) return;
|
|
2168
2173
|
let r;
|
|
2169
|
-
if (n instanceof
|
|
2170
|
-
else if (n instanceof
|
|
2171
|
-
else if (n instanceof
|
|
2174
|
+
if (n instanceof j) r = new Rt(n.value, { encodingWidth: n.encodingWidth });
|
|
2175
|
+
else if (n instanceof M) r = new zt(n.value, { encodingWidth: n.encodingWidth });
|
|
2176
|
+
else if (n instanceof N) r = new Bt(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
2172
2177
|
else return;
|
|
2173
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
2178
|
+
return r.start = n.start, r.end = n.end, t ? new Ht(r) : new Vt(r);
|
|
2174
2179
|
}
|
|
2175
2180
|
};
|
|
2176
2181
|
return t && (r.fromJS = (e, t) => {
|
|
2177
|
-
if (e instanceof Date) return new
|
|
2182
|
+
if (e instanceof Date) return new Ht(W(e.getTime() / 1e3));
|
|
2178
2183
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2179
2184
|
}
|
|
2180
|
-
var
|
|
2185
|
+
var Wt = Ut(), Gt = Ut({ jsDate: !0 });
|
|
2181
2186
|
//#endregion
|
|
2182
2187
|
//#region src/utils/ip.ts
|
|
2183
|
-
function
|
|
2188
|
+
function Kt(e) {
|
|
2184
2189
|
let t = e.split(".");
|
|
2185
2190
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2186
2191
|
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
@@ -2193,11 +2198,11 @@ function qt(e) {
|
|
|
2193
2198
|
}
|
|
2194
2199
|
return n;
|
|
2195
2200
|
}
|
|
2196
|
-
function
|
|
2201
|
+
function qt(e) {
|
|
2197
2202
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
2198
2203
|
if (e === "::") return t;
|
|
2199
2204
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2200
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2205
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Kt(i[2]));
|
|
2201
2206
|
let a = n.split("::");
|
|
2202
2207
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2203
2208
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2214,11 +2219,11 @@ function Jt(e) {
|
|
|
2214
2219
|
}
|
|
2215
2220
|
return r && t.set(r, 12), t;
|
|
2216
2221
|
}
|
|
2217
|
-
function
|
|
2222
|
+
function Jt(e) {
|
|
2218
2223
|
return Array.from(e).join(".");
|
|
2219
2224
|
}
|
|
2220
|
-
function
|
|
2221
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2225
|
+
function Yt(e) {
|
|
2226
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Jt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2222
2227
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2223
2228
|
let i = -1, a = 0, o = 0;
|
|
2224
2229
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2232,26 +2237,26 @@ function Xt(e) {
|
|
|
2232
2237
|
}
|
|
2233
2238
|
//#endregion
|
|
2234
2239
|
//#region src/extensions/ip.ts
|
|
2235
|
-
var
|
|
2240
|
+
var Xt = "ip", G = "IP", Zt = 52n, Qt = 54n, $t = new TextDecoder("utf-8", { fatal: !0 });
|
|
2236
2241
|
function en(e) {
|
|
2237
2242
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2238
2243
|
let t = e[0];
|
|
2239
|
-
if (t instanceof
|
|
2240
|
-
if (t instanceof
|
|
2244
|
+
if (t instanceof U) return t.value;
|
|
2245
|
+
if (t instanceof F) return $t.decode(t.value);
|
|
2241
2246
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2242
2247
|
}
|
|
2243
2248
|
function tn(e) {
|
|
2244
2249
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2245
|
-
bytes:
|
|
2250
|
+
bytes: Kt(e),
|
|
2246
2251
|
isV4: !0
|
|
2247
2252
|
} : {
|
|
2248
|
-
bytes:
|
|
2253
|
+
bytes: qt(e),
|
|
2249
2254
|
isV4: !1
|
|
2250
2255
|
};
|
|
2251
2256
|
}
|
|
2252
2257
|
function nn(e) {
|
|
2253
|
-
if (e.length === 4) return
|
|
2254
|
-
if (e.length === 16) return
|
|
2258
|
+
if (e.length === 4) return Jt(e);
|
|
2259
|
+
if (e.length === 16) return Yt(e);
|
|
2255
2260
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2256
2261
|
}
|
|
2257
2262
|
function rn(e, t) {
|
|
@@ -2268,38 +2273,38 @@ function an(e, t) {
|
|
|
2268
2273
|
let n = new Uint8Array(t);
|
|
2269
2274
|
return n.set(e), n;
|
|
2270
2275
|
}
|
|
2271
|
-
var on = class extends
|
|
2276
|
+
var on = class extends F {
|
|
2272
2277
|
_toCDN(e, t) {
|
|
2273
2278
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2274
2279
|
let n = w(e, this.encodingWidth, () => C(BigInt(this.value.length)));
|
|
2275
|
-
return `${
|
|
2280
|
+
return `${Xt}'${nn(this.value)}'${n}`;
|
|
2276
2281
|
}
|
|
2277
|
-
}, sn = class extends
|
|
2282
|
+
}, sn = class extends R {
|
|
2278
2283
|
_isV4;
|
|
2279
2284
|
constructor(e, t, n) {
|
|
2280
|
-
super([new
|
|
2285
|
+
super([new j(BigInt(e)), new F(t)]), this._isV4 = n;
|
|
2281
2286
|
}
|
|
2282
2287
|
_toCDN(e, t) {
|
|
2283
2288
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2284
2289
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2285
|
-
return `${
|
|
2290
|
+
return `${Xt}'${nn(an(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2286
2291
|
}
|
|
2287
|
-
}, cn = class extends
|
|
2292
|
+
}, cn = class extends P {
|
|
2288
2293
|
constructor(e, t) {
|
|
2289
2294
|
super(e, t);
|
|
2290
2295
|
}
|
|
2291
2296
|
_toCDN(e, t) {
|
|
2292
2297
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2293
|
-
let n = this.tag ===
|
|
2294
|
-
if (r instanceof
|
|
2298
|
+
let n = this.tag === Zt ? 4 : 16, r = this.content;
|
|
2299
|
+
if (r instanceof F) {
|
|
2295
2300
|
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2296
2301
|
let n = w(e, this.encodingWidth, () => C(this.tag));
|
|
2297
|
-
return `${
|
|
2302
|
+
return `${G}'${nn(r.value)}'${n}`;
|
|
2298
2303
|
}
|
|
2299
|
-
if (r instanceof
|
|
2304
|
+
if (r instanceof R && r.items.length === 2 && r.items[0] instanceof j && r.items[1] instanceof F) {
|
|
2300
2305
|
if (r.encodingWidth !== void 0 || r.items[0].encodingWidth !== void 0 || r.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2301
2306
|
let i = Number(r.items[0].value), a = an(r.items[1].value, n), o = w(e, this.encodingWidth, () => C(this.tag));
|
|
2302
|
-
return `${
|
|
2307
|
+
return `${G}'${nn(a)}/${i}'${o}`;
|
|
2303
2308
|
}
|
|
2304
2309
|
return super._toCDN(e, t);
|
|
2305
2310
|
}
|
|
@@ -2308,18 +2313,18 @@ function ln(e, t) {
|
|
|
2308
2313
|
let n = t.indexOf("/");
|
|
2309
2314
|
if (n === -1) {
|
|
2310
2315
|
let { bytes: n, isV4: r } = tn(t);
|
|
2311
|
-
return e ===
|
|
2316
|
+
return e === G ? new cn(r ? Zt : Qt, new F(n)) : new on(n);
|
|
2312
2317
|
}
|
|
2313
2318
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2314
2319
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2315
2320
|
let a = parseInt(i, 10), { bytes: o, isV4: s } = tn(r), c = s ? 32 : 128;
|
|
2316
2321
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2317
2322
|
let l = rn(o, a);
|
|
2318
|
-
return e ===
|
|
2323
|
+
return e === G ? new cn(s ? Zt : Qt, new R([new j(BigInt(a)), new F(l)])) : new sn(a, l, s);
|
|
2319
2324
|
}
|
|
2320
2325
|
var un = {
|
|
2321
|
-
appStringPrefixes: [
|
|
2322
|
-
tagNumbers: [
|
|
2326
|
+
appStringPrefixes: [Xt, G],
|
|
2327
|
+
tagNumbers: [Zt, Qt],
|
|
2323
2328
|
parseAppString(e, t) {
|
|
2324
2329
|
return ln(e, t);
|
|
2325
2330
|
},
|
|
@@ -2327,7 +2332,7 @@ var un = {
|
|
|
2327
2332
|
return ln(e, en(t));
|
|
2328
2333
|
},
|
|
2329
2334
|
parseTag(e, t) {
|
|
2330
|
-
if (!(e !==
|
|
2335
|
+
if (!(e !== Zt && e !== Qt) && (t instanceof F || t instanceof R)) return new cn(e, t);
|
|
2331
2336
|
}
|
|
2332
2337
|
}, dn = "cri", fn = "CRI", pn = 99n, mn = /* @__PURE__ */ new Map([
|
|
2333
2338
|
["coap", -1n],
|
|
@@ -2380,7 +2385,7 @@ function Tn(e) {
|
|
|
2380
2385
|
}
|
|
2381
2386
|
function En(e) {
|
|
2382
2387
|
let t = [], n = e, r = n.indexOf("@");
|
|
2383
|
-
r >= 0 && (t.push(
|
|
2388
|
+
r >= 0 && (t.push(B.FALSE), t.push(new U(K(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2384
2389
|
let i, a = null;
|
|
2385
2390
|
if (n.startsWith("[")) {
|
|
2386
2391
|
let e = n.indexOf("]");
|
|
@@ -2389,46 +2394,46 @@ function En(e) {
|
|
|
2389
2394
|
let r = n.slice(e + 1);
|
|
2390
2395
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2391
2396
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2392
|
-
t.push(new
|
|
2397
|
+
t.push(new F(qt(i)));
|
|
2393
2398
|
} else {
|
|
2394
2399
|
let e = n.lastIndexOf(":");
|
|
2395
|
-
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new
|
|
2396
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2400
|
+
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new F(Kt(i)));
|
|
2401
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new U(e));
|
|
2397
2402
|
}
|
|
2398
2403
|
if (a !== null && a !== "") {
|
|
2399
2404
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2400
2405
|
let e = parseInt(a, 10);
|
|
2401
2406
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2402
|
-
t.push(new
|
|
2407
|
+
t.push(new j(BigInt(e)));
|
|
2403
2408
|
}
|
|
2404
|
-
return new
|
|
2409
|
+
return new R(t);
|
|
2405
2410
|
}
|
|
2406
2411
|
function Dn(e) {
|
|
2407
2412
|
let t = e.items, n = 0, r = "";
|
|
2408
|
-
if (n < t.length && t[n] instanceof
|
|
2413
|
+
if (n < t.length && t[n] instanceof B && t[n].value === 20) {
|
|
2409
2414
|
n++;
|
|
2410
2415
|
let e = t[n++];
|
|
2411
2416
|
r += q(e.value, wn) + "@";
|
|
2412
2417
|
}
|
|
2413
2418
|
if (n >= t.length) return r;
|
|
2414
2419
|
let i = t[n];
|
|
2415
|
-
if (i instanceof
|
|
2420
|
+
if (i instanceof F) {
|
|
2416
2421
|
n++;
|
|
2417
2422
|
let { length: e } = i.value;
|
|
2418
|
-
if (e === 4) r +=
|
|
2419
|
-
else if (e === 16) r += "[" +
|
|
2423
|
+
if (e === 4) r += Jt(i.value);
|
|
2424
|
+
else if (e === 16) r += "[" + Yt(i.value) + "]";
|
|
2420
2425
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2421
|
-
n < t.length && t[n] instanceof
|
|
2426
|
+
n < t.length && t[n] instanceof U && (r += `%25${q(t[n++].value, Tn)}`);
|
|
2422
2427
|
} else {
|
|
2423
2428
|
let e = [];
|
|
2424
|
-
for (; n < t.length && t[n] instanceof
|
|
2429
|
+
for (; n < t.length && t[n] instanceof U;) e.push(q(t[n++].value, Tn));
|
|
2425
2430
|
r += e.join(".");
|
|
2426
2431
|
}
|
|
2427
|
-
return n < t.length && t[n] instanceof
|
|
2432
|
+
return n < t.length && t[n] instanceof j && (r += ":" + t[n].value.toString()), r;
|
|
2428
2433
|
}
|
|
2429
2434
|
function On(e) {
|
|
2430
2435
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2431
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2436
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new U(K(e)))) : (r = t, i = []), {
|
|
2432
2437
|
authority: En(r),
|
|
2433
2438
|
pathSegments: i
|
|
2434
2439
|
};
|
|
@@ -2439,109 +2444,109 @@ function kn(e) {
|
|
|
2439
2444
|
let i = null, a = t.indexOf("?");
|
|
2440
2445
|
if (a >= 0) {
|
|
2441
2446
|
let e = t.slice(a + 1);
|
|
2442
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2447
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new U(K(e)));
|
|
2443
2448
|
}
|
|
2444
2449
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2445
2450
|
if (s) {
|
|
2446
2451
|
let e = s[1].toLowerCase(), t = s[2], n = mn.get(e);
|
|
2447
|
-
if (o.push(n === void 0 ? new
|
|
2452
|
+
if (o.push(n === void 0 ? new U(e) : new M(n)), t.startsWith("//")) {
|
|
2448
2453
|
let { authority: e, pathSegments: n } = On(t);
|
|
2449
|
-
o.push(e, new
|
|
2454
|
+
o.push(e, new R(n));
|
|
2450
2455
|
} else if (t.startsWith("/")) {
|
|
2451
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2452
|
-
o.push(
|
|
2456
|
+
let e = t.slice(1).split("/").map((e) => new U(K(e)));
|
|
2457
|
+
o.push(B.NULL, new R(e));
|
|
2453
2458
|
} else {
|
|
2454
|
-
let e = t.split("/").map((e) => new
|
|
2455
|
-
o.push(
|
|
2459
|
+
let e = t.split("/").map((e) => new U(K(e)));
|
|
2460
|
+
o.push(B.TRUE, new R(e));
|
|
2456
2461
|
}
|
|
2457
2462
|
} else if (t.startsWith("//")) {
|
|
2458
2463
|
let { authority: e, pathSegments: n } = On(t);
|
|
2459
|
-
o.push(
|
|
2464
|
+
o.push(B.FALSE, e, new R(n));
|
|
2460
2465
|
} else if (t.startsWith("/")) {
|
|
2461
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2462
|
-
o.push(
|
|
2463
|
-
} else if (t === "") o.push(new
|
|
2466
|
+
let e = t.slice(1).split("/").map((e) => new U(K(e)));
|
|
2467
|
+
o.push(B.TRUE, new R(e));
|
|
2468
|
+
} else if (t === "") o.push(new j(0n));
|
|
2464
2469
|
else {
|
|
2465
2470
|
let n = 1n, r = t, i = !1;
|
|
2466
2471
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2467
2472
|
if (r === ".." ? (n++, r = "") : r === "." && (r = ""), n === 1n && !i && r !== "" && r.split("/")[0].includes(":")) throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);
|
|
2468
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2469
|
-
o.push(new
|
|
2473
|
+
let a = r === "" ? [] : r.split("/").map((e) => new U(K(e)));
|
|
2474
|
+
o.push(new j(n), new R(a));
|
|
2470
2475
|
}
|
|
2471
|
-
if (i !== null && o.push(new
|
|
2476
|
+
if (i !== null && o.push(new R(i)), n !== null && (i === null && o.push(B.NULL), o.push(new U(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2472
2477
|
let e = o[o.length - 1];
|
|
2473
|
-
e instanceof
|
|
2478
|
+
e instanceof R && e.items.length === 0 && o.pop();
|
|
2474
2479
|
}
|
|
2475
|
-
return o.length === 1 && o[0] instanceof
|
|
2480
|
+
return o.length === 1 && o[0] instanceof j && o[0].value === 0n ? [] : o;
|
|
2476
2481
|
}
|
|
2477
2482
|
function An(e, t) {
|
|
2478
2483
|
let n = t, r = "";
|
|
2479
2484
|
if (n < e.length) {
|
|
2480
2485
|
let t = e[n];
|
|
2481
|
-
if (t instanceof
|
|
2486
|
+
if (t instanceof R) {
|
|
2482
2487
|
if (n++, t.items.length > 0) {
|
|
2483
2488
|
let e = t.items.map((e) => {
|
|
2484
|
-
if (!(e instanceof
|
|
2489
|
+
if (!(e instanceof U)) throw Error("cri: query item must be a text string");
|
|
2485
2490
|
return q(e.value, Sn);
|
|
2486
2491
|
});
|
|
2487
2492
|
r += "?" + e.join("&");
|
|
2488
2493
|
}
|
|
2489
|
-
} else t instanceof
|
|
2494
|
+
} else t instanceof B && t.value === 22 && n++;
|
|
2490
2495
|
}
|
|
2491
|
-
return n < e.length && e[n] instanceof
|
|
2496
|
+
return n < e.length && e[n] instanceof U && (r += "#" + q(e[n].value, Cn)), r;
|
|
2492
2497
|
}
|
|
2493
2498
|
function jn(e) {
|
|
2494
2499
|
return e.items.map((e) => {
|
|
2495
|
-
if (!(e instanceof
|
|
2500
|
+
if (!(e instanceof U)) throw Error("cri: path segment must be a text string");
|
|
2496
2501
|
return q(e.value, xn);
|
|
2497
2502
|
});
|
|
2498
2503
|
}
|
|
2499
2504
|
function Mn(e) {
|
|
2500
2505
|
if (e.length === 0) return "";
|
|
2501
2506
|
let t = 0, n = e[t++];
|
|
2502
|
-
if (n instanceof
|
|
2507
|
+
if (n instanceof M || n instanceof U) {
|
|
2503
2508
|
let r;
|
|
2504
|
-
if (n instanceof
|
|
2509
|
+
if (n instanceof M) {
|
|
2505
2510
|
let e = hn.get(n.value);
|
|
2506
2511
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2507
2512
|
r = e + ":";
|
|
2508
2513
|
} else r = n.value + ":";
|
|
2509
2514
|
if (t >= e.length) return r;
|
|
2510
2515
|
let i = e[t++], a = "", o = !1;
|
|
2511
|
-
if (i instanceof
|
|
2512
|
-
else if (i instanceof
|
|
2516
|
+
if (i instanceof R) a = "//" + Dn(i), o = !0;
|
|
2517
|
+
else if (i instanceof B) if (i.value === 22) o = !0;
|
|
2513
2518
|
else if (i.value === 21) o = !1;
|
|
2514
2519
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2515
2520
|
else throw Error("cri: unexpected type for authority element");
|
|
2516
2521
|
let s = "";
|
|
2517
|
-
if (t < e.length && e[t] instanceof
|
|
2522
|
+
if (t < e.length && e[t] instanceof R) {
|
|
2518
2523
|
let n = e[t++];
|
|
2519
2524
|
n.items.length > 0 && (s = (o ? "/" : "") + jn(n).join("/"));
|
|
2520
2525
|
}
|
|
2521
2526
|
return r + a + s + An(e, t);
|
|
2522
2527
|
}
|
|
2523
|
-
if (n instanceof
|
|
2524
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2528
|
+
if (n instanceof B && n.value === 20) {
|
|
2529
|
+
if (t >= e.length || !(e[t] instanceof R)) throw Error("cri: network-path reference requires an authority array");
|
|
2525
2530
|
let n = Dn(e[t++]), r = "";
|
|
2526
|
-
if (t < e.length && e[t] instanceof
|
|
2531
|
+
if (t < e.length && e[t] instanceof R) {
|
|
2527
2532
|
let n = e[t++];
|
|
2528
2533
|
n.items.length > 0 && (r = "/" + jn(n).join("/"));
|
|
2529
2534
|
}
|
|
2530
2535
|
return "//" + n + r + An(e, t);
|
|
2531
2536
|
}
|
|
2532
|
-
if (n instanceof
|
|
2537
|
+
if (n instanceof B && n.value === 21) {
|
|
2533
2538
|
let n = "/";
|
|
2534
|
-
if (t < e.length && e[t] instanceof
|
|
2539
|
+
if (t < e.length && e[t] instanceof R) {
|
|
2535
2540
|
let r = e[t++];
|
|
2536
2541
|
n = "/" + jn(r).join("/");
|
|
2537
2542
|
}
|
|
2538
2543
|
return n + An(e, t);
|
|
2539
2544
|
}
|
|
2540
|
-
if (n instanceof
|
|
2545
|
+
if (n instanceof j) {
|
|
2541
2546
|
let r = n.value;
|
|
2542
2547
|
if (r === 0n) return An(e, t);
|
|
2543
2548
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2544
|
-
if (t < e.length && e[t] instanceof
|
|
2549
|
+
if (t < e.length && e[t] instanceof R) {
|
|
2545
2550
|
let n = e[t++];
|
|
2546
2551
|
if (n.items.length > 0) {
|
|
2547
2552
|
let e = jn(n);
|
|
@@ -2552,7 +2557,7 @@ function Mn(e) {
|
|
|
2552
2557
|
}
|
|
2553
2558
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2554
2559
|
}
|
|
2555
|
-
var Nn = class extends
|
|
2560
|
+
var Nn = class extends R {
|
|
2556
2561
|
_toCDN(e, t) {
|
|
2557
2562
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2558
2563
|
try {
|
|
@@ -2562,7 +2567,7 @@ var Nn = class extends L {
|
|
|
2562
2567
|
return super._toCDN(e, t);
|
|
2563
2568
|
}
|
|
2564
2569
|
}
|
|
2565
|
-
}, Pn = class extends
|
|
2570
|
+
}, Pn = class extends P {
|
|
2566
2571
|
constructor(e) {
|
|
2567
2572
|
super(pn, e);
|
|
2568
2573
|
}
|
|
@@ -2581,8 +2586,8 @@ var Nn = class extends L {
|
|
|
2581
2586
|
function Fn(e) {
|
|
2582
2587
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2583
2588
|
let t = e[0];
|
|
2584
|
-
if (t instanceof
|
|
2585
|
-
if (t instanceof
|
|
2589
|
+
if (t instanceof U) return t.value;
|
|
2590
|
+
if (t instanceof F) return _n.decode(t.value);
|
|
2586
2591
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2587
2592
|
}
|
|
2588
2593
|
function In(e, t) {
|
|
@@ -2599,7 +2604,7 @@ var Ln = {
|
|
|
2599
2604
|
return In(e, Fn(t));
|
|
2600
2605
|
},
|
|
2601
2606
|
parseTag(e, t) {
|
|
2602
|
-
if (e !== 99n || !(t instanceof
|
|
2607
|
+
if (e !== 99n || !(t instanceof R)) return;
|
|
2603
2608
|
let n = new Nn(t.items, {
|
|
2604
2609
|
indefiniteLength: t.indefiniteLength,
|
|
2605
2610
|
encodingWidth: t.encodingWidth
|
|
@@ -2609,7 +2614,7 @@ var Ln = {
|
|
|
2609
2614
|
}, Rn = 18446744073709551615n, zn = -18446744073709551616n, Bn = {
|
|
2610
2615
|
tagNumbers: [qe, Je],
|
|
2611
2616
|
parseTag(e, t) {
|
|
2612
|
-
if (t instanceof
|
|
2617
|
+
if (t instanceof F) {
|
|
2613
2618
|
if (e === 2n) {
|
|
2614
2619
|
let e = Qe(t.value);
|
|
2615
2620
|
return e > Rn ? new $e(e) : void 0;
|
|
@@ -2657,47 +2662,47 @@ function Y(e, t) {
|
|
|
2657
2662
|
e.warnings ??= [], e.warnings.push(t);
|
|
2658
2663
|
}
|
|
2659
2664
|
function Kn(e) {
|
|
2660
|
-
if (e instanceof
|
|
2661
|
-
if (e instanceof
|
|
2662
|
-
if (e instanceof
|
|
2663
|
-
if (e instanceof
|
|
2664
|
-
if (e instanceof
|
|
2665
|
-
if (e instanceof
|
|
2665
|
+
if (e instanceof j) return ["u", String(e.value)];
|
|
2666
|
+
if (e instanceof M) return ["n", String(e.value)];
|
|
2667
|
+
if (e instanceof U) return ["t", e.value];
|
|
2668
|
+
if (e instanceof L) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2669
|
+
if (e instanceof F) return ["b", i(e.value)];
|
|
2670
|
+
if (e instanceof I) {
|
|
2666
2671
|
let t = "";
|
|
2667
2672
|
for (let n of e.chunks) t += i(n.value);
|
|
2668
2673
|
return ["b", t];
|
|
2669
2674
|
}
|
|
2670
|
-
if (e instanceof
|
|
2671
|
-
if (e instanceof
|
|
2672
|
-
if (e instanceof
|
|
2673
|
-
if (e instanceof
|
|
2675
|
+
if (e instanceof N) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2676
|
+
if (e instanceof B) return ["s", e.value];
|
|
2677
|
+
if (e instanceof R) return ["A", e.items.map(Kn)];
|
|
2678
|
+
if (e instanceof z) {
|
|
2674
2679
|
let t = e.entries.map(([e, t]) => [Kn(e), Kn(t)]);
|
|
2675
2680
|
if (t.length <= 1) return ["M", t];
|
|
2676
2681
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2677
2682
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2678
2683
|
}
|
|
2679
|
-
return e instanceof
|
|
2684
|
+
return e instanceof P ? [
|
|
2680
2685
|
"G",
|
|
2681
2686
|
String(e.tag),
|
|
2682
2687
|
Kn(e.content)
|
|
2683
2688
|
] : ["c", i(e.toCBOR())];
|
|
2684
2689
|
}
|
|
2685
2690
|
function qn(e) {
|
|
2686
|
-
if (e instanceof
|
|
2687
|
-
if (e instanceof
|
|
2688
|
-
if (e instanceof
|
|
2689
|
-
if (e instanceof
|
|
2691
|
+
if (e instanceof j) return "u" + e.value;
|
|
2692
|
+
if (e instanceof M) return "n" + e.value;
|
|
2693
|
+
if (e instanceof U) return "t" + e.value;
|
|
2694
|
+
if (e instanceof L) {
|
|
2690
2695
|
let t = "t";
|
|
2691
2696
|
for (let n of e.chunks) t += n.value;
|
|
2692
2697
|
return t;
|
|
2693
2698
|
}
|
|
2694
|
-
if (e instanceof
|
|
2695
|
-
if (e instanceof
|
|
2699
|
+
if (e instanceof F) return "b" + i(e.value);
|
|
2700
|
+
if (e instanceof I) {
|
|
2696
2701
|
let t = "b";
|
|
2697
2702
|
for (let n of e.chunks) t += i(n.value);
|
|
2698
2703
|
return t;
|
|
2699
2704
|
}
|
|
2700
|
-
return e instanceof
|
|
2705
|
+
return e instanceof N ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof B ? "s" + e.value : JSON.stringify(Kn(e));
|
|
2701
2706
|
}
|
|
2702
2707
|
var Jn = Array.from({ length: 24 }, (e, t) => BigInt(t)), Yn;
|
|
2703
2708
|
function Xn(e) {
|
|
@@ -2794,36 +2799,36 @@ function rr(e, t, n, r) {
|
|
|
2794
2799
|
case 0: {
|
|
2795
2800
|
let { value: n, nextOffset: r } = Qn(e, t, o);
|
|
2796
2801
|
return {
|
|
2797
|
-
value: new
|
|
2802
|
+
value: new j(n, { encodingWidth: Vn(o, n) }),
|
|
2798
2803
|
nextOffset: r
|
|
2799
2804
|
};
|
|
2800
2805
|
}
|
|
2801
2806
|
case 1: {
|
|
2802
2807
|
let { value: n, nextOffset: r } = Qn(e, t, o), i = Vn(o, n);
|
|
2803
2808
|
return {
|
|
2804
|
-
value: new
|
|
2809
|
+
value: new M(-1n - n, { encodingWidth: i }),
|
|
2805
2810
|
nextOffset: r
|
|
2806
2811
|
};
|
|
2807
2812
|
}
|
|
2808
2813
|
case 2: {
|
|
2809
2814
|
if (o === 31) {
|
|
2810
|
-
let { chunks: i, nextOffset: a } = er(e, t, n, r, "byte string", (e) => e instanceof
|
|
2815
|
+
let { chunks: i, nextOffset: a } = er(e, t, n, r, "byte string", (e) => e instanceof F);
|
|
2811
2816
|
return {
|
|
2812
|
-
value: new
|
|
2817
|
+
value: new I(i),
|
|
2813
2818
|
nextOffset: a
|
|
2814
2819
|
};
|
|
2815
2820
|
}
|
|
2816
2821
|
let { value: i, nextOffset: a } = $n(e, t, o), s = Hn(o, i);
|
|
2817
2822
|
return a + i > e.byteLength && J("byte string extends beyond input"), {
|
|
2818
|
-
value: new
|
|
2823
|
+
value: new F(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
2819
2824
|
nextOffset: a + i
|
|
2820
2825
|
};
|
|
2821
2826
|
}
|
|
2822
2827
|
case 3: {
|
|
2823
2828
|
if (o === 31) {
|
|
2824
|
-
let { chunks: i, nextOffset: a } = er(e, t, n, r, "text string", (e) => e instanceof
|
|
2829
|
+
let { chunks: i, nextOffset: a } = er(e, t, n, r, "text string", (e) => e instanceof U);
|
|
2825
2830
|
return {
|
|
2826
|
-
value: new
|
|
2831
|
+
value: new L(i),
|
|
2827
2832
|
nextOffset: a
|
|
2828
2833
|
};
|
|
2829
2834
|
}
|
|
@@ -2836,7 +2841,7 @@ function rr(e, t, n, r) {
|
|
|
2836
2841
|
} catch {
|
|
2837
2842
|
u = Gn("invalid UTF-8 sequence in text string", a, n), l = Wn.decode(c);
|
|
2838
2843
|
}
|
|
2839
|
-
let f = new
|
|
2844
|
+
let f = new U(l, { encodingWidth: s });
|
|
2840
2845
|
return u && Y(f, u), {
|
|
2841
2846
|
value: f,
|
|
2842
2847
|
nextOffset: a + i
|
|
@@ -2854,7 +2859,7 @@ function rr(e, t, n, r) {
|
|
|
2854
2859
|
i.push(t.value), a = t.nextOffset;
|
|
2855
2860
|
}
|
|
2856
2861
|
return {
|
|
2857
|
-
value: new
|
|
2862
|
+
value: new R(i, { indefiniteLength: !0 }),
|
|
2858
2863
|
nextOffset: a
|
|
2859
2864
|
};
|
|
2860
2865
|
}
|
|
@@ -2864,7 +2869,7 @@ function rr(e, t, n, r) {
|
|
|
2864
2869
|
c.push(t.value), l = t.nextOffset;
|
|
2865
2870
|
}
|
|
2866
2871
|
return {
|
|
2867
|
-
value: new
|
|
2872
|
+
value: new R(c, { encodingWidth: s }),
|
|
2868
2873
|
nextOffset: l
|
|
2869
2874
|
};
|
|
2870
2875
|
}
|
|
@@ -2881,7 +2886,7 @@ function rr(e, t, n, r) {
|
|
|
2881
2886
|
let c = X(e, s, n, r);
|
|
2882
2887
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2883
2888
|
}
|
|
2884
|
-
let c = new
|
|
2889
|
+
let c = new z(i, { indefiniteLength: !0 });
|
|
2885
2890
|
for (let e of o) Y(c, e);
|
|
2886
2891
|
return {
|
|
2887
2892
|
value: c,
|
|
@@ -2895,7 +2900,7 @@ function rr(e, t, n, r) {
|
|
|
2895
2900
|
let i = X(e, d, n, r);
|
|
2896
2901
|
d = i.nextOffset, c.push([t.value, i.value]);
|
|
2897
2902
|
}
|
|
2898
|
-
let f = new
|
|
2903
|
+
let f = new z(c, { encodingWidth: s });
|
|
2899
2904
|
for (let e of u) Y(f, e);
|
|
2900
2905
|
return {
|
|
2901
2906
|
value: f,
|
|
@@ -2907,49 +2912,49 @@ function rr(e, t, n, r) {
|
|
|
2907
2912
|
let { value: i, nextOffset: a } = Qn(e, t, o), s = Vn(o, i), c = X(e, a, n, r);
|
|
2908
2913
|
for (let e of r) {
|
|
2909
2914
|
let t = e.parseTag(i, c.value, n);
|
|
2910
|
-
if (t !== void 0) return t instanceof
|
|
2915
|
+
if (t !== void 0) return t instanceof P && s !== void 0 && (t.encodingWidth = s), {
|
|
2911
2916
|
value: t,
|
|
2912
2917
|
nextOffset: c.nextOffset
|
|
2913
2918
|
};
|
|
2914
2919
|
}
|
|
2915
2920
|
return {
|
|
2916
|
-
value: new
|
|
2921
|
+
value: new P(i, c.value, { encodingWidth: s }),
|
|
2917
2922
|
nextOffset: c.nextOffset
|
|
2918
2923
|
};
|
|
2919
2924
|
}
|
|
2920
2925
|
case 7:
|
|
2921
2926
|
if (o <= 19) return {
|
|
2922
|
-
value: new
|
|
2927
|
+
value: new B(o),
|
|
2923
2928
|
nextOffset: t
|
|
2924
2929
|
};
|
|
2925
2930
|
if (o === 20) return {
|
|
2926
|
-
value: new
|
|
2931
|
+
value: new B(20),
|
|
2927
2932
|
nextOffset: t
|
|
2928
2933
|
};
|
|
2929
2934
|
if (o === 21) return {
|
|
2930
|
-
value: new
|
|
2935
|
+
value: new B(21),
|
|
2931
2936
|
nextOffset: t
|
|
2932
2937
|
};
|
|
2933
2938
|
if (o === 22) return {
|
|
2934
|
-
value: new
|
|
2939
|
+
value: new B(22),
|
|
2935
2940
|
nextOffset: t
|
|
2936
2941
|
};
|
|
2937
2942
|
if (o === 23) return {
|
|
2938
|
-
value: new
|
|
2943
|
+
value: new B(23),
|
|
2939
2944
|
nextOffset: t
|
|
2940
2945
|
};
|
|
2941
2946
|
if (o === 24) {
|
|
2942
2947
|
t + 1 > e.byteLength && J("unexpected end of input");
|
|
2943
2948
|
let r = e.getUint8(t);
|
|
2944
2949
|
if (r < 32) {
|
|
2945
|
-
let e = Gn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new
|
|
2950
|
+
let e = Gn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new B(r);
|
|
2946
2951
|
return Y(i, e), {
|
|
2947
2952
|
value: i,
|
|
2948
2953
|
nextOffset: t + 1
|
|
2949
2954
|
};
|
|
2950
2955
|
}
|
|
2951
2956
|
return {
|
|
2952
|
-
value: new
|
|
2957
|
+
value: new B(r),
|
|
2953
2958
|
nextOffset: t + 1
|
|
2954
2959
|
};
|
|
2955
2960
|
}
|
|
@@ -2957,7 +2962,7 @@ function rr(e, t, n, r) {
|
|
|
2957
2962
|
t + 2 > e.byteLength && J("unexpected end of input");
|
|
2958
2963
|
let n = E(e.getUint16(t, !1));
|
|
2959
2964
|
return {
|
|
2960
|
-
value: new
|
|
2965
|
+
value: new N(n, {
|
|
2961
2966
|
precision: "half",
|
|
2962
2967
|
rawBits: Number.isNaN(n) ? nr(e, t, 2) : void 0
|
|
2963
2968
|
}),
|
|
@@ -2968,7 +2973,7 @@ function rr(e, t, n, r) {
|
|
|
2968
2973
|
t + 4 > e.byteLength && J("unexpected end of input");
|
|
2969
2974
|
let n = e.getFloat32(t, !1);
|
|
2970
2975
|
return {
|
|
2971
|
-
value: new
|
|
2976
|
+
value: new N(n, {
|
|
2972
2977
|
precision: "single",
|
|
2973
2978
|
rawBits: Number.isNaN(n) ? nr(e, t, 4) : void 0
|
|
2974
2979
|
}),
|
|
@@ -2979,7 +2984,7 @@ function rr(e, t, n, r) {
|
|
|
2979
2984
|
t + 8 > e.byteLength && J("unexpected end of input");
|
|
2980
2985
|
let n = e.getFloat64(t, !1);
|
|
2981
2986
|
return {
|
|
2982
|
-
value: new
|
|
2987
|
+
value: new N(n, {
|
|
2983
2988
|
precision: "double",
|
|
2984
2989
|
rawBits: Number.isNaN(n) ? nr(e, t, 8) : void 0
|
|
2985
2990
|
}),
|
|
@@ -3014,7 +3019,7 @@ function ar(e, t) {
|
|
|
3014
3019
|
var or = 24n, sr = {
|
|
3015
3020
|
tagNumbers: [or],
|
|
3016
3021
|
parseTag(e, t, n) {
|
|
3017
|
-
if (e !== 24n || !(t instanceof
|
|
3022
|
+
if (e !== 24n || !(t instanceof F)) return;
|
|
3018
3023
|
let r = (t.end ?? t.value.length) - t.value.length, i = n ? {
|
|
3019
3024
|
extensions: n.extensions,
|
|
3020
3025
|
builtinExtensions: n.builtinExtensions,
|
|
@@ -3026,7 +3031,7 @@ var or = 24n, sr = {
|
|
|
3026
3031
|
silent: n.silent
|
|
3027
3032
|
} : void 0;
|
|
3028
3033
|
try {
|
|
3029
|
-
return new
|
|
3034
|
+
return new P(or, new Ve([ar(t.value, i)], { encodingWidth: t.encodingWidth }));
|
|
3030
3035
|
} catch (e) {
|
|
3031
3036
|
if (i?.strict !== !1) throw e;
|
|
3032
3037
|
let t = `tag 24 content is not valid CBOR: ${e instanceof Error ? e.message : String(e)}`, a = {
|
|
@@ -3041,15 +3046,15 @@ var or = 24n, sr = {
|
|
|
3041
3046
|
//#endregion
|
|
3042
3047
|
//#region src/extensions/ellipsis.ts
|
|
3043
3048
|
function cr(e) {
|
|
3044
|
-
return e instanceof
|
|
3049
|
+
return e instanceof V && !(e.content instanceof R);
|
|
3045
3050
|
}
|
|
3046
3051
|
function lr(e) {
|
|
3047
3052
|
let t = !1, n = !1, r = !1, i;
|
|
3048
3053
|
for (let a of e) {
|
|
3049
3054
|
let e;
|
|
3050
3055
|
if (cr(a)) e = !0, r = !0;
|
|
3051
|
-
else if (a instanceof
|
|
3052
|
-
else if (a instanceof
|
|
3056
|
+
else if (a instanceof U) e = !1, t = !0;
|
|
3057
|
+
else if (a instanceof F) e = !1, n = !0;
|
|
3053
3058
|
else return !1;
|
|
3054
3059
|
if (e === i) return !1;
|
|
3055
3060
|
i = e;
|
|
@@ -3060,8 +3065,8 @@ var ur = {
|
|
|
3060
3065
|
tagNumbers: [Ke],
|
|
3061
3066
|
parseTag(e, t) {
|
|
3062
3067
|
if (e === 888n) {
|
|
3063
|
-
if (t instanceof
|
|
3064
|
-
if (t instanceof
|
|
3068
|
+
if (t instanceof B && t.value === 22) return new V();
|
|
3069
|
+
if (t instanceof R && lr(t.items)) return new V(t.items);
|
|
3065
3070
|
}
|
|
3066
3071
|
}
|
|
3067
3072
|
}, dr = new TextEncoder(), fr = new TextDecoder("utf-8", { fatal: !0 }), pr = new TextDecoder("utf-8", { fatal: !1 }), mr = Symbol("ellipsis");
|
|
@@ -3077,24 +3082,24 @@ function gr(e, t, n) {
|
|
|
3077
3082
|
gr(e, t.inner, n);
|
|
3078
3083
|
return;
|
|
3079
3084
|
}
|
|
3080
|
-
if (t instanceof
|
|
3081
|
-
if (t.content instanceof
|
|
3085
|
+
if (t instanceof V) {
|
|
3086
|
+
if (t.content instanceof R) for (let r of t.content.items) gr(e, r, n);
|
|
3082
3087
|
else n.push(mr);
|
|
3083
3088
|
return;
|
|
3084
3089
|
}
|
|
3085
|
-
if (t instanceof
|
|
3090
|
+
if (t instanceof U) {
|
|
3086
3091
|
n.push(dr.encode(t.value));
|
|
3087
3092
|
return;
|
|
3088
3093
|
}
|
|
3089
|
-
if (t instanceof
|
|
3094
|
+
if (t instanceof F) {
|
|
3090
3095
|
n.push(t.value);
|
|
3091
3096
|
return;
|
|
3092
3097
|
}
|
|
3093
|
-
if (t instanceof
|
|
3098
|
+
if (t instanceof L) {
|
|
3094
3099
|
n.push(dr.encode(t.chunks.map((e) => e.value).join("")));
|
|
3095
3100
|
return;
|
|
3096
3101
|
}
|
|
3097
|
-
if (t instanceof
|
|
3102
|
+
if (t instanceof I) {
|
|
3098
3103
|
n.push(hr(t.chunks.map((e) => e.value)));
|
|
3099
3104
|
return;
|
|
3100
3105
|
}
|
|
@@ -3116,21 +3121,21 @@ function vr(e, t, n) {
|
|
|
3116
3121
|
let i = e === "t1", a = [], o = !1, s = [], c = () => {
|
|
3117
3122
|
if (s.length === 0) return;
|
|
3118
3123
|
let e = hr(s);
|
|
3119
|
-
s.length = 0, e.length !== 0 && a.push(i ? new
|
|
3124
|
+
s.length = 0, e.length !== 0 && a.push(i ? new U(_r(e, n)) : new F(e));
|
|
3120
3125
|
};
|
|
3121
|
-
for (let e of r) e === mr ? (c(), a[a.length - 1] instanceof
|
|
3126
|
+
for (let e of r) e === mr ? (c(), a[a.length - 1] instanceof V || (a.push(new V()), o = !0)) : s.push(e);
|
|
3122
3127
|
if (!o) {
|
|
3123
3128
|
let e = hr(s);
|
|
3124
|
-
return i ? new
|
|
3129
|
+
return i ? new U(_r(e, n)) : new F(e);
|
|
3125
3130
|
}
|
|
3126
|
-
return c(), a.length === 1 ? new
|
|
3131
|
+
return c(), a.length === 1 ? new V() : new V(a);
|
|
3127
3132
|
}
|
|
3128
3133
|
function yr(e) {
|
|
3129
3134
|
return {
|
|
3130
3135
|
appStringPrefixes: [e],
|
|
3131
3136
|
preserveAppSeqSource: !0,
|
|
3132
3137
|
parseAppString(t, n, r) {
|
|
3133
|
-
return vr(e, [new
|
|
3138
|
+
return vr(e, [new U(n)], r);
|
|
3134
3139
|
},
|
|
3135
3140
|
parseAppSequence(t, n, r) {
|
|
3136
3141
|
return vr(e, n, r);
|
|
@@ -3148,12 +3153,12 @@ function Tr(e) {
|
|
|
3148
3153
|
function Er(e, t, n) {
|
|
3149
3154
|
let r = e === "ilts", i = [], a = [];
|
|
3150
3155
|
for (let o of t) {
|
|
3151
|
-
if (o instanceof Ge && (o = o.inner), o instanceof
|
|
3156
|
+
if (o instanceof Ge && (o = o.inner), o instanceof V) throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);
|
|
3152
3157
|
let t, s, c;
|
|
3153
|
-
if (o instanceof
|
|
3154
|
-
else if (o instanceof
|
|
3155
|
-
else if (o instanceof
|
|
3156
|
-
else if (o instanceof
|
|
3158
|
+
if (o instanceof U) t = o.value, c = o.encodingWidth;
|
|
3159
|
+
else if (o instanceof F) s = o.value, c = o.encodingWidth;
|
|
3160
|
+
else if (o instanceof L) t = o.chunks.map((e) => e.value).join("");
|
|
3161
|
+
else if (o instanceof I) s = Tr(o.chunks.map((e) => e.value));
|
|
3157
3162
|
else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);
|
|
3158
3163
|
if (r) {
|
|
3159
3164
|
let e;
|
|
@@ -3166,20 +3171,20 @@ function Er(e, t, n) {
|
|
|
3166
3171
|
else throw SyntaxError(t);
|
|
3167
3172
|
e = wr.decode(s);
|
|
3168
3173
|
}
|
|
3169
|
-
a.push(new
|
|
3174
|
+
a.push(new U(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3170
3175
|
} else {
|
|
3171
3176
|
let e = s ?? Sr.encode(t);
|
|
3172
|
-
i.push(new
|
|
3177
|
+
i.push(new F(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3173
3178
|
}
|
|
3174
3179
|
}
|
|
3175
|
-
return r ? new
|
|
3180
|
+
return r ? new L(a) : new I(i);
|
|
3176
3181
|
}
|
|
3177
3182
|
function Dr(e) {
|
|
3178
3183
|
return {
|
|
3179
3184
|
appStringPrefixes: [e],
|
|
3180
3185
|
preserveAppSeqSource: !0,
|
|
3181
3186
|
parseAppString(t, n, r) {
|
|
3182
|
-
return new Ge(Er(e, [new
|
|
3187
|
+
return new Ge(Er(e, [new U(n)], r), `${e}${ve(n)}`);
|
|
3183
3188
|
},
|
|
3184
3189
|
parseAppSequence(t, n, r) {
|
|
3185
3190
|
return Er(e, n, r);
|
|
@@ -3224,7 +3229,7 @@ function Ar(e) {
|
|
|
3224
3229
|
}
|
|
3225
3230
|
//#endregion
|
|
3226
3231
|
//#region src/extensions/float.ts
|
|
3227
|
-
var jr = class extends
|
|
3232
|
+
var jr = class extends N {
|
|
3228
3233
|
_bits;
|
|
3229
3234
|
constructor(e) {
|
|
3230
3235
|
super(E(e), { precision: "half" }), this._bits = e & 65535;
|
|
@@ -3236,7 +3241,7 @@ var jr = class extends M {
|
|
|
3236
3241
|
this._bits & 255
|
|
3237
3242
|
]);
|
|
3238
3243
|
}
|
|
3239
|
-
}, Mr = class extends
|
|
3244
|
+
}, Mr = class extends N {
|
|
3240
3245
|
_raw;
|
|
3241
3246
|
constructor(e) {
|
|
3242
3247
|
super(new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), { precision: "single" }), this._raw = e.slice();
|
|
@@ -3245,7 +3250,7 @@ var jr = class extends M {
|
|
|
3245
3250
|
let e = /* @__PURE__ */ new Uint8Array(5);
|
|
3246
3251
|
return e[0] = 250, e.set(this._raw, 1), e;
|
|
3247
3252
|
}
|
|
3248
|
-
}, Nr = class extends
|
|
3253
|
+
}, Nr = class extends N {
|
|
3249
3254
|
_raw;
|
|
3250
3255
|
constructor(e) {
|
|
3251
3256
|
super(new DataView(e.buffer, e.byteOffset).getFloat64(0, !1), { precision: "double" }), this._raw = e.slice();
|
|
@@ -3347,7 +3352,7 @@ var zr = {
|
|
|
3347
3352
|
if (n) n(e);
|
|
3348
3353
|
else throw SyntaxError(e);
|
|
3349
3354
|
}
|
|
3350
|
-
if (!(t[0] instanceof
|
|
3355
|
+
if (!(t[0] instanceof F)) throw SyntaxError("float<<...>> item must be a byte string");
|
|
3351
3356
|
return Pr(t[0].value);
|
|
3352
3357
|
}
|
|
3353
3358
|
}, Br = [
|
|
@@ -3355,7 +3360,7 @@ var zr = {
|
|
|
3355
3360
|
sr,
|
|
3356
3361
|
ur
|
|
3357
3362
|
], Vr = [
|
|
3358
|
-
|
|
3363
|
+
Wt,
|
|
3359
3364
|
un,
|
|
3360
3365
|
Ln,
|
|
3361
3366
|
br,
|
|
@@ -3395,7 +3400,7 @@ function Gr(e) {
|
|
|
3395
3400
|
function Kr(e, t) {
|
|
3396
3401
|
if (t?.replacer) {
|
|
3397
3402
|
let { replacer: n, ...r } = t, i = Jr(e, n, r.extensions, r.undefinedOmits, r.builtinExtensions);
|
|
3398
|
-
return i === h ?
|
|
3403
|
+
return i === h ? B.UNDEFINED : Kr(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3399
3404
|
}
|
|
3400
3405
|
return Q(e, t, !0, Gr(t));
|
|
3401
3406
|
}
|
|
@@ -3410,27 +3415,27 @@ function Q(e, t, n, r) {
|
|
|
3410
3415
|
let t = e.parseTag(n, i);
|
|
3411
3416
|
if (t !== void 0) return t;
|
|
3412
3417
|
}
|
|
3413
|
-
return new
|
|
3414
|
-
}
|
|
3415
|
-
if (e instanceof m.Null) return
|
|
3416
|
-
if (e instanceof m.Undefined) return
|
|
3417
|
-
if (e instanceof g) return new
|
|
3418
|
-
if (e === null) return
|
|
3419
|
-
if (e === void 0) return
|
|
3420
|
-
if (e === !0) return
|
|
3421
|
-
if (e === !1) return
|
|
3422
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new $e(e) : e < -18446744073709551616n ? new et(e) : e >= 0n ? new
|
|
3423
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
3424
|
-
if (typeof e == "string") return new
|
|
3418
|
+
return new P(n, i);
|
|
3419
|
+
}
|
|
3420
|
+
if (e instanceof m.Null) return B.NULL;
|
|
3421
|
+
if (e instanceof m.Undefined) return B.UNDEFINED;
|
|
3422
|
+
if (e instanceof g) return new B(e.value);
|
|
3423
|
+
if (e === null) return B.NULL;
|
|
3424
|
+
if (e === void 0) return B.UNDEFINED;
|
|
3425
|
+
if (e === !0) return B.TRUE;
|
|
3426
|
+
if (e === !1) return B.FALSE;
|
|
3427
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new $e(e) : e < -18446744073709551616n ? new et(e) : e >= 0n ? new j(e) : new M(e);
|
|
3428
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new j(BigInt(e)) : new M(BigInt(e)) : new N(e);
|
|
3429
|
+
if (typeof e == "string") return new U(e);
|
|
3425
3430
|
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Q(e.valueOf(), t, !1, r);
|
|
3426
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
3427
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
3428
|
-
if (e instanceof $) return new
|
|
3429
|
-
if (Array.isArray(e)) return new
|
|
3431
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new F(new Uint8Array(e));
|
|
3432
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new R(Array.from(e, (e) => new j(BigInt(e)))) : new F(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3433
|
+
if (e instanceof $) return new z([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
|
|
3434
|
+
if (Array.isArray(e)) return new R(e.map((e) => Q(e, t, !0, r)));
|
|
3430
3435
|
if (typeof e == "object") {
|
|
3431
3436
|
let n = [];
|
|
3432
|
-
for (let [i, a] of Object.entries(e)) n.push([new
|
|
3433
|
-
return new
|
|
3437
|
+
for (let [i, a] of Object.entries(e)) n.push([new U(i), Q(a, t, !0, r)]);
|
|
3438
|
+
return new z(n);
|
|
3434
3439
|
}
|
|
3435
3440
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3436
3441
|
}
|
|
@@ -3513,6 +3518,6 @@ var $ = class extends Array {
|
|
|
3513
3518
|
}
|
|
3514
3519
|
};
|
|
3515
3520
|
//#endregion
|
|
3516
|
-
export { A,
|
|
3521
|
+
export { P as A, s as B, Ve as C, L as D, R as E, A as F, c as H, k as I, g as L, Re as M, M as N, I as O, j as P, h as R, He as S, z as T, m as V, it as _, zr as a, V as b, kr as c, ar as d, Ln as f, U as g, Gt as h, Vr as i, N as j, F as k, xr as l, Wt as m, Jr as n, Ar as o, un as p, Kr as r, Or as s, $ as t, br as u, et as v, B as w, Ge as x, $e as y, o as z };
|
|
3517
3522
|
|
|
3518
|
-
//# sourceMappingURL=mapEntries-
|
|
3523
|
+
//# sourceMappingURL=mapEntries-Czxt-cmd.js.map
|