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