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