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