@cbortech/cbor 0.26.6 → 0.26.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +125 -0
- package/README.md +124 -0
- package/dist/ast/CborByteString.d.ts +25 -0
- package/dist/ast/CborEllipsis.d.ts +94 -2
- package/dist/ast/CborFloat.d.ts +10 -0
- package/dist/ast/CborItem.d.ts +93 -4
- package/dist/ast/CborNint.d.ts +9 -0
- package/dist/ast/CborSimple.d.ts +11 -2
- package/dist/ast/CborTag.d.ts +8 -0
- package/dist/ast/CborTextString.d.ts +36 -0
- package/dist/ast/CborUint.d.ts +8 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +2 -2
- package/dist/cddl/index.cjs +1 -1
- package/dist/cddl/index.js +1 -1
- package/dist/cdn/index.cjs +2 -2
- package/dist/cdn/index.cjs.map +1 -1
- package/dist/cdn/index.d.ts +2 -0
- package/dist/cdn/index.js +26 -26
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/serialize-utils.d.ts +208 -9
- package/dist/extensions/dt.d.ts +3 -0
- package/dist/extensions/types.d.ts +31 -9
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +62 -99
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-BJzyBUH5.cjs +13 -0
- package/dist/mapEntries-BJzyBUH5.cjs.map +1 -0
- package/dist/{mapEntries-Czxt-cmd.js → mapEntries-Ci_dppP6.js} +1499 -1219
- package/dist/mapEntries-Ci_dppP6.js.map +1 -0
- package/dist/{schema-BmGsaEaW.cjs → schema-DgnkH0P6.cjs} +5 -5
- package/dist/{schema-BmGsaEaW.cjs.map → schema-DgnkH0P6.cjs.map} +1 -1
- package/dist/{schema-BxkgvUY6.js → schema-y8G5mDIS.js} +248 -248
- package/dist/{schema-BxkgvUY6.js.map → schema-y8G5mDIS.js.map} +1 -1
- package/dist/tokenizer-BD08xbyd.cjs +36 -0
- package/dist/tokenizer-BD08xbyd.cjs.map +1 -0
- package/dist/{tokenizer-CeuixxXi.js → tokenizer-N-vAvRdj.js} +350 -14
- package/dist/tokenizer-N-vAvRdj.js.map +1 -0
- package/dist/types.d.ts +176 -7
- package/package.json +2 -3
- package/dist/mapEntries-BhMlCwYo.cjs +0 -15
- package/dist/mapEntries-BhMlCwYo.cjs.map +0 -1
- package/dist/mapEntries-Czxt-cmd.js.map +0 -1
- package/dist/tokenizer-CeuixxXi.js.map +0 -1
- package/dist/tokenizer-EciPlN0n.cjs +0 -30
- package/dist/tokenizer-EciPlN0n.cjs.map +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as e, D as t, E as n, S as r, T as i, _ as a, a as o, b as s, c, d as l, f as u, g as d, h as f, i as p, l as ee, m as te, n as m, o as ne, p as h, r as g, s as _, t as re, u as ie, v, w as y, x as ae, y as oe } from "./tokenizer-N-vAvRdj.js";
|
|
2
2
|
//#region src/tag.ts
|
|
3
|
-
var
|
|
3
|
+
var se = Symbol.for("cbor.tag"), ce = class {
|
|
4
4
|
valueOf() {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
7
|
toJSON() {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
},
|
|
10
|
+
}, le = class {
|
|
11
11
|
valueOf() {}
|
|
12
12
|
toJSON() {}
|
|
13
13
|
};
|
|
14
|
-
function
|
|
15
|
-
if (!
|
|
16
|
-
let t = e[
|
|
14
|
+
function ue(e) {
|
|
15
|
+
if (!me(e)) return;
|
|
16
|
+
let t = e[se];
|
|
17
17
|
return typeof t == "bigint" ? t : void 0;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function de(e, t) {
|
|
20
20
|
let n;
|
|
21
21
|
switch (typeof e) {
|
|
22
22
|
case "number":
|
|
@@ -32,50 +32,50 @@ function u(e, t) {
|
|
|
32
32
|
n = Object(e);
|
|
33
33
|
break;
|
|
34
34
|
case "undefined":
|
|
35
|
-
n = new
|
|
35
|
+
n = new le();
|
|
36
36
|
break;
|
|
37
37
|
case "object":
|
|
38
38
|
if (e === null) {
|
|
39
|
-
n = new
|
|
39
|
+
n = new ce();
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
42
42
|
n = e;
|
|
43
43
|
break;
|
|
44
44
|
default: throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`);
|
|
45
45
|
}
|
|
46
|
-
return n[
|
|
46
|
+
return n[se] = t, n;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function fe(e) {
|
|
49
49
|
if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
|
|
50
|
-
if (e instanceof
|
|
51
|
-
if (!(e instanceof
|
|
50
|
+
if (e instanceof ce) return null;
|
|
51
|
+
if (!(e instanceof le)) return typeof e == "object" && e && delete e[se], e;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function pe(e) {
|
|
54
54
|
if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
|
|
55
|
-
if (e instanceof
|
|
56
|
-
if (!(e instanceof
|
|
55
|
+
if (e instanceof ce) return null;
|
|
56
|
+
if (!(e instanceof le)) return e;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function me(e) {
|
|
59
59
|
return typeof e == "object" && !!e;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
61
|
+
var b = class {
|
|
62
62
|
constructor() {}
|
|
63
|
-
static symbol =
|
|
64
|
-
static Null =
|
|
65
|
-
static Undefined =
|
|
63
|
+
static symbol = se;
|
|
64
|
+
static Null = ce;
|
|
65
|
+
static Undefined = le;
|
|
66
66
|
static get(e) {
|
|
67
|
-
return
|
|
67
|
+
return ue(e);
|
|
68
68
|
}
|
|
69
69
|
static set(e, t) {
|
|
70
|
-
return
|
|
70
|
+
return de(e, t);
|
|
71
71
|
}
|
|
72
72
|
static remove(e) {
|
|
73
|
-
return
|
|
73
|
+
return fe(e);
|
|
74
74
|
}
|
|
75
75
|
static getValue(e) {
|
|
76
|
-
return
|
|
76
|
+
return pe(e);
|
|
77
77
|
}
|
|
78
|
-
},
|
|
78
|
+
}, x = Symbol("cbor.omit"), he = class e {
|
|
79
79
|
value;
|
|
80
80
|
constructor(e) {
|
|
81
81
|
if (!Number.isInteger(e) || e < 0 || e > 255) throw RangeError("Simple value must be an integer in 0–255");
|
|
@@ -93,211 +93,10 @@ var m = class {
|
|
|
93
93
|
static get(t) {
|
|
94
94
|
return t instanceof e ? t.value : void 0;
|
|
95
95
|
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
let t = e?.indent;
|
|
101
|
-
if (t === void 0) return null;
|
|
102
|
-
let n = typeof t == "number" ? " ".repeat(t) : t;
|
|
103
|
-
return n === "" ? null : n;
|
|
104
|
-
}
|
|
105
|
-
function v(e, t) {
|
|
106
|
-
return e.repeat(t);
|
|
107
|
-
}
|
|
108
|
-
function ee(e, t, n) {
|
|
109
|
-
return t === null ? e.join(" + ") : e.join(` +\n${v(t, n + 1)}`);
|
|
110
|
-
}
|
|
111
|
-
function y(e) {
|
|
112
|
-
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
113
|
-
}
|
|
114
|
-
function te(e) {
|
|
115
|
-
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
116
|
-
}
|
|
117
|
-
function b(e, t) {
|
|
118
|
-
if (!t) return e.text;
|
|
119
|
-
let { marker: n, text: r } = e;
|
|
120
|
-
if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
|
|
121
|
-
if (n === "//") return "#" + r.slice(2);
|
|
122
|
-
if (n === "/*") {
|
|
123
|
-
let e = r.slice(2, -2);
|
|
124
|
-
return e.includes("/") ? r : "/" + (e.startsWith("*") || e.startsWith("/") ? " " + e : e) + "/";
|
|
125
|
-
}
|
|
126
|
-
return r;
|
|
127
|
-
}
|
|
128
|
-
function ne(e, t, n) {
|
|
129
|
-
return (e.comments?.leading ?? []).map((e) => t + b(e, n));
|
|
130
|
-
}
|
|
131
|
-
function re(e, t) {
|
|
132
|
-
let n = e.comments?.trailing ?? [];
|
|
133
|
-
return n.length === 0 ? "" : " " + n.map((e) => b(e, t)).join(" ");
|
|
134
|
-
}
|
|
135
|
-
function ie(e, t, n) {
|
|
136
|
-
return (e.comments?.dangling ?? []).map((e) => t + b(e, n));
|
|
137
|
-
}
|
|
138
|
-
function ae(e, t = !1) {
|
|
139
|
-
let n = e?.commas ?? "comma", r = n !== "none";
|
|
140
|
-
return {
|
|
141
|
-
inlineSep: r ? t ? "," : ", " : " ",
|
|
142
|
-
multilineSep: r ? "," : "",
|
|
143
|
-
trailSep: n === "trailing" ? "," : "",
|
|
144
|
-
colSep: t ? ":" : ": "
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function x(e) {
|
|
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
|
-
if (o === null || a === 0 && !l) {
|
|
150
|
-
let t = "";
|
|
151
|
-
for (let n = 0; n < a; n++) n > 0 && (t += u), t += e.renderEntry(n, p);
|
|
152
|
-
return ee(t);
|
|
153
|
-
}
|
|
154
|
-
let y = null;
|
|
155
|
-
if (t?.inlineLeafContainers && a > 0 && !l) {
|
|
156
|
-
let t = [], n = !0;
|
|
157
|
-
for (let r = 0; r < a; r++) {
|
|
158
|
-
if (e.entryIsLeaf && !e.entryIsLeaf(r)) {
|
|
159
|
-
n = !1;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
let i = e.renderEntry(r, p);
|
|
163
|
-
if (t.push(i), i.includes("\n")) {
|
|
164
|
-
n = !1;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (n) return ee(t.join(u));
|
|
169
|
-
y = t;
|
|
170
|
-
}
|
|
171
|
-
let b = v(o, n + 1), re = v(o, n), x = e.indefiniteLength ? g ? `${r}_ ` : r : `${r}${h}`, S = [];
|
|
172
|
-
for (let t = 0; t < a; t++) {
|
|
173
|
-
s && S.push(...ne(e.entryLeadingNode(t), b, c));
|
|
174
|
-
let n = t < a - 1 ? d : f, r = y?.[t] ?? e.renderEntry(t, p);
|
|
175
|
-
S.push(`${b}${r}${n}${s ? e.entryTrailing(t, c) : ""}`);
|
|
176
|
-
}
|
|
177
|
-
return s && S.push(...ie(e.node, b, c)), `${x}\n${S.join("\n")}\n${re}${i}`;
|
|
178
|
-
}
|
|
179
|
-
var S = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
|
|
180
|
-
function oe(e) {
|
|
181
|
-
if (S) return e.toBase64({ omitPadding: !0 });
|
|
182
|
-
let t = "";
|
|
183
|
-
for (let n of e) t += String.fromCharCode(n);
|
|
184
|
-
return btoa(t).replace(/=/g, "");
|
|
185
|
-
}
|
|
186
|
-
function se(e) {
|
|
187
|
-
if (S) return e.toBase64({
|
|
188
|
-
alphabet: "base64url",
|
|
189
|
-
omitPadding: !0
|
|
190
|
-
});
|
|
191
|
-
let t = "";
|
|
192
|
-
for (let n of e) t += String.fromCharCode(n);
|
|
193
|
-
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
194
|
-
}
|
|
195
|
-
var ce = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", le = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
196
|
-
function ue(e, t) {
|
|
197
|
-
let n = "", r = 0, i = 0;
|
|
198
|
-
for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
|
|
199
|
-
return i > 0 && (n += t[r << 5 - i & 31]), n;
|
|
200
|
-
}
|
|
201
|
-
function de(e) {
|
|
202
|
-
for (let t of e) {
|
|
203
|
-
let e = t.codePointAt(0);
|
|
204
|
-
if (e < 32 || e === 127) return !0;
|
|
205
|
-
}
|
|
206
|
-
return !1;
|
|
207
|
-
}
|
|
208
|
-
function fe(e, t, n) {
|
|
209
|
-
if (n === "string") {
|
|
210
|
-
let t = me(e);
|
|
211
|
-
if (t != null) return _e(t);
|
|
212
|
-
}
|
|
213
|
-
if (n === "printable-string" || n === void 0) {
|
|
214
|
-
let t = me(e);
|
|
215
|
-
if (t != null && !de(t)) return _e(t);
|
|
216
|
-
}
|
|
217
|
-
switch (t) {
|
|
218
|
-
case "base64": return `b64'${oe(e)}'`;
|
|
219
|
-
case "base64url": return `b64'${se(e)}'`;
|
|
220
|
-
case "base32": return `b32'${ue(e, ce)}'`;
|
|
221
|
-
case "base32hex": return `h32'${ue(e, le)}'`;
|
|
222
|
-
default: return `h'${i(e)}'`;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
var pe = new TextDecoder("utf-8", { fatal: !0 });
|
|
226
|
-
function me(e) {
|
|
227
|
-
try {
|
|
228
|
-
return pe.decode(e);
|
|
229
|
-
} catch {
|
|
230
|
-
return null;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
function he(e, t) {
|
|
234
|
-
for (let n = 0; n < e.length; n++) {
|
|
235
|
-
let r = e.charCodeAt(n);
|
|
236
|
-
if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
|
|
237
|
-
}
|
|
238
|
-
return !1;
|
|
239
|
-
}
|
|
240
|
-
function ge(e, t) {
|
|
241
|
-
let n = t.codePointAt(0);
|
|
242
|
-
if (!he(e, n)) return t + e + t;
|
|
243
|
-
let r = t;
|
|
244
|
-
for (let i of e) {
|
|
245
|
-
let e = i.codePointAt(0);
|
|
246
|
-
switch (e) {
|
|
247
|
-
case n:
|
|
248
|
-
r += `\\${t}`;
|
|
249
|
-
break;
|
|
250
|
-
case 92:
|
|
251
|
-
r += "\\\\";
|
|
252
|
-
break;
|
|
253
|
-
case 10:
|
|
254
|
-
r += "\\n";
|
|
255
|
-
break;
|
|
256
|
-
case 13:
|
|
257
|
-
r += "\\r";
|
|
258
|
-
break;
|
|
259
|
-
case 9:
|
|
260
|
-
r += "\\t";
|
|
261
|
-
break;
|
|
262
|
-
default: e < 32 || e === 127 || e === 8232 || e === 8233 || e === 8203 || e === 8204 || e === 8205 || e === 65279 ? r += `\\u${e.toString(16).padStart(4, "0")}` : r += i;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return r + t;
|
|
266
|
-
}
|
|
267
|
-
function _e(e) {
|
|
268
|
-
return ge(e, "'");
|
|
269
|
-
}
|
|
270
|
-
function ve(e) {
|
|
271
|
-
return ge(e, "'");
|
|
272
|
-
}
|
|
273
|
-
function ye(e) {
|
|
274
|
-
return ge(e, "\"");
|
|
275
|
-
}
|
|
276
|
-
function be(e) {
|
|
277
|
-
if (isNaN(e)) return "NaN";
|
|
278
|
-
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
279
|
-
if (Object.is(e, -0)) return "-0.0";
|
|
280
|
-
let t = e.toString();
|
|
281
|
-
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
282
|
-
}
|
|
283
|
-
function xe(e, t, n, r) {
|
|
284
|
-
if (r === "never") return "";
|
|
285
|
-
let i = t ?? n;
|
|
286
|
-
return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
287
|
-
}
|
|
288
|
-
function C(e) {
|
|
289
|
-
return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
|
|
290
|
-
}
|
|
291
|
-
function w(e, t, n) {
|
|
292
|
-
let r = e?.encodingIndicators ?? "auto";
|
|
293
|
-
return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
|
|
294
|
-
}
|
|
295
|
-
//#endregion
|
|
296
|
-
//#region src/utils/float16.ts
|
|
297
|
-
var Se = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Ce = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
298
|
-
function T(e) {
|
|
299
|
-
Ce.setFloat64(0, e, !1);
|
|
300
|
-
let t = Ce.getUint32(0, !1), n = Ce.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
96
|
+
}, ge = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, _e = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
97
|
+
function S(e) {
|
|
98
|
+
_e.setFloat64(0, e, !1);
|
|
99
|
+
let t = _e.getUint32(0, !1), n = _e.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
301
100
|
if (i === 2047) {
|
|
302
101
|
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
303
102
|
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
@@ -318,19 +117,19 @@ function T(e) {
|
|
|
318
117
|
let u = o <= 0 ? 0 : o;
|
|
319
118
|
return r << 15 | u << 10 | s;
|
|
320
119
|
}
|
|
321
|
-
function
|
|
120
|
+
function C(e) {
|
|
322
121
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
323
122
|
return n === 31 ? r === 0 ? t ? -Infinity : Infinity : NaN : n === 0 ? r === 0 ? t ? -0 : 0 : (t ? -1 : 1) * 2 ** -14 * (r / 1024) : (t ? -1 : 1) * 2 ** (n - 15) * (1 + r / 1024);
|
|
324
123
|
}
|
|
325
|
-
var
|
|
124
|
+
var ve = ge ? (e, t, n, r) => {
|
|
326
125
|
e.setFloat16(t, n, r);
|
|
327
126
|
} : (e, t, n, r) => {
|
|
328
|
-
e.setUint16(t,
|
|
329
|
-
},
|
|
330
|
-
function
|
|
127
|
+
e.setUint16(t, S(n), r);
|
|
128
|
+
}, w = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), T = new Uint8Array(w.buffer), ye = new TextEncoder(), be = typeof ye.encodeInto == "function";
|
|
129
|
+
function xe(e) {
|
|
331
130
|
return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
|
|
332
131
|
}
|
|
333
|
-
function
|
|
132
|
+
function Se(e) {
|
|
334
133
|
return e === "i" ? 1 : [
|
|
335
134
|
2,
|
|
336
135
|
3,
|
|
@@ -338,7 +137,7 @@ function ke(e) {
|
|
|
338
137
|
9
|
|
339
138
|
][e];
|
|
340
139
|
}
|
|
341
|
-
var
|
|
140
|
+
var Ce = class {
|
|
342
141
|
buf;
|
|
343
142
|
len = 0;
|
|
344
143
|
constructor(e = 256) {
|
|
@@ -369,45 +168,45 @@ var Ae = class {
|
|
|
369
168
|
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
370
169
|
}
|
|
371
170
|
writeBigUint64(e) {
|
|
372
|
-
|
|
171
|
+
w.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
|
|
373
172
|
}
|
|
374
173
|
writeFloat16(e) {
|
|
375
|
-
|
|
174
|
+
ve(w, 0, e, !1), this._ensure(2);
|
|
376
175
|
let t = this.buf;
|
|
377
|
-
t[this.len++] =
|
|
176
|
+
t[this.len++] = T[0], t[this.len++] = T[1];
|
|
378
177
|
}
|
|
379
178
|
writeFloat32(e) {
|
|
380
|
-
|
|
179
|
+
w.setFloat32(0, e, !1), this._ensure(4);
|
|
381
180
|
let t = this.buf;
|
|
382
|
-
t[this.len++] =
|
|
181
|
+
t[this.len++] = T[0], t[this.len++] = T[1], t[this.len++] = T[2], t[this.len++] = T[3];
|
|
383
182
|
}
|
|
384
183
|
writeFloat64(e) {
|
|
385
|
-
|
|
184
|
+
w.setFloat64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
|
|
386
185
|
}
|
|
387
186
|
writeTextString(e, t, n) {
|
|
388
|
-
if (!
|
|
389
|
-
let r =
|
|
390
|
-
|
|
187
|
+
if (!be) {
|
|
188
|
+
let r = ye.encode(t);
|
|
189
|
+
E(this, e, r.length, n), this.writeBytes(r);
|
|
391
190
|
return;
|
|
392
191
|
}
|
|
393
|
-
let r = n === void 0 ?
|
|
192
|
+
let r = n === void 0 ? xe(t.length) : Se(n);
|
|
394
193
|
this._ensure(9 + 3 * t.length);
|
|
395
|
-
let { written: i } =
|
|
396
|
-
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i),
|
|
194
|
+
let { written: i } = ye.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? xe(i) : r;
|
|
195
|
+
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), E(this, e, i, n), this.len += i;
|
|
397
196
|
}
|
|
398
197
|
finish() {
|
|
399
198
|
return this.buf.slice(0, this.len);
|
|
400
199
|
}
|
|
401
|
-
},
|
|
200
|
+
}, we = [
|
|
402
201
|
255n,
|
|
403
202
|
65535n,
|
|
404
203
|
4294967295n,
|
|
405
204
|
18446744073709551615n
|
|
406
205
|
];
|
|
407
|
-
function
|
|
408
|
-
return e === "i" ? 23n :
|
|
206
|
+
function Te(e) {
|
|
207
|
+
return e === "i" ? 23n : we[e];
|
|
409
208
|
}
|
|
410
|
-
function
|
|
209
|
+
function E(e, t, n, r) {
|
|
411
210
|
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
412
211
|
n <= 23 ? e.writeByte(t << 5 | n) : n <= 255 ? (e.writeByte(t << 5 | 24), e.writeByte(n)) : n <= 65535 ? (e.writeByte(t << 5 | 25), e.writeUint16(n)) : (e.writeByte(t << 5 | 26), e.writeUint32(n));
|
|
413
212
|
return;
|
|
@@ -419,33 +218,52 @@ function O(e, t, n, r) {
|
|
|
419
218
|
e.writeByte(t << 5 | Number(i));
|
|
420
219
|
return;
|
|
421
220
|
}
|
|
422
|
-
if (i >
|
|
221
|
+
if (i > we[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${we[r]})`);
|
|
423
222
|
let n = 24 + r;
|
|
424
223
|
e.writeByte(t << 5 | n), n === 24 ? e.writeByte(Number(i)) : n === 25 ? e.writeUint16(Number(i)) : n === 26 ? e.writeUint32(Number(i)) : e.writeBigUint64(i);
|
|
425
224
|
return;
|
|
426
225
|
}
|
|
427
226
|
i <= 23n ? e.writeByte(t << 5 | Number(i)) : i <= 255n ? (e.writeByte(t << 5 | 24), e.writeByte(Number(i))) : i <= 65535n ? (e.writeByte(t << 5 | 25), e.writeUint16(Number(i))) : i <= 4294967295n ? (e.writeByte(t << 5 | 26), e.writeUint32(Number(i))) : (e.writeByte(t << 5 | 27), e.writeBigUint64(i));
|
|
428
227
|
}
|
|
429
|
-
function
|
|
430
|
-
let r = new
|
|
431
|
-
return
|
|
228
|
+
function Ee(e, t, n) {
|
|
229
|
+
let r = new Ce(9);
|
|
230
|
+
return E(r, e, t, n), r.finish();
|
|
432
231
|
}
|
|
433
|
-
var
|
|
434
|
-
function
|
|
435
|
-
return Object.is(
|
|
232
|
+
var De = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
233
|
+
function Oe(e) {
|
|
234
|
+
return Object.is(C(S(e)), e);
|
|
436
235
|
}
|
|
437
|
-
function
|
|
438
|
-
return
|
|
236
|
+
function ke(e) {
|
|
237
|
+
return De.setFloat32(0, e, !1), Object.is(De.getFloat32(0, !1), e);
|
|
439
238
|
}
|
|
440
|
-
function
|
|
441
|
-
return
|
|
239
|
+
function D(e) {
|
|
240
|
+
return Oe(e) ? "half" : ke(e) ? "single" : "double";
|
|
442
241
|
}
|
|
443
242
|
//#endregion
|
|
444
243
|
//#region src/ast/CborItem.ts
|
|
445
|
-
|
|
244
|
+
function Ae(e) {
|
|
245
|
+
return {
|
|
246
|
+
...e,
|
|
247
|
+
preserveComments: e.preserveComments ?? !0,
|
|
248
|
+
preserveByteString: e.preserveByteString ?? !0,
|
|
249
|
+
preserveRawString: e.preserveRawString ?? !0,
|
|
250
|
+
preserveConcatenation: e.preserveConcatenation ?? !0,
|
|
251
|
+
preserveNumberFormat: e.preserveNumberFormat ?? !0,
|
|
252
|
+
preserveAppSequence: e.preserveAppSequence ?? !0,
|
|
253
|
+
preserveBlankLines: e.preserveBlankLines ?? !0
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
var O = class e {
|
|
446
257
|
start;
|
|
447
258
|
end;
|
|
448
259
|
comments;
|
|
260
|
+
blankLineBefore;
|
|
261
|
+
appSeqSource;
|
|
262
|
+
appSeqComments;
|
|
263
|
+
appSeqEncodingEdits;
|
|
264
|
+
appSeqEncodingEditsComplete;
|
|
265
|
+
appSeqInnerEnd;
|
|
266
|
+
appSeqSourceFeatures;
|
|
449
267
|
warnings;
|
|
450
268
|
_defaults;
|
|
451
269
|
get _containsCdnContainer() {
|
|
@@ -455,17 +273,19 @@ var A = class e {
|
|
|
455
273
|
let t = this._defaults ? {
|
|
456
274
|
...this._defaults,
|
|
457
275
|
...e
|
|
458
|
-
} : e, n = new
|
|
276
|
+
} : e, n = new Ce();
|
|
459
277
|
return this._encode(n, t), n.finish();
|
|
460
278
|
}
|
|
461
279
|
toCDN(e) {
|
|
462
280
|
let t = this._defaults ? {
|
|
463
281
|
...this._defaults,
|
|
464
282
|
...e
|
|
465
|
-
} : e
|
|
466
|
-
|
|
467
|
-
let
|
|
468
|
-
|
|
283
|
+
} : e;
|
|
284
|
+
t?.preserveAll && (t = Ae(t));
|
|
285
|
+
let n = this._toCDN(t, 0), r = t?.preserveComments;
|
|
286
|
+
if (!r || v(t) === null) return n;
|
|
287
|
+
let i = typeof r == "string" ? r : void 0, { ownLines: a, inlinePrefix: s } = ae(this, "", i), c = this.comments?.trailing ?? [], l = c.length === 0 ? n : `${n} ${c.map((e) => o(e, i).trimEnd()).join(" ")}`;
|
|
288
|
+
return [...a, `${s}${l}`].join("\n");
|
|
469
289
|
}
|
|
470
290
|
toEDN(e) {
|
|
471
291
|
return this.toCDN(e);
|
|
@@ -477,7 +297,7 @@ var A = class e {
|
|
|
477
297
|
} : e, n = this._toJS(t);
|
|
478
298
|
if (!t?.reviver) return n;
|
|
479
299
|
let r = t.reviver.call({ "": n }, "", n);
|
|
480
|
-
return r ===
|
|
300
|
+
return r === x ? void 0 : r;
|
|
481
301
|
}
|
|
482
302
|
toHexDump(e) {
|
|
483
303
|
let t = this._defaults ? {
|
|
@@ -503,29 +323,32 @@ var A = class e {
|
|
|
503
323
|
t.writeBytes(this._toCBOR(n));
|
|
504
324
|
}
|
|
505
325
|
_toCBOR(e) {
|
|
506
|
-
let t = new
|
|
326
|
+
let t = new Ce();
|
|
507
327
|
return this._encodeTo(t, e), t.finish();
|
|
508
328
|
}
|
|
509
|
-
_toHexDump(e,
|
|
329
|
+
_toHexDump(e, t) {
|
|
510
330
|
return [{
|
|
511
331
|
depth: e,
|
|
512
|
-
hex:
|
|
513
|
-
comment: this._toCDN(
|
|
332
|
+
hex: i(this._toCBOR()),
|
|
333
|
+
comment: this._toCDN(t, 0)
|
|
514
334
|
}];
|
|
515
335
|
}
|
|
516
|
-
},
|
|
336
|
+
}, k = class extends O {
|
|
517
337
|
value;
|
|
518
338
|
encodingWidth;
|
|
339
|
+
ednSource;
|
|
519
340
|
constructor(e, t) {
|
|
520
341
|
if (super(), this.value = BigInt(e), this.value < 0n) throw RangeError("CborUint value must be non-negative");
|
|
521
342
|
if (this.value > 18446744073709551615n) throw RangeError("CborUint value exceeds maximum uint64");
|
|
522
|
-
this.encodingWidth = t?.encodingWidth;
|
|
343
|
+
this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
523
344
|
}
|
|
524
345
|
_encodeTo(e, t) {
|
|
525
|
-
|
|
346
|
+
E(e, 0, this.value, this.encodingWidth);
|
|
526
347
|
}
|
|
527
348
|
_toCDN(e, t) {
|
|
528
|
-
let n =
|
|
349
|
+
let n = a(e, this.encodingWidth, () => p(this.value));
|
|
350
|
+
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + n;
|
|
351
|
+
let r = this.value;
|
|
529
352
|
switch (e?.intFormat) {
|
|
530
353
|
case "hex": return `0x${r.toString(16)}${n}`;
|
|
531
354
|
case "octal": return `0o${r.toString(8)}${n}`;
|
|
@@ -537,24 +360,27 @@ var A = class e {
|
|
|
537
360
|
let t = e?.integerAs ?? "auto";
|
|
538
361
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
539
362
|
}
|
|
540
|
-
},
|
|
363
|
+
}, A = class extends O {
|
|
541
364
|
argument;
|
|
542
365
|
encodingWidth;
|
|
366
|
+
ednSource;
|
|
543
367
|
constructor(e, t) {
|
|
544
368
|
super();
|
|
545
369
|
let n = BigInt(e);
|
|
546
370
|
if (n >= 0n) throw RangeError("CborNint value must be negative");
|
|
547
371
|
if (n < -18446744073709551616n) throw RangeError("CborNint value exceeds minimum int64");
|
|
548
|
-
this.argument = -1n - n, this.encodingWidth = t?.encodingWidth;
|
|
372
|
+
this.argument = -1n - n, this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
549
373
|
}
|
|
550
374
|
get value() {
|
|
551
375
|
return -1n - this.argument;
|
|
552
376
|
}
|
|
553
377
|
_encodeTo(e, t) {
|
|
554
|
-
|
|
378
|
+
E(e, 1, this.argument, this.encodingWidth);
|
|
555
379
|
}
|
|
556
380
|
_toCDN(e, t) {
|
|
557
|
-
let n =
|
|
381
|
+
let n = a(e, this.encodingWidth, () => p(this.argument));
|
|
382
|
+
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + n;
|
|
383
|
+
let r = this.argument + 1n;
|
|
558
384
|
switch (e?.intFormat) {
|
|
559
385
|
case "hex": return `-0x${r.toString(16)}${n}`;
|
|
560
386
|
case "octal": return `-0o${r.toString(8)}${n}`;
|
|
@@ -566,8 +392,8 @@ var A = class e {
|
|
|
566
392
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
567
393
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
568
394
|
}
|
|
569
|
-
},
|
|
570
|
-
function
|
|
395
|
+
}, je = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
396
|
+
function Me(e) {
|
|
571
397
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
572
398
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
573
399
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -585,115 +411,134 @@ function Re(e) {
|
|
|
585
411
|
let l = c * 2 ** o;
|
|
586
412
|
return t ? -l : l;
|
|
587
413
|
}
|
|
588
|
-
function
|
|
414
|
+
function Ne(e) {
|
|
589
415
|
if (isNaN(e)) return "NaN";
|
|
590
416
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
591
417
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
592
418
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
593
|
-
|
|
594
|
-
let r =
|
|
419
|
+
je.setFloat64(0, n, !1);
|
|
420
|
+
let r = je.getUint32(0, !1), i = je.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
421
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
596
422
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
597
423
|
return t ? `-${p}` : p;
|
|
598
424
|
}
|
|
599
425
|
//#endregion
|
|
600
426
|
//#region src/ast/CborFloat.ts
|
|
601
|
-
var
|
|
427
|
+
var j = class extends O {
|
|
602
428
|
value;
|
|
603
429
|
precision;
|
|
604
430
|
ednSource;
|
|
431
|
+
literalSource;
|
|
605
432
|
rawBits;
|
|
606
433
|
constructor(e, t) {
|
|
607
|
-
super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits;
|
|
434
|
+
super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits, this.literalSource = t?.literalSource;
|
|
608
435
|
}
|
|
609
436
|
_encodeTo(e, t) {
|
|
610
|
-
let n = this.precision ??
|
|
437
|
+
let n = this.precision ?? D(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
|
|
611
438
|
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
439
|
}
|
|
613
440
|
_toCDN(e, t) {
|
|
614
441
|
let n = e?.encodingIndicators ?? "auto";
|
|
615
|
-
if (e?.appStrings !== !1 && this.ednSource !== void 0 && (
|
|
442
|
+
if (e?.appStrings !== !1 && this.ednSource !== void 0 && (v(e) !== null || !/[\r\n]/.test(this.ednSource))) {
|
|
616
443
|
let e = this.ednSource;
|
|
617
444
|
if (n === "never") return e.replace(/_[0-3i]$/, "");
|
|
618
445
|
if (n === "always") {
|
|
619
446
|
if (/_[0-3i]$/.test(e)) return e;
|
|
620
|
-
let t = this.precision ??
|
|
447
|
+
let t = this.precision ?? D(this.value);
|
|
621
448
|
return e + (t === "half" ? "_1" : t === "single" ? "_2" : "_3");
|
|
622
449
|
}
|
|
623
450
|
return e;
|
|
624
451
|
}
|
|
625
|
-
|
|
626
|
-
|
|
452
|
+
if (e?.preserveNumberFormat && this.literalSource !== void 0) {
|
|
453
|
+
let e = this.literalSource;
|
|
454
|
+
if (n === "never") return e.replace(/_[0-7i]$/, "");
|
|
455
|
+
if (n === "always") {
|
|
456
|
+
if (/_[0-7i]$/.test(e)) return e;
|
|
457
|
+
let t = D(this.value);
|
|
458
|
+
return e + ie(this.value, this.precision, t, "always");
|
|
459
|
+
}
|
|
460
|
+
return e;
|
|
461
|
+
}
|
|
462
|
+
let r = D(this.value);
|
|
463
|
+
return (e?.floatFormat === "hex" ? Ne(this.value) : l(this.value)) + ie(this.value, this.precision, r, n);
|
|
627
464
|
}
|
|
628
465
|
_toJS(e) {
|
|
629
466
|
return this.value;
|
|
630
467
|
}
|
|
631
|
-
},
|
|
468
|
+
}, M = class extends O {
|
|
632
469
|
tag;
|
|
633
470
|
content;
|
|
634
471
|
encodingWidth;
|
|
472
|
+
ednSource;
|
|
635
473
|
constructor(e, t, n) {
|
|
636
474
|
if (super(), this.tag = BigInt(e), this.tag < 0n) throw RangeError("CborTag tag number must be non-negative");
|
|
637
|
-
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
475
|
+
this.content = t, this.encodingWidth = n?.encodingWidth, this.ednSource = n?.ednSource;
|
|
638
476
|
}
|
|
639
477
|
get _containsCdnContainer() {
|
|
640
478
|
return this.content._containsCdnContainer;
|
|
641
479
|
}
|
|
642
480
|
_encodeTo(e, t) {
|
|
643
|
-
|
|
481
|
+
E(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
644
482
|
}
|
|
645
483
|
_toCDN(e, t) {
|
|
646
|
-
let n =
|
|
647
|
-
return `${this.tag}${n}
|
|
484
|
+
let n = a(e, this.encodingWidth, () => p(this.tag));
|
|
485
|
+
return `${e?.preserveNumberFormat && this.ednSource !== void 0 ? this.ednSource : this.tag.toString()}${n}${d(this.content, this, e, t, (t) => this.content._toCDN(e, t), "(", ")")}`;
|
|
648
486
|
}
|
|
649
|
-
_toHexDump(e,
|
|
650
|
-
let
|
|
487
|
+
_toHexDump(e, t) {
|
|
488
|
+
let n = [{
|
|
651
489
|
depth: e,
|
|
652
|
-
hex:
|
|
490
|
+
hex: i(Ee(6, this.tag, this.encodingWidth)),
|
|
653
491
|
comment: `Tag ${this.tag}`
|
|
654
492
|
}];
|
|
655
|
-
return
|
|
656
|
-
...
|
|
493
|
+
return n.push(...this.content._toHexDump(e + 1, {
|
|
494
|
+
...t,
|
|
657
495
|
appStrings: !1
|
|
658
|
-
})),
|
|
496
|
+
})), n;
|
|
659
497
|
}
|
|
660
498
|
_toJS(e) {
|
|
661
499
|
let t = this.content._toJS(e);
|
|
662
|
-
return e?.stripTags ? t :
|
|
500
|
+
return e?.stripTags ? t : b.set(t, this.tag);
|
|
663
501
|
}
|
|
664
|
-
}
|
|
502
|
+
};
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/ast/CborByteString.ts
|
|
505
|
+
function Pe(e, t, n) {
|
|
506
|
+
if (e !== void 0) return t?.preserveComments || n === void 0 ? e : r(e, n);
|
|
507
|
+
}
|
|
508
|
+
var N = class extends O {
|
|
665
509
|
indefiniteLength = !1;
|
|
666
510
|
value;
|
|
667
511
|
ednEncoding;
|
|
668
512
|
encodingWidth;
|
|
669
513
|
ednSource;
|
|
514
|
+
ednCommentSyntax;
|
|
670
515
|
ednParts;
|
|
671
516
|
constructor(e, t) {
|
|
672
|
-
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednParts = t?.ednParts;
|
|
517
|
+
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednCommentSyntax = t?.ednCommentSyntax, this.ednParts = t?.ednParts;
|
|
673
518
|
}
|
|
674
519
|
_encodeTo(e, t) {
|
|
675
|
-
|
|
520
|
+
E(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
676
521
|
}
|
|
677
522
|
_toCDN(e, t) {
|
|
678
|
-
let n =
|
|
523
|
+
let n = v(e);
|
|
679
524
|
if (e?.preserveConcatenation && n !== null && this.ednParts !== void 0 && this.ednParts.length > 1) {
|
|
680
|
-
let r =
|
|
525
|
+
let r = a(e, this.encodingWidth, () => p(BigInt(this.value.length))), i = e?.bstrEncoding ?? this.ednEncoding;
|
|
681
526
|
e?.appStrings === !1 && i !== "hex" && (i = "hex");
|
|
682
|
-
let
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
let t = w(e, this.encodingWidth, () => C(BigInt(this.value.length)));
|
|
688
|
-
return this.ednSource + t;
|
|
527
|
+
let o = this.ednParts.map((t) => {
|
|
528
|
+
let n = e?.preserveByteString ? Pe(t.source, e, t.commentSyntax) : void 0;
|
|
529
|
+
return n === void 0 ? oe(t.bytes, i, e?.sqstr) : n;
|
|
530
|
+
});
|
|
531
|
+
return o[o.length - 1] += r, f(o, n, t, e?.preserveComments ? ne(this.comments?.dangling, this.ednParts, typeof e.preserveComments == "string" ? e.preserveComments : void 0) : void 0);
|
|
689
532
|
}
|
|
690
|
-
let r =
|
|
691
|
-
|
|
533
|
+
let r = e?.preserveByteString ? Pe(this.ednSource, e, this.ednCommentSyntax) : void 0;
|
|
534
|
+
if (r !== void 0 && (n !== null || !/[\r\n]/.test(r))) return /_[0-3i]$/.test(r) ? (e?.encodingIndicators ?? "auto") === "never" ? r.replace(/_[0-3i]$/, "") : r : r + a(e, this.encodingWidth, () => p(BigInt(this.value.length)));
|
|
535
|
+
let i = a(e, this.encodingWidth, () => p(BigInt(this.value.length))), o = e?.bstrEncoding ?? this.ednEncoding;
|
|
536
|
+
return e?.appStrings === !1 && o !== "hex" && (o = "hex"), oe(this.value, o, e?.sqstr) + i;
|
|
692
537
|
}
|
|
693
538
|
_toJS(e) {
|
|
694
539
|
return this.value;
|
|
695
540
|
}
|
|
696
|
-
},
|
|
541
|
+
}, P = class extends O {
|
|
697
542
|
indefiniteLength = !0;
|
|
698
543
|
chunks;
|
|
699
544
|
constructor(e) {
|
|
@@ -708,9 +553,9 @@ var N = class extends A {
|
|
|
708
553
|
if ((e?.encodingIndicators ?? "auto") === "never") {
|
|
709
554
|
let n = this.chunks.reduce((e, t) => e + t.value.length, 0), r = new Uint8Array(n), i = 0;
|
|
710
555
|
for (let e of this.chunks) r.set(e.value, i), i += e.value.length;
|
|
711
|
-
return new
|
|
556
|
+
return new N(r)._toCDN(e, t);
|
|
712
557
|
}
|
|
713
|
-
return this.chunks.length === 0 ? "''_" :
|
|
558
|
+
return this.chunks.length === 0 ? "''_" : s({
|
|
714
559
|
node: this,
|
|
715
560
|
options: e,
|
|
716
561
|
depth: t,
|
|
@@ -719,22 +564,22 @@ var N = class extends A {
|
|
|
719
564
|
count: this.chunks.length,
|
|
720
565
|
indefiniteLength: !0,
|
|
721
566
|
encodingWidth: void 0,
|
|
722
|
-
hasEntryComments: () => this.chunks.some(
|
|
567
|
+
hasEntryComments: () => this.chunks.some(h),
|
|
723
568
|
renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
|
|
724
569
|
entryLeadingNode: (e) => this.chunks[e],
|
|
725
|
-
entryTrailing: (e, t) =>
|
|
570
|
+
entryTrailing: (e, t) => u(this.chunks[e], t)
|
|
726
571
|
});
|
|
727
572
|
}
|
|
728
|
-
_toHexDump(
|
|
573
|
+
_toHexDump(t, n) {
|
|
729
574
|
let r = [{
|
|
730
|
-
depth:
|
|
731
|
-
hex:
|
|
575
|
+
depth: t,
|
|
576
|
+
hex: e(95),
|
|
732
577
|
comment: "Start indefinite-length byte string"
|
|
733
578
|
}];
|
|
734
|
-
for (let
|
|
579
|
+
for (let e of this.chunks) r.push(...e._toHexDump(t + 1, n));
|
|
735
580
|
return r.push({
|
|
736
|
-
depth:
|
|
737
|
-
hex:
|
|
581
|
+
depth: t,
|
|
582
|
+
hex: e(255),
|
|
738
583
|
comment: "\"break\""
|
|
739
584
|
}), r;
|
|
740
585
|
}
|
|
@@ -743,7 +588,7 @@ var N = class extends A {
|
|
|
743
588
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
744
589
|
return n;
|
|
745
590
|
}
|
|
746
|
-
},
|
|
591
|
+
}, F = class extends O {
|
|
747
592
|
indefiniteLength = !0;
|
|
748
593
|
chunks;
|
|
749
594
|
constructor(e) {
|
|
@@ -755,7 +600,7 @@ var N = class extends A {
|
|
|
755
600
|
e.writeByte(255);
|
|
756
601
|
}
|
|
757
602
|
_toCDN(e, t) {
|
|
758
|
-
return (e?.encodingIndicators ?? "auto") === "never" ? new
|
|
603
|
+
return (e?.encodingIndicators ?? "auto") === "never" ? new G(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : s({
|
|
759
604
|
node: this,
|
|
760
605
|
options: e,
|
|
761
606
|
depth: t,
|
|
@@ -764,29 +609,29 @@ var N = class extends A {
|
|
|
764
609
|
count: this.chunks.length,
|
|
765
610
|
indefiniteLength: !0,
|
|
766
611
|
encodingWidth: void 0,
|
|
767
|
-
hasEntryComments: () => this.chunks.some(
|
|
612
|
+
hasEntryComments: () => this.chunks.some(h),
|
|
768
613
|
renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
|
|
769
614
|
entryLeadingNode: (e) => this.chunks[e],
|
|
770
|
-
entryTrailing: (e, t) =>
|
|
615
|
+
entryTrailing: (e, t) => u(this.chunks[e], t)
|
|
771
616
|
});
|
|
772
617
|
}
|
|
773
|
-
_toHexDump(
|
|
618
|
+
_toHexDump(t, n) {
|
|
774
619
|
let r = [{
|
|
775
|
-
depth:
|
|
776
|
-
hex:
|
|
620
|
+
depth: t,
|
|
621
|
+
hex: e(127),
|
|
777
622
|
comment: "Start indefinite-length text string"
|
|
778
623
|
}];
|
|
779
|
-
for (let
|
|
624
|
+
for (let e of this.chunks) r.push(...e._toHexDump(t + 1, n));
|
|
780
625
|
return r.push({
|
|
781
|
-
depth:
|
|
782
|
-
hex:
|
|
626
|
+
depth: t,
|
|
627
|
+
hex: e(255),
|
|
783
628
|
comment: "\"break\""
|
|
784
629
|
}), r;
|
|
785
630
|
}
|
|
786
631
|
_toJS(e) {
|
|
787
632
|
return this.chunks.map((e) => e.value).join("");
|
|
788
633
|
}
|
|
789
|
-
},
|
|
634
|
+
}, I = class extends O {
|
|
790
635
|
items;
|
|
791
636
|
indefiniteLength;
|
|
792
637
|
encodingWidth;
|
|
@@ -803,11 +648,11 @@ var N = class extends A {
|
|
|
803
648
|
e.writeByte(255);
|
|
804
649
|
return;
|
|
805
650
|
}
|
|
806
|
-
|
|
651
|
+
E(e, 4, this.items.length, this.encodingWidth);
|
|
807
652
|
for (let n of this.items) n._encode(e, t);
|
|
808
653
|
}
|
|
809
654
|
_toCDN(e, t) {
|
|
810
|
-
return
|
|
655
|
+
return s({
|
|
811
656
|
node: this,
|
|
812
657
|
options: e,
|
|
813
658
|
depth: t,
|
|
@@ -816,34 +661,34 @@ var N = class extends A {
|
|
|
816
661
|
count: this.items.length,
|
|
817
662
|
indefiniteLength: this.indefiniteLength,
|
|
818
663
|
encodingWidth: this.encodingWidth,
|
|
819
|
-
hasEntryComments: () => this.items.some(
|
|
664
|
+
hasEntryComments: () => this.items.some(h),
|
|
820
665
|
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
821
666
|
entryIsLeaf: (e) => !this.items[e]._containsCdnContainer,
|
|
822
667
|
entryLeadingNode: (e) => this.items[e],
|
|
823
|
-
entryTrailing: (e, t) =>
|
|
668
|
+
entryTrailing: (e, t) => u(this.items[e], t)
|
|
824
669
|
});
|
|
825
670
|
}
|
|
826
|
-
_toHexDump(
|
|
671
|
+
_toHexDump(t, n) {
|
|
827
672
|
if (this.indefiniteLength) {
|
|
828
|
-
let
|
|
829
|
-
depth:
|
|
830
|
-
hex:
|
|
673
|
+
let r = [{
|
|
674
|
+
depth: t,
|
|
675
|
+
hex: e(159),
|
|
831
676
|
comment: "Start indefinite-length array"
|
|
832
677
|
}];
|
|
833
|
-
for (let
|
|
834
|
-
return
|
|
835
|
-
depth:
|
|
836
|
-
hex:
|
|
678
|
+
for (let e of this.items) r.push(...e._toHexDump(t + 1, n));
|
|
679
|
+
return r.push({
|
|
680
|
+
depth: t,
|
|
681
|
+
hex: e(255),
|
|
837
682
|
comment: "\"break\""
|
|
838
|
-
}),
|
|
683
|
+
}), r;
|
|
839
684
|
}
|
|
840
|
-
let
|
|
841
|
-
depth:
|
|
842
|
-
hex:
|
|
685
|
+
let r = [{
|
|
686
|
+
depth: t,
|
|
687
|
+
hex: i(Ee(4, BigInt(this.items.length), this.encodingWidth)),
|
|
843
688
|
comment: `Array of length ${this.items.length}`
|
|
844
689
|
}];
|
|
845
|
-
for (let
|
|
846
|
-
return
|
|
690
|
+
for (let e of this.items) r.push(...e._toHexDump(t + 1, n));
|
|
691
|
+
return r;
|
|
847
692
|
}
|
|
848
693
|
_toJS(e) {
|
|
849
694
|
let t = e?.reviver;
|
|
@@ -854,11 +699,11 @@ var N = class extends A {
|
|
|
854
699
|
} : void 0, r = this.items.map((e) => e._toJS(n)), i = 0;
|
|
855
700
|
for (let n = 0; n < this.items.length; n++) {
|
|
856
701
|
let a = n - i, o = this.items[n]._toJS(e), s = t.call(r, String(n), o);
|
|
857
|
-
s ===
|
|
702
|
+
s === x || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
|
|
858
703
|
}
|
|
859
704
|
return r;
|
|
860
705
|
}
|
|
861
|
-
},
|
|
706
|
+
}, L = class extends O {
|
|
862
707
|
entries;
|
|
863
708
|
indefiniteLength;
|
|
864
709
|
encodingWidth;
|
|
@@ -875,11 +720,11 @@ var N = class extends A {
|
|
|
875
720
|
e.writeByte(255);
|
|
876
721
|
return;
|
|
877
722
|
}
|
|
878
|
-
|
|
723
|
+
E(e, 5, this.entries.length, this.encodingWidth);
|
|
879
724
|
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
880
725
|
}
|
|
881
726
|
_toCDN(e, t) {
|
|
882
|
-
return
|
|
727
|
+
return s({
|
|
883
728
|
node: this,
|
|
884
729
|
options: e,
|
|
885
730
|
depth: t,
|
|
@@ -888,7 +733,7 @@ var N = class extends A {
|
|
|
888
733
|
count: this.entries.length,
|
|
889
734
|
indefiniteLength: this.indefiniteLength,
|
|
890
735
|
encodingWidth: this.encodingWidth,
|
|
891
|
-
hasEntryComments: () => this.entries.some(([e, t]) =>
|
|
736
|
+
hasEntryComments: () => this.entries.some(([e, t]) => h(e) || h(t)),
|
|
892
737
|
renderEntry: (n, r) => {
|
|
893
738
|
let [i, a] = this.entries[n];
|
|
894
739
|
return `${i._toCDN(e, t + 1)}${r}${a._toCDN(e, t + 1)}`;
|
|
@@ -900,7 +745,7 @@ var N = class extends A {
|
|
|
900
745
|
entryLeadingNode: (e) => this.entries[e][0],
|
|
901
746
|
entryTrailing: (e, t) => {
|
|
902
747
|
let [n, r] = this.entries[e];
|
|
903
|
-
return
|
|
748
|
+
return Fe([
|
|
904
749
|
...n.comments?.trailing ?? [],
|
|
905
750
|
...r.comments?.leading ?? [],
|
|
906
751
|
...r.comments?.trailing ?? []
|
|
@@ -908,27 +753,27 @@ var N = class extends A {
|
|
|
908
753
|
}
|
|
909
754
|
});
|
|
910
755
|
}
|
|
911
|
-
_toHexDump(
|
|
756
|
+
_toHexDump(t, n) {
|
|
912
757
|
if (this.indefiniteLength) {
|
|
913
|
-
let
|
|
914
|
-
depth:
|
|
915
|
-
hex:
|
|
758
|
+
let r = [{
|
|
759
|
+
depth: t,
|
|
760
|
+
hex: e(191),
|
|
916
761
|
comment: "Start indefinite-length map"
|
|
917
762
|
}];
|
|
918
|
-
for (let [
|
|
919
|
-
return
|
|
920
|
-
depth:
|
|
921
|
-
hex:
|
|
763
|
+
for (let [e, i] of this.entries) r.push(...e._toHexDump(t + 1, n)), r.push(...i._toHexDump(t + 1, n));
|
|
764
|
+
return r.push({
|
|
765
|
+
depth: t,
|
|
766
|
+
hex: e(255),
|
|
922
767
|
comment: "\"break\""
|
|
923
|
-
}),
|
|
768
|
+
}), r;
|
|
924
769
|
}
|
|
925
|
-
let
|
|
926
|
-
depth:
|
|
927
|
-
hex:
|
|
770
|
+
let r = [{
|
|
771
|
+
depth: t,
|
|
772
|
+
hex: i(Ee(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
928
773
|
comment: `Map of length ${this.entries.length}`
|
|
929
774
|
}];
|
|
930
|
-
for (let [
|
|
931
|
-
return
|
|
775
|
+
for (let [e, i] of this.entries) r.push(...e._toHexDump(t + 1, n)), r.push(...i._toHexDump(t + 1, n));
|
|
776
|
+
return r;
|
|
932
777
|
}
|
|
933
778
|
_toJS(e) {
|
|
934
779
|
let t = e?.reviver, n = () => {
|
|
@@ -937,17 +782,17 @@ var N = class extends A {
|
|
|
937
782
|
let r = e?.undefinedOmits;
|
|
938
783
|
for (let e = 0; e < n.length; e++) {
|
|
939
784
|
let [i, a] = n[e], o = t.call(n, i, a);
|
|
940
|
-
o ===
|
|
785
|
+
o === x || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
|
|
941
786
|
}
|
|
942
787
|
return n;
|
|
943
788
|
};
|
|
944
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
789
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof G) ? (() => {
|
|
945
790
|
let n = e ? {
|
|
946
791
|
...e,
|
|
947
792
|
reviver: void 0
|
|
948
793
|
} : void 0, r = {};
|
|
949
794
|
for (let [e, t] of this.entries) {
|
|
950
|
-
let i = e instanceof
|
|
795
|
+
let i = e instanceof G ? e.value : e.toCDN(), a = t._toJS(n);
|
|
951
796
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
952
797
|
value: a,
|
|
953
798
|
writable: !0,
|
|
@@ -959,13 +804,13 @@ var N = class extends A {
|
|
|
959
804
|
let i = /* @__PURE__ */ new Map();
|
|
960
805
|
for (let e = 0; e < this.entries.length; e++) {
|
|
961
806
|
let [t] = this.entries[e];
|
|
962
|
-
i.set(t instanceof
|
|
807
|
+
i.set(t instanceof G ? t.value : t.toCDN(), e);
|
|
963
808
|
}
|
|
964
809
|
for (let n = 0; n < this.entries.length; n++) {
|
|
965
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
810
|
+
let [a, o] = this.entries[n], s = a instanceof G ? a.value : a.toCDN();
|
|
966
811
|
if (i.get(s) !== n) continue;
|
|
967
812
|
let c = o._toJS(e), l = t.call(r, s, c);
|
|
968
|
-
l ===
|
|
813
|
+
l === x || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
969
814
|
value: l,
|
|
970
815
|
writable: !0,
|
|
971
816
|
enumerable: !0,
|
|
@@ -976,16 +821,17 @@ var N = class extends A {
|
|
|
976
821
|
})() : n();
|
|
977
822
|
}
|
|
978
823
|
};
|
|
979
|
-
function
|
|
980
|
-
return e.length === 0 ? "" : " " + e.map((e) =>
|
|
824
|
+
function Fe(e, t) {
|
|
825
|
+
return e.length === 0 ? "" : " " + e.map((e) => o(e, t).trimEnd()).join(" ");
|
|
981
826
|
}
|
|
982
827
|
//#endregion
|
|
983
828
|
//#region src/ast/CborSimple.ts
|
|
984
|
-
var
|
|
829
|
+
var R = class e extends O {
|
|
985
830
|
value;
|
|
986
|
-
|
|
831
|
+
ednSource;
|
|
832
|
+
constructor(e, t) {
|
|
987
833
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
988
|
-
this.value = e;
|
|
834
|
+
this.value = e, this.ednSource = t?.ednSource;
|
|
989
835
|
}
|
|
990
836
|
static FALSE = new e(20);
|
|
991
837
|
static TRUE = new e(21);
|
|
@@ -999,6 +845,7 @@ var B = class e extends A {
|
|
|
999
845
|
e.writeByte(248), e.writeByte(this.value);
|
|
1000
846
|
}
|
|
1001
847
|
_toCDN(e, t) {
|
|
848
|
+
if (e?.preserveNumberFormat && this.ednSource !== void 0) return `simple(${this.ednSource})`;
|
|
1002
849
|
switch (this.value) {
|
|
1003
850
|
case 20: return "false";
|
|
1004
851
|
case 21: return "true";
|
|
@@ -1013,10 +860,10 @@ var B = class e extends A {
|
|
|
1013
860
|
case 21: return !0;
|
|
1014
861
|
case 22: return null;
|
|
1015
862
|
case 23: return;
|
|
1016
|
-
default: return new
|
|
863
|
+
default: return new he(this.value);
|
|
1017
864
|
}
|
|
1018
865
|
}
|
|
1019
|
-
},
|
|
866
|
+
}, z = class extends O {
|
|
1020
867
|
items;
|
|
1021
868
|
encodingWidth;
|
|
1022
869
|
constructor(e, t) {
|
|
@@ -1026,38 +873,120 @@ var B = class e extends A {
|
|
|
1026
873
|
return this.items.some((e) => e._containsCdnContainer);
|
|
1027
874
|
}
|
|
1028
875
|
_content(e) {
|
|
1029
|
-
let t = new
|
|
876
|
+
let t = new Ce();
|
|
1030
877
|
for (let n of this.items) n._encode(t, e);
|
|
1031
878
|
return t.finish();
|
|
1032
879
|
}
|
|
1033
880
|
_encodeTo(e, t) {
|
|
1034
881
|
let n = this._content(t);
|
|
1035
|
-
|
|
882
|
+
E(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
1036
883
|
}
|
|
1037
884
|
_toCDN(e, t) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
885
|
+
return s({
|
|
886
|
+
node: this,
|
|
887
|
+
options: e,
|
|
888
|
+
depth: t,
|
|
889
|
+
openChar: "<<",
|
|
890
|
+
closeChar: ">>",
|
|
891
|
+
count: this.items.length,
|
|
892
|
+
indefiniteLength: !1,
|
|
893
|
+
encodingWidth: this.encodingWidth,
|
|
894
|
+
eiPosition: "close",
|
|
895
|
+
canonicalCount: () => BigInt(this._content(e).length),
|
|
896
|
+
hasEntryComments: () => this.items.some(h),
|
|
897
|
+
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
898
|
+
entryLeadingNode: (e) => this.items[e],
|
|
899
|
+
entryTrailing: (e, t) => u(this.items[e], t)
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
_toHexDump(e, t) {
|
|
903
|
+
let n = this._content().length, r = [{
|
|
1047
904
|
depth: e,
|
|
1048
|
-
hex:
|
|
1049
|
-
comment: `Embedded CBOR sequence, ${
|
|
905
|
+
hex: i(Ee(2, BigInt(n), this.encodingWidth)),
|
|
906
|
+
comment: `Embedded CBOR sequence, ${n} byte${n === 1 ? "" : "s"}`
|
|
1050
907
|
}];
|
|
1051
|
-
for (let
|
|
1052
|
-
return
|
|
908
|
+
for (let n of this.items) r.push(...n._toHexDump(e + 1, t));
|
|
909
|
+
return r;
|
|
1053
910
|
}
|
|
1054
911
|
_toJS(e) {
|
|
1055
912
|
return this._content();
|
|
1056
913
|
}
|
|
1057
914
|
};
|
|
1058
915
|
//#endregion
|
|
916
|
+
//#region src/utils/strip-comments.ts
|
|
917
|
+
function Ie(e) {
|
|
918
|
+
let t = "", n = 0;
|
|
919
|
+
for (; n < e.length;) {
|
|
920
|
+
let r = e[n];
|
|
921
|
+
if (r === " " || r === "\n" || r === "\r") {
|
|
922
|
+
n++;
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
if (r === "#") {
|
|
926
|
+
for (; n < e.length && e[n] !== "\n";) n++;
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
if (r === "/") {
|
|
930
|
+
let t = e[n + 1] ?? "";
|
|
931
|
+
if (t === "/") {
|
|
932
|
+
for (; n < e.length && e[n] !== "\n";) n++;
|
|
933
|
+
continue;
|
|
934
|
+
}
|
|
935
|
+
if (t === "*") {
|
|
936
|
+
for (n += 2; n < e.length && !(e[n] === "*" && (e[n + 1] ?? "") === "/");) n++;
|
|
937
|
+
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
938
|
+
n += 2;
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
for (n++; n < e.length && e[n] !== "/";) n++;
|
|
942
|
+
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
943
|
+
n++;
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
t += r, n++;
|
|
947
|
+
}
|
|
948
|
+
return t;
|
|
949
|
+
}
|
|
950
|
+
//#endregion
|
|
951
|
+
//#region src/extensions/b32.ts
|
|
952
|
+
var Le = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", Re = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
953
|
+
function ze(e) {
|
|
954
|
+
let t = e.length;
|
|
955
|
+
for (; t > 0 && e.charCodeAt(t - 1) === 61;) t--;
|
|
956
|
+
return e.slice(0, t);
|
|
957
|
+
}
|
|
958
|
+
function Be(e, t, n) {
|
|
959
|
+
let r = ze(e).toUpperCase(), i = r.length % 8;
|
|
960
|
+
if (i === 1 || i === 3 || i === 6) throw SyntaxError(`invalid base32 length: ${r.length} characters`);
|
|
961
|
+
let a = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
|
|
962
|
+
for (let e = 0; e < t.length; e++) a[t.charCodeAt(e)] = e;
|
|
963
|
+
let o = new Uint8Array(Math.floor(r.length * 5 / 8)), s = 0, c = 0, l = 0;
|
|
964
|
+
for (let e of r) {
|
|
965
|
+
let t = e.charCodeAt(0), n = t < 128 ? a[t] : 255;
|
|
966
|
+
if (n === 255) throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);
|
|
967
|
+
s = s << 5 | n, c += 5, c >= 8 && (c -= 8, o[l++] = s >> c & 255);
|
|
968
|
+
}
|
|
969
|
+
if (c > 0 && s & (1 << c) - 1) {
|
|
970
|
+
let e = "non-zero trailing bits in base32 input";
|
|
971
|
+
if (n) n(e);
|
|
972
|
+
else throw SyntaxError(e);
|
|
973
|
+
}
|
|
974
|
+
return o;
|
|
975
|
+
}
|
|
976
|
+
var Ve = {
|
|
977
|
+
appStringPrefixes: ["b32"],
|
|
978
|
+
parseAppString(e, t, n) {
|
|
979
|
+
return new N(Be(Ie(t), Le, n), { ednEncoding: "base32" });
|
|
980
|
+
}
|
|
981
|
+
}, He = {
|
|
982
|
+
appStringPrefixes: ["h32"],
|
|
983
|
+
parseAppString(e, t, n) {
|
|
984
|
+
return new N(Be(Ie(t), Re, n), { ednEncoding: "base32hex" });
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
//#endregion
|
|
1059
988
|
//#region src/utils/base64.ts
|
|
1060
|
-
function
|
|
989
|
+
function Ue(e, t) {
|
|
1061
990
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1062
991
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1063
992
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -1096,17 +1025,17 @@ function He(e, t) {
|
|
|
1096
1025
|
}
|
|
1097
1026
|
//#endregion
|
|
1098
1027
|
//#region src/ast/CborUnresolvedAppExt.ts
|
|
1099
|
-
var
|
|
1028
|
+
var We = 999n, Ge = class extends M {
|
|
1100
1029
|
constructor(e, t) {
|
|
1101
|
-
let n = t.length === 1 && t[0] instanceof
|
|
1102
|
-
super(
|
|
1030
|
+
let n = t.length === 1 && t[0] instanceof G ? t[0] : new I(t);
|
|
1031
|
+
super(We, new I([new G(e), n]));
|
|
1103
1032
|
}
|
|
1104
1033
|
_toCDN(e, t) {
|
|
1105
1034
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1106
1035
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1107
|
-
return i instanceof
|
|
1036
|
+
return i instanceof G ? `${r}${c(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1108
1037
|
}
|
|
1109
|
-
},
|
|
1038
|
+
}, B = class extends O {
|
|
1110
1039
|
inner;
|
|
1111
1040
|
ednSource;
|
|
1112
1041
|
constructor(e, t) {
|
|
@@ -1120,26 +1049,135 @@ var Ue = 999n, We = class extends P {
|
|
|
1120
1049
|
}
|
|
1121
1050
|
_toCDN(e, t) {
|
|
1122
1051
|
let n = e?.encodingIndicators ?? "auto";
|
|
1123
|
-
return e?.appStrings !== !1 && n === "auto" && (
|
|
1052
|
+
return e?.appStrings !== !1 && n === "auto" && (v(e) !== null || !/[\r\n]/.test(this.ednSource)) ? this.ednSource : this.inner._toCDN(e, t);
|
|
1124
1053
|
}
|
|
1125
1054
|
_toJS(e) {
|
|
1126
1055
|
return this.inner._toJS(e);
|
|
1127
1056
|
}
|
|
1128
|
-
}, Ke = 888n
|
|
1129
|
-
|
|
1130
|
-
|
|
1057
|
+
}, Ke = 888n;
|
|
1058
|
+
function qe(e, t, n, r) {
|
|
1059
|
+
return n ? [...(e.comments?.trailing ?? []).map((e) => o(e, r)), ...(t.comments?.leading ?? []).map((e) => o(e, r))] : [];
|
|
1060
|
+
}
|
|
1061
|
+
function Je(e, t, n, r) {
|
|
1062
|
+
return n === null || !t.some((e) => e.length > 0) ? e.join(" + ") : f(e, n, r, t);
|
|
1063
|
+
}
|
|
1064
|
+
function Ye(e, t, n, i) {
|
|
1065
|
+
if (e === void 0) return;
|
|
1066
|
+
let a = t?.preserveComments || i === void 0 ? e : r(e, i);
|
|
1067
|
+
return Ze(a, n) ? a : void 0;
|
|
1068
|
+
}
|
|
1069
|
+
function Xe(e, t) {
|
|
1070
|
+
return e !== void 0 && Ze(e, t);
|
|
1071
|
+
}
|
|
1072
|
+
function Ze(e, t) {
|
|
1073
|
+
return t !== null || !/[\r\n]/.test(e);
|
|
1074
|
+
}
|
|
1075
|
+
var V = class e extends M {
|
|
1076
|
+
realBoundary;
|
|
1077
|
+
fromByteLiteral;
|
|
1078
|
+
literalSource;
|
|
1079
|
+
constructor(e, t) {
|
|
1080
|
+
Array.isArray(e) ? (super(Ke, new I(e)), this.fromByteLiteral = !1, this.literalSource = void 0, this.realBoundary = t) : (super(Ke, R.NULL), this.fromByteLiteral = e ?? !1, this.literalSource = t, this.realBoundary = void 0);
|
|
1131
1081
|
}
|
|
1132
1082
|
_toCDN(e, t) {
|
|
1133
1083
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1134
|
-
if (this.content instanceof
|
|
1135
|
-
if (this.content instanceof
|
|
1136
|
-
let n =
|
|
1137
|
-
|
|
1084
|
+
if (this.content instanceof R) return "...";
|
|
1085
|
+
if (this.content instanceof I) {
|
|
1086
|
+
let n = !!e?.preserveConcatenation;
|
|
1087
|
+
if (n || e?.preserveByteString && !this._hasRealConcatenation()) {
|
|
1088
|
+
let n = this._renderPreservedBytesElision(e, t);
|
|
1089
|
+
if (n !== void 0) return n;
|
|
1090
|
+
}
|
|
1091
|
+
if (!n || this.realBoundary === void 0) {
|
|
1092
|
+
let e = this._compactHexElided();
|
|
1093
|
+
if (e !== void 0) return e;
|
|
1094
|
+
}
|
|
1095
|
+
let r = this.content.items, i = r.map((r) => n ? this._renderFragment(r, e, t) : r._toCDN(e, t)), a = !!e?.preserveComments, o = typeof e?.preserveComments == "string" ? e.preserveComments : void 0;
|
|
1096
|
+
return Je(i, r.slice(1).map((e, t) => qe(r[t], e, a, o)), v(e), t);
|
|
1138
1097
|
}
|
|
1139
1098
|
return super._toCDN(e, t);
|
|
1140
1099
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1100
|
+
_hasRealConcatenation() {
|
|
1101
|
+
return this.realBoundary?.some((e, t) => t > 0 && e) ? !0 : this.content.items.some((e) => e instanceof N && e.ednParts !== void 0 && e.ednParts.length > 1);
|
|
1102
|
+
}
|
|
1103
|
+
_renderFragment(e, t, n) {
|
|
1104
|
+
let r = v(t), i = !!t?.preserveComments, a = typeof t?.preserveComments == "string" ? t.preserveComments : void 0;
|
|
1105
|
+
if (e instanceof N && e.ednParts !== void 0 && e.ednParts.length > 1) {
|
|
1106
|
+
let o = t?.appStrings === !1 ? "hex" : t?.bstrEncoding ?? e.ednEncoding;
|
|
1107
|
+
return Je(e.ednParts.map((e) => {
|
|
1108
|
+
let n = t?.preserveByteString ? Ye(e.source, t, r, e.commentSyntax) : void 0;
|
|
1109
|
+
return n === void 0 ? oe(e.bytes, o, t?.sqstr) : n;
|
|
1110
|
+
}), i ? ne(e.comments?.dangling, e.ednParts, a) ?? [] : [], r, n);
|
|
1111
|
+
}
|
|
1112
|
+
if (e instanceof G && e.ednParts !== void 0 && e.ednParts.length > 1) {
|
|
1113
|
+
let o = t?.preserveRawString ? e.ednPartSources : void 0;
|
|
1114
|
+
return Je(e.ednParts.map((e, t) => {
|
|
1115
|
+
let n = o?.[t];
|
|
1116
|
+
return Xe(n, r) ? n : ee(e);
|
|
1117
|
+
}), i ? ne(e.comments?.dangling, e.ednPartSpans, a) ?? [] : [], r, n);
|
|
1118
|
+
}
|
|
1119
|
+
return e._toCDN(t, n);
|
|
1120
|
+
}
|
|
1121
|
+
_compactHexElided() {
|
|
1122
|
+
let t = this.content.items, n = "", r = !1;
|
|
1123
|
+
for (let i of t) if (i instanceof N) n += y(i.value), r = !0;
|
|
1124
|
+
else if (i instanceof e && i.content instanceof R) n += "...";
|
|
1125
|
+
else return;
|
|
1126
|
+
if (r) return `h'${n}'`;
|
|
1127
|
+
}
|
|
1128
|
+
_renderPreservedBytesElision(t, n) {
|
|
1129
|
+
if (this.realBoundary === void 0) return;
|
|
1130
|
+
let r = this.realBoundary, i = this.content.items, a = [], o = [], s = [], c = (e) => {
|
|
1131
|
+
s.length > 0 && (a.push(s), o.push(e ?? []), s = []);
|
|
1132
|
+
}, l = !!t?.preserveComments, u = typeof t?.preserveComments == "string" ? t.preserveComments : void 0;
|
|
1133
|
+
for (let t = 0; t < i.length; t++) {
|
|
1134
|
+
let n = i[t];
|
|
1135
|
+
if (t > 0 && r[t] && c(qe(i[t - 1], n, l, u)), n instanceof e && n.content instanceof R) s.push({
|
|
1136
|
+
ellipsis: !0,
|
|
1137
|
+
fromByteLiteral: n.fromByteLiteral,
|
|
1138
|
+
literalSource: n.literalSource
|
|
1139
|
+
});
|
|
1140
|
+
else if (n instanceof N) if (n.ednParts !== void 0 && n.ednParts.length > 1) {
|
|
1141
|
+
let [e, ...t] = n.ednParts;
|
|
1142
|
+
s.push({
|
|
1143
|
+
bytes: e.bytes,
|
|
1144
|
+
source: e.source,
|
|
1145
|
+
commentSyntax: e.commentSyntax
|
|
1146
|
+
});
|
|
1147
|
+
let r = l ? ne(n.comments?.dangling, n.ednParts, u) : void 0;
|
|
1148
|
+
t.forEach((e, t) => {
|
|
1149
|
+
c(r?.[t]), s.push({
|
|
1150
|
+
bytes: e.bytes,
|
|
1151
|
+
source: e.source,
|
|
1152
|
+
commentSyntax: e.commentSyntax
|
|
1153
|
+
});
|
|
1154
|
+
});
|
|
1155
|
+
} else s.push({
|
|
1156
|
+
bytes: n.value,
|
|
1157
|
+
source: n.ednSource,
|
|
1158
|
+
commentSyntax: n.ednCommentSyntax
|
|
1159
|
+
});
|
|
1160
|
+
else return;
|
|
1161
|
+
}
|
|
1162
|
+
if (s.length > 0 && a.push(s), a.length === 0) return;
|
|
1163
|
+
let d = t?.appStrings === !1 ? "hex" : t?.bstrEncoding ?? "hex", f = v(t);
|
|
1164
|
+
return Je(a.map((e) => {
|
|
1165
|
+
if (t?.preserveByteString) for (let n of e) {
|
|
1166
|
+
if (!("ellipsis" in n)) continue;
|
|
1167
|
+
let e = Ye(n.literalSource, t, f, "full");
|
|
1168
|
+
if (e !== void 0) return e;
|
|
1169
|
+
}
|
|
1170
|
+
let n = e.filter((e) => !("ellipsis" in e));
|
|
1171
|
+
if (n.length === 0) return e.some((e) => "ellipsis" in e && e.fromByteLiteral) ? "h'...'" : "...";
|
|
1172
|
+
if (e.length === 1) {
|
|
1173
|
+
let e = n[0], r = t?.preserveByteString ? Ye(e.source, t, f, e.commentSyntax) : void 0;
|
|
1174
|
+
return r === void 0 ? oe(e.bytes, d, t?.sqstr) : r;
|
|
1175
|
+
}
|
|
1176
|
+
return `h'${e.map((e) => "ellipsis" in e ? "..." : y(e.bytes)).join("")}'`;
|
|
1177
|
+
}), o, f, n);
|
|
1178
|
+
}
|
|
1179
|
+
}, Qe = 2n, $e = 3n, et = 18446744073709551615n, tt = -18446744073709551616n;
|
|
1180
|
+
function nt(e) {
|
|
1143
1181
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1144
1182
|
if (e === 0n) return /* @__PURE__ */ new Uint8Array();
|
|
1145
1183
|
let t = e.toString(16);
|
|
@@ -1148,16 +1186,16 @@ function Ze(e) {
|
|
|
1148
1186
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1149
1187
|
return n;
|
|
1150
1188
|
}
|
|
1151
|
-
function
|
|
1189
|
+
function rt(e) {
|
|
1152
1190
|
let t = 0n;
|
|
1153
1191
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1154
1192
|
return t;
|
|
1155
1193
|
}
|
|
1156
|
-
var
|
|
1194
|
+
var it = class extends M {
|
|
1157
1195
|
bigValue;
|
|
1158
1196
|
constructor(e) {
|
|
1159
|
-
if (e <=
|
|
1160
|
-
super(
|
|
1197
|
+
if (e <= et) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1198
|
+
super(Qe, new N(nt(e))), this.bigValue = e;
|
|
1161
1199
|
}
|
|
1162
1200
|
_toCDN(e, t) {
|
|
1163
1201
|
return this.bigValue.toString();
|
|
@@ -1165,11 +1203,11 @@ var $e = class extends P {
|
|
|
1165
1203
|
_toJS(e) {
|
|
1166
1204
|
return this.bigValue;
|
|
1167
1205
|
}
|
|
1168
|
-
},
|
|
1206
|
+
}, at = class extends M {
|
|
1169
1207
|
bigValue;
|
|
1170
1208
|
constructor(e) {
|
|
1171
|
-
if (e >=
|
|
1172
|
-
super(
|
|
1209
|
+
if (e >= tt) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1210
|
+
super($e, new N(nt(-1n - e))), this.bigValue = e;
|
|
1173
1211
|
}
|
|
1174
1212
|
_toCDN(e, t) {
|
|
1175
1213
|
return this.bigValue.toString();
|
|
@@ -1177,25 +1215,59 @@ var $e = class extends P {
|
|
|
1177
1215
|
_toJS(e) {
|
|
1178
1216
|
return this.bigValue;
|
|
1179
1217
|
}
|
|
1180
|
-
},
|
|
1181
|
-
function
|
|
1182
|
-
let n = new
|
|
1218
|
+
}, ot = new TextEncoder(), st = new TextDecoder("utf-8", { fatal: !0 }), ct = new TextDecoder("utf-8", { fatal: !1 });
|
|
1219
|
+
function lt(e, t) {
|
|
1220
|
+
let n = new re(e, {
|
|
1183
1221
|
offset: t?.offset,
|
|
1184
1222
|
skipRS: t?._skipRS
|
|
1185
|
-
}), r = new
|
|
1186
|
-
return t?.preserveComments &&
|
|
1223
|
+
}), r = new Dt(n, t ?? {}).parse();
|
|
1224
|
+
return (t?.preserveComments || t?.preserveAll) && (bt(r, n.comments, e), U(r)), r;
|
|
1187
1225
|
}
|
|
1188
|
-
function
|
|
1226
|
+
function ut(e) {
|
|
1189
1227
|
let t = e, n;
|
|
1190
1228
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1191
1229
|
numStr: t,
|
|
1192
1230
|
rawSuffix: n
|
|
1193
1231
|
};
|
|
1194
1232
|
}
|
|
1195
|
-
function
|
|
1233
|
+
function dt(e) {
|
|
1196
1234
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1197
1235
|
}
|
|
1198
|
-
function
|
|
1236
|
+
function H(e) {
|
|
1237
|
+
if (e !== void 0) return pt([e.appSeqSourceFeatures, ft(e)]);
|
|
1238
|
+
}
|
|
1239
|
+
function ft(e) {
|
|
1240
|
+
if (e instanceof N) return {
|
|
1241
|
+
byteString: !0,
|
|
1242
|
+
concatenation: e.ednParts !== void 0 && e.ednParts.length > 1
|
|
1243
|
+
};
|
|
1244
|
+
if (e instanceof G) {
|
|
1245
|
+
let t = e.ednParts !== void 0, n = e.ednPartSources?.filter((e) => e !== void 0).length ?? 0, r = t ? e.ednParts.reduce((t, n, r) => {
|
|
1246
|
+
let i = e.ednPartSources?.[r] !== void 0, a = e.ednPartIsByteString?.[r] ?? !1;
|
|
1247
|
+
return i || !a ? t : t + 1;
|
|
1248
|
+
}, 0) : 0, i = (t ? e.ednParts.length : 0) - n - r;
|
|
1249
|
+
return {
|
|
1250
|
+
byteString: r > 0,
|
|
1251
|
+
textString: e.quotedEdnSource !== void 0 || i > 0,
|
|
1252
|
+
rawString: e.ednSource !== void 0 || n > 0,
|
|
1253
|
+
concatenation: t && e.ednParts.length > 1
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
if (e instanceof I) return pt(e.items.map(H));
|
|
1257
|
+
if (e instanceof L) return pt(e.entries.flatMap(([e, t]) => [H(e), H(t)]));
|
|
1258
|
+
if (e instanceof M) return H(e.content);
|
|
1259
|
+
if (e instanceof P || e instanceof F || e instanceof z) return pt((e instanceof z ? e.items : e.chunks).map(H));
|
|
1260
|
+
}
|
|
1261
|
+
function pt(e) {
|
|
1262
|
+
let t = e.filter((e) => e !== void 0);
|
|
1263
|
+
if (t.length !== 0) return {
|
|
1264
|
+
byteString: t.some((e) => e.byteString),
|
|
1265
|
+
textString: t.some((e) => e.textString),
|
|
1266
|
+
rawString: t.some((e) => e.rawString),
|
|
1267
|
+
concatenation: t.some((e) => e.concatenation)
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
function mt(e, t) {
|
|
1199
1271
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1200
1272
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1201
1273
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1219,72 +1291,162 @@ function st(e, t) {
|
|
|
1219
1291
|
};
|
|
1220
1292
|
let n = e, r;
|
|
1221
1293
|
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) ? {
|
|
1222
|
-
value:
|
|
1294
|
+
value: Me(n),
|
|
1223
1295
|
precision: r
|
|
1224
1296
|
} : {
|
|
1225
1297
|
value: parseFloat(n),
|
|
1226
1298
|
precision: r
|
|
1227
1299
|
};
|
|
1228
1300
|
}
|
|
1229
|
-
|
|
1301
|
+
var ht = /\r?\n[ \t]*\r?\n/;
|
|
1302
|
+
function gt(e, t, n) {
|
|
1303
|
+
return ht.test(e.slice(t, n));
|
|
1304
|
+
}
|
|
1305
|
+
function _t(e, t, n, r) {
|
|
1306
|
+
let i = [];
|
|
1307
|
+
for (let a = t; a < e.length; a++) {
|
|
1308
|
+
let t = e[a];
|
|
1309
|
+
if (t.start >= r) break;
|
|
1310
|
+
t.start >= n && t.end <= r && i.push({
|
|
1311
|
+
...t,
|
|
1312
|
+
start: t.start - n,
|
|
1313
|
+
end: t.end - n
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
return i;
|
|
1317
|
+
}
|
|
1318
|
+
function vt(e, t, n, r) {
|
|
1319
|
+
if (n.end !== void 0) return {
|
|
1320
|
+
start: (/_[0-7i]$/.test(e.slice(Math.max(0, n.end - 2), n.end)) ? n.end - 2 : n.end) - t,
|
|
1321
|
+
end: n.end - t,
|
|
1322
|
+
always: r,
|
|
1323
|
+
never: ""
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
function yt(e, t, n) {
|
|
1327
|
+
if (n instanceof k) {
|
|
1328
|
+
let r = vt(e, t, n, `_${n.encodingWidth ?? p(n.value)}`);
|
|
1329
|
+
return r ? [r] : [];
|
|
1330
|
+
}
|
|
1331
|
+
if (n instanceof A) {
|
|
1332
|
+
let r = vt(e, t, n, `_${n.encodingWidth ?? p(n.argument)}`);
|
|
1333
|
+
return r ? [r] : [];
|
|
1334
|
+
}
|
|
1335
|
+
if (n instanceof j) {
|
|
1336
|
+
let r = n.precision ?? D(n.value), i = vt(e, t, n, r === "half" ? "_1" : r === "single" ? "_2" : "_3");
|
|
1337
|
+
return i ? [i] : [];
|
|
1338
|
+
}
|
|
1339
|
+
if (n instanceof N) {
|
|
1340
|
+
let r = vt(e, t, n, `_${n.encodingWidth ?? p(BigInt(n.value.length))}`);
|
|
1341
|
+
return r ? [r] : [];
|
|
1342
|
+
}
|
|
1343
|
+
if (n instanceof G) {
|
|
1344
|
+
let r = vt(e, t, n, `_${n.encodingWidth ?? p(BigInt(ot.encode(n.value).length))}`);
|
|
1345
|
+
return r ? [r] : [];
|
|
1346
|
+
}
|
|
1347
|
+
if (n instanceof I) {
|
|
1348
|
+
let r = [];
|
|
1349
|
+
if (n.indefiniteLength) return;
|
|
1350
|
+
if (n.start !== void 0) {
|
|
1351
|
+
let i = new re(e, { offset: n.start }), a = i.consume(), o = i.peek(), s = o.type === "ENCODING_INDICATOR", c = `_${n.encodingWidth ?? p(BigInt(n.items.length))}`, l = e[a.endOffset] ?? "", u = !s && /[+\-.0-9A-Z_a-z]/.test(l) ? " " : "";
|
|
1352
|
+
r.push({
|
|
1353
|
+
start: (s ? o.offset : a.endOffset) - t,
|
|
1354
|
+
end: (s ? o.endOffset : a.endOffset) - t,
|
|
1355
|
+
always: c + u,
|
|
1356
|
+
never: ""
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
for (let i of n.items) {
|
|
1360
|
+
let n = yt(e, t, i);
|
|
1361
|
+
if (n === void 0) return;
|
|
1362
|
+
r.push(...n);
|
|
1363
|
+
}
|
|
1364
|
+
return r;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
function bt(e, t, n) {
|
|
1230
1368
|
if (t.length === 0) return;
|
|
1231
|
-
let r =
|
|
1232
|
-
for (let
|
|
1233
|
-
let
|
|
1234
|
-
for (;
|
|
1235
|
-
let
|
|
1236
|
-
o[
|
|
1237
|
-
}
|
|
1238
|
-
let
|
|
1239
|
-
if (
|
|
1240
|
-
|
|
1369
|
+
let r = xt(e), i = Ct(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;
|
|
1370
|
+
for (let e of s) {
|
|
1371
|
+
let t = { ...e }, r = 0, s = o.length;
|
|
1372
|
+
for (; r < s;) {
|
|
1373
|
+
let t = r + s >> 1;
|
|
1374
|
+
o[t].end <= e.start ? r = t + 1 : s = t;
|
|
1375
|
+
}
|
|
1376
|
+
let u = r > 0 ? o[r - 1] : void 0, d = u ? n.slice(u.end, e.start) : "";
|
|
1377
|
+
if (u && i(u.end) === e.line && !d.includes(":")) {
|
|
1378
|
+
St(u.node, "trailing", t);
|
|
1241
1379
|
continue;
|
|
1242
1380
|
}
|
|
1243
|
-
for (; l < a.length && a[l].start <
|
|
1381
|
+
for (; l < a.length && a[l].start < e.start;) {
|
|
1244
1382
|
let e = a[l++];
|
|
1245
1383
|
for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
|
|
1246
1384
|
c.push(e);
|
|
1247
1385
|
}
|
|
1248
|
-
for (; c.length > 0 && c[c.length - 1].end <=
|
|
1249
|
-
let
|
|
1250
|
-
for (
|
|
1251
|
-
let
|
|
1252
|
-
a[
|
|
1386
|
+
for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
|
|
1387
|
+
let f = c.length > 0 ? c[c.length - 1] : void 0;
|
|
1388
|
+
for (r = 0, s = a.length; r < s;) {
|
|
1389
|
+
let t = r + s >> 1;
|
|
1390
|
+
a[t].start < e.end ? r = t + 1 : s = t;
|
|
1253
1391
|
}
|
|
1254
|
-
let
|
|
1255
|
-
if ((!
|
|
1256
|
-
|
|
1392
|
+
let p = r < a.length ? a[r] : void 0;
|
|
1393
|
+
if ((!f || p && p.end <= f.end) && p) {
|
|
1394
|
+
t.sameLine = i(e.end) === i(p.start), St(p.node, "leading", t);
|
|
1257
1395
|
continue;
|
|
1258
1396
|
}
|
|
1259
|
-
|
|
1397
|
+
f && St(f.node, "dangling", t);
|
|
1260
1398
|
}
|
|
1261
1399
|
}
|
|
1262
|
-
function
|
|
1400
|
+
function xt(e) {
|
|
1263
1401
|
let t = [], n = (e) => {
|
|
1264
1402
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1265
1403
|
node: e,
|
|
1266
1404
|
start: e.start,
|
|
1267
1405
|
end: e.end
|
|
1268
|
-
}), e instanceof
|
|
1406
|
+
}), e instanceof I || e instanceof z) {
|
|
1269
1407
|
for (let t of e.items) n(t);
|
|
1270
1408
|
return;
|
|
1271
1409
|
}
|
|
1272
|
-
if (e instanceof
|
|
1410
|
+
if (e instanceof L) {
|
|
1273
1411
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1274
1412
|
return;
|
|
1275
1413
|
}
|
|
1276
|
-
if (e instanceof
|
|
1414
|
+
if (e instanceof P || e instanceof F) {
|
|
1277
1415
|
for (let t of e.chunks) n(t);
|
|
1278
1416
|
return;
|
|
1279
1417
|
}
|
|
1280
|
-
e instanceof
|
|
1418
|
+
e instanceof M && n(e.content);
|
|
1281
1419
|
};
|
|
1282
1420
|
return n(e), t;
|
|
1283
1421
|
}
|
|
1284
|
-
function
|
|
1422
|
+
function St(e, t, n) {
|
|
1285
1423
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1286
1424
|
}
|
|
1287
|
-
function
|
|
1425
|
+
function U(e) {
|
|
1426
|
+
if (e instanceof V) {
|
|
1427
|
+
if (e.content instanceof I) {
|
|
1428
|
+
let t = e.content.items;
|
|
1429
|
+
for (let e of t) U(e);
|
|
1430
|
+
let n = t[t.length - 1], r = n?.comments?.trailing;
|
|
1431
|
+
r !== void 0 && r.length > 0 && !e.comments?.trailing?.length && (e.comments ??= {}, e.comments.trailing = r, n.comments.trailing = void 0);
|
|
1432
|
+
}
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
if (e instanceof I || e instanceof z) {
|
|
1436
|
+
for (let t of e.items) U(t);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
if (e instanceof L) {
|
|
1440
|
+
for (let [t, n] of e.entries) U(t), U(n);
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
if (e instanceof P || e instanceof F) {
|
|
1444
|
+
for (let t of e.chunks) U(t);
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
e instanceof M && U(e.content);
|
|
1448
|
+
}
|
|
1449
|
+
function Ct(e) {
|
|
1288
1450
|
let t = [0];
|
|
1289
1451
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1290
1452
|
return (n) => {
|
|
@@ -1298,25 +1460,25 @@ function dt(e) {
|
|
|
1298
1460
|
return a + 1;
|
|
1299
1461
|
};
|
|
1300
1462
|
}
|
|
1301
|
-
var
|
|
1302
|
-
["b32",
|
|
1303
|
-
["h32",
|
|
1304
|
-
["same",
|
|
1305
|
-
["hash",
|
|
1306
|
-
["uuid",
|
|
1307
|
-
["UUID",
|
|
1308
|
-
["dt",
|
|
1309
|
-
["DT",
|
|
1310
|
-
["ip",
|
|
1311
|
-
["IP",
|
|
1312
|
-
["cri",
|
|
1313
|
-
["CRI",
|
|
1314
|
-
["t1",
|
|
1315
|
-
["b1",
|
|
1316
|
-
["ilbs",
|
|
1317
|
-
["ilts",
|
|
1318
|
-
["float",
|
|
1319
|
-
]),
|
|
1463
|
+
var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, Tt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, W = (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)`, Et = /* @__PURE__ */ new Map([
|
|
1464
|
+
["b32", wt("b32")],
|
|
1465
|
+
["h32", wt("h32")],
|
|
1466
|
+
["same", wt("same")],
|
|
1467
|
+
["hash", Tt("hash", "@cbortech/hash-extension")],
|
|
1468
|
+
["uuid", Tt("uuid", "@cbortech/uuid-extension")],
|
|
1469
|
+
["UUID", Tt("uuid", "@cbortech/uuid-extension")],
|
|
1470
|
+
["dt", W("dt")],
|
|
1471
|
+
["DT", W("dt")],
|
|
1472
|
+
["ip", W("ip")],
|
|
1473
|
+
["IP", W("ip")],
|
|
1474
|
+
["cri", W("cri")],
|
|
1475
|
+
["CRI", W("cri")],
|
|
1476
|
+
["t1", W("t1")],
|
|
1477
|
+
["b1", W("b1")],
|
|
1478
|
+
["ilbs", W("ilbs")],
|
|
1479
|
+
["ilts", W("ilts")],
|
|
1480
|
+
["float", W("float")]
|
|
1481
|
+
]), Dt = class {
|
|
1320
1482
|
t;
|
|
1321
1483
|
_options;
|
|
1322
1484
|
extByPrefix;
|
|
@@ -1324,24 +1486,24 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1324
1486
|
unresolvedExtension;
|
|
1325
1487
|
_pendingWarnings = [];
|
|
1326
1488
|
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1327
|
-
constructor(e,
|
|
1328
|
-
this.t = e, this._options =
|
|
1329
|
-
let
|
|
1330
|
-
for (let e of [...
|
|
1489
|
+
constructor(e, n) {
|
|
1490
|
+
this.t = e, this._options = n, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = n.unresolvedExtension ?? "cpa999";
|
|
1491
|
+
let r = Z(n.builtinExtensions);
|
|
1492
|
+
for (let e of [...r, ...n.extensions ?? []]) {
|
|
1331
1493
|
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1332
1494
|
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1333
1495
|
}
|
|
1334
|
-
this.t.onEscapeWarning = (e,
|
|
1496
|
+
this.t.onEscapeWarning = (e, n, r, i, a) => {
|
|
1335
1497
|
let o = {
|
|
1336
1498
|
message: e,
|
|
1337
|
-
offset:
|
|
1338
|
-
line:
|
|
1499
|
+
offset: n,
|
|
1500
|
+
line: r,
|
|
1339
1501
|
column: i,
|
|
1340
1502
|
endOffset: a
|
|
1341
1503
|
};
|
|
1342
|
-
if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${
|
|
1343
|
-
offset:
|
|
1344
|
-
line:
|
|
1504
|
+
if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${r}, column ${i}: ${e}`), this._options.strict !== !1) throw new t(e, {
|
|
1505
|
+
offset: n,
|
|
1506
|
+
line: r,
|
|
1345
1507
|
column: i,
|
|
1346
1508
|
endOffset: a
|
|
1347
1509
|
});
|
|
@@ -1376,13 +1538,13 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1376
1538
|
case "RAWSTRING": return this.parseString();
|
|
1377
1539
|
case "BYTES_HEX":
|
|
1378
1540
|
case "SQSTR":
|
|
1379
|
-
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1380
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1381
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1382
|
-
case "TRUE": return this.t.consume(), new
|
|
1383
|
-
case "FALSE": return this.t.consume(), new
|
|
1384
|
-
case "NULL": return this.t.consume(), new
|
|
1385
|
-
case "UNDEFINED": return this.t.consume(), new
|
|
1541
|
+
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw, e.offset, e.endOffset);
|
|
1542
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new P([]);
|
|
1543
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new F([]);
|
|
1544
|
+
case "TRUE": return this.t.consume(), new R(21);
|
|
1545
|
+
case "FALSE": return this.t.consume(), new R(20);
|
|
1546
|
+
case "NULL": return this.t.consume(), new R(22);
|
|
1547
|
+
case "UNDEFINED": return this.t.consume(), new R(23);
|
|
1386
1548
|
case "SIMPLE": return this.parseSimple();
|
|
1387
1549
|
case "LBRACKET": return this.parseArray();
|
|
1388
1550
|
case "LBRACE": return this.parseMap();
|
|
@@ -1397,54 +1559,57 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1397
1559
|
}
|
|
1398
1560
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1399
1561
|
if (!r?.parseAppString) {
|
|
1400
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1562
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, [new G(e.value)]);
|
|
1401
1563
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1402
1564
|
}
|
|
1403
1565
|
{
|
|
1404
1566
|
let i = this._pendingWarnings.length;
|
|
1405
1567
|
try {
|
|
1406
1568
|
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1407
|
-
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof
|
|
1569
|
+
return t !== void 0 && this._applyEiToResult(i, t, e), r.preserveAppSeqSource === "optional" ? (i.appSeqSource = e.raw + n, i) : i instanceof N && Object.getPrototypeOf(i) === N.prototype && i.ednSource === void 0 ? new N(i.value, {
|
|
1408
1570
|
ednEncoding: i.ednEncoding,
|
|
1409
1571
|
encodingWidth: i.encodingWidth,
|
|
1410
|
-
ednSource: e.raw + n
|
|
1411
|
-
|
|
1572
|
+
ednSource: e.raw + n,
|
|
1573
|
+
ednCommentSyntax: r === Ve || r === He ? "full" : void 0
|
|
1574
|
+
}) : (i instanceof j && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1412
1575
|
} catch (t) {
|
|
1413
1576
|
if (this._options.strict !== !1) throw t;
|
|
1414
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1577
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ge(e.appPrefix, [new G(e.value)]);
|
|
1415
1578
|
}
|
|
1416
1579
|
}
|
|
1417
1580
|
}
|
|
1418
1581
|
case "APP_SEQUENCE": {
|
|
1582
|
+
let t = this.t.comments.length;
|
|
1419
1583
|
this.t.consume();
|
|
1420
|
-
let
|
|
1584
|
+
let n = [];
|
|
1421
1585
|
for (; this.t.peek().type !== "GT_GT";) {
|
|
1422
|
-
if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e),
|
|
1586
|
+
if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), n.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1423
1587
|
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1424
1588
|
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1425
|
-
|
|
1589
|
+
n.push(this.parseValue());
|
|
1426
1590
|
}
|
|
1427
1591
|
this.expect("GT_GT");
|
|
1428
|
-
let
|
|
1429
|
-
this.t.peek().type === "ENCODING_INDICATOR" && (
|
|
1430
|
-
let
|
|
1431
|
-
if (!
|
|
1432
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1592
|
+
let r, i;
|
|
1593
|
+
this.t.peek().type === "ENCODING_INDICATOR" && (i = this.t.consume(), r = this._resolveEncodingWidth(i.value, i));
|
|
1594
|
+
let a = this.extByPrefix.get(e.appPrefix);
|
|
1595
|
+
if (!a) {
|
|
1596
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, n);
|
|
1433
1597
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1434
1598
|
}
|
|
1435
|
-
|
|
1599
|
+
a.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
1436
1600
|
{
|
|
1437
|
-
let
|
|
1601
|
+
let o = this._pendingWarnings.length;
|
|
1438
1602
|
try {
|
|
1439
|
-
let
|
|
1440
|
-
|
|
1441
|
-
let
|
|
1442
|
-
if (a
|
|
1443
|
-
else if (
|
|
1444
|
-
return
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1603
|
+
let o = a.parseAppSequence(e.appPrefix, n, this._extOnError(e));
|
|
1604
|
+
r !== void 0 && this._applyEiToResult(o, r, i ?? e);
|
|
1605
|
+
let s = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1606
|
+
if (a.preserveAppSeqSource === "optional") o.appSeqSource = s, o.appSeqComments = _t(this.t.comments, t, e.offset, this.t.lastEndOffset), n.length === 1 && (n[0].end !== void 0 && (o.appSeqInnerEnd = n[0].end - e.offset), o.appSeqSourceFeatures = H(n[0]));
|
|
1607
|
+
else if (o instanceof j) o.ednSource === void 0 && (o.ednSource = s);
|
|
1608
|
+
else if (a.preserveAppSeqSource) return new B(o, s);
|
|
1609
|
+
return o;
|
|
1610
|
+
} catch (t) {
|
|
1611
|
+
if (this._options.strict !== !1) throw t;
|
|
1612
|
+
return this._pendingWarnings.length === o && this._warn(t instanceof Error ? t.message : String(t), e), new Ge(e.appPrefix, n);
|
|
1448
1613
|
}
|
|
1449
1614
|
}
|
|
1450
1615
|
}
|
|
@@ -1452,99 +1617,163 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1452
1617
|
if (this.t.consume(), this.t.peek().type !== "PLUS") return new V();
|
|
1453
1618
|
let e = [new V()];
|
|
1454
1619
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1455
|
-
return new V(e);
|
|
1620
|
+
return new V(e, e.map(() => !0));
|
|
1456
1621
|
}
|
|
1457
1622
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1458
1623
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1459
1624
|
}
|
|
1460
1625
|
}
|
|
1461
1626
|
parseIntegerOrTag() {
|
|
1462
|
-
let e = this.t.consume(), { numStr:
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
if (
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1627
|
+
let e = this.t.comments.length, t = this.t.consume(), { numStr: n, rawSuffix: r } = ut(t.value), i = r === void 0 ? t.endOffset : t.endOffset - 2, a = t.endOffset, o = r === void 0 ? this.consumeEncodingIndicator(void 0, (e) => {
|
|
1628
|
+
i = e.offset, a = e.endOffset;
|
|
1629
|
+
}) : this._resolveEncodingWidth(r, t), s = dt(n), c = r === void 0 ? t.raw : t.raw.slice(0, -2);
|
|
1630
|
+
if (s > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", t), new it(s);
|
|
1631
|
+
if (s < -18446744073709551616n) return new at(s);
|
|
1632
|
+
if (o !== void 0) {
|
|
1633
|
+
let e = s >= 0n ? s : -(s + 1n);
|
|
1634
|
+
o = this._validateEncodingFit(e, o, t);
|
|
1635
|
+
}
|
|
1636
|
+
let l = s >= 0n ? new k(s, {
|
|
1637
|
+
encodingWidth: o,
|
|
1638
|
+
ednSource: c
|
|
1639
|
+
}) : new A(s, {
|
|
1640
|
+
encodingWidth: o,
|
|
1641
|
+
ednSource: c
|
|
1642
|
+
});
|
|
1470
1643
|
if (this.t.peek().type === "LPAREN") {
|
|
1471
|
-
|
|
1472
|
-
let
|
|
1644
|
+
l instanceof k || this._fail("tag number must be non-negative", t), this.t.consume();
|
|
1645
|
+
let n = this._pendingWarnings.splice(0), r = this.parseValue();
|
|
1473
1646
|
this.expect("RPAREN");
|
|
1474
|
-
let
|
|
1475
|
-
if (
|
|
1476
|
-
let
|
|
1477
|
-
if (
|
|
1647
|
+
let s = l.value, u = this.extByTag.get(s);
|
|
1648
|
+
if (u?.parseTag) {
|
|
1649
|
+
let l = u.parseTag(s, r);
|
|
1650
|
+
if (l !== void 0) {
|
|
1651
|
+
if (l instanceof M && (o !== void 0 && l.encodingWidth === void 0 && (l.encodingWidth = o), l.ednSource === void 0 && (l.ednSource = c), u.preserveAppSeqSource === "optional" && l.appSeqSource === void 0)) {
|
|
1652
|
+
l.appSeqSource = this.t.source.slice(t.offset, this.t.lastEndOffset), l.appSeqComments = _t(this.t.comments, e, t.offset, this.t.lastEndOffset);
|
|
1653
|
+
let n = l.encodingWidth ?? p(l.tag), o = yt(this.t.source, t.offset, l.content);
|
|
1654
|
+
l.appSeqEncodingEdits = [{
|
|
1655
|
+
start: i - t.offset,
|
|
1656
|
+
end: a - t.offset,
|
|
1657
|
+
always: `_${n}`,
|
|
1658
|
+
never: ""
|
|
1659
|
+
}, ...o ?? []], o === void 0 && (l.appSeqEncodingEditsComplete = !1), l.appSeqSourceFeatures = H(r);
|
|
1660
|
+
}
|
|
1661
|
+
return n.length > 0 && (l.warnings ??= [], l.warnings.push(...n)), l;
|
|
1662
|
+
}
|
|
1478
1663
|
}
|
|
1479
|
-
let
|
|
1480
|
-
|
|
1664
|
+
let d = new M(s, r, {
|
|
1665
|
+
encodingWidth: o,
|
|
1666
|
+
ednSource: c
|
|
1667
|
+
});
|
|
1668
|
+
return n.length > 0 && (d.warnings ??= [], d.warnings.push(...n)), d;
|
|
1481
1669
|
}
|
|
1482
|
-
return
|
|
1670
|
+
return l;
|
|
1483
1671
|
}
|
|
1484
1672
|
parseFloat() {
|
|
1485
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1673
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = mt(e.value, t);
|
|
1486
1674
|
if (r === "half" || r === "single") {
|
|
1487
|
-
let e = r === "half" ?
|
|
1675
|
+
let e = r === "half" ? C(S(n)) : Math.fround(n);
|
|
1488
1676
|
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`);
|
|
1489
1677
|
}
|
|
1490
|
-
return new
|
|
1678
|
+
return new j(n, {
|
|
1679
|
+
precision: r,
|
|
1680
|
+
literalSource: e.raw
|
|
1681
|
+
});
|
|
1491
1682
|
}
|
|
1492
1683
|
parseString() {
|
|
1493
1684
|
let e = this.t.consume();
|
|
1494
1685
|
if (this.t.peek().type !== "PLUS") {
|
|
1495
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1496
|
-
return e.type === "RAWSTRING" ? new
|
|
1686
|
+
let t = this.consumeEncodingIndicator(() => BigInt(ot.encode(e.value).length));
|
|
1687
|
+
return e.type === "RAWSTRING" ? new G(e.value, {
|
|
1497
1688
|
ednSource: e.raw,
|
|
1498
1689
|
...t === void 0 ? {} : { encodingWidth: t }
|
|
1499
|
-
}) : new
|
|
1690
|
+
}) : new G(e.value, {
|
|
1691
|
+
quotedEdnSource: e.raw,
|
|
1692
|
+
...t === void 0 ? {} : { encodingWidth: t }
|
|
1693
|
+
});
|
|
1500
1694
|
}
|
|
1501
1695
|
let t = !1, n = [e.type === "RAWSTRING" ? {
|
|
1502
1696
|
text: e.value,
|
|
1503
|
-
source: e.raw
|
|
1504
|
-
|
|
1697
|
+
source: e.raw,
|
|
1698
|
+
start: e.offset,
|
|
1699
|
+
end: e.endOffset
|
|
1700
|
+
} : {
|
|
1701
|
+
text: e.value,
|
|
1702
|
+
start: e.offset,
|
|
1703
|
+
end: e.endOffset
|
|
1704
|
+
}];
|
|
1505
1705
|
for (; this.t.peek().type === "PLUS";) {
|
|
1506
1706
|
this.t.consume();
|
|
1507
1707
|
let e = this.t.peek();
|
|
1508
|
-
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({
|
|
1708
|
+
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({
|
|
1709
|
+
ellipsis: !0,
|
|
1710
|
+
start: e.offset,
|
|
1711
|
+
end: e.endOffset
|
|
1712
|
+
}), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push(e.type === "RAWSTRING" ? {
|
|
1509
1713
|
text: e.value,
|
|
1510
|
-
source: e.raw
|
|
1511
|
-
|
|
1714
|
+
source: e.raw,
|
|
1715
|
+
start: e.offset,
|
|
1716
|
+
end: e.endOffset
|
|
1717
|
+
} : {
|
|
1718
|
+
text: e.value,
|
|
1719
|
+
start: e.offset,
|
|
1720
|
+
end: e.endOffset
|
|
1721
|
+
})) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({
|
|
1722
|
+
text: this._decodeUtf8(this._decodeBytesToken(e), e),
|
|
1723
|
+
isByteString: !0,
|
|
1724
|
+
start: e.offset,
|
|
1725
|
+
end: e.endOffset
|
|
1726
|
+
})) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1512
1727
|
}
|
|
1513
1728
|
if (!t) {
|
|
1514
|
-
let e = n.map((e) => "text" in e ? e.text : ""), t = n.map((e) => "text" in e ? e.source : void 0), r =
|
|
1515
|
-
|
|
1729
|
+
let e = n.map((e) => "text" in e ? e.text : ""), t = n.map((e) => "text" in e ? e.source : void 0), r = n.map((e) => "text" in e ? e.isByteString ?? !1 : !1), i = n.map((e) => ({
|
|
1730
|
+
start: e.start,
|
|
1731
|
+
end: e.end
|
|
1732
|
+
})), a = e.join(""), o = this.consumeEncodingIndicator(() => BigInt(ot.encode(a).length));
|
|
1733
|
+
return new G(a, {
|
|
1516
1734
|
ednParts: e,
|
|
1735
|
+
ednPartSpans: i,
|
|
1517
1736
|
...t.some((e) => e !== void 0) ? { ednPartSources: t } : {},
|
|
1518
|
-
...
|
|
1737
|
+
...r.some((e) => e) ? { ednPartIsByteString: r } : {},
|
|
1738
|
+
...o === void 0 ? {} : { encodingWidth: o }
|
|
1519
1739
|
});
|
|
1520
1740
|
}
|
|
1521
1741
|
let r = [], i = [], a = () => {
|
|
1522
1742
|
let e = i.map((e) => e.text), t = e.join("");
|
|
1523
1743
|
if (t !== "") {
|
|
1524
|
-
let n = i.map((e) => e.source)
|
|
1525
|
-
r.push(new U(t, {
|
|
1744
|
+
let n = i.map((e) => e.source), a = i.map((e) => e.isByteString ?? !1), o = new G(t, {
|
|
1526
1745
|
ednParts: e,
|
|
1527
|
-
|
|
1528
|
-
|
|
1746
|
+
ednPartSpans: i.map((e) => ({
|
|
1747
|
+
start: e.start,
|
|
1748
|
+
end: e.end
|
|
1749
|
+
})),
|
|
1750
|
+
...n.some((e) => e !== void 0) ? { ednPartSources: n } : {},
|
|
1751
|
+
...a.some((e) => e) ? { ednPartIsByteString: a } : {}
|
|
1752
|
+
});
|
|
1753
|
+
o.start = i[0].start, o.end = i[i.length - 1].end, r.push(o);
|
|
1529
1754
|
}
|
|
1530
1755
|
i.length = 0;
|
|
1531
1756
|
};
|
|
1532
|
-
for (let e of n) "ellipsis" in e
|
|
1757
|
+
for (let e of n) if ("ellipsis" in e) {
|
|
1758
|
+
a();
|
|
1759
|
+
let t = new V();
|
|
1760
|
+
t.start = e.start, t.end = e.end, r.push(t);
|
|
1761
|
+
} else i.push(e);
|
|
1533
1762
|
return a(), new V(r);
|
|
1534
1763
|
}
|
|
1535
1764
|
_isBytesToken(e) {
|
|
1536
1765
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
1537
1766
|
}
|
|
1538
|
-
_hexToBytes(
|
|
1767
|
+
_hexToBytes(e, r) {
|
|
1539
1768
|
try {
|
|
1540
|
-
return e
|
|
1769
|
+
return n(e);
|
|
1541
1770
|
} catch (e) {
|
|
1542
|
-
if (e instanceof
|
|
1543
|
-
this._fail(e.message,
|
|
1771
|
+
if (e instanceof t || !(e instanceof SyntaxError)) throw e;
|
|
1772
|
+
this._fail(e.message, r);
|
|
1544
1773
|
}
|
|
1545
1774
|
}
|
|
1546
1775
|
_decodeBytesToken(e) {
|
|
1547
|
-
let
|
|
1776
|
+
let n = (t) => this._warnOrFail(t, e);
|
|
1548
1777
|
switch (e.type) {
|
|
1549
1778
|
case "SQSTR": {
|
|
1550
1779
|
let t = e._sqstrBytes;
|
|
@@ -1552,92 +1781,133 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1552
1781
|
}
|
|
1553
1782
|
case "BYTES_HEX": return this._hexToBytes(e.value, e);
|
|
1554
1783
|
case "BYTES_B64": try {
|
|
1555
|
-
return
|
|
1556
|
-
} catch (
|
|
1557
|
-
if (
|
|
1558
|
-
this._fail(
|
|
1784
|
+
return Ue(e.value, n);
|
|
1785
|
+
} catch (n) {
|
|
1786
|
+
if (n instanceof t || !(n instanceof SyntaxError)) throw n;
|
|
1787
|
+
this._fail(n.message, e);
|
|
1559
1788
|
}
|
|
1560
1789
|
default: this._fail("expected byte string token", e);
|
|
1561
1790
|
}
|
|
1562
1791
|
}
|
|
1563
1792
|
_decodeUtf8(e, t) {
|
|
1564
|
-
if (this._options.allowInvalidUtf8) return
|
|
1793
|
+
if (this._options.allowInvalidUtf8) return ct.decode(e);
|
|
1565
1794
|
try {
|
|
1566
|
-
return
|
|
1795
|
+
return st.decode(e);
|
|
1567
1796
|
} catch {
|
|
1568
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1797
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), ct.decode(e);
|
|
1569
1798
|
}
|
|
1570
1799
|
}
|
|
1571
1800
|
_tokenTypeToCdnEncoding(e) {
|
|
1572
1801
|
return e === "BYTES_B64" ? "base64" : "hex";
|
|
1573
1802
|
}
|
|
1574
|
-
|
|
1803
|
+
_tokenTypeToCommentSyntax(e) {
|
|
1804
|
+
if (e === "BYTES_HEX") return "full";
|
|
1805
|
+
if (e === "BYTES_B64") return "hash-only";
|
|
1806
|
+
}
|
|
1807
|
+
_parseBytesConcat(e, t, n, r, i) {
|
|
1575
1808
|
if (this.t.peek().type !== "PLUS") {
|
|
1576
1809
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1577
|
-
return new
|
|
1810
|
+
return new N(e, {
|
|
1578
1811
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1579
1812
|
ednSource: n,
|
|
1813
|
+
ednCommentSyntax: this._tokenTypeToCommentSyntax(t),
|
|
1580
1814
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
1581
1815
|
});
|
|
1582
1816
|
}
|
|
1583
|
-
let
|
|
1817
|
+
let a = [{
|
|
1584
1818
|
bytes: e,
|
|
1585
|
-
source: n
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
this.t.consume();
|
|
1593
|
-
let t = this._buildBytesElidedItems(e.value, e);
|
|
1594
|
-
for (let e of t) e instanceof V ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof F && i.push({ bytes: e.value });
|
|
1595
|
-
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
|
|
1596
|
-
bytes: this._decodeBytesToken(e),
|
|
1597
|
-
source: e.raw
|
|
1598
|
-
})) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: tt.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1599
|
-
}
|
|
1600
|
-
if (!r) {
|
|
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));
|
|
1602
|
-
return new F(n, {
|
|
1603
|
-
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1604
|
-
ednParts: e,
|
|
1605
|
-
...r === void 0 ? {} : { encodingWidth: r }
|
|
1606
|
-
});
|
|
1607
|
-
}
|
|
1608
|
-
let a = [], o = [], s = () => {
|
|
1609
|
-
o.length > 0 && (a.push(new F(this._concatBytes([...o]))), o.length = 0);
|
|
1610
|
-
};
|
|
1611
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new V())) : o.push(e.bytes);
|
|
1612
|
-
return s(), new V(a);
|
|
1819
|
+
source: n,
|
|
1820
|
+
commentSyntax: this._tokenTypeToCommentSyntax(t),
|
|
1821
|
+
real: !1,
|
|
1822
|
+
start: r,
|
|
1823
|
+
end: i
|
|
1824
|
+
}], o = this._consumeByteEllipsisChain(a);
|
|
1825
|
+
return this._buildFromByteAtoms(o, this._tokenTypeToCdnEncoding(t));
|
|
1613
1826
|
}
|
|
1614
1827
|
_parseHexElidedConcat(e) {
|
|
1615
|
-
let t = this.
|
|
1828
|
+
let t = this._consumeByteEllipsisChain(this._elidedHexAtoms(e.value, e));
|
|
1829
|
+
return this._buildFromByteAtoms(t, "hex");
|
|
1830
|
+
}
|
|
1831
|
+
_consumeByteEllipsisChain(e) {
|
|
1832
|
+
let t = e;
|
|
1616
1833
|
for (; this.t.peek().type === "PLUS";) {
|
|
1617
1834
|
this.t.consume();
|
|
1618
1835
|
let e = this.t.peek();
|
|
1619
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(
|
|
1836
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push({
|
|
1837
|
+
ellipsis: !0,
|
|
1838
|
+
real: !0,
|
|
1839
|
+
fromByteLiteral: !1,
|
|
1840
|
+
start: e.offset,
|
|
1841
|
+
end: e.endOffset
|
|
1842
|
+
});
|
|
1620
1843
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1621
1844
|
this.t.consume();
|
|
1622
|
-
let n = this.
|
|
1623
|
-
|
|
1624
|
-
} else
|
|
1625
|
-
this.
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1845
|
+
let n = this._elidedHexAtoms(e.value, e);
|
|
1846
|
+
n.length > 0 && (n[0].real = !0), t.push(...n);
|
|
1847
|
+
} else this._isBytesToken(e.type) ? (this.t.consume(), t.push({
|
|
1848
|
+
bytes: this._decodeBytesToken(e),
|
|
1849
|
+
source: e.raw,
|
|
1850
|
+
commentSyntax: this._tokenTypeToCommentSyntax(e.type),
|
|
1851
|
+
real: !0,
|
|
1852
|
+
start: e.offset,
|
|
1853
|
+
end: e.endOffset
|
|
1854
|
+
})) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), t.push({
|
|
1855
|
+
bytes: ot.encode(e.value),
|
|
1856
|
+
real: !0,
|
|
1857
|
+
start: e.offset,
|
|
1858
|
+
end: e.endOffset
|
|
1859
|
+
})) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1629
1860
|
}
|
|
1630
|
-
return
|
|
1861
|
+
return t;
|
|
1631
1862
|
}
|
|
1632
|
-
|
|
1863
|
+
_elidedHexAtoms(e, t) {
|
|
1633
1864
|
let n = e.split("..."), r = [];
|
|
1634
|
-
for (let e = 0; e < n.length; e++) e > 0 && r.push(
|
|
1865
|
+
for (let e = 0; e < n.length; e++) e > 0 && r.push({
|
|
1866
|
+
ellipsis: !0,
|
|
1867
|
+
real: !1,
|
|
1868
|
+
fromByteLiteral: !0,
|
|
1869
|
+
literalSource: t.raw,
|
|
1870
|
+
start: t.offset,
|
|
1871
|
+
end: t.endOffset
|
|
1872
|
+
}), n[e].length > 0 && r.push({
|
|
1873
|
+
bytes: this._hexToBytes(n[e], t),
|
|
1874
|
+
commentSyntax: "full",
|
|
1875
|
+
real: !1,
|
|
1876
|
+
start: t.offset,
|
|
1877
|
+
end: t.endOffset
|
|
1878
|
+
});
|
|
1635
1879
|
return r;
|
|
1636
1880
|
}
|
|
1637
|
-
|
|
1638
|
-
if (
|
|
1639
|
-
|
|
1640
|
-
|
|
1881
|
+
_buildFromByteAtoms(e, t) {
|
|
1882
|
+
if (!e.some((e) => "ellipsis" in e)) {
|
|
1883
|
+
let n = e, r = this._concatBytes(n.map((e) => e.bytes)), i = this.consumeEncodingIndicator(() => BigInt(r.length));
|
|
1884
|
+
return new N(r, {
|
|
1885
|
+
ednEncoding: t,
|
|
1886
|
+
ednParts: n,
|
|
1887
|
+
...i === void 0 ? {} : { encodingWidth: i }
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
let n = [], r = [], i = [], a = () => {
|
|
1891
|
+
if (i.length > 0) {
|
|
1892
|
+
let e = new N(this._concatBytes(i.map((e) => e.bytes)), { ...i.length > 1 ? { ednParts: i.map(({ bytes: e, source: t, commentSyntax: n, start: r, end: i }) => ({
|
|
1893
|
+
bytes: e,
|
|
1894
|
+
source: t,
|
|
1895
|
+
commentSyntax: n,
|
|
1896
|
+
start: r,
|
|
1897
|
+
end: i
|
|
1898
|
+
})) } : {
|
|
1899
|
+
ednSource: i[0].source,
|
|
1900
|
+
ednCommentSyntax: i[0].commentSyntax
|
|
1901
|
+
} });
|
|
1902
|
+
e.start = i[0].start, e.end = i[i.length - 1].end, n.push(e), r.push(i[0].real), i.length = 0;
|
|
1903
|
+
}
|
|
1904
|
+
};
|
|
1905
|
+
for (let t of e) if ("ellipsis" in t) {
|
|
1906
|
+
a();
|
|
1907
|
+
let e = new V(t.fromByteLiteral, t.literalSource);
|
|
1908
|
+
e.start = t.start, e.end = t.end, n.push(e), r.push(t.real);
|
|
1909
|
+
} else i.push(t);
|
|
1910
|
+
return a(), new V(n, r);
|
|
1641
1911
|
}
|
|
1642
1912
|
_concatBytes(e) {
|
|
1643
1913
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1648,8 +1918,8 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1648
1918
|
this.t.consume(), this.expect("LPAREN");
|
|
1649
1919
|
let e = this.t.peek();
|
|
1650
1920
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1651
|
-
let { numStr: t } =
|
|
1652
|
-
return this.expect("RPAREN"), new
|
|
1921
|
+
let { numStr: t } = ut(e.value), n = Number(dt(t));
|
|
1922
|
+
return this.expect("RPAREN"), new R(n, { ednSource: e.raw });
|
|
1653
1923
|
}
|
|
1654
1924
|
parseEmbeddedCBOR() {
|
|
1655
1925
|
this.t.consume();
|
|
@@ -1666,46 +1936,47 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1666
1936
|
let e = this.t.consume();
|
|
1667
1937
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1668
1938
|
}
|
|
1669
|
-
return new
|
|
1939
|
+
return new z(e, { encodingWidth: t });
|
|
1670
1940
|
}
|
|
1671
1941
|
parseArray() {
|
|
1672
1942
|
this.t.consume();
|
|
1673
1943
|
let e = !1, t, n;
|
|
1674
1944
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1675
|
-
let r = this._pendingWarnings.splice(0), i = [];
|
|
1945
|
+
let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
|
|
1676
1946
|
for (; this.t.peek().type !== "RBRACKET";) {
|
|
1677
1947
|
if (i.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1678
1948
|
if (this.t.consume(), this.t.peek().type === "RBRACKET") break;
|
|
1679
1949
|
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("array items must be separated by \",\" or whitespace", this.t.peek());
|
|
1680
|
-
|
|
1950
|
+
let e = this.parseValue();
|
|
1951
|
+
gt(this.t.source, a, e.start) && (e.blankLineBefore = !0), a = e.end, i.push(e);
|
|
1681
1952
|
}
|
|
1682
1953
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1683
|
-
let
|
|
1954
|
+
let o = new I(i, {
|
|
1684
1955
|
indefiniteLength: e,
|
|
1685
1956
|
encodingWidth: t
|
|
1686
1957
|
});
|
|
1687
|
-
return r.length > 0 && (
|
|
1958
|
+
return r.length > 0 && (o.warnings ??= [], o.warnings.push(...r)), o;
|
|
1688
1959
|
}
|
|
1689
1960
|
parseMap() {
|
|
1690
1961
|
this.t.consume();
|
|
1691
1962
|
let e = !1, t, n;
|
|
1692
1963
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1693
|
-
let r = this._pendingWarnings.splice(0), i = [];
|
|
1964
|
+
let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
|
|
1694
1965
|
for (; this.t.peek().type !== "RBRACE";) {
|
|
1695
1966
|
if (i.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1696
1967
|
if (this.t.consume(), this.t.peek().type === "RBRACE") break;
|
|
1697
1968
|
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("map entries must be separated by \",\" or whitespace", this.t.peek());
|
|
1698
1969
|
let e = this.parseValue();
|
|
1699
|
-
this.expect("COLON");
|
|
1970
|
+
gt(this.t.source, a, e.start) && (e.blankLineBefore = !0), this.expect("COLON");
|
|
1700
1971
|
let t = this.parseValue();
|
|
1701
|
-
i.push([e, t]);
|
|
1972
|
+
a = t.end, i.push([e, t]);
|
|
1702
1973
|
}
|
|
1703
1974
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1704
|
-
let
|
|
1975
|
+
let o = new L(i, {
|
|
1705
1976
|
indefiniteLength: e,
|
|
1706
1977
|
encodingWidth: t
|
|
1707
1978
|
});
|
|
1708
|
-
return r.length > 0 && (
|
|
1979
|
+
return r.length > 0 && (o.warnings ??= [], o.warnings.push(...r)), o;
|
|
1709
1980
|
}
|
|
1710
1981
|
parseIndefGroup() {
|
|
1711
1982
|
this.t.consume();
|
|
@@ -1716,35 +1987,38 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1716
1987
|
let e = this.t.consume(), t = `encoding indicator _${e.value} is not valid in an indefinite string group; use _`;
|
|
1717
1988
|
this._warnOrFail(t, e);
|
|
1718
1989
|
} else e.type !== "RPAREN" && this._warnOrFail("indefinite string group is missing _ after (; interpreting as (_ ...)", e);
|
|
1719
|
-
let t = this._pendingWarnings.splice(0), n = [];
|
|
1990
|
+
let t = this._pendingWarnings.splice(0), n = [], r = this.t.lastEndOffset;
|
|
1720
1991
|
for (; this.t.peek().type !== "RPAREN";) {
|
|
1721
1992
|
if (n.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1722
1993
|
if (this.t.consume(), this.t.peek().type === "RPAREN") break;
|
|
1723
1994
|
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("indefinite string chunks must be separated by \",\" or whitespace", this.t.peek());
|
|
1724
|
-
|
|
1995
|
+
let e = this.parseValue();
|
|
1996
|
+
gt(this.t.source, r, e.start) && (e.blankLineBefore = !0), r = e.end, n.push(e);
|
|
1725
1997
|
}
|
|
1726
1998
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1727
|
-
let
|
|
1728
|
-
if (
|
|
1729
|
-
let e = new
|
|
1730
|
-
if (e instanceof
|
|
1999
|
+
let i = n[0];
|
|
2000
|
+
if (i instanceof N) {
|
|
2001
|
+
let e = new P(n.map((e, t) => {
|
|
2002
|
+
if (e instanceof N) return e;
|
|
1731
2003
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1732
2004
|
}));
|
|
1733
2005
|
return t.length > 0 && (e.warnings = t), e;
|
|
1734
2006
|
}
|
|
1735
|
-
if (
|
|
1736
|
-
let e = new
|
|
1737
|
-
if (e instanceof
|
|
2007
|
+
if (i instanceof G) {
|
|
2008
|
+
let e = new F(n.map((e, t) => {
|
|
2009
|
+
if (e instanceof G) return e;
|
|
1738
2010
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1739
2011
|
}));
|
|
1740
2012
|
return t.length > 0 && (e.warnings = t), e;
|
|
1741
2013
|
}
|
|
1742
2014
|
this._fail("indefinite group chunks must be byte strings or text strings");
|
|
1743
2015
|
}
|
|
1744
|
-
consumeEncodingIndicator(e) {
|
|
2016
|
+
consumeEncodingIndicator(e, t) {
|
|
1745
2017
|
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
1746
|
-
let
|
|
1747
|
-
|
|
2018
|
+
let n = this.t.consume();
|
|
2019
|
+
t?.(n);
|
|
2020
|
+
let r = this._resolveEncodingWidth(n.value, n);
|
|
2021
|
+
return r !== void 0 && e !== void 0 && (r = this._validateEncodingFit(e(), r, n)), r;
|
|
1748
2022
|
}
|
|
1749
2023
|
}
|
|
1750
2024
|
expect(e) {
|
|
@@ -1752,47 +2026,47 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1752
2026
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1753
2027
|
}
|
|
1754
2028
|
_applyEiToResult(e, t, n) {
|
|
1755
|
-
if (e instanceof
|
|
2029
|
+
if (e instanceof j) {
|
|
1756
2030
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1757
2031
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1758
2032
|
else if (e.precision !== r) {
|
|
1759
2033
|
if (r !== "double") {
|
|
1760
|
-
let t = r === "half" ?
|
|
2034
|
+
let t = r === "half" ? C(S(e.value)) : Math.fround(e.value);
|
|
1761
2035
|
!Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
|
|
1762
2036
|
}
|
|
1763
2037
|
e.precision = r;
|
|
1764
2038
|
}
|
|
1765
|
-
} else if (e instanceof
|
|
2039
|
+
} else if (e instanceof k) {
|
|
1766
2040
|
if (e.encodingWidth === void 0) {
|
|
1767
2041
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
1768
2042
|
r !== void 0 && (e.encodingWidth = r);
|
|
1769
2043
|
}
|
|
1770
|
-
} else if (e instanceof
|
|
2044
|
+
} else if (e instanceof A) {
|
|
1771
2045
|
if (e.encodingWidth === void 0) {
|
|
1772
2046
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1773
2047
|
r !== void 0 && (e.encodingWidth = r);
|
|
1774
2048
|
}
|
|
1775
|
-
} else if (e instanceof
|
|
2049
|
+
} else if (e instanceof N) {
|
|
1776
2050
|
if (e.encodingWidth === void 0) {
|
|
1777
2051
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1778
2052
|
r !== void 0 && (e.encodingWidth = r);
|
|
1779
2053
|
}
|
|
1780
|
-
} else if (e instanceof
|
|
2054
|
+
} else if (e instanceof G) {
|
|
1781
2055
|
if (e.encodingWidth === void 0) {
|
|
1782
|
-
let r = this._validateEncodingFit(BigInt(
|
|
2056
|
+
let r = this._validateEncodingFit(BigInt(ot.encode(e.value).length), t, n);
|
|
1783
2057
|
r !== void 0 && (e.encodingWidth = r);
|
|
1784
2058
|
}
|
|
1785
|
-
} else if (e instanceof
|
|
2059
|
+
} else if (e instanceof I) {
|
|
1786
2060
|
if (e.encodingWidth === void 0) {
|
|
1787
2061
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1788
2062
|
r !== void 0 && (e.encodingWidth = r);
|
|
1789
2063
|
}
|
|
1790
|
-
} else if (e instanceof
|
|
2064
|
+
} else if (e instanceof L) {
|
|
1791
2065
|
if (e.encodingWidth === void 0) {
|
|
1792
2066
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1793
2067
|
r !== void 0 && (e.encodingWidth = r);
|
|
1794
2068
|
}
|
|
1795
|
-
} else if (e instanceof
|
|
2069
|
+
} else if (e instanceof M) {
|
|
1796
2070
|
if (e.encodingWidth === void 0) {
|
|
1797
2071
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1798
2072
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -1800,7 +2074,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1800
2074
|
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
1801
2075
|
}
|
|
1802
2076
|
_validateEncodingFit(e, t, n) {
|
|
1803
|
-
let r =
|
|
2077
|
+
let r = Te(t);
|
|
1804
2078
|
if (e <= r) return t;
|
|
1805
2079
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
1806
2080
|
this._warnOrFail(i, n);
|
|
@@ -1824,29 +2098,29 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1824
2098
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1825
2099
|
}
|
|
1826
2100
|
_hintMissingExtension(e, t) {
|
|
1827
|
-
let n =
|
|
2101
|
+
let n = Et.get(e);
|
|
1828
2102
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1829
2103
|
this._hintedPrefixes.add(e);
|
|
1830
2104
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
1831
2105
|
this._options.onWarning ? this._options.onWarning({
|
|
1832
2106
|
message: r,
|
|
1833
|
-
...
|
|
2107
|
+
...Ot(t),
|
|
1834
2108
|
hint: !0
|
|
1835
2109
|
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
1836
2110
|
}
|
|
1837
2111
|
_warn(e, t) {
|
|
1838
2112
|
let n = { message: e };
|
|
1839
|
-
if (t !== void 0 && Object.assign(n,
|
|
2113
|
+
if (t !== void 0 && Object.assign(n, Ot(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
|
|
1840
2114
|
else if (!this._options.silent) {
|
|
1841
2115
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
1842
2116
|
console.warn(`CDN strict violation${n}: ${e}`);
|
|
1843
2117
|
}
|
|
1844
2118
|
}
|
|
1845
|
-
_fail(e,
|
|
1846
|
-
throw new
|
|
2119
|
+
_fail(e, n) {
|
|
2120
|
+
throw new t(e, n ? Ot(n) : void 0);
|
|
1847
2121
|
}
|
|
1848
2122
|
};
|
|
1849
|
-
function
|
|
2123
|
+
function Ot(e) {
|
|
1850
2124
|
return {
|
|
1851
2125
|
offset: e.offset,
|
|
1852
2126
|
line: e.line,
|
|
@@ -1856,85 +2130,93 @@ function gt(e) {
|
|
|
1856
2130
|
}
|
|
1857
2131
|
//#endregion
|
|
1858
2132
|
//#region src/ast/CborTextString.ts
|
|
1859
|
-
var
|
|
2133
|
+
var kt = new TextEncoder(), At = !1, G = class extends O {
|
|
1860
2134
|
indefiniteLength = !1;
|
|
1861
2135
|
value;
|
|
1862
2136
|
encodingWidth;
|
|
1863
2137
|
ednParts;
|
|
1864
2138
|
ednSource;
|
|
2139
|
+
quotedEdnSource;
|
|
1865
2140
|
ednPartSources;
|
|
2141
|
+
ednPartIsByteString;
|
|
2142
|
+
ednPartSpans;
|
|
1866
2143
|
constructor(e, t) {
|
|
1867
|
-
super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts, this.ednSource = t?.ednSource, this.ednPartSources = t?.ednPartSources;
|
|
2144
|
+
super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts, this.ednSource = t?.ednSource, this.quotedEdnSource = t?.quotedEdnSource, this.ednPartSources = t?.ednPartSources, this.ednPartIsByteString = t?.ednPartIsByteString, this.ednPartSpans = t?.ednPartSpans;
|
|
1868
2145
|
}
|
|
1869
2146
|
_encodeTo(e, t) {
|
|
1870
2147
|
e.writeTextString(3, this.value, this.encodingWidth);
|
|
1871
2148
|
}
|
|
1872
2149
|
_toCDN(e, t) {
|
|
1873
|
-
let n =
|
|
1874
|
-
return
|
|
2150
|
+
let n = a(e, this.encodingWidth, () => p(BigInt(kt.encode(this.value).length)));
|
|
2151
|
+
return jt(this.value, n, e, t, this.ednParts, this.ednSource, this.quotedEdnSource, this.ednPartSources, this.ednPartSpans, this.comments?.dangling);
|
|
1875
2152
|
}
|
|
1876
2153
|
_toJS(e) {
|
|
1877
2154
|
return this.value;
|
|
1878
2155
|
}
|
|
1879
2156
|
};
|
|
1880
|
-
function
|
|
1881
|
-
let
|
|
1882
|
-
if (n?.preserveRawString && a !== void 0 && (
|
|
1883
|
-
if (
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2157
|
+
function jt(e, t, n, r, i, a, o, s, c, l) {
|
|
2158
|
+
let u = v(n);
|
|
2159
|
+
if (n?.preserveRawString && a !== void 0 && (u !== null || !/[\r\n]/.test(a))) return a + t;
|
|
2160
|
+
if (n?.preserveTextString && o !== void 0 && (u !== null || !/[\r\n]/.test(o))) return o + t;
|
|
2161
|
+
if (u === null) return ee(e) + t;
|
|
2162
|
+
let d = n?.preserveRawString ? s : void 0, f = d?.some((e) => e !== void 0) ?? !1, { cdn: p, newline: te } = Nt(n), m = n?.preserveConcatenation && i !== void 0 && (i.length > 1 || f) ? i : void 0;
|
|
2163
|
+
if (!p && !te && m === void 0) return ee(e) + t;
|
|
2164
|
+
let h = p ? It(e) : null;
|
|
2165
|
+
if (m !== void 0 && (h === null || f)) {
|
|
2166
|
+
let e = n?.preserveComments ? ne(l, c, typeof n.preserveComments == "string" ? n.preserveComments : void 0) : void 0, i = [];
|
|
2167
|
+
for (let [t, n] of m.entries()) {
|
|
2168
|
+
let r = d?.[t];
|
|
2169
|
+
if (r !== void 0) i.push({
|
|
1892
2170
|
text: n,
|
|
1893
2171
|
contentDepth: 0,
|
|
1894
2172
|
source: r
|
|
1895
2173
|
});
|
|
1896
|
-
else if (
|
|
1897
|
-
let
|
|
1898
|
-
for (let { point:
|
|
1899
|
-
|
|
1900
|
-
} else
|
|
2174
|
+
else if (te) {
|
|
2175
|
+
let e = /* @__PURE__ */ new Map();
|
|
2176
|
+
for (let { point: t, contentDepth: r } of Ft(n, 0)) e.set(t, r);
|
|
2177
|
+
i.push(...Wt(n, e));
|
|
2178
|
+
} else i.push({
|
|
1901
2179
|
text: n,
|
|
1902
2180
|
contentDepth: 0
|
|
1903
2181
|
});
|
|
2182
|
+
let a = e?.[t];
|
|
2183
|
+
a && a.length > 0 && (i[i.length - 1].commentsAfter = a);
|
|
1904
2184
|
}
|
|
1905
|
-
return
|
|
2185
|
+
return Mt(i, t, u, r);
|
|
1906
2186
|
}
|
|
1907
|
-
let
|
|
1908
|
-
if (
|
|
1909
|
-
if (
|
|
1910
|
-
let t =
|
|
1911
|
-
for (let { point: e, contentDepth: n } of t)
|
|
2187
|
+
let g = /* @__PURE__ */ new Map();
|
|
2188
|
+
if (h !== null) for (let { point: e, contentDepth: t } of h) g.set(e, t);
|
|
2189
|
+
if (te) {
|
|
2190
|
+
let t = h === null ? Ft(e, 0) : Lt(e);
|
|
2191
|
+
for (let { point: e, contentDepth: n } of t) g.has(e) || g.set(e, n);
|
|
1912
2192
|
}
|
|
1913
|
-
let
|
|
1914
|
-
return
|
|
2193
|
+
let _ = Wt(e, g);
|
|
2194
|
+
return _.length <= 1 ? ee(e) + t : Mt(_, t, u, r);
|
|
1915
2195
|
}
|
|
1916
|
-
function
|
|
2196
|
+
function Mt(e, t, n, r) {
|
|
1917
2197
|
let i = e.map(({ text: n, source: r }, i) => {
|
|
1918
|
-
let a = r ??
|
|
2198
|
+
let a = r ?? ee(n);
|
|
1919
2199
|
return i === e.length - 1 ? a + t : a;
|
|
1920
2200
|
}), a = i[0];
|
|
1921
2201
|
for (let t = 1; t < i.length; t++) {
|
|
1922
|
-
let o =
|
|
1923
|
-
a +=
|
|
2202
|
+
let o = te(n, r + 1 + e[t].contentDepth);
|
|
2203
|
+
a += " +\n";
|
|
2204
|
+
for (let n of e[t - 1].commentsAfter ?? []) a += `${o}${n}\n`;
|
|
2205
|
+
a += `${o}${i[t]}`;
|
|
1924
2206
|
}
|
|
1925
2207
|
return a;
|
|
1926
2208
|
}
|
|
1927
|
-
function
|
|
1928
|
-
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ?
|
|
2209
|
+
function Nt(e) {
|
|
2210
|
+
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? Pt(e?.textStringFormat ?? []) : [];
|
|
1929
2211
|
return {
|
|
1930
2212
|
cdn: e?.splitCdn ?? t.includes("cdn"),
|
|
1931
2213
|
newline: e?.splitNewline ?? t.includes("newline")
|
|
1932
2214
|
};
|
|
1933
2215
|
}
|
|
1934
|
-
function
|
|
1935
|
-
return e.map((e) => e === "cboredn" ? (
|
|
2216
|
+
function Pt(e) {
|
|
2217
|
+
return e.map((e) => e === "cboredn" ? (At || (At = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1936
2218
|
}
|
|
1937
|
-
function
|
|
2219
|
+
function Ft(e, t) {
|
|
1938
2220
|
let n = [];
|
|
1939
2221
|
for (let r = 0; r < e.length; r++) {
|
|
1940
2222
|
let i = e[r];
|
|
@@ -1951,66 +2233,66 @@ function Ct(e, t) {
|
|
|
1951
2233
|
}
|
|
1952
2234
|
return n;
|
|
1953
2235
|
}
|
|
1954
|
-
function
|
|
2236
|
+
function It(e) {
|
|
1955
2237
|
try {
|
|
1956
|
-
|
|
2238
|
+
lt(e);
|
|
1957
2239
|
} catch {
|
|
1958
2240
|
return null;
|
|
1959
2241
|
}
|
|
1960
|
-
let t = [], n = new
|
|
2242
|
+
let t = [], n = new re(e), r = 0, i = null, a = !1, o = 0;
|
|
1961
2243
|
for (;;) {
|
|
1962
|
-
let
|
|
1963
|
-
if (
|
|
2244
|
+
let s = n.consume();
|
|
2245
|
+
if (s.type === "EOF") break;
|
|
1964
2246
|
let c = !1;
|
|
1965
|
-
if (
|
|
1966
|
-
point:
|
|
2247
|
+
if (a || (a = !0, s.offset > 0 && Ht(n.comments, 0, s.offset) && t.push({
|
|
2248
|
+
point: s.offset,
|
|
1967
2249
|
contentDepth: r
|
|
1968
2250
|
})), i !== null) {
|
|
1969
|
-
if (i.kind === "opener" &&
|
|
1970
|
-
i.point =
|
|
2251
|
+
if (i.kind === "opener" && zt.has(s.type)) {
|
|
2252
|
+
i.point = s.endOffset, o = s.endOffset;
|
|
1971
2253
|
continue;
|
|
1972
|
-
} else i.kind === "opener" &&
|
|
1973
|
-
point:
|
|
2254
|
+
} else i.kind === "opener" && Vt.has(s.type) && Ut(e, i.point, s.offset) ? c = !0 : t.push({
|
|
2255
|
+
point: s.offset,
|
|
1974
2256
|
contentDepth: i.contentDepth
|
|
1975
2257
|
});
|
|
1976
2258
|
i = null;
|
|
1977
2259
|
}
|
|
1978
|
-
|
|
1979
|
-
point:
|
|
2260
|
+
Bt.has(s.type) ? (r++, i = {
|
|
2261
|
+
point: s.endOffset,
|
|
1980
2262
|
contentDepth: r,
|
|
1981
2263
|
kind: "opener"
|
|
1982
|
-
}) :
|
|
1983
|
-
point:
|
|
2264
|
+
}) : Vt.has(s.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
2265
|
+
point: s.offset,
|
|
1984
2266
|
contentDepth: r
|
|
1985
|
-
})) :
|
|
1986
|
-
point:
|
|
2267
|
+
})) : s.type === "COMMA" && (i = {
|
|
2268
|
+
point: s.endOffset,
|
|
1987
2269
|
contentDepth: r,
|
|
1988
2270
|
kind: "comma"
|
|
1989
|
-
}),
|
|
2271
|
+
}), o = s.endOffset;
|
|
1990
2272
|
}
|
|
1991
|
-
let
|
|
1992
|
-
return
|
|
1993
|
-
point:
|
|
2273
|
+
let s = n.comments.find((e) => e.start >= o);
|
|
2274
|
+
return s !== void 0 && t.push({
|
|
2275
|
+
point: s.start,
|
|
1994
2276
|
contentDepth: r
|
|
1995
2277
|
}), t;
|
|
1996
2278
|
}
|
|
1997
|
-
function
|
|
1998
|
-
let t = [], n = new
|
|
2279
|
+
function Lt(e) {
|
|
2280
|
+
let t = [], n = new re(e), r = 0;
|
|
1999
2281
|
for (;;) {
|
|
2000
2282
|
let i = n.consume();
|
|
2001
2283
|
if (i.type === "EOF") break;
|
|
2002
|
-
if (
|
|
2003
|
-
else if (
|
|
2284
|
+
if (Bt.has(i.type)) r++;
|
|
2285
|
+
else if (Vt.has(i.type)) r = Math.max(0, r - 1);
|
|
2004
2286
|
else if (i.type !== "COMMA") {
|
|
2005
2287
|
if (i.type === "TSTR") {
|
|
2006
2288
|
let n = e.slice(i.offset, i.endOffset);
|
|
2007
|
-
for (let e of
|
|
2289
|
+
for (let e of Rt(n)) t.push({
|
|
2008
2290
|
point: i.offset + e,
|
|
2009
2291
|
contentDepth: r + 1
|
|
2010
2292
|
});
|
|
2011
2293
|
} else if (i.type === "RAWSTRING") {
|
|
2012
2294
|
let n = e.slice(i.offset, i.endOffset);
|
|
2013
|
-
for (let { point: e } of
|
|
2295
|
+
for (let { point: e } of Ft(n, 0)) t.push({
|
|
2014
2296
|
point: i.offset + e,
|
|
2015
2297
|
contentDepth: r + 1
|
|
2016
2298
|
});
|
|
@@ -2019,7 +2301,7 @@ function Tt(e) {
|
|
|
2019
2301
|
}
|
|
2020
2302
|
return t;
|
|
2021
2303
|
}
|
|
2022
|
-
function
|
|
2304
|
+
function Rt(e) {
|
|
2023
2305
|
let t = [], n = 1, r = e.length - 1;
|
|
2024
2306
|
for (; n < r;) {
|
|
2025
2307
|
let r = e[n];
|
|
@@ -2035,24 +2317,24 @@ function Et(e) {
|
|
|
2035
2317
|
}
|
|
2036
2318
|
return t;
|
|
2037
2319
|
}
|
|
2038
|
-
var
|
|
2320
|
+
var zt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Bt = /* @__PURE__ */ new Set([
|
|
2039
2321
|
"LBRACKET",
|
|
2040
2322
|
"LBRACE",
|
|
2041
2323
|
"LPAREN",
|
|
2042
2324
|
"LT_LT"
|
|
2043
|
-
]),
|
|
2325
|
+
]), Vt = /* @__PURE__ */ new Set([
|
|
2044
2326
|
"RBRACKET",
|
|
2045
2327
|
"RBRACE",
|
|
2046
2328
|
"RPAREN",
|
|
2047
2329
|
"GT_GT"
|
|
2048
2330
|
]);
|
|
2049
|
-
function
|
|
2331
|
+
function Ht(e, t, n) {
|
|
2050
2332
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
2051
2333
|
}
|
|
2052
|
-
function
|
|
2334
|
+
function Ut(e, t, n) {
|
|
2053
2335
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
2054
2336
|
}
|
|
2055
|
-
function
|
|
2337
|
+
function Wt(e, t) {
|
|
2056
2338
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2057
2339
|
if (n.length === 0) return [{
|
|
2058
2340
|
text: e,
|
|
@@ -2070,7 +2352,7 @@ function Mt(e, t) {
|
|
|
2070
2352
|
}
|
|
2071
2353
|
//#endregion
|
|
2072
2354
|
//#region src/extensions/dt.ts
|
|
2073
|
-
function
|
|
2355
|
+
function Gt(e) {
|
|
2074
2356
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2075
2357
|
let t = Math.round(e * 1e3);
|
|
2076
2358
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -2078,17 +2360,17 @@ function W(e) {
|
|
|
2078
2360
|
for (; s.length < 3;) s += "0";
|
|
2079
2361
|
return `${i}.${s}Z`;
|
|
2080
2362
|
}
|
|
2081
|
-
var
|
|
2082
|
-
function
|
|
2363
|
+
var Kt = new TextDecoder("utf-8", { fatal: !0 });
|
|
2364
|
+
function qt(e) {
|
|
2083
2365
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2084
2366
|
let t = e[0];
|
|
2085
|
-
if (t instanceof
|
|
2086
|
-
if (t instanceof
|
|
2367
|
+
if (t instanceof G) return t.value;
|
|
2368
|
+
if (t instanceof N) return Kt.decode(t.value);
|
|
2087
2369
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2088
2370
|
}
|
|
2089
|
-
var
|
|
2090
|
-
function
|
|
2091
|
-
if (!
|
|
2371
|
+
var Jt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
2372
|
+
function Yt(e, t) {
|
|
2373
|
+
if (!Jt.test(e)) {
|
|
2092
2374
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
2093
2375
|
if (t) t(n);
|
|
2094
2376
|
else throw SyntaxError(n);
|
|
@@ -2099,93 +2381,110 @@ function It(e, t) {
|
|
|
2099
2381
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2100
2382
|
if (i === void 0) {
|
|
2101
2383
|
let e = a / 1e3;
|
|
2102
|
-
return e >= 0 ? new
|
|
2384
|
+
return e >= 0 ? new Zt(BigInt(e)) : new Qt(BigInt(e));
|
|
2103
2385
|
}
|
|
2104
|
-
return new
|
|
2386
|
+
return new $t(a / 1e3 + i);
|
|
2105
2387
|
}
|
|
2106
|
-
var
|
|
2388
|
+
var Xt = 1n, Zt = class extends k {
|
|
2107
2389
|
constructor(e, t) {
|
|
2108
2390
|
super(e, t);
|
|
2109
2391
|
}
|
|
2110
2392
|
_toCDN(e, t) {
|
|
2111
2393
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2112
|
-
let n =
|
|
2113
|
-
return `dt'${
|
|
2394
|
+
let n = a(e, this.encodingWidth, () => p(this.value));
|
|
2395
|
+
return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Gt(Number(this.value))}'${n}`;
|
|
2114
2396
|
}
|
|
2115
|
-
},
|
|
2397
|
+
}, Qt = class extends A {
|
|
2116
2398
|
constructor(e, t) {
|
|
2117
2399
|
super(e, t);
|
|
2118
2400
|
}
|
|
2119
2401
|
_toCDN(e, t) {
|
|
2120
2402
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2121
|
-
let n =
|
|
2122
|
-
return `dt'${
|
|
2403
|
+
let n = a(e, this.encodingWidth, () => p(this.argument));
|
|
2404
|
+
return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Gt(Number(this.value))}'${n}`;
|
|
2123
2405
|
}
|
|
2124
|
-
},
|
|
2406
|
+
}, $t = class extends j {
|
|
2125
2407
|
constructor(e, t) {
|
|
2126
2408
|
super(e, t);
|
|
2127
2409
|
}
|
|
2128
2410
|
_toCDN(e, t) {
|
|
2129
2411
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2130
|
-
let n =
|
|
2131
|
-
return `dt'${
|
|
2412
|
+
let n = D(this.value), r = ie(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
2413
|
+
return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Gt(this.value)}'${r}`;
|
|
2132
2414
|
}
|
|
2133
|
-
},
|
|
2415
|
+
}, en = class extends M {
|
|
2134
2416
|
constructor(e, t) {
|
|
2135
|
-
super(
|
|
2417
|
+
super(Xt, typeof e == "string" ? Yt(e) : e, t);
|
|
2136
2418
|
}
|
|
2137
2419
|
_toCDN(e, t) {
|
|
2138
2420
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2139
|
-
let n = this.
|
|
2140
|
-
if (n
|
|
2421
|
+
let n = _(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
2422
|
+
if (n === "verbatim") return this.appSeqSource;
|
|
2423
|
+
if (n === "source") return g(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
2424
|
+
if (n === "structural") return super._toCDN({
|
|
2141
2425
|
...e,
|
|
2142
2426
|
appStrings: !1
|
|
2143
2427
|
}, t);
|
|
2144
|
-
let r =
|
|
2145
|
-
return
|
|
2428
|
+
let r = a(e, this.encodingWidth, () => p(Xt));
|
|
2429
|
+
if (n === "adjusted") return m(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2430
|
+
let i = this.content;
|
|
2431
|
+
return (i instanceof j ? i.precision !== void 0 && i.precision !== D(i.value) : i.encodingWidth !== void 0) ? super._toCDN({
|
|
2432
|
+
...e,
|
|
2433
|
+
appStrings: !1
|
|
2434
|
+
}, t) : `DT'${Gt(i instanceof j ? i.value : Number(i.value))}'${r}`;
|
|
2146
2435
|
}
|
|
2147
|
-
},
|
|
2436
|
+
}, tn = class extends en {
|
|
2148
2437
|
constructor(e, t) {
|
|
2149
2438
|
super(e, t);
|
|
2150
2439
|
}
|
|
2151
2440
|
_toJS(e) {
|
|
2152
|
-
let t = this.content, n = t instanceof
|
|
2441
|
+
let t = this.content, n = t instanceof j ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2153
2442
|
return new Date(n);
|
|
2154
2443
|
}
|
|
2155
2444
|
};
|
|
2156
|
-
function
|
|
2445
|
+
function nn(e) {
|
|
2157
2446
|
let t = e?.jsDate ?? !1;
|
|
2158
2447
|
function n(e) {
|
|
2159
|
-
return t ? new
|
|
2448
|
+
return t ? new tn(e) : new en(e);
|
|
2160
2449
|
}
|
|
2161
2450
|
let r = {
|
|
2162
2451
|
appStringPrefixes: ["dt", "DT"],
|
|
2163
|
-
tagNumbers: [
|
|
2452
|
+
tagNumbers: [Xt],
|
|
2453
|
+
preserveAppSeqSource: "optional",
|
|
2164
2454
|
parseAppString(e, t, r) {
|
|
2165
|
-
return e === "DT" ? n(t) :
|
|
2455
|
+
return e === "DT" ? n(t) : Yt(t, r);
|
|
2166
2456
|
},
|
|
2167
2457
|
parseAppSequence(e, t, r) {
|
|
2168
|
-
let i =
|
|
2169
|
-
return e === "DT" ? n(i) :
|
|
2458
|
+
let i = qt(t);
|
|
2459
|
+
return e === "DT" ? n(i) : Yt(i, r);
|
|
2170
2460
|
},
|
|
2171
2461
|
parseTag(e, n) {
|
|
2172
2462
|
if (e !== 1n) return;
|
|
2173
2463
|
let r;
|
|
2174
|
-
if (n instanceof
|
|
2175
|
-
|
|
2176
|
-
|
|
2464
|
+
if (n instanceof k) r = new Zt(n.value, {
|
|
2465
|
+
encodingWidth: n.encodingWidth,
|
|
2466
|
+
ednSource: n.ednSource
|
|
2467
|
+
});
|
|
2468
|
+
else if (n instanceof A) r = new Qt(n.value, {
|
|
2469
|
+
encodingWidth: n.encodingWidth,
|
|
2470
|
+
ednSource: n.ednSource
|
|
2471
|
+
});
|
|
2472
|
+
else if (n instanceof j) r = new $t(n.value, {
|
|
2473
|
+
precision: n.precision,
|
|
2474
|
+
literalSource: n.literalSource
|
|
2475
|
+
});
|
|
2177
2476
|
else return;
|
|
2178
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
2477
|
+
return r.start = n.start, r.end = n.end, t ? new tn(r) : new en(r);
|
|
2179
2478
|
}
|
|
2180
2479
|
};
|
|
2181
2480
|
return t && (r.fromJS = (e, t) => {
|
|
2182
|
-
if (e instanceof Date) return new
|
|
2481
|
+
if (e instanceof Date) return new tn(Gt(e.getTime() / 1e3));
|
|
2183
2482
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2184
2483
|
}
|
|
2185
|
-
var
|
|
2484
|
+
var rn = nn(), an = nn({ jsDate: !0 });
|
|
2186
2485
|
//#endregion
|
|
2187
2486
|
//#region src/utils/ip.ts
|
|
2188
|
-
function
|
|
2487
|
+
function on(e) {
|
|
2189
2488
|
let t = e.split(".");
|
|
2190
2489
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2191
2490
|
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
@@ -2198,11 +2497,11 @@ function Kt(e) {
|
|
|
2198
2497
|
}
|
|
2199
2498
|
return n;
|
|
2200
2499
|
}
|
|
2201
|
-
function
|
|
2500
|
+
function sn(e) {
|
|
2202
2501
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
2203
2502
|
if (e === "::") return t;
|
|
2204
2503
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2205
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2504
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = on(i[2]));
|
|
2206
2505
|
let a = n.split("::");
|
|
2207
2506
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2208
2507
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2219,11 +2518,11 @@ function qt(e) {
|
|
|
2219
2518
|
}
|
|
2220
2519
|
return r && t.set(r, 12), t;
|
|
2221
2520
|
}
|
|
2222
|
-
function
|
|
2521
|
+
function cn(e) {
|
|
2223
2522
|
return Array.from(e).join(".");
|
|
2224
2523
|
}
|
|
2225
|
-
function
|
|
2226
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2524
|
+
function ln(e) {
|
|
2525
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? cn(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2227
2526
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2228
2527
|
let i = -1, a = 0, o = 0;
|
|
2229
2528
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2237,29 +2536,29 @@ function Yt(e) {
|
|
|
2237
2536
|
}
|
|
2238
2537
|
//#endregion
|
|
2239
2538
|
//#region src/extensions/ip.ts
|
|
2240
|
-
var
|
|
2241
|
-
function
|
|
2539
|
+
var un = "ip", dn = "IP", fn = 52n, pn = 54n, mn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2540
|
+
function hn(e) {
|
|
2242
2541
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2243
2542
|
let t = e[0];
|
|
2244
|
-
if (t instanceof
|
|
2245
|
-
if (t instanceof
|
|
2543
|
+
if (t instanceof G) return t.value;
|
|
2544
|
+
if (t instanceof N) return mn.decode(t.value);
|
|
2246
2545
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2247
2546
|
}
|
|
2248
|
-
function
|
|
2547
|
+
function gn(e) {
|
|
2249
2548
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2250
|
-
bytes:
|
|
2549
|
+
bytes: on(e),
|
|
2251
2550
|
isV4: !0
|
|
2252
2551
|
} : {
|
|
2253
|
-
bytes:
|
|
2552
|
+
bytes: sn(e),
|
|
2254
2553
|
isV4: !1
|
|
2255
2554
|
};
|
|
2256
2555
|
}
|
|
2257
|
-
function
|
|
2258
|
-
if (e.length === 4) return
|
|
2259
|
-
if (e.length === 16) return
|
|
2556
|
+
function _n(e) {
|
|
2557
|
+
if (e.length === 4) return cn(e);
|
|
2558
|
+
if (e.length === 16) return ln(e);
|
|
2260
2559
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2261
2560
|
}
|
|
2262
|
-
function
|
|
2561
|
+
function vn(e, t) {
|
|
2263
2562
|
let n = new Uint8Array(e.length);
|
|
2264
2563
|
n.set(e);
|
|
2265
2564
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2269,72 +2568,82 @@ function rn(e, t) {
|
|
|
2269
2568
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2270
2569
|
return n.slice(0, a);
|
|
2271
2570
|
}
|
|
2272
|
-
function
|
|
2571
|
+
function yn(e, t) {
|
|
2273
2572
|
let n = new Uint8Array(t);
|
|
2274
2573
|
return n.set(e), n;
|
|
2275
2574
|
}
|
|
2276
|
-
var
|
|
2575
|
+
var bn = class extends N {
|
|
2277
2576
|
_toCDN(e, t) {
|
|
2278
2577
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2279
|
-
let n =
|
|
2280
|
-
return `${
|
|
2578
|
+
let n = a(e, this.encodingWidth, () => p(BigInt(this.value.length)));
|
|
2579
|
+
return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments) : `${un}'${_n(this.value)}'${n}`;
|
|
2281
2580
|
}
|
|
2282
|
-
},
|
|
2581
|
+
}, xn = class extends I {
|
|
2283
2582
|
_isV4;
|
|
2284
2583
|
constructor(e, t, n) {
|
|
2285
|
-
super([new
|
|
2584
|
+
super([new k(BigInt(e)), new N(t)]), this._isV4 = n;
|
|
2286
2585
|
}
|
|
2287
2586
|
_toCDN(e, t) {
|
|
2288
2587
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2588
|
+
if (_(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return m(this.appSeqSource, "", e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2289
2589
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2290
|
-
return `${
|
|
2590
|
+
return `${un}'${_n(yn(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2291
2591
|
}
|
|
2292
|
-
},
|
|
2592
|
+
}, Sn = class extends M {
|
|
2293
2593
|
constructor(e, t) {
|
|
2294
2594
|
super(e, t);
|
|
2295
2595
|
}
|
|
2296
2596
|
_toCDN(e, t) {
|
|
2297
2597
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2298
|
-
let n = this.
|
|
2299
|
-
if (
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2598
|
+
let n = _(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
2599
|
+
if (n === "verbatim") return this.appSeqSource;
|
|
2600
|
+
if (n === "source") return g(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
2601
|
+
if (n === "structural") return super._toCDN(e, t);
|
|
2602
|
+
if (n === "adjusted") {
|
|
2603
|
+
let t = a(e, this.encodingWidth, () => p(this.tag));
|
|
2604
|
+
return m(this.appSeqSource, t, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2605
|
+
}
|
|
2606
|
+
let r = this.tag === fn ? 4 : 16, i = this.content;
|
|
2607
|
+
if (i instanceof N) {
|
|
2608
|
+
if (i.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2609
|
+
let n = a(e, this.encodingWidth, () => p(this.tag));
|
|
2610
|
+
return `${dn}'${_n(i.value)}'${n}`;
|
|
2611
|
+
}
|
|
2612
|
+
if (i instanceof I && i.items.length === 2 && i.items[0] instanceof k && i.items[1] instanceof N) {
|
|
2613
|
+
if (i.encodingWidth !== void 0 || i.items[0].encodingWidth !== void 0 || i.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2614
|
+
let n = Number(i.items[0].value), o = yn(i.items[1].value, r), s = a(e, this.encodingWidth, () => p(this.tag));
|
|
2615
|
+
return `${dn}'${_n(o)}/${n}'${s}`;
|
|
2308
2616
|
}
|
|
2309
2617
|
return super._toCDN(e, t);
|
|
2310
2618
|
}
|
|
2311
2619
|
};
|
|
2312
|
-
function
|
|
2620
|
+
function Cn(e, t) {
|
|
2313
2621
|
let n = t.indexOf("/");
|
|
2314
2622
|
if (n === -1) {
|
|
2315
|
-
let { bytes: n, isV4: r } =
|
|
2316
|
-
return e ===
|
|
2623
|
+
let { bytes: n, isV4: r } = gn(t);
|
|
2624
|
+
return e === dn ? new Sn(r ? fn : pn, new N(n)) : new bn(n);
|
|
2317
2625
|
}
|
|
2318
2626
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2319
2627
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2320
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2628
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = gn(r), c = s ? 32 : 128;
|
|
2321
2629
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2322
|
-
let l =
|
|
2323
|
-
return e ===
|
|
2630
|
+
let l = vn(o, a);
|
|
2631
|
+
return e === dn ? new Sn(s ? fn : pn, new I([new k(BigInt(a)), new N(l)])) : new xn(a, l, s);
|
|
2324
2632
|
}
|
|
2325
|
-
var
|
|
2326
|
-
appStringPrefixes: [
|
|
2327
|
-
tagNumbers: [
|
|
2633
|
+
var wn = {
|
|
2634
|
+
appStringPrefixes: [un, dn],
|
|
2635
|
+
tagNumbers: [fn, pn],
|
|
2636
|
+
preserveAppSeqSource: "optional",
|
|
2328
2637
|
parseAppString(e, t) {
|
|
2329
|
-
return
|
|
2638
|
+
return Cn(e, t);
|
|
2330
2639
|
},
|
|
2331
2640
|
parseAppSequence(e, t) {
|
|
2332
|
-
return
|
|
2641
|
+
return Cn(e, hn(t));
|
|
2333
2642
|
},
|
|
2334
2643
|
parseTag(e, t) {
|
|
2335
|
-
if (!(e !==
|
|
2644
|
+
if (!(e !== fn && e !== pn) && (t instanceof N || t instanceof I)) return new Sn(e, t);
|
|
2336
2645
|
}
|
|
2337
|
-
},
|
|
2646
|
+
}, Tn = "cri", En = "CRI", Dn = 99n, On = /* @__PURE__ */ new Map([
|
|
2338
2647
|
["coap", -1n],
|
|
2339
2648
|
["coaps", -2n],
|
|
2340
2649
|
["http", -3n],
|
|
@@ -2345,7 +2654,7 @@ var un = {
|
|
|
2345
2654
|
["coaps+tcp", -8n],
|
|
2346
2655
|
["coap+ws", -25n],
|
|
2347
2656
|
["coaps+ws", -26n]
|
|
2348
|
-
]),
|
|
2657
|
+
]), kn = new Map([...On.entries()].map(([e, t]) => [t, e]));
|
|
2349
2658
|
function K(e) {
|
|
2350
2659
|
try {
|
|
2351
2660
|
return decodeURIComponent(e);
|
|
@@ -2353,39 +2662,39 @@ function K(e) {
|
|
|
2353
2662
|
return e;
|
|
2354
2663
|
}
|
|
2355
2664
|
}
|
|
2356
|
-
var
|
|
2357
|
-
function
|
|
2358
|
-
return Array.from(
|
|
2665
|
+
var An = new TextEncoder(), jn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2666
|
+
function Mn(e) {
|
|
2667
|
+
return Array.from(An.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2359
2668
|
}
|
|
2360
2669
|
function q(e, t) {
|
|
2361
2670
|
let n = "";
|
|
2362
|
-
for (let r of e) n += t(r) ? r :
|
|
2671
|
+
for (let r of e) n += t(r) ? r : Mn(r);
|
|
2363
2672
|
return n;
|
|
2364
2673
|
}
|
|
2365
|
-
function
|
|
2674
|
+
function Nn(e) {
|
|
2366
2675
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2367
2676
|
}
|
|
2368
|
-
function
|
|
2677
|
+
function Pn(e) {
|
|
2369
2678
|
return /[!$&'()*+,;=]/.test(e);
|
|
2370
2679
|
}
|
|
2371
|
-
function
|
|
2372
|
-
return
|
|
2680
|
+
function Fn(e) {
|
|
2681
|
+
return Nn(e) || Pn(e) || e === ":" || e === "@";
|
|
2373
2682
|
}
|
|
2374
|
-
function
|
|
2375
|
-
return (
|
|
2683
|
+
function In(e) {
|
|
2684
|
+
return (Fn(e) || e === "/" || e === "?") && e !== "&";
|
|
2376
2685
|
}
|
|
2377
|
-
function
|
|
2378
|
-
return
|
|
2686
|
+
function Ln(e) {
|
|
2687
|
+
return Fn(e) || e === "/" || e === "?";
|
|
2379
2688
|
}
|
|
2380
|
-
function
|
|
2381
|
-
return
|
|
2689
|
+
function Rn(e) {
|
|
2690
|
+
return Nn(e) || Pn(e) || e === ":";
|
|
2382
2691
|
}
|
|
2383
|
-
function
|
|
2384
|
-
return
|
|
2692
|
+
function zn(e) {
|
|
2693
|
+
return Nn(e) || Pn(e);
|
|
2385
2694
|
}
|
|
2386
|
-
function
|
|
2695
|
+
function Bn(e) {
|
|
2387
2696
|
let t = [], n = e, r = n.indexOf("@");
|
|
2388
|
-
r >= 0 && (t.push(
|
|
2697
|
+
r >= 0 && (t.push(R.FALSE), t.push(new G(K(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2389
2698
|
let i, a = null;
|
|
2390
2699
|
if (n.startsWith("[")) {
|
|
2391
2700
|
let e = n.indexOf("]");
|
|
@@ -2394,263 +2703,272 @@ function En(e) {
|
|
|
2394
2703
|
let r = n.slice(e + 1);
|
|
2395
2704
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2396
2705
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2397
|
-
t.push(new
|
|
2706
|
+
t.push(new N(sn(i)));
|
|
2398
2707
|
} else {
|
|
2399
2708
|
let e = n.lastIndexOf(":");
|
|
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
|
|
2401
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2709
|
+
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 N(on(i)));
|
|
2710
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new G(e));
|
|
2402
2711
|
}
|
|
2403
2712
|
if (a !== null && a !== "") {
|
|
2404
2713
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2405
2714
|
let e = parseInt(a, 10);
|
|
2406
2715
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2407
|
-
t.push(new
|
|
2716
|
+
t.push(new k(BigInt(e)));
|
|
2408
2717
|
}
|
|
2409
|
-
return new
|
|
2718
|
+
return new I(t);
|
|
2410
2719
|
}
|
|
2411
|
-
function
|
|
2720
|
+
function Vn(e) {
|
|
2412
2721
|
let t = e.items, n = 0, r = "";
|
|
2413
|
-
if (n < t.length && t[n] instanceof
|
|
2722
|
+
if (n < t.length && t[n] instanceof R && t[n].value === 20) {
|
|
2414
2723
|
n++;
|
|
2415
2724
|
let e = t[n++];
|
|
2416
|
-
r += q(e.value,
|
|
2725
|
+
r += q(e.value, Rn) + "@";
|
|
2417
2726
|
}
|
|
2418
2727
|
if (n >= t.length) return r;
|
|
2419
2728
|
let i = t[n];
|
|
2420
|
-
if (i instanceof
|
|
2729
|
+
if (i instanceof N) {
|
|
2421
2730
|
n++;
|
|
2422
2731
|
let { length: e } = i.value;
|
|
2423
|
-
if (e === 4) r +=
|
|
2424
|
-
else if (e === 16) r += "[" +
|
|
2732
|
+
if (e === 4) r += cn(i.value);
|
|
2733
|
+
else if (e === 16) r += "[" + ln(i.value) + "]";
|
|
2425
2734
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2426
|
-
n < t.length && t[n] instanceof
|
|
2735
|
+
n < t.length && t[n] instanceof G && (r += `%25${q(t[n++].value, zn)}`);
|
|
2427
2736
|
} else {
|
|
2428
2737
|
let e = [];
|
|
2429
|
-
for (; n < t.length && t[n] instanceof
|
|
2738
|
+
for (; n < t.length && t[n] instanceof G;) e.push(q(t[n++].value, zn));
|
|
2430
2739
|
r += e.join(".");
|
|
2431
2740
|
}
|
|
2432
|
-
return n < t.length && t[n] instanceof
|
|
2741
|
+
return n < t.length && t[n] instanceof k && (r += ":" + t[n].value.toString()), r;
|
|
2433
2742
|
}
|
|
2434
|
-
function
|
|
2743
|
+
function Hn(e) {
|
|
2435
2744
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2436
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2437
|
-
authority:
|
|
2745
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new G(K(e)))) : (r = t, i = []), {
|
|
2746
|
+
authority: Bn(r),
|
|
2438
2747
|
pathSegments: i
|
|
2439
2748
|
};
|
|
2440
2749
|
}
|
|
2441
|
-
function
|
|
2750
|
+
function Un(e) {
|
|
2442
2751
|
let t = e, n = null, r = t.indexOf("#");
|
|
2443
2752
|
r >= 0 && (n = K(t.slice(r + 1)), t = t.slice(0, r));
|
|
2444
2753
|
let i = null, a = t.indexOf("?");
|
|
2445
2754
|
if (a >= 0) {
|
|
2446
2755
|
let e = t.slice(a + 1);
|
|
2447
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2756
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new G(K(e)));
|
|
2448
2757
|
}
|
|
2449
2758
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2450
2759
|
if (s) {
|
|
2451
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2452
|
-
if (o.push(n === void 0 ? new
|
|
2453
|
-
let { authority: e, pathSegments: n } =
|
|
2454
|
-
o.push(e, new
|
|
2760
|
+
let e = s[1].toLowerCase(), t = s[2], n = On.get(e);
|
|
2761
|
+
if (o.push(n === void 0 ? new G(e) : new A(n)), t.startsWith("//")) {
|
|
2762
|
+
let { authority: e, pathSegments: n } = Hn(t);
|
|
2763
|
+
o.push(e, new I(n));
|
|
2455
2764
|
} else if (t.startsWith("/")) {
|
|
2456
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2457
|
-
o.push(
|
|
2765
|
+
let e = t.slice(1).split("/").map((e) => new G(K(e)));
|
|
2766
|
+
o.push(R.NULL, new I(e));
|
|
2458
2767
|
} else {
|
|
2459
|
-
let e = t.split("/").map((e) => new
|
|
2460
|
-
o.push(
|
|
2768
|
+
let e = t.split("/").map((e) => new G(K(e)));
|
|
2769
|
+
o.push(R.TRUE, new I(e));
|
|
2461
2770
|
}
|
|
2462
2771
|
} else if (t.startsWith("//")) {
|
|
2463
|
-
let { authority: e, pathSegments: n } =
|
|
2464
|
-
o.push(
|
|
2772
|
+
let { authority: e, pathSegments: n } = Hn(t);
|
|
2773
|
+
o.push(R.FALSE, e, new I(n));
|
|
2465
2774
|
} else if (t.startsWith("/")) {
|
|
2466
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2467
|
-
o.push(
|
|
2468
|
-
} else if (t === "") o.push(new
|
|
2775
|
+
let e = t.slice(1).split("/").map((e) => new G(K(e)));
|
|
2776
|
+
o.push(R.TRUE, new I(e));
|
|
2777
|
+
} else if (t === "") o.push(new k(0n));
|
|
2469
2778
|
else {
|
|
2470
2779
|
let n = 1n, r = t, i = !1;
|
|
2471
2780
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2472
2781
|
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)}`);
|
|
2473
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2474
|
-
o.push(new
|
|
2782
|
+
let a = r === "" ? [] : r.split("/").map((e) => new G(K(e)));
|
|
2783
|
+
o.push(new k(n), new I(a));
|
|
2475
2784
|
}
|
|
2476
|
-
if (i !== null && o.push(new
|
|
2785
|
+
if (i !== null && o.push(new I(i)), n !== null && (i === null && o.push(R.NULL), o.push(new G(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2477
2786
|
let e = o[o.length - 1];
|
|
2478
|
-
e instanceof
|
|
2787
|
+
e instanceof I && e.items.length === 0 && o.pop();
|
|
2479
2788
|
}
|
|
2480
|
-
return o.length === 1 && o[0] instanceof
|
|
2789
|
+
return o.length === 1 && o[0] instanceof k && o[0].value === 0n ? [] : o;
|
|
2481
2790
|
}
|
|
2482
|
-
function
|
|
2791
|
+
function Wn(e, t) {
|
|
2483
2792
|
let n = t, r = "";
|
|
2484
2793
|
if (n < e.length) {
|
|
2485
2794
|
let t = e[n];
|
|
2486
|
-
if (t instanceof
|
|
2795
|
+
if (t instanceof I) {
|
|
2487
2796
|
if (n++, t.items.length > 0) {
|
|
2488
2797
|
let e = t.items.map((e) => {
|
|
2489
|
-
if (!(e instanceof
|
|
2490
|
-
return q(e.value,
|
|
2798
|
+
if (!(e instanceof G)) throw Error("cri: query item must be a text string");
|
|
2799
|
+
return q(e.value, In);
|
|
2491
2800
|
});
|
|
2492
2801
|
r += "?" + e.join("&");
|
|
2493
2802
|
}
|
|
2494
|
-
} else t instanceof
|
|
2803
|
+
} else t instanceof R && t.value === 22 && n++;
|
|
2495
2804
|
}
|
|
2496
|
-
return n < e.length && e[n] instanceof
|
|
2805
|
+
return n < e.length && e[n] instanceof G && (r += "#" + q(e[n].value, Ln)), r;
|
|
2497
2806
|
}
|
|
2498
|
-
function
|
|
2807
|
+
function Gn(e) {
|
|
2499
2808
|
return e.items.map((e) => {
|
|
2500
|
-
if (!(e instanceof
|
|
2501
|
-
return q(e.value,
|
|
2809
|
+
if (!(e instanceof G)) throw Error("cri: path segment must be a text string");
|
|
2810
|
+
return q(e.value, Fn);
|
|
2502
2811
|
});
|
|
2503
2812
|
}
|
|
2504
|
-
function
|
|
2813
|
+
function Kn(e) {
|
|
2505
2814
|
if (e.length === 0) return "";
|
|
2506
2815
|
let t = 0, n = e[t++];
|
|
2507
|
-
if (n instanceof
|
|
2816
|
+
if (n instanceof A || n instanceof G) {
|
|
2508
2817
|
let r;
|
|
2509
|
-
if (n instanceof
|
|
2510
|
-
let e =
|
|
2818
|
+
if (n instanceof A) {
|
|
2819
|
+
let e = kn.get(n.value);
|
|
2511
2820
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2512
2821
|
r = e + ":";
|
|
2513
2822
|
} else r = n.value + ":";
|
|
2514
2823
|
if (t >= e.length) return r;
|
|
2515
2824
|
let i = e[t++], a = "", o = !1;
|
|
2516
|
-
if (i instanceof
|
|
2517
|
-
else if (i instanceof
|
|
2825
|
+
if (i instanceof I) a = "//" + Vn(i), o = !0;
|
|
2826
|
+
else if (i instanceof R) if (i.value === 22) o = !0;
|
|
2518
2827
|
else if (i.value === 21) o = !1;
|
|
2519
2828
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2520
2829
|
else throw Error("cri: unexpected type for authority element");
|
|
2521
2830
|
let s = "";
|
|
2522
|
-
if (t < e.length && e[t] instanceof
|
|
2831
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2523
2832
|
let n = e[t++];
|
|
2524
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2833
|
+
n.items.length > 0 && (s = (o ? "/" : "") + Gn(n).join("/"));
|
|
2525
2834
|
}
|
|
2526
|
-
return r + a + s +
|
|
2835
|
+
return r + a + s + Wn(e, t);
|
|
2527
2836
|
}
|
|
2528
|
-
if (n instanceof
|
|
2529
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2530
|
-
let n =
|
|
2531
|
-
if (t < e.length && e[t] instanceof
|
|
2837
|
+
if (n instanceof R && n.value === 20) {
|
|
2838
|
+
if (t >= e.length || !(e[t] instanceof I)) throw Error("cri: network-path reference requires an authority array");
|
|
2839
|
+
let n = Vn(e[t++]), r = "";
|
|
2840
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2532
2841
|
let n = e[t++];
|
|
2533
|
-
n.items.length > 0 && (r = "/" +
|
|
2842
|
+
n.items.length > 0 && (r = "/" + Gn(n).join("/"));
|
|
2534
2843
|
}
|
|
2535
|
-
return "//" + n + r +
|
|
2844
|
+
return "//" + n + r + Wn(e, t);
|
|
2536
2845
|
}
|
|
2537
|
-
if (n instanceof
|
|
2846
|
+
if (n instanceof R && n.value === 21) {
|
|
2538
2847
|
let n = "/";
|
|
2539
|
-
if (t < e.length && e[t] instanceof
|
|
2848
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2540
2849
|
let r = e[t++];
|
|
2541
|
-
n = "/" +
|
|
2850
|
+
n = "/" + Gn(r).join("/");
|
|
2542
2851
|
}
|
|
2543
|
-
return n +
|
|
2852
|
+
return n + Wn(e, t);
|
|
2544
2853
|
}
|
|
2545
|
-
if (n instanceof
|
|
2854
|
+
if (n instanceof k) {
|
|
2546
2855
|
let r = n.value;
|
|
2547
|
-
if (r === 0n) return
|
|
2856
|
+
if (r === 0n) return Wn(e, t);
|
|
2548
2857
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2549
|
-
if (t < e.length && e[t] instanceof
|
|
2858
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2550
2859
|
let n = e[t++];
|
|
2551
2860
|
if (n.items.length > 0) {
|
|
2552
|
-
let e =
|
|
2861
|
+
let e = Gn(n);
|
|
2553
2862
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2554
2863
|
} else a = i === "" ? "./" : i;
|
|
2555
2864
|
} else a = i === "" ? "./" : i;
|
|
2556
|
-
return a +
|
|
2865
|
+
return a + Wn(e, t);
|
|
2557
2866
|
}
|
|
2558
2867
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2559
2868
|
}
|
|
2560
|
-
var
|
|
2869
|
+
var qn = class extends I {
|
|
2561
2870
|
_toCDN(e, t) {
|
|
2562
2871
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2872
|
+
let n = a(e, this.encodingWidth, () => p(BigInt(this.items.length)));
|
|
2873
|
+
if (_(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2563
2874
|
try {
|
|
2564
|
-
|
|
2565
|
-
return `${dn}'${Mn(this.items)}'${t}`;
|
|
2875
|
+
return `${Tn}'${Kn(this.items)}'${n}`;
|
|
2566
2876
|
} catch {
|
|
2567
2877
|
return super._toCDN(e, t);
|
|
2568
2878
|
}
|
|
2569
2879
|
}
|
|
2570
|
-
},
|
|
2880
|
+
}, Jn = class extends M {
|
|
2571
2881
|
constructor(e) {
|
|
2572
|
-
super(
|
|
2882
|
+
super(Dn, e);
|
|
2573
2883
|
}
|
|
2574
2884
|
_toCDN(e, t) {
|
|
2575
2885
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2886
|
+
let n = _(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
2887
|
+
if (n === "verbatim") return this.appSeqSource;
|
|
2888
|
+
if (n === "source") return g(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
2889
|
+
if (n === "structural") return super._toCDN({
|
|
2890
|
+
...e,
|
|
2891
|
+
appStrings: !1
|
|
2892
|
+
}, t);
|
|
2576
2893
|
try {
|
|
2577
|
-
let
|
|
2578
|
-
if (
|
|
2579
|
-
let
|
|
2580
|
-
return `${
|
|
2894
|
+
let r = this.content;
|
|
2895
|
+
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2896
|
+
let i = a(e, this.encodingWidth, () => p(Dn));
|
|
2897
|
+
return n === "adjusted" ? m(this.appSeqSource, i, e, this.appSeqInnerEnd, this.appSeqComments) : `${En}'${Kn(r.items)}'${i}`;
|
|
2581
2898
|
} catch {
|
|
2582
2899
|
return super._toCDN(e, t);
|
|
2583
2900
|
}
|
|
2584
2901
|
}
|
|
2585
2902
|
};
|
|
2586
|
-
function
|
|
2903
|
+
function Yn(e) {
|
|
2587
2904
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2588
2905
|
let t = e[0];
|
|
2589
|
-
if (t instanceof
|
|
2590
|
-
if (t instanceof
|
|
2906
|
+
if (t instanceof G) return t.value;
|
|
2907
|
+
if (t instanceof N) return jn.decode(t.value);
|
|
2591
2908
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2592
2909
|
}
|
|
2593
|
-
function
|
|
2594
|
-
let n = new
|
|
2595
|
-
return e ===
|
|
2910
|
+
function Xn(e, t) {
|
|
2911
|
+
let n = new qn(Un(t));
|
|
2912
|
+
return e === En ? new Jn(n) : n;
|
|
2596
2913
|
}
|
|
2597
|
-
var
|
|
2598
|
-
appStringPrefixes: [
|
|
2599
|
-
tagNumbers: [
|
|
2914
|
+
var Zn = {
|
|
2915
|
+
appStringPrefixes: [Tn, En],
|
|
2916
|
+
tagNumbers: [Dn],
|
|
2917
|
+
preserveAppSeqSource: "optional",
|
|
2600
2918
|
parseAppString(e, t) {
|
|
2601
|
-
return
|
|
2919
|
+
return Xn(e, t);
|
|
2602
2920
|
},
|
|
2603
2921
|
parseAppSequence(e, t) {
|
|
2604
|
-
return
|
|
2922
|
+
return Xn(e, Yn(t));
|
|
2605
2923
|
},
|
|
2606
2924
|
parseTag(e, t) {
|
|
2607
|
-
if (e !== 99n || !(t instanceof
|
|
2608
|
-
let n = new
|
|
2925
|
+
if (e !== 99n || !(t instanceof I)) return;
|
|
2926
|
+
let n = new qn(t.items, {
|
|
2609
2927
|
indefiniteLength: t.indefiniteLength,
|
|
2610
2928
|
encodingWidth: t.encodingWidth
|
|
2611
2929
|
});
|
|
2612
|
-
return n.start = t.start, n.end = t.end, new
|
|
2930
|
+
return n.start = t.start, n.end = t.end, new Jn(n);
|
|
2613
2931
|
}
|
|
2614
|
-
},
|
|
2615
|
-
tagNumbers: [
|
|
2932
|
+
}, Qn = 18446744073709551615n, $n = -18446744073709551616n, er = {
|
|
2933
|
+
tagNumbers: [Qe, $e],
|
|
2616
2934
|
parseTag(e, t) {
|
|
2617
|
-
if (t instanceof
|
|
2935
|
+
if (t instanceof N) {
|
|
2618
2936
|
if (e === 2n) {
|
|
2619
|
-
let e =
|
|
2620
|
-
return e >
|
|
2937
|
+
let e = rt(t.value);
|
|
2938
|
+
return e > Qn ? new it(e) : void 0;
|
|
2621
2939
|
}
|
|
2622
2940
|
if (e === 3n) {
|
|
2623
|
-
let e = -1n -
|
|
2624
|
-
return e <
|
|
2941
|
+
let e = -1n - rt(t.value);
|
|
2942
|
+
return e < $n ? new at(e) : void 0;
|
|
2625
2943
|
}
|
|
2626
2944
|
}
|
|
2627
2945
|
}
|
|
2628
2946
|
};
|
|
2629
2947
|
//#endregion
|
|
2630
2948
|
//#region src/cbor/decoder.ts
|
|
2631
|
-
function
|
|
2949
|
+
function tr(e, t) {
|
|
2632
2950
|
if (e === 24 && t <= 23n) return 0;
|
|
2633
2951
|
if (e === 25 && t <= 255n) return 1;
|
|
2634
2952
|
if (e === 26 && t <= 65535n) return 2;
|
|
2635
2953
|
if (e === 27 && t <= 4294967295n) return 3;
|
|
2636
2954
|
}
|
|
2637
|
-
function
|
|
2955
|
+
function nr(e, t) {
|
|
2638
2956
|
if (e === 24 && t <= 23) return 0;
|
|
2639
2957
|
if (e === 25 && t <= 255) return 1;
|
|
2640
2958
|
if (e === 26 && t <= 65535) return 2;
|
|
2641
2959
|
if (e === 27 && t <= 4294967295) return 3;
|
|
2642
2960
|
}
|
|
2643
|
-
var
|
|
2961
|
+
var rr = new TextDecoder("utf-8", {
|
|
2644
2962
|
fatal: !0,
|
|
2645
2963
|
ignoreBOM: !0
|
|
2646
|
-
}),
|
|
2964
|
+
}), ir = new TextDecoder("utf-8", {
|
|
2647
2965
|
fatal: !1,
|
|
2648
2966
|
ignoreBOM: !0
|
|
2649
2967
|
});
|
|
2650
2968
|
function J(e) {
|
|
2651
2969
|
throw Error(`CBOR decode error: ${e}`);
|
|
2652
2970
|
}
|
|
2653
|
-
function
|
|
2971
|
+
function ar(e, t, n) {
|
|
2654
2972
|
let r = {
|
|
2655
2973
|
message: e,
|
|
2656
2974
|
offset: t
|
|
@@ -2658,63 +2976,63 @@ function Gn(e, t, n) {
|
|
|
2658
2976
|
if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
|
|
2659
2977
|
return r;
|
|
2660
2978
|
}
|
|
2661
|
-
function
|
|
2979
|
+
function or(e, t) {
|
|
2662
2980
|
e.warnings ??= [], e.warnings.push(t);
|
|
2663
2981
|
}
|
|
2664
|
-
function
|
|
2665
|
-
if (e instanceof
|
|
2666
|
-
if (e instanceof
|
|
2667
|
-
if (e instanceof
|
|
2668
|
-
if (e instanceof
|
|
2669
|
-
if (e instanceof
|
|
2670
|
-
if (e instanceof
|
|
2982
|
+
function Y(e) {
|
|
2983
|
+
if (e instanceof k) return ["u", String(e.value)];
|
|
2984
|
+
if (e instanceof A) return ["n", String(e.value)];
|
|
2985
|
+
if (e instanceof G) return ["t", e.value];
|
|
2986
|
+
if (e instanceof F) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2987
|
+
if (e instanceof N) return ["b", y(e.value)];
|
|
2988
|
+
if (e instanceof P) {
|
|
2671
2989
|
let t = "";
|
|
2672
|
-
for (let n of e.chunks) t +=
|
|
2990
|
+
for (let n of e.chunks) t += y(n.value);
|
|
2673
2991
|
return ["b", t];
|
|
2674
2992
|
}
|
|
2675
|
-
if (e instanceof
|
|
2676
|
-
if (e instanceof
|
|
2677
|
-
if (e instanceof
|
|
2678
|
-
if (e instanceof
|
|
2679
|
-
let t = e.entries.map(([e, t]) => [
|
|
2993
|
+
if (e instanceof j) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2994
|
+
if (e instanceof R) return ["s", e.value];
|
|
2995
|
+
if (e instanceof I) return ["A", e.items.map(Y)];
|
|
2996
|
+
if (e instanceof L) {
|
|
2997
|
+
let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
|
|
2680
2998
|
if (t.length <= 1) return ["M", t];
|
|
2681
2999
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2682
3000
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2683
3001
|
}
|
|
2684
|
-
return e instanceof
|
|
3002
|
+
return e instanceof M ? [
|
|
2685
3003
|
"G",
|
|
2686
3004
|
String(e.tag),
|
|
2687
|
-
|
|
2688
|
-
] : ["c",
|
|
2689
|
-
}
|
|
2690
|
-
function
|
|
2691
|
-
if (e instanceof
|
|
2692
|
-
if (e instanceof
|
|
2693
|
-
if (e instanceof
|
|
2694
|
-
if (e instanceof
|
|
3005
|
+
Y(e.content)
|
|
3006
|
+
] : ["c", y(e.toCBOR())];
|
|
3007
|
+
}
|
|
3008
|
+
function sr(e) {
|
|
3009
|
+
if (e instanceof k) return "u" + e.value;
|
|
3010
|
+
if (e instanceof A) return "n" + e.value;
|
|
3011
|
+
if (e instanceof G) return "t" + e.value;
|
|
3012
|
+
if (e instanceof F) {
|
|
2695
3013
|
let t = "t";
|
|
2696
3014
|
for (let n of e.chunks) t += n.value;
|
|
2697
3015
|
return t;
|
|
2698
3016
|
}
|
|
2699
|
-
if (e instanceof
|
|
2700
|
-
if (e instanceof
|
|
3017
|
+
if (e instanceof N) return "b" + y(e.value);
|
|
3018
|
+
if (e instanceof P) {
|
|
2701
3019
|
let t = "b";
|
|
2702
|
-
for (let n of e.chunks) t +=
|
|
3020
|
+
for (let n of e.chunks) t += y(n.value);
|
|
2703
3021
|
return t;
|
|
2704
3022
|
}
|
|
2705
|
-
return e instanceof
|
|
3023
|
+
return e instanceof j ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof R ? "s" + e.value : JSON.stringify(Y(e));
|
|
2706
3024
|
}
|
|
2707
|
-
var
|
|
2708
|
-
function
|
|
2709
|
-
return e === void 0 ?
|
|
3025
|
+
var cr = Array.from({ length: 24 }, (e, t) => BigInt(t)), lr;
|
|
3026
|
+
function ur(e) {
|
|
3027
|
+
return e === void 0 ? lr ??= Z(void 0).filter((e) => e.parseTag !== void 0) : Z(e).filter((e) => e.parseTag !== void 0);
|
|
2710
3028
|
}
|
|
2711
|
-
function
|
|
3029
|
+
function dr(e, t) {
|
|
2712
3030
|
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
2713
3031
|
return String.fromCharCode.apply(null, e);
|
|
2714
3032
|
}
|
|
2715
|
-
function
|
|
3033
|
+
function fr(e, t, n) {
|
|
2716
3034
|
if (n <= 23) return {
|
|
2717
|
-
value:
|
|
3035
|
+
value: cr[n],
|
|
2718
3036
|
nextOffset: t
|
|
2719
3037
|
};
|
|
2720
3038
|
switch (n) {
|
|
@@ -2737,7 +3055,7 @@ function Qn(e, t, n) {
|
|
|
2737
3055
|
default: J(`reserved additional info value: ${n}`);
|
|
2738
3056
|
}
|
|
2739
3057
|
}
|
|
2740
|
-
function
|
|
3058
|
+
function pr(e, t, n) {
|
|
2741
3059
|
if (n <= 23) return {
|
|
2742
3060
|
value: n,
|
|
2743
3061
|
nextOffset: t
|
|
@@ -2766,7 +3084,7 @@ function $n(e, t, n) {
|
|
|
2766
3084
|
default: J(`reserved additional info value: ${n}`);
|
|
2767
3085
|
}
|
|
2768
3086
|
}
|
|
2769
|
-
function
|
|
3087
|
+
function mr(e, t, n, r, i, a) {
|
|
2770
3088
|
let o = [], s = t;
|
|
2771
3089
|
for (;;) {
|
|
2772
3090
|
if (s >= e.byteLength && J(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
@@ -2781,68 +3099,68 @@ function er(e, t, n, r, i, a) {
|
|
|
2781
3099
|
nextOffset: s
|
|
2782
3100
|
};
|
|
2783
3101
|
}
|
|
2784
|
-
function
|
|
2785
|
-
let i =
|
|
2786
|
-
t.has(i) && n.push(
|
|
3102
|
+
function hr(e, t, n, r) {
|
|
3103
|
+
let i = sr(e);
|
|
3104
|
+
t.has(i) && n.push(ar(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2787
3105
|
}
|
|
2788
3106
|
function X(e, t, n, r) {
|
|
2789
|
-
let i = t, a =
|
|
3107
|
+
let i = t, a = _r(e, t, n, r);
|
|
2790
3108
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2791
3109
|
}
|
|
2792
|
-
function
|
|
3110
|
+
function gr(e, t, n) {
|
|
2793
3111
|
return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
|
|
2794
3112
|
}
|
|
2795
|
-
function
|
|
3113
|
+
function _r(e, t, n, r) {
|
|
2796
3114
|
t >= e.byteLength && J("unexpected end of input");
|
|
2797
3115
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2798
3116
|
switch (a) {
|
|
2799
3117
|
case 0: {
|
|
2800
|
-
let { value: n, nextOffset: r } =
|
|
3118
|
+
let { value: n, nextOffset: r } = fr(e, t, o);
|
|
2801
3119
|
return {
|
|
2802
|
-
value: new
|
|
3120
|
+
value: new k(n, { encodingWidth: tr(o, n) }),
|
|
2803
3121
|
nextOffset: r
|
|
2804
3122
|
};
|
|
2805
3123
|
}
|
|
2806
3124
|
case 1: {
|
|
2807
|
-
let { value: n, nextOffset: r } =
|
|
3125
|
+
let { value: n, nextOffset: r } = fr(e, t, o), i = tr(o, n);
|
|
2808
3126
|
return {
|
|
2809
|
-
value: new
|
|
3127
|
+
value: new A(-1n - n, { encodingWidth: i }),
|
|
2810
3128
|
nextOffset: r
|
|
2811
3129
|
};
|
|
2812
3130
|
}
|
|
2813
3131
|
case 2: {
|
|
2814
3132
|
if (o === 31) {
|
|
2815
|
-
let { chunks: i, nextOffset: a } =
|
|
3133
|
+
let { chunks: i, nextOffset: a } = mr(e, t, n, r, "byte string", (e) => e instanceof N);
|
|
2816
3134
|
return {
|
|
2817
|
-
value: new
|
|
3135
|
+
value: new P(i),
|
|
2818
3136
|
nextOffset: a
|
|
2819
3137
|
};
|
|
2820
3138
|
}
|
|
2821
|
-
let { value: i, nextOffset: a } =
|
|
3139
|
+
let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i);
|
|
2822
3140
|
return a + i > e.byteLength && J("byte string extends beyond input"), {
|
|
2823
|
-
value: new
|
|
3141
|
+
value: new N(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
2824
3142
|
nextOffset: a + i
|
|
2825
3143
|
};
|
|
2826
3144
|
}
|
|
2827
3145
|
case 3: {
|
|
2828
3146
|
if (o === 31) {
|
|
2829
|
-
let { chunks: i, nextOffset: a } =
|
|
3147
|
+
let { chunks: i, nextOffset: a } = mr(e, t, n, r, "text string", (e) => e instanceof G);
|
|
2830
3148
|
return {
|
|
2831
|
-
value: new
|
|
3149
|
+
value: new F(i),
|
|
2832
3150
|
nextOffset: a
|
|
2833
3151
|
};
|
|
2834
3152
|
}
|
|
2835
|
-
let { value: i, nextOffset: a } =
|
|
3153
|
+
let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i);
|
|
2836
3154
|
a + i > e.byteLength && J("text string extends beyond input");
|
|
2837
|
-
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ?
|
|
3155
|
+
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? dr(c, i) : void 0;
|
|
2838
3156
|
if (d !== void 0) l = d;
|
|
2839
3157
|
else try {
|
|
2840
|
-
l =
|
|
3158
|
+
l = rr.decode(c);
|
|
2841
3159
|
} catch {
|
|
2842
|
-
u =
|
|
3160
|
+
u = ar("invalid UTF-8 sequence in text string", a, n), l = ir.decode(c);
|
|
2843
3161
|
}
|
|
2844
|
-
let f = new
|
|
2845
|
-
return u &&
|
|
3162
|
+
let f = new G(l, { encodingWidth: s });
|
|
3163
|
+
return u && or(f, u), {
|
|
2846
3164
|
value: f,
|
|
2847
3165
|
nextOffset: a + i
|
|
2848
3166
|
};
|
|
@@ -2859,17 +3177,17 @@ function rr(e, t, n, r) {
|
|
|
2859
3177
|
i.push(t.value), a = t.nextOffset;
|
|
2860
3178
|
}
|
|
2861
3179
|
return {
|
|
2862
|
-
value: new
|
|
3180
|
+
value: new I(i, { indefiniteLength: !0 }),
|
|
2863
3181
|
nextOffset: a
|
|
2864
3182
|
};
|
|
2865
3183
|
}
|
|
2866
|
-
let { value: i, nextOffset: a } =
|
|
3184
|
+
let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i), c = [], l = a;
|
|
2867
3185
|
for (let t = 0; t < i; t++) {
|
|
2868
3186
|
let t = X(e, l, n, r);
|
|
2869
3187
|
c.push(t.value), l = t.nextOffset;
|
|
2870
3188
|
}
|
|
2871
3189
|
return {
|
|
2872
|
-
value: new
|
|
3190
|
+
value: new I(c, { encodingWidth: s }),
|
|
2873
3191
|
nextOffset: l
|
|
2874
3192
|
};
|
|
2875
3193
|
}
|
|
@@ -2882,26 +3200,26 @@ function rr(e, t, n, r) {
|
|
|
2882
3200
|
break;
|
|
2883
3201
|
}
|
|
2884
3202
|
let t = X(e, s, n, r);
|
|
2885
|
-
|
|
3203
|
+
hr(t.value, a, o, n), s = t.nextOffset;
|
|
2886
3204
|
let c = X(e, s, n, r);
|
|
2887
3205
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2888
3206
|
}
|
|
2889
|
-
let c = new
|
|
2890
|
-
for (let e of o)
|
|
3207
|
+
let c = new L(i, { indefiniteLength: !0 });
|
|
3208
|
+
for (let e of o) or(c, e);
|
|
2891
3209
|
return {
|
|
2892
3210
|
value: c,
|
|
2893
3211
|
nextOffset: s
|
|
2894
3212
|
};
|
|
2895
3213
|
}
|
|
2896
|
-
let { value: i, nextOffset: a } =
|
|
3214
|
+
let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
2897
3215
|
for (let t = 0; t < i; t++) {
|
|
2898
3216
|
let t = X(e, d, n, r);
|
|
2899
|
-
|
|
3217
|
+
hr(t.value, l, u, n), d = t.nextOffset;
|
|
2900
3218
|
let i = X(e, d, n, r);
|
|
2901
3219
|
d = i.nextOffset, c.push([t.value, i.value]);
|
|
2902
3220
|
}
|
|
2903
|
-
let f = new
|
|
2904
|
-
for (let e of u)
|
|
3221
|
+
let f = new L(c, { encodingWidth: s });
|
|
3222
|
+
for (let e of u) or(f, e);
|
|
2905
3223
|
return {
|
|
2906
3224
|
value: f,
|
|
2907
3225
|
nextOffset: d
|
|
@@ -2909,62 +3227,62 @@ function rr(e, t, n, r) {
|
|
|
2909
3227
|
}
|
|
2910
3228
|
case 6: {
|
|
2911
3229
|
o === 31 && J("tags cannot use indefinite-length encoding");
|
|
2912
|
-
let { value: i, nextOffset: a } =
|
|
3230
|
+
let { value: i, nextOffset: a } = fr(e, t, o), s = tr(o, i), c = X(e, a, n, r);
|
|
2913
3231
|
for (let e of r) {
|
|
2914
3232
|
let t = e.parseTag(i, c.value, n);
|
|
2915
|
-
if (t !== void 0) return t instanceof
|
|
3233
|
+
if (t !== void 0) return t instanceof M && s !== void 0 && (t.encodingWidth = s), {
|
|
2916
3234
|
value: t,
|
|
2917
3235
|
nextOffset: c.nextOffset
|
|
2918
3236
|
};
|
|
2919
3237
|
}
|
|
2920
3238
|
return {
|
|
2921
|
-
value: new
|
|
3239
|
+
value: new M(i, c.value, { encodingWidth: s }),
|
|
2922
3240
|
nextOffset: c.nextOffset
|
|
2923
3241
|
};
|
|
2924
3242
|
}
|
|
2925
3243
|
case 7:
|
|
2926
3244
|
if (o <= 19) return {
|
|
2927
|
-
value: new
|
|
3245
|
+
value: new R(o),
|
|
2928
3246
|
nextOffset: t
|
|
2929
3247
|
};
|
|
2930
3248
|
if (o === 20) return {
|
|
2931
|
-
value: new
|
|
3249
|
+
value: new R(20),
|
|
2932
3250
|
nextOffset: t
|
|
2933
3251
|
};
|
|
2934
3252
|
if (o === 21) return {
|
|
2935
|
-
value: new
|
|
3253
|
+
value: new R(21),
|
|
2936
3254
|
nextOffset: t
|
|
2937
3255
|
};
|
|
2938
3256
|
if (o === 22) return {
|
|
2939
|
-
value: new
|
|
3257
|
+
value: new R(22),
|
|
2940
3258
|
nextOffset: t
|
|
2941
3259
|
};
|
|
2942
3260
|
if (o === 23) return {
|
|
2943
|
-
value: new
|
|
3261
|
+
value: new R(23),
|
|
2944
3262
|
nextOffset: t
|
|
2945
3263
|
};
|
|
2946
3264
|
if (o === 24) {
|
|
2947
3265
|
t + 1 > e.byteLength && J("unexpected end of input");
|
|
2948
3266
|
let r = e.getUint8(t);
|
|
2949
3267
|
if (r < 32) {
|
|
2950
|
-
let e =
|
|
2951
|
-
return
|
|
3268
|
+
let e = ar(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new R(r);
|
|
3269
|
+
return or(i, e), {
|
|
2952
3270
|
value: i,
|
|
2953
3271
|
nextOffset: t + 1
|
|
2954
3272
|
};
|
|
2955
3273
|
}
|
|
2956
3274
|
return {
|
|
2957
|
-
value: new
|
|
3275
|
+
value: new R(r),
|
|
2958
3276
|
nextOffset: t + 1
|
|
2959
3277
|
};
|
|
2960
3278
|
}
|
|
2961
3279
|
if (o === 25) {
|
|
2962
3280
|
t + 2 > e.byteLength && J("unexpected end of input");
|
|
2963
|
-
let n =
|
|
3281
|
+
let n = C(e.getUint16(t, !1));
|
|
2964
3282
|
return {
|
|
2965
|
-
value: new
|
|
3283
|
+
value: new j(n, {
|
|
2966
3284
|
precision: "half",
|
|
2967
|
-
rawBits: Number.isNaN(n) ?
|
|
3285
|
+
rawBits: Number.isNaN(n) ? gr(e, t, 2) : void 0
|
|
2968
3286
|
}),
|
|
2969
3287
|
nextOffset: t + 2
|
|
2970
3288
|
};
|
|
@@ -2973,9 +3291,9 @@ function rr(e, t, n, r) {
|
|
|
2973
3291
|
t + 4 > e.byteLength && J("unexpected end of input");
|
|
2974
3292
|
let n = e.getFloat32(t, !1);
|
|
2975
3293
|
return {
|
|
2976
|
-
value: new
|
|
3294
|
+
value: new j(n, {
|
|
2977
3295
|
precision: "single",
|
|
2978
|
-
rawBits: Number.isNaN(n) ?
|
|
3296
|
+
rawBits: Number.isNaN(n) ? gr(e, t, 4) : void 0
|
|
2979
3297
|
}),
|
|
2980
3298
|
nextOffset: t + 4
|
|
2981
3299
|
};
|
|
@@ -2984,9 +3302,9 @@ function rr(e, t, n, r) {
|
|
|
2984
3302
|
t + 8 > e.byteLength && J("unexpected end of input");
|
|
2985
3303
|
let n = e.getFloat64(t, !1);
|
|
2986
3304
|
return {
|
|
2987
|
-
value: new
|
|
3305
|
+
value: new j(n, {
|
|
2988
3306
|
precision: "double",
|
|
2989
|
-
rawBits: Number.isNaN(n) ?
|
|
3307
|
+
rawBits: Number.isNaN(n) ? gr(e, t, 8) : void 0
|
|
2990
3308
|
}),
|
|
2991
3309
|
nextOffset: t + 8
|
|
2992
3310
|
};
|
|
@@ -2995,17 +3313,17 @@ function rr(e, t, n, r) {
|
|
|
2995
3313
|
}
|
|
2996
3314
|
return J(`unknown major type: ${a}`);
|
|
2997
3315
|
}
|
|
2998
|
-
function
|
|
3316
|
+
function vr(e) {
|
|
2999
3317
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
3000
3318
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
3001
3319
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
3002
3320
|
}
|
|
3003
|
-
function
|
|
3004
|
-
let n =
|
|
3321
|
+
function yr(e, t) {
|
|
3322
|
+
let n = vr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
3005
3323
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
3006
|
-
let a =
|
|
3324
|
+
let a = ur(t?.builtinExtensions), o = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...a] : a, { value: s, nextOffset: c } = X(r, i, t, o);
|
|
3007
3325
|
if (!t?.allowTrailing && c !== r.byteLength) {
|
|
3008
|
-
|
|
3326
|
+
or(s, ar(`${r.byteLength - c} trailing byte(s) after end of CBOR item`, c, t));
|
|
3009
3327
|
let e = {
|
|
3010
3328
|
strict: !1,
|
|
3011
3329
|
silent: !0
|
|
@@ -3016,10 +3334,10 @@ function ar(e, t) {
|
|
|
3016
3334
|
}
|
|
3017
3335
|
//#endregion
|
|
3018
3336
|
//#region src/extensions/cbordata.ts
|
|
3019
|
-
var
|
|
3020
|
-
tagNumbers: [
|
|
3337
|
+
var br = 24n, xr = {
|
|
3338
|
+
tagNumbers: [br],
|
|
3021
3339
|
parseTag(e, t, n) {
|
|
3022
|
-
if (e !== 24n || !(t instanceof
|
|
3340
|
+
if (e !== 24n || !(t instanceof N)) return;
|
|
3023
3341
|
let r = (t.end ?? t.value.length) - t.value.length, i = n ? {
|
|
3024
3342
|
extensions: n.extensions,
|
|
3025
3343
|
builtinExtensions: n.builtinExtensions,
|
|
@@ -3031,7 +3349,7 @@ var or = 24n, sr = {
|
|
|
3031
3349
|
silent: n.silent
|
|
3032
3350
|
} : void 0;
|
|
3033
3351
|
try {
|
|
3034
|
-
return new
|
|
3352
|
+
return new M(br, new z([yr(t.value, i)], { encodingWidth: t.encodingWidth }));
|
|
3035
3353
|
} catch (e) {
|
|
3036
3354
|
if (i?.strict !== !1) throw e;
|
|
3037
3355
|
let t = `tag 24 content is not valid CBOR: ${e instanceof Error ? e.message : String(e)}`, a = {
|
|
@@ -3045,194 +3363,156 @@ var or = 24n, sr = {
|
|
|
3045
3363
|
};
|
|
3046
3364
|
//#endregion
|
|
3047
3365
|
//#region src/extensions/ellipsis.ts
|
|
3048
|
-
function
|
|
3049
|
-
return e instanceof V && !(e.content instanceof
|
|
3366
|
+
function Sr(e) {
|
|
3367
|
+
return e instanceof V && !(e.content instanceof I);
|
|
3050
3368
|
}
|
|
3051
|
-
function
|
|
3369
|
+
function Cr(e) {
|
|
3052
3370
|
let t = !1, n = !1, r = !1, i;
|
|
3053
3371
|
for (let a of e) {
|
|
3054
3372
|
let e;
|
|
3055
|
-
if (
|
|
3056
|
-
else if (a instanceof
|
|
3057
|
-
else if (a instanceof
|
|
3373
|
+
if (Sr(a)) e = !0, r = !0;
|
|
3374
|
+
else if (a instanceof G) e = !1, t = !0;
|
|
3375
|
+
else if (a instanceof N) e = !1, n = !0;
|
|
3058
3376
|
else return !1;
|
|
3059
3377
|
if (e === i) return !1;
|
|
3060
3378
|
i = e;
|
|
3061
3379
|
}
|
|
3062
3380
|
return r && !(t && n);
|
|
3063
3381
|
}
|
|
3064
|
-
var
|
|
3382
|
+
var wr = {
|
|
3065
3383
|
tagNumbers: [Ke],
|
|
3066
3384
|
parseTag(e, t) {
|
|
3067
3385
|
if (e === 888n) {
|
|
3068
|
-
if (t instanceof
|
|
3069
|
-
if (t instanceof
|
|
3386
|
+
if (t instanceof R && t.value === 22) return new V();
|
|
3387
|
+
if (t instanceof I && Cr(t.items)) return new V(t.items);
|
|
3070
3388
|
}
|
|
3071
3389
|
}
|
|
3072
|
-
},
|
|
3073
|
-
function
|
|
3390
|
+
}, Tr = new TextEncoder(), Er = new TextDecoder("utf-8", { fatal: !0 }), Dr = new TextDecoder("utf-8", { fatal: !1 }), Or = Symbol("ellipsis");
|
|
3391
|
+
function kr(e) {
|
|
3074
3392
|
let t = 0;
|
|
3075
3393
|
for (let n of e) t += n.length;
|
|
3076
3394
|
let n = new Uint8Array(t), r = 0;
|
|
3077
3395
|
for (let t of e) n.set(t, r), r += t.length;
|
|
3078
3396
|
return n;
|
|
3079
3397
|
}
|
|
3080
|
-
function
|
|
3081
|
-
if (t instanceof
|
|
3082
|
-
|
|
3398
|
+
function Ar(e, t, n) {
|
|
3399
|
+
if (t instanceof B) {
|
|
3400
|
+
Ar(e, t.inner, n);
|
|
3083
3401
|
return;
|
|
3084
3402
|
}
|
|
3085
3403
|
if (t instanceof V) {
|
|
3086
|
-
if (t.content instanceof
|
|
3087
|
-
else n.push(
|
|
3404
|
+
if (t.content instanceof I) for (let r of t.content.items) Ar(e, r, n);
|
|
3405
|
+
else n.push(Or);
|
|
3088
3406
|
return;
|
|
3089
3407
|
}
|
|
3090
|
-
if (t instanceof
|
|
3091
|
-
n.push(
|
|
3408
|
+
if (t instanceof G) {
|
|
3409
|
+
n.push(Tr.encode(t.value));
|
|
3092
3410
|
return;
|
|
3093
3411
|
}
|
|
3094
|
-
if (t instanceof
|
|
3412
|
+
if (t instanceof N) {
|
|
3095
3413
|
n.push(t.value);
|
|
3096
3414
|
return;
|
|
3097
3415
|
}
|
|
3098
|
-
if (t instanceof
|
|
3099
|
-
n.push(
|
|
3416
|
+
if (t instanceof F) {
|
|
3417
|
+
n.push(Tr.encode(t.chunks.map((e) => e.value).join("")));
|
|
3100
3418
|
return;
|
|
3101
3419
|
}
|
|
3102
|
-
if (t instanceof
|
|
3103
|
-
n.push(
|
|
3420
|
+
if (t instanceof P) {
|
|
3421
|
+
n.push(kr(t.chunks.map((e) => e.value)));
|
|
3104
3422
|
return;
|
|
3105
3423
|
}
|
|
3106
3424
|
throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings or ellipses`);
|
|
3107
3425
|
}
|
|
3108
|
-
function
|
|
3426
|
+
function jr(e, t) {
|
|
3109
3427
|
try {
|
|
3110
|
-
return
|
|
3428
|
+
return Er.decode(e);
|
|
3111
3429
|
} catch {
|
|
3112
3430
|
let n = "t1 concatenation result is not valid UTF-8";
|
|
3113
3431
|
if (t) t(n);
|
|
3114
3432
|
else throw SyntaxError(n);
|
|
3115
|
-
return
|
|
3433
|
+
return Dr.decode(e);
|
|
3116
3434
|
}
|
|
3117
3435
|
}
|
|
3118
|
-
function
|
|
3436
|
+
function Mr(e, t, n) {
|
|
3119
3437
|
let r = [];
|
|
3120
|
-
for (let n of t)
|
|
3438
|
+
for (let n of t) Ar(e, n, r);
|
|
3121
3439
|
let i = e === "t1", a = [], o = !1, s = [], c = () => {
|
|
3122
3440
|
if (s.length === 0) return;
|
|
3123
|
-
let e =
|
|
3124
|
-
s.length = 0, e.length !== 0 && a.push(i ? new
|
|
3441
|
+
let e = kr(s);
|
|
3442
|
+
s.length = 0, e.length !== 0 && a.push(i ? new G(jr(e, n)) : new N(e));
|
|
3125
3443
|
};
|
|
3126
|
-
for (let e of r) e ===
|
|
3444
|
+
for (let e of r) e === Or ? (c(), a[a.length - 1] instanceof V || (a.push(new V()), o = !0)) : s.push(e);
|
|
3127
3445
|
if (!o) {
|
|
3128
|
-
let e =
|
|
3129
|
-
return i ? new
|
|
3446
|
+
let e = kr(s);
|
|
3447
|
+
return i ? new G(jr(e, n)) : new N(e);
|
|
3130
3448
|
}
|
|
3131
3449
|
return c(), a.length === 1 ? new V() : new V(a);
|
|
3132
3450
|
}
|
|
3133
|
-
function
|
|
3451
|
+
function Nr(e) {
|
|
3134
3452
|
return {
|
|
3135
3453
|
appStringPrefixes: [e],
|
|
3136
3454
|
preserveAppSeqSource: !0,
|
|
3137
3455
|
parseAppString(t, n, r) {
|
|
3138
|
-
return
|
|
3456
|
+
return Mr(e, [new G(n)], r);
|
|
3139
3457
|
},
|
|
3140
3458
|
parseAppSequence(t, n, r) {
|
|
3141
|
-
return
|
|
3459
|
+
return Mr(e, n, r);
|
|
3142
3460
|
}
|
|
3143
3461
|
};
|
|
3144
3462
|
}
|
|
3145
|
-
var
|
|
3146
|
-
function
|
|
3463
|
+
var Pr = Nr("t1"), Fr = Nr("b1"), Ir = new TextEncoder(), Lr = new TextDecoder("utf-8", { fatal: !0 }), Rr = new TextDecoder("utf-8", { fatal: !1 });
|
|
3464
|
+
function zr(e) {
|
|
3147
3465
|
let t = 0;
|
|
3148
3466
|
for (let n of e) t += n.length;
|
|
3149
3467
|
let n = new Uint8Array(t), r = 0;
|
|
3150
3468
|
for (let t of e) n.set(t, r), r += t.length;
|
|
3151
3469
|
return n;
|
|
3152
3470
|
}
|
|
3153
|
-
function
|
|
3471
|
+
function Br(e, t, n) {
|
|
3154
3472
|
let r = e === "ilts", i = [], a = [];
|
|
3155
3473
|
for (let o of t) {
|
|
3156
|
-
if (o instanceof
|
|
3474
|
+
if (o instanceof B && (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`);
|
|
3157
3475
|
let t, s, c;
|
|
3158
|
-
if (o instanceof
|
|
3159
|
-
else if (o instanceof
|
|
3160
|
-
else if (o instanceof
|
|
3161
|
-
else if (o instanceof
|
|
3476
|
+
if (o instanceof G) t = o.value, c = o.encodingWidth;
|
|
3477
|
+
else if (o instanceof N) s = o.value, c = o.encodingWidth;
|
|
3478
|
+
else if (o instanceof F) t = o.chunks.map((e) => e.value).join("");
|
|
3479
|
+
else if (o instanceof P) s = zr(o.chunks.map((e) => e.value));
|
|
3162
3480
|
else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);
|
|
3163
3481
|
if (r) {
|
|
3164
3482
|
let e;
|
|
3165
3483
|
if (t !== void 0) e = t;
|
|
3166
3484
|
else try {
|
|
3167
|
-
e =
|
|
3485
|
+
e = Lr.decode(s);
|
|
3168
3486
|
} catch {
|
|
3169
3487
|
let t = "ilts chunk is not valid UTF-8";
|
|
3170
3488
|
if (n) n(t);
|
|
3171
3489
|
else throw SyntaxError(t);
|
|
3172
|
-
e =
|
|
3490
|
+
e = Rr.decode(s);
|
|
3173
3491
|
}
|
|
3174
|
-
a.push(new
|
|
3492
|
+
a.push(new G(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3175
3493
|
} else {
|
|
3176
|
-
let e = s ??
|
|
3177
|
-
i.push(new
|
|
3494
|
+
let e = s ?? Ir.encode(t);
|
|
3495
|
+
i.push(new N(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3178
3496
|
}
|
|
3179
3497
|
}
|
|
3180
|
-
return r ? new
|
|
3498
|
+
return r ? new F(a) : new P(i);
|
|
3181
3499
|
}
|
|
3182
|
-
function
|
|
3500
|
+
function Vr(e) {
|
|
3183
3501
|
return {
|
|
3184
3502
|
appStringPrefixes: [e],
|
|
3185
3503
|
preserveAppSeqSource: !0,
|
|
3186
3504
|
parseAppString(t, n, r) {
|
|
3187
|
-
return new
|
|
3505
|
+
return new B(Br(e, [new G(n)], r), `${e}${c(n)}`);
|
|
3188
3506
|
},
|
|
3189
3507
|
parseAppSequence(t, n, r) {
|
|
3190
|
-
return
|
|
3508
|
+
return Br(e, n, r);
|
|
3191
3509
|
}
|
|
3192
3510
|
};
|
|
3193
3511
|
}
|
|
3194
|
-
var
|
|
3195
|
-
//#endregion
|
|
3196
|
-
//#region src/utils/strip-comments.ts
|
|
3197
|
-
function Ar(e) {
|
|
3198
|
-
let t = "", n = 0;
|
|
3199
|
-
for (; n < e.length;) {
|
|
3200
|
-
let r = e[n];
|
|
3201
|
-
if (r === " " || r === "\n" || r === "\r") {
|
|
3202
|
-
n++;
|
|
3203
|
-
continue;
|
|
3204
|
-
}
|
|
3205
|
-
if (r === "#") {
|
|
3206
|
-
for (; n < e.length && e[n] !== "\n";) n++;
|
|
3207
|
-
continue;
|
|
3208
|
-
}
|
|
3209
|
-
if (r === "/") {
|
|
3210
|
-
let t = e[n + 1] ?? "";
|
|
3211
|
-
if (t === "/") {
|
|
3212
|
-
for (; n < e.length && e[n] !== "\n";) n++;
|
|
3213
|
-
continue;
|
|
3214
|
-
}
|
|
3215
|
-
if (t === "*") {
|
|
3216
|
-
for (n += 2; n < e.length && !(e[n] === "*" && (e[n + 1] ?? "") === "/");) n++;
|
|
3217
|
-
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
3218
|
-
n += 2;
|
|
3219
|
-
continue;
|
|
3220
|
-
}
|
|
3221
|
-
for (n++; n < e.length && e[n] !== "/";) n++;
|
|
3222
|
-
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
3223
|
-
n++;
|
|
3224
|
-
continue;
|
|
3225
|
-
}
|
|
3226
|
-
t += r, n++;
|
|
3227
|
-
}
|
|
3228
|
-
return t;
|
|
3229
|
-
}
|
|
3230
|
-
//#endregion
|
|
3231
|
-
//#region src/extensions/float.ts
|
|
3232
|
-
var jr = class extends N {
|
|
3512
|
+
var Hr = Vr("ilbs"), Ur = Vr("ilts"), Wr = class extends j {
|
|
3233
3513
|
_bits;
|
|
3234
3514
|
constructor(e) {
|
|
3235
|
-
super(
|
|
3515
|
+
super(C(e), { precision: "half" }), this._bits = e & 65535;
|
|
3236
3516
|
}
|
|
3237
3517
|
_toCBOR() {
|
|
3238
3518
|
return new Uint8Array([
|
|
@@ -3241,7 +3521,7 @@ var jr = class extends N {
|
|
|
3241
3521
|
this._bits & 255
|
|
3242
3522
|
]);
|
|
3243
3523
|
}
|
|
3244
|
-
},
|
|
3524
|
+
}, Gr = class extends j {
|
|
3245
3525
|
_raw;
|
|
3246
3526
|
constructor(e) {
|
|
3247
3527
|
super(new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), { precision: "single" }), this._raw = e.slice();
|
|
@@ -3250,7 +3530,7 @@ var jr = class extends N {
|
|
|
3250
3530
|
let e = /* @__PURE__ */ new Uint8Array(5);
|
|
3251
3531
|
return e[0] = 250, e.set(this._raw, 1), e;
|
|
3252
3532
|
}
|
|
3253
|
-
},
|
|
3533
|
+
}, Kr = class extends j {
|
|
3254
3534
|
_raw;
|
|
3255
3535
|
constructor(e) {
|
|
3256
3536
|
super(new DataView(e.buffer, e.byteOffset).getFloat64(0, !1), { precision: "double" }), this._raw = e.slice();
|
|
@@ -3260,13 +3540,13 @@ var jr = class extends N {
|
|
|
3260
3540
|
return e[0] = 251, e.set(this._raw, 1), e;
|
|
3261
3541
|
}
|
|
3262
3542
|
};
|
|
3263
|
-
function
|
|
3264
|
-
if (e.length === 2) return new
|
|
3265
|
-
if (e.length === 4) return new
|
|
3266
|
-
if (e.length === 8) return new
|
|
3543
|
+
function qr(e) {
|
|
3544
|
+
if (e.length === 2) return new Wr(e[0] << 8 | e[1]);
|
|
3545
|
+
if (e.length === 4) return new Gr(e);
|
|
3546
|
+
if (e.length === 8) return new Kr(e);
|
|
3267
3547
|
throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`);
|
|
3268
3548
|
}
|
|
3269
|
-
function
|
|
3549
|
+
function Jr(e) {
|
|
3270
3550
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i;
|
|
3271
3551
|
if (n === 31) i = t << 31 | 2139095040 | r << 13;
|
|
3272
3552
|
else if (n === 0 && r === 0) i = t << 31;
|
|
@@ -3278,7 +3558,7 @@ function Fr(e) {
|
|
|
3278
3558
|
let a = /* @__PURE__ */ new Uint8Array(4);
|
|
3279
3559
|
return new DataView(a.buffer).setUint32(0, i >>> 0, !1), a;
|
|
3280
3560
|
}
|
|
3281
|
-
function
|
|
3561
|
+
function Yr(e) {
|
|
3282
3562
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i = /* @__PURE__ */ new Uint8Array(8), a = new DataView(i.buffer);
|
|
3283
3563
|
if (n === 31) a.setUint32(0, (t << 31 | 2146435072 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3284
3564
|
else if (n === 0 && r === 0) a.setUint32(0, t << 31 >>> 0, !1), a.setUint32(4, 0, !1);
|
|
@@ -3289,7 +3569,7 @@ function Ir(e) {
|
|
|
3289
3569
|
} else a.setUint32(0, (t << 31 | n + 1008 << 20 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3290
3570
|
return i;
|
|
3291
3571
|
}
|
|
3292
|
-
function
|
|
3572
|
+
function Xr(e) {
|
|
3293
3573
|
let t = new DataView(e.buffer, e.byteOffset).getUint32(0, !1), n = t >>> 31 & 1, r = t >>> 23 & 255, i = t & 8388607, a = /* @__PURE__ */ new Uint8Array(8), o = new DataView(a.buffer);
|
|
3294
3574
|
if (r === 255) o.setUint32(0, (n << 31 | 2146435072 | i >>> 3) >>> 0, !1), o.setUint32(4, (i & 7) << 29, !1);
|
|
3295
3575
|
else if (r === 0 && i === 0) o.setUint32(0, n << 31 >>> 0, !1), o.setUint32(4, 0, !1);
|
|
@@ -3299,49 +3579,49 @@ function Lr(e) {
|
|
|
3299
3579
|
}
|
|
3300
3580
|
return a;
|
|
3301
3581
|
}
|
|
3302
|
-
function
|
|
3582
|
+
function Zr(e, t, n) {
|
|
3303
3583
|
let r = e.length === 2 ? 1 : e.length === 4 ? 2 : 3;
|
|
3304
3584
|
if (r === 1) {
|
|
3305
3585
|
let n = e[0] << 8 | e[1];
|
|
3306
|
-
if (t === 2) return new
|
|
3307
|
-
if (t === 3) return new
|
|
3586
|
+
if (t === 2) return new Gr(Jr(n));
|
|
3587
|
+
if (t === 3) return new Kr(Yr(n));
|
|
3308
3588
|
}
|
|
3309
3589
|
if (r === 2) {
|
|
3310
|
-
if (t === 3) return new
|
|
3590
|
+
if (t === 3) return new Kr(Xr(e));
|
|
3311
3591
|
if (t === 1) {
|
|
3312
|
-
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r =
|
|
3313
|
-
return !Object.is(
|
|
3592
|
+
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r = S(t);
|
|
3593
|
+
return !Object.is(C(r), t) && !isNaN(t) && n("float'...' value cannot be exactly represented as float16 (_1)"), new Wr(r);
|
|
3314
3594
|
}
|
|
3315
3595
|
}
|
|
3316
3596
|
if (r === 3) {
|
|
3317
3597
|
let r = new DataView(e.buffer, e.byteOffset).getFloat64(0, !1);
|
|
3318
3598
|
if (t === 1) {
|
|
3319
|
-
let e =
|
|
3320
|
-
return !Object.is(
|
|
3599
|
+
let e = S(r);
|
|
3600
|
+
return !Object.is(C(e), r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float16 (_1)"), new Wr(e);
|
|
3321
3601
|
}
|
|
3322
3602
|
if (t === 2) {
|
|
3323
3603
|
let e = Math.fround(r);
|
|
3324
3604
|
!Object.is(e, r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float32 (_2)");
|
|
3325
3605
|
let t = /* @__PURE__ */ new Uint8Array(4);
|
|
3326
|
-
return new DataView(t.buffer).setFloat32(0, e, !1), new
|
|
3606
|
+
return new DataView(t.buffer).setFloat32(0, e, !1), new Gr(t);
|
|
3327
3607
|
}
|
|
3328
3608
|
}
|
|
3329
|
-
return
|
|
3609
|
+
return qr(e);
|
|
3330
3610
|
}
|
|
3331
|
-
var
|
|
3611
|
+
var Qr = {
|
|
3332
3612
|
appStringPrefixes: ["float"],
|
|
3333
|
-
parseAppString(
|
|
3334
|
-
let a =
|
|
3613
|
+
parseAppString(e, t, r, i) {
|
|
3614
|
+
let a = Ie(t);
|
|
3335
3615
|
if (!/^[0-9a-fA-F]*$/.test(a)) throw SyntaxError("float'...' contains non-hex characters");
|
|
3336
3616
|
if (a.length % 2 != 0) throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);
|
|
3337
|
-
let o =
|
|
3338
|
-
if (s === void 0) return
|
|
3617
|
+
let o = n(a), s = i?.encodingWidth;
|
|
3618
|
+
if (s === void 0) return qr(o);
|
|
3339
3619
|
if (s !== 1 && s !== 2 && s !== 3) {
|
|
3340
3620
|
let e = `float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;
|
|
3341
|
-
if (r) return r(e),
|
|
3621
|
+
if (r) return r(e), qr(o);
|
|
3342
3622
|
throw SyntaxError(e);
|
|
3343
3623
|
}
|
|
3344
|
-
return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ?
|
|
3624
|
+
return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ? qr(o) : Zr(o, s, r ?? ((e) => {
|
|
3345
3625
|
throw SyntaxError(e);
|
|
3346
3626
|
}));
|
|
3347
3627
|
},
|
|
@@ -3352,34 +3632,34 @@ var zr = {
|
|
|
3352
3632
|
if (n) n(e);
|
|
3353
3633
|
else throw SyntaxError(e);
|
|
3354
3634
|
}
|
|
3355
|
-
if (!(t[0] instanceof
|
|
3356
|
-
return
|
|
3357
|
-
}
|
|
3358
|
-
},
|
|
3359
|
-
|
|
3360
|
-
sr,
|
|
3361
|
-
ur
|
|
3362
|
-
], Vr = [
|
|
3363
|
-
Wt,
|
|
3364
|
-
un,
|
|
3365
|
-
Ln,
|
|
3366
|
-
br,
|
|
3635
|
+
if (!(t[0] instanceof N)) throw SyntaxError("float<<...>> item must be a byte string");
|
|
3636
|
+
return qr(t[0].value);
|
|
3637
|
+
}
|
|
3638
|
+
}, $r = [
|
|
3639
|
+
er,
|
|
3367
3640
|
xr,
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3641
|
+
wr
|
|
3642
|
+
], ei = [
|
|
3643
|
+
rn,
|
|
3644
|
+
wn,
|
|
3645
|
+
Zn,
|
|
3646
|
+
Pr,
|
|
3647
|
+
Fr,
|
|
3648
|
+
Hr,
|
|
3649
|
+
Ur,
|
|
3650
|
+
Qr
|
|
3651
|
+
], ti;
|
|
3372
3652
|
function Z(e) {
|
|
3373
|
-
return e === void 0 ?
|
|
3653
|
+
return e === void 0 ? ti ??= [...$r, ...ei] : e === !1 ? $r : [...$r, ...e];
|
|
3374
3654
|
}
|
|
3375
3655
|
//#endregion
|
|
3376
3656
|
//#region src/js/fromJS.ts
|
|
3377
|
-
var
|
|
3378
|
-
function
|
|
3657
|
+
var ni;
|
|
3658
|
+
function ri(e) {
|
|
3379
3659
|
if (e === void 0) {
|
|
3380
|
-
if (
|
|
3660
|
+
if (ni) return ni;
|
|
3381
3661
|
let e = Z(void 0);
|
|
3382
|
-
return
|
|
3662
|
+
return ni = {
|
|
3383
3663
|
fromJS: e.filter((e) => e.fromJS !== void 0),
|
|
3384
3664
|
parseTag: e.filter((e) => e.parseTag !== void 0)
|
|
3385
3665
|
};
|
|
@@ -3390,62 +3670,62 @@ function Wr(e) {
|
|
|
3390
3670
|
parseTag: t.filter((e) => e.parseTag !== void 0)
|
|
3391
3671
|
};
|
|
3392
3672
|
}
|
|
3393
|
-
function
|
|
3394
|
-
let t = e?.extensions, n =
|
|
3673
|
+
function ii(e) {
|
|
3674
|
+
let t = e?.extensions, n = ri(e?.builtinExtensions);
|
|
3395
3675
|
return t?.length ? {
|
|
3396
3676
|
fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
|
|
3397
3677
|
parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
|
|
3398
3678
|
} : n;
|
|
3399
3679
|
}
|
|
3400
|
-
function
|
|
3680
|
+
function ai(e, t) {
|
|
3401
3681
|
if (t?.replacer) {
|
|
3402
|
-
let { replacer: n, ...r } = t, i =
|
|
3403
|
-
return i ===
|
|
3682
|
+
let { replacer: n, ...r } = t, i = si(e, n, r.extensions, r.undefinedOmits, r.builtinExtensions);
|
|
3683
|
+
return i === x ? R.UNDEFINED : ai(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3404
3684
|
}
|
|
3405
|
-
return Q(e, t, !0,
|
|
3685
|
+
return Q(e, t, !0, ii(t));
|
|
3406
3686
|
}
|
|
3407
3687
|
function Q(e, t, n, r) {
|
|
3408
3688
|
for (let n of r.fromJS) {
|
|
3409
3689
|
let r = n.fromJS(e, t ?? {});
|
|
3410
3690
|
if (r !== void 0) return r;
|
|
3411
3691
|
}
|
|
3412
|
-
if (n && typeof e == "object" && e &&
|
|
3413
|
-
let n = e[
|
|
3692
|
+
if (n && typeof e == "object" && e && b.symbol in e) {
|
|
3693
|
+
let n = e[b.symbol], i = Q(e, t, !1, r);
|
|
3414
3694
|
for (let e of r.parseTag) {
|
|
3415
3695
|
let t = e.parseTag(n, i);
|
|
3416
3696
|
if (t !== void 0) return t;
|
|
3417
3697
|
}
|
|
3418
|
-
return new
|
|
3419
|
-
}
|
|
3420
|
-
if (e instanceof
|
|
3421
|
-
if (e instanceof
|
|
3422
|
-
if (e instanceof
|
|
3423
|
-
if (e === null) return
|
|
3424
|
-
if (e === void 0) return
|
|
3425
|
-
if (e === !0) return
|
|
3426
|
-
if (e === !1) return
|
|
3427
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
3428
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
3429
|
-
if (typeof e == "string") return new
|
|
3698
|
+
return new M(n, i);
|
|
3699
|
+
}
|
|
3700
|
+
if (e instanceof b.Null) return R.NULL;
|
|
3701
|
+
if (e instanceof b.Undefined) return R.UNDEFINED;
|
|
3702
|
+
if (e instanceof he) return new R(e.value);
|
|
3703
|
+
if (e === null) return R.NULL;
|
|
3704
|
+
if (e === void 0) return R.UNDEFINED;
|
|
3705
|
+
if (e === !0) return R.TRUE;
|
|
3706
|
+
if (e === !1) return R.FALSE;
|
|
3707
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new it(e) : e < -18446744073709551616n ? new at(e) : e >= 0n ? new k(e) : new A(e);
|
|
3708
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new k(BigInt(e)) : new A(BigInt(e)) : new j(e);
|
|
3709
|
+
if (typeof e == "string") return new G(e);
|
|
3430
3710
|
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Q(e.valueOf(), t, !1, r);
|
|
3431
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
3432
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
3433
|
-
if (e instanceof $) return new
|
|
3434
|
-
if (Array.isArray(e)) return new
|
|
3711
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new N(new Uint8Array(e));
|
|
3712
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new I(Array.from(e, (e) => new k(BigInt(e)))) : new N(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3713
|
+
if (e instanceof $) return new L([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
|
|
3714
|
+
if (Array.isArray(e)) return new I(e.map((e) => Q(e, t, !0, r)));
|
|
3435
3715
|
if (typeof e == "object") {
|
|
3436
3716
|
let n = [];
|
|
3437
|
-
for (let [i, a] of Object.entries(e)) n.push([new
|
|
3438
|
-
return new
|
|
3717
|
+
for (let [i, a] of Object.entries(e)) n.push([new G(i), Q(a, t, !0, r)]);
|
|
3718
|
+
return new L(n);
|
|
3439
3719
|
}
|
|
3440
3720
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3441
3721
|
}
|
|
3442
|
-
function
|
|
3443
|
-
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof
|
|
3722
|
+
function oi(e) {
|
|
3723
|
+
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof b.Null || e instanceof b.Undefined || e instanceof he;
|
|
3444
3724
|
}
|
|
3445
|
-
function
|
|
3725
|
+
function si(e, t, n, r, i) {
|
|
3446
3726
|
let a = [...n ?? [], ...Z(i)].filter((e) => e.isJSType !== void 0);
|
|
3447
3727
|
function o(e) {
|
|
3448
|
-
return e ===
|
|
3728
|
+
return e === x || r === !0 && e === void 0;
|
|
3449
3729
|
}
|
|
3450
3730
|
if (Array.isArray(t)) {
|
|
3451
3731
|
let n = t.map(String);
|
|
@@ -3453,7 +3733,7 @@ function Jr(e, t, n, r, i) {
|
|
|
3453
3733
|
if (typeof e != "object" || !e) return e;
|
|
3454
3734
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
3455
3735
|
if (Array.isArray(e)) return e.map(r);
|
|
3456
|
-
if (
|
|
3736
|
+
if (b.symbol in e || oi(e) || a.some((t) => t.isJSType(e))) return e;
|
|
3457
3737
|
let t = Object.getPrototypeOf(e);
|
|
3458
3738
|
if (t === Object.prototype || t === null) {
|
|
3459
3739
|
let t = e.toJSON;
|
|
@@ -3475,7 +3755,7 @@ function Jr(e, t, n, r, i) {
|
|
|
3475
3755
|
}
|
|
3476
3756
|
}
|
|
3477
3757
|
if (e = s.call(n, t, e), typeof e == "object" && e) {
|
|
3478
|
-
if (
|
|
3758
|
+
if (b.symbol in e) return e;
|
|
3479
3759
|
if (e instanceof $) {
|
|
3480
3760
|
let t = new $();
|
|
3481
3761
|
for (let [n, r] of e) {
|
|
@@ -3488,7 +3768,7 @@ function Jr(e, t, n, r, i) {
|
|
|
3488
3768
|
let r = c(t, String(n), e);
|
|
3489
3769
|
return o(r) ? null : r;
|
|
3490
3770
|
});
|
|
3491
|
-
if (
|
|
3771
|
+
if (oi(e) || a.some((t) => t.isJSType(e))) return e;
|
|
3492
3772
|
let t = {};
|
|
3493
3773
|
for (let n of Object.keys(e)) {
|
|
3494
3774
|
let r = c(e[n], n, e);
|
|
@@ -3506,7 +3786,7 @@ var $ = class extends Array {
|
|
|
3506
3786
|
toJSON() {
|
|
3507
3787
|
let e = {};
|
|
3508
3788
|
for (let [t, n] of this) {
|
|
3509
|
-
let r = typeof t == "string" ? t :
|
|
3789
|
+
let r = typeof t == "string" ? t : ai(t).toCDN();
|
|
3510
3790
|
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
3511
3791
|
value: n,
|
|
3512
3792
|
writable: !0,
|
|
@@ -3518,6 +3798,6 @@ var $ = class extends Array {
|
|
|
3518
3798
|
}
|
|
3519
3799
|
};
|
|
3520
3800
|
//#endregion
|
|
3521
|
-
export {
|
|
3801
|
+
export { N as A, se as B, He as C, I as D, L as E, k as F, b as H, O as I, D as L, j as M, Me as N, F as O, A as P, he as R, Ve as S, R as T, le as U, ce as V, at as _, Qr as a, B as b, Fr as c, Zn as d, wn as f, lt as g, G as h, ei as i, M as j, P as k, Pr as l, an as m, si as n, Hr as o, rn as p, ai as r, Ur as s, $ as t, yr as u, it as v, z as w, Ue as x, V as y, x as z };
|
|
3522
3802
|
|
|
3523
|
-
//# sourceMappingURL=mapEntries-
|
|
3803
|
+
//# sourceMappingURL=mapEntries-Ci_dppP6.js.map
|