@cbortech/cbor 0.25.9 → 0.25.11
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 +34 -5
- package/README.md +36 -5
- package/dist/ast/CborByteString.d.ts +9 -0
- package/dist/ast/CborFloat.d.ts +9 -0
- package/dist/ast/CborTextString.d.ts +3 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/cbor/encode.d.ts +11 -0
- package/dist/cbor.d.ts +8 -1
- package/dist/cdn/index.cjs +2 -2
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/serialize-utils.d.ts +36 -0
- package/dist/cdn/tokenizer.d.ts +37 -2
- package/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +83 -75
- package/dist/index.js.map +1 -1
- package/dist/{mapEntries-I8f0WuwK.js → mapEntries-CYvdsAfP.js} +1047 -872
- package/dist/mapEntries-CYvdsAfP.js.map +1 -0
- package/dist/mapEntries-vOYb5Q1s.cjs +11 -0
- package/dist/mapEntries-vOYb5Q1s.cjs.map +1 -0
- package/dist/tokenizer-CVcIyZZa.cjs +30 -0
- package/dist/tokenizer-CVcIyZZa.cjs.map +1 -0
- package/dist/{tokenizer-CETZf2NR.js → tokenizer-DkLlZ1gc.js} +161 -349
- package/dist/tokenizer-DkLlZ1gc.js.map +1 -0
- package/dist/types.d.ts +66 -1
- package/dist/utils/hex.d.ts +5 -0
- package/package.json +3 -3
- package/dist/mapEntries-BkcJsv3C.cjs +0 -12
- package/dist/mapEntries-BkcJsv3C.cjs.map +0 -1
- package/dist/mapEntries-I8f0WuwK.js.map +0 -1
- package/dist/tokenizer-CETZf2NR.js.map +0 -1
- package/dist/tokenizer-CMK8MtYl.cjs +0 -30
- package/dist/tokenizer-CMK8MtYl.cjs.map +0 -1
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./tokenizer-DkLlZ1gc.js";
|
|
2
2
|
//#region src/tag.ts
|
|
3
|
-
var
|
|
3
|
+
var o = Symbol.for("cbor.tag"), s = class {
|
|
4
4
|
valueOf() {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
7
|
toJSON() {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
},
|
|
10
|
+
}, c = class {
|
|
11
11
|
valueOf() {}
|
|
12
12
|
toJSON() {}
|
|
13
13
|
};
|
|
14
|
-
function
|
|
15
|
-
if (!
|
|
16
|
-
let t = e[
|
|
14
|
+
function l(e) {
|
|
15
|
+
if (!p(e)) return;
|
|
16
|
+
let t = e[o];
|
|
17
17
|
return typeof t == "bigint" ? t : void 0;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
let
|
|
19
|
+
function u(e, t) {
|
|
20
|
+
let n;
|
|
21
21
|
switch (typeof e) {
|
|
22
22
|
case "number":
|
|
23
|
-
|
|
23
|
+
n = new Number(e);
|
|
24
24
|
break;
|
|
25
25
|
case "string":
|
|
26
|
-
|
|
26
|
+
n = new String(e);
|
|
27
27
|
break;
|
|
28
28
|
case "boolean":
|
|
29
|
-
|
|
29
|
+
n = new Boolean(e);
|
|
30
30
|
break;
|
|
31
31
|
case "bigint":
|
|
32
|
-
|
|
32
|
+
n = Object(e);
|
|
33
33
|
break;
|
|
34
34
|
case "undefined":
|
|
35
|
-
|
|
35
|
+
n = new c();
|
|
36
36
|
break;
|
|
37
37
|
case "object":
|
|
38
38
|
if (e === null) {
|
|
39
|
-
|
|
39
|
+
n = new s();
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
n = e;
|
|
43
43
|
break;
|
|
44
44
|
default: throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return n[o] = t, n;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function d(e) {
|
|
49
49
|
if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
|
|
50
|
-
if (e instanceof
|
|
51
|
-
if (!(e instanceof
|
|
50
|
+
if (e instanceof s) return null;
|
|
51
|
+
if (!(e instanceof c)) return typeof e == "object" && e && delete e[o], e;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function f(e) {
|
|
54
54
|
if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
|
|
55
|
-
if (e instanceof
|
|
56
|
-
if (!(e instanceof
|
|
55
|
+
if (e instanceof s) return null;
|
|
56
|
+
if (!(e instanceof c)) return e;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function p(e) {
|
|
59
59
|
return typeof e == "object" && !!e;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
61
|
+
var m = class {
|
|
62
62
|
constructor() {}
|
|
63
|
-
static symbol =
|
|
64
|
-
static Null =
|
|
65
|
-
static Undefined =
|
|
63
|
+
static symbol = o;
|
|
64
|
+
static Null = s;
|
|
65
|
+
static Undefined = c;
|
|
66
66
|
static get(e) {
|
|
67
|
-
return
|
|
67
|
+
return l(e);
|
|
68
68
|
}
|
|
69
69
|
static set(e, t) {
|
|
70
|
-
return
|
|
70
|
+
return u(e, t);
|
|
71
71
|
}
|
|
72
72
|
static remove(e) {
|
|
73
|
-
return
|
|
73
|
+
return d(e);
|
|
74
74
|
}
|
|
75
75
|
static getValue(e) {
|
|
76
|
-
return
|
|
76
|
+
return f(e);
|
|
77
77
|
}
|
|
78
|
-
},
|
|
78
|
+
}, h = Symbol("cbor.omit"), g = class e {
|
|
79
79
|
value;
|
|
80
80
|
constructor(e) {
|
|
81
81
|
if (!Number.isInteger(e) || e < 0 || e > 255) throw RangeError("Simple value must be an integer in 0–255");
|
|
@@ -93,42 +93,23 @@ var u = class {
|
|
|
93
93
|
static get(t) {
|
|
94
94
|
return t instanceof e ? t.value : void 0;
|
|
95
95
|
}
|
|
96
|
-
}
|
|
97
|
-
for (let e = 0; e < 16; e++) m["0123456789abcdef".charCodeAt(e)] = e, m["0123456789ABCDEF".charCodeAt(e)] = e;
|
|
98
|
-
var h = typeof Uint8Array.prototype.toHex == "function", g = typeof Uint8Array.fromHex == "function", ee = 256;
|
|
99
|
-
function te(e) {
|
|
100
|
-
if (h) return e.toHex();
|
|
101
|
-
let t = "";
|
|
102
|
-
for (let n = 0; n < e.length; n++) t += p[e[n]];
|
|
103
|
-
return t;
|
|
104
|
-
}
|
|
105
|
-
function ne(e) {
|
|
106
|
-
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
107
|
-
if (g && e.length >= ee) return Uint8Array.fromHex(e);
|
|
108
|
-
let t = new Uint8Array(e.length / 2);
|
|
109
|
-
for (let n = 0, r = 0; n < e.length; n += 2, r++) {
|
|
110
|
-
let i = e.charCodeAt(n), a = e.charCodeAt(n + 1), o = i < 128 ? m[i] : -1, s = a < 128 ? m[a] : -1;
|
|
111
|
-
if ((o | s) < 0) {
|
|
112
|
-
let t = o < 0 ? e[n] : e[n + 1];
|
|
113
|
-
throw SyntaxError(`invalid character ${JSON.stringify(t)} in hex string`);
|
|
114
|
-
}
|
|
115
|
-
t[r] = o << 4 | s;
|
|
116
|
-
}
|
|
117
|
-
return t;
|
|
118
|
-
}
|
|
96
|
+
};
|
|
119
97
|
//#endregion
|
|
120
98
|
//#region src/cdn/serialize-utils.ts
|
|
121
|
-
function
|
|
99
|
+
function ee(e) {
|
|
122
100
|
let t = e?.indent;
|
|
123
101
|
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
124
102
|
}
|
|
125
103
|
function _(e, t) {
|
|
126
104
|
return e.repeat(t);
|
|
127
105
|
}
|
|
128
|
-
function
|
|
106
|
+
function te(e, t, n) {
|
|
107
|
+
return t === null ? e.join(" + ") : e.join(` +\n${_(t, n + 1)}`);
|
|
108
|
+
}
|
|
109
|
+
function ne(e) {
|
|
129
110
|
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
130
111
|
}
|
|
131
|
-
function
|
|
112
|
+
function re(e) {
|
|
132
113
|
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
133
114
|
}
|
|
134
115
|
function v(e, t) {
|
|
@@ -142,17 +123,17 @@ function v(e, t) {
|
|
|
142
123
|
}
|
|
143
124
|
return r;
|
|
144
125
|
}
|
|
145
|
-
function
|
|
126
|
+
function ie(e, t, n) {
|
|
146
127
|
return (e.comments?.leading ?? []).map((e) => t + v(e, n));
|
|
147
128
|
}
|
|
148
|
-
function
|
|
129
|
+
function y(e, t) {
|
|
149
130
|
let n = e.comments?.trailing ?? [];
|
|
150
131
|
return n.length === 0 ? "" : " " + n.map((e) => v(e, t)).join(" ");
|
|
151
132
|
}
|
|
152
|
-
function
|
|
133
|
+
function ae(e, t, n) {
|
|
153
134
|
return (e.comments?.dangling ?? []).map((e) => t + v(e, n));
|
|
154
135
|
}
|
|
155
|
-
function
|
|
136
|
+
function oe(e, t = !1) {
|
|
156
137
|
let n = e?.commas ?? "comma", r = n !== "none";
|
|
157
138
|
return {
|
|
158
139
|
inlineSep: r ? t ? "," : ", " : " ",
|
|
@@ -161,15 +142,32 @@ function le(e, t = !1) {
|
|
|
161
142
|
colSep: t ? ":" : ": "
|
|
162
143
|
};
|
|
163
144
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
145
|
+
function se(e) {
|
|
146
|
+
let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = ee(t), s = t?.preserveComments, c = typeof s == "string" ? s : void 0, l = s && (re(e.node) || e.hasEntryComments());
|
|
147
|
+
o === null && l && (o = " ");
|
|
148
|
+
let { inlineSep: u, multilineSep: d, trailSep: f, colSep: p } = oe(t, o === null), m = e.indefiniteLength ? "" : x(t, e.encodingWidth, () => b(BigInt(a))), h = m ? m + " " : "", g = e.indefiniteLength && (t?.encodingIndicators ?? "auto") !== "never";
|
|
149
|
+
if (o === null || a === 0 && !l) {
|
|
150
|
+
let t = "";
|
|
151
|
+
for (let n = 0; n < a; n++) n > 0 && (t += u), t += e.renderEntry(n, p);
|
|
152
|
+
return e.indefiniteLength ? g ? a === 0 ? `${r}_ ${i}` : `${r}_ ${t}${i}` : `${r}${t}${i}` : `${r}${h}${t}${i}`;
|
|
153
|
+
}
|
|
154
|
+
let te = _(o, n + 1), ne = _(o, n), v = e.indefiniteLength ? g ? `${r}_ ` : r : `${r}${h}`, y = [];
|
|
155
|
+
for (let t = 0; t < a; t++) {
|
|
156
|
+
s && y.push(...ie(e.entryLeadingNode(t), te, c));
|
|
157
|
+
let n = t < a - 1 ? d : f;
|
|
158
|
+
y.push(`${te}${e.renderEntry(t, p)}${n}${s ? e.entryTrailing(t, c) : ""}`);
|
|
159
|
+
}
|
|
160
|
+
return s && y.push(...ae(e.node, te, c)), `${v}\n${y.join("\n")}\n${ne}${i}`;
|
|
161
|
+
}
|
|
162
|
+
var ce = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
|
|
163
|
+
function le(e) {
|
|
164
|
+
if (ce) return e.toBase64({ omitPadding: !0 });
|
|
167
165
|
let t = "";
|
|
168
166
|
for (let n of e) t += String.fromCharCode(n);
|
|
169
167
|
return btoa(t).replace(/=/g, "");
|
|
170
168
|
}
|
|
171
|
-
function
|
|
172
|
-
if (
|
|
169
|
+
function ue(e) {
|
|
170
|
+
if (ce) return e.toBase64({
|
|
173
171
|
alphabet: "base64url",
|
|
174
172
|
omitPadding: !0
|
|
175
173
|
});
|
|
@@ -177,54 +175,54 @@ function fe(e) {
|
|
|
177
175
|
for (let n of e) t += String.fromCharCode(n);
|
|
178
176
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
179
177
|
}
|
|
180
|
-
var
|
|
181
|
-
function
|
|
178
|
+
var de = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", fe = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
179
|
+
function pe(e, t) {
|
|
182
180
|
let n = "", r = 0, i = 0;
|
|
183
181
|
for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
|
|
184
182
|
return i > 0 && (n += t[r << 5 - i & 31]), n;
|
|
185
183
|
}
|
|
186
|
-
function
|
|
184
|
+
function me(e) {
|
|
187
185
|
for (let t of e) {
|
|
188
186
|
let e = t.codePointAt(0);
|
|
189
187
|
if (e < 32 || e === 127) return !0;
|
|
190
188
|
}
|
|
191
189
|
return !1;
|
|
192
190
|
}
|
|
193
|
-
function
|
|
191
|
+
function he(e, t, n) {
|
|
194
192
|
if (n === "string") {
|
|
195
|
-
let t =
|
|
196
|
-
if (t != null) return
|
|
193
|
+
let t = _e(e);
|
|
194
|
+
if (t != null) return be(t);
|
|
197
195
|
}
|
|
198
196
|
if (n === "printable-string" || n === void 0) {
|
|
199
|
-
let t =
|
|
200
|
-
if (t != null && !
|
|
197
|
+
let t = _e(e);
|
|
198
|
+
if (t != null && !me(t)) return be(t);
|
|
201
199
|
}
|
|
202
200
|
switch (t) {
|
|
203
|
-
case "base64": return `b64'${
|
|
204
|
-
case "base64url": return `b64'${
|
|
205
|
-
case "base32": return `b32'${
|
|
206
|
-
case "base32hex": return `h32'${
|
|
207
|
-
default: return `h'${
|
|
201
|
+
case "base64": return `b64'${le(e)}'`;
|
|
202
|
+
case "base64url": return `b64'${ue(e)}'`;
|
|
203
|
+
case "base32": return `b32'${pe(e, de)}'`;
|
|
204
|
+
case "base32hex": return `h32'${pe(e, fe)}'`;
|
|
205
|
+
default: return `h'${i(e)}'`;
|
|
208
206
|
}
|
|
209
207
|
}
|
|
210
|
-
var
|
|
211
|
-
function
|
|
208
|
+
var ge = new TextDecoder("utf-8", { fatal: !0 });
|
|
209
|
+
function _e(e) {
|
|
212
210
|
try {
|
|
213
|
-
return
|
|
211
|
+
return ge.decode(e);
|
|
214
212
|
} catch {
|
|
215
213
|
return null;
|
|
216
214
|
}
|
|
217
215
|
}
|
|
218
|
-
function
|
|
216
|
+
function ve(e, t) {
|
|
219
217
|
for (let n = 0; n < e.length; n++) {
|
|
220
218
|
let r = e.charCodeAt(n);
|
|
221
219
|
if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
|
|
222
220
|
}
|
|
223
221
|
return !1;
|
|
224
222
|
}
|
|
225
|
-
function
|
|
223
|
+
function ye(e, t) {
|
|
226
224
|
let n = t.codePointAt(0);
|
|
227
|
-
if (!
|
|
225
|
+
if (!ve(e, n)) return t + e + t;
|
|
228
226
|
let r = t;
|
|
229
227
|
for (let i of e) {
|
|
230
228
|
let e = i.codePointAt(0);
|
|
@@ -249,40 +247,40 @@ function xe(e, t) {
|
|
|
249
247
|
}
|
|
250
248
|
return r + t;
|
|
251
249
|
}
|
|
252
|
-
function
|
|
253
|
-
return
|
|
250
|
+
function be(e) {
|
|
251
|
+
return ye(e, "'");
|
|
254
252
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
253
|
+
function xe(e) {
|
|
254
|
+
return ye(e, "'");
|
|
257
255
|
}
|
|
258
|
-
function
|
|
259
|
-
return
|
|
256
|
+
function Se(e) {
|
|
257
|
+
return ye(e, "\"");
|
|
260
258
|
}
|
|
261
|
-
function
|
|
259
|
+
function Ce(e) {
|
|
262
260
|
if (isNaN(e)) return "NaN";
|
|
263
261
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
264
262
|
if (Object.is(e, -0)) return "-0.0";
|
|
265
263
|
let t = e.toString();
|
|
266
264
|
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
267
265
|
}
|
|
268
|
-
function
|
|
266
|
+
function we(e, t, n, r) {
|
|
269
267
|
if (r === "never") return "";
|
|
270
268
|
let i = t ?? n;
|
|
271
269
|
return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
272
270
|
}
|
|
273
|
-
function
|
|
271
|
+
function b(e) {
|
|
274
272
|
return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
|
|
275
273
|
}
|
|
276
|
-
function
|
|
274
|
+
function x(e, t, n) {
|
|
277
275
|
let r = e?.encodingIndicators ?? "auto";
|
|
278
276
|
return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
|
|
279
277
|
}
|
|
280
278
|
//#endregion
|
|
281
279
|
//#region src/utils/float16.ts
|
|
282
|
-
var
|
|
283
|
-
function
|
|
284
|
-
|
|
285
|
-
let t =
|
|
280
|
+
var Te = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Ee = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
281
|
+
function S(e) {
|
|
282
|
+
Ee.setFloat64(0, e, !1);
|
|
283
|
+
let t = Ee.getUint32(0, !1), n = Ee.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
286
284
|
if (i === 2047) {
|
|
287
285
|
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
288
286
|
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
@@ -303,15 +301,27 @@ function x(e) {
|
|
|
303
301
|
let u = o <= 0 ? 0 : o;
|
|
304
302
|
return r << 15 | u << 10 | s;
|
|
305
303
|
}
|
|
306
|
-
function
|
|
304
|
+
function C(e) {
|
|
307
305
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
308
306
|
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);
|
|
309
307
|
}
|
|
310
|
-
var
|
|
308
|
+
var De = Te ? (e, t, n, r) => {
|
|
311
309
|
e.setFloat16(t, n, r);
|
|
312
310
|
} : (e, t, n, r) => {
|
|
313
|
-
e.setUint16(t,
|
|
314
|
-
},
|
|
311
|
+
e.setUint16(t, S(n), r);
|
|
312
|
+
}, w = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), T = new Uint8Array(w.buffer), Oe = new TextEncoder(), ke = typeof Oe.encodeInto == "function";
|
|
313
|
+
function Ae(e) {
|
|
314
|
+
return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
|
|
315
|
+
}
|
|
316
|
+
function je(e) {
|
|
317
|
+
return e === "i" ? 1 : [
|
|
318
|
+
2,
|
|
319
|
+
3,
|
|
320
|
+
5,
|
|
321
|
+
9
|
|
322
|
+
][e];
|
|
323
|
+
}
|
|
324
|
+
var Me = class {
|
|
315
325
|
buf;
|
|
316
326
|
len = 0;
|
|
317
327
|
constructor(e = 256) {
|
|
@@ -342,34 +352,45 @@ var ke = De ? (e, t, n, r) => {
|
|
|
342
352
|
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
343
353
|
}
|
|
344
354
|
writeBigUint64(e) {
|
|
345
|
-
|
|
355
|
+
w.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
|
|
346
356
|
}
|
|
347
357
|
writeFloat16(e) {
|
|
348
|
-
|
|
358
|
+
De(w, 0, e, !1), this._ensure(2);
|
|
349
359
|
let t = this.buf;
|
|
350
|
-
t[this.len++] =
|
|
360
|
+
t[this.len++] = T[0], t[this.len++] = T[1];
|
|
351
361
|
}
|
|
352
362
|
writeFloat32(e) {
|
|
353
|
-
|
|
363
|
+
w.setFloat32(0, e, !1), this._ensure(4);
|
|
354
364
|
let t = this.buf;
|
|
355
|
-
t[this.len++] =
|
|
365
|
+
t[this.len++] = T[0], t[this.len++] = T[1], t[this.len++] = T[2], t[this.len++] = T[3];
|
|
356
366
|
}
|
|
357
367
|
writeFloat64(e) {
|
|
358
|
-
|
|
368
|
+
w.setFloat64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
|
|
369
|
+
}
|
|
370
|
+
writeTextString(e, t, n) {
|
|
371
|
+
if (!ke) {
|
|
372
|
+
let r = Oe.encode(t);
|
|
373
|
+
E(this, e, r.length, n), this.writeBytes(r);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
let r = n === void 0 ? Ae(t.length) : je(n);
|
|
377
|
+
this._ensure(9 + 3 * t.length);
|
|
378
|
+
let { written: i } = Oe.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? Ae(i) : r;
|
|
379
|
+
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), E(this, e, i, n), this.len += i;
|
|
359
380
|
}
|
|
360
381
|
finish() {
|
|
361
382
|
return this.buf.slice(0, this.len);
|
|
362
383
|
}
|
|
363
|
-
},
|
|
384
|
+
}, Ne = [
|
|
364
385
|
255n,
|
|
365
386
|
65535n,
|
|
366
387
|
4294967295n,
|
|
367
388
|
18446744073709551615n
|
|
368
389
|
];
|
|
369
|
-
function
|
|
370
|
-
return e === "i" ? 23n :
|
|
390
|
+
function Pe(e) {
|
|
391
|
+
return e === "i" ? 23n : Ne[e];
|
|
371
392
|
}
|
|
372
|
-
function
|
|
393
|
+
function E(e, t, n, r) {
|
|
373
394
|
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
374
395
|
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));
|
|
375
396
|
return;
|
|
@@ -381,30 +402,30 @@ function T(e, t, n, r) {
|
|
|
381
402
|
e.writeByte(t << 5 | Number(i));
|
|
382
403
|
return;
|
|
383
404
|
}
|
|
384
|
-
if (i >
|
|
405
|
+
if (i > Ne[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Ne[r]})`);
|
|
385
406
|
let n = 24 + r;
|
|
386
407
|
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);
|
|
387
408
|
return;
|
|
388
409
|
}
|
|
389
410
|
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));
|
|
390
411
|
}
|
|
391
|
-
function
|
|
392
|
-
let r = new
|
|
393
|
-
return
|
|
412
|
+
function Fe(e, t, n) {
|
|
413
|
+
let r = new Me(9);
|
|
414
|
+
return E(r, e, t, n), r.finish();
|
|
394
415
|
}
|
|
395
|
-
var
|
|
396
|
-
function
|
|
397
|
-
return Object.is(S(
|
|
416
|
+
var Ie = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
417
|
+
function Le(e) {
|
|
418
|
+
return Object.is(C(S(e)), e);
|
|
398
419
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
420
|
+
function Re(e) {
|
|
421
|
+
return Ie.setFloat32(0, e, !1), Object.is(Ie.getFloat32(0, !1), e);
|
|
401
422
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
423
|
+
function D(e) {
|
|
424
|
+
return Le(e) ? "half" : Re(e) ? "single" : "double";
|
|
404
425
|
}
|
|
405
426
|
//#endregion
|
|
406
427
|
//#region src/ast/CborItem.ts
|
|
407
|
-
var
|
|
428
|
+
var O = class e {
|
|
408
429
|
start;
|
|
409
430
|
end;
|
|
410
431
|
comments;
|
|
@@ -414,7 +435,7 @@ var D = class e {
|
|
|
414
435
|
let t = this._defaults ? {
|
|
415
436
|
...this._defaults,
|
|
416
437
|
...e
|
|
417
|
-
} : e, n = new
|
|
438
|
+
} : e, n = new Me();
|
|
418
439
|
return this._encode(n, t), n.finish();
|
|
419
440
|
}
|
|
420
441
|
toCDN(e) {
|
|
@@ -436,14 +457,19 @@ var D = class e {
|
|
|
436
457
|
} : e, n = this._toJS(t);
|
|
437
458
|
if (!t?.reviver) return n;
|
|
438
459
|
let r = t.reviver.call({ "": n }, "", n);
|
|
439
|
-
return r ===
|
|
460
|
+
return r === h ? void 0 : r;
|
|
440
461
|
}
|
|
441
462
|
toHexDump(e) {
|
|
442
463
|
let t = this._defaults ? {
|
|
443
464
|
...this._defaults,
|
|
444
465
|
...e
|
|
445
|
-
} : e, n = t?.indent ?? 3, r = typeof n == "string" ? n : " ".repeat(n), i = (t?.commentStyle ?? "--") + " ", a = this._toHexDump(0, t), o =
|
|
446
|
-
|
|
466
|
+
} : e, n = t?.indent ?? 3, r = typeof n == "string" ? n : " ".repeat(n), i = (t?.commentStyle ?? "--") + " ", a = this._toHexDump(0, t), o = 0;
|
|
467
|
+
for (let e of a) {
|
|
468
|
+
let t = e.depth * r.length + e.hex.length;
|
|
469
|
+
t > o && (o = t);
|
|
470
|
+
}
|
|
471
|
+
let s = o + 2;
|
|
472
|
+
return a.map((e) => (r.repeat(e.depth) + e.hex).padEnd(s) + i + e.comment).join("\n");
|
|
447
473
|
}
|
|
448
474
|
_encode(t, n) {
|
|
449
475
|
if (this._toCBOR !== e.prototype._toCBOR) {
|
|
@@ -457,17 +483,17 @@ var D = class e {
|
|
|
457
483
|
t.writeBytes(this._toCBOR(n));
|
|
458
484
|
}
|
|
459
485
|
_toCBOR(e) {
|
|
460
|
-
let t = new
|
|
486
|
+
let t = new Me();
|
|
461
487
|
return this._encodeTo(t, e), t.finish();
|
|
462
488
|
}
|
|
463
|
-
_toHexDump(e,
|
|
489
|
+
_toHexDump(e, n) {
|
|
464
490
|
return [{
|
|
465
491
|
depth: e,
|
|
466
|
-
hex:
|
|
467
|
-
comment: this._toCDN(
|
|
492
|
+
hex: t(this._toCBOR()),
|
|
493
|
+
comment: this._toCDN(n, 0)
|
|
468
494
|
}];
|
|
469
495
|
}
|
|
470
|
-
},
|
|
496
|
+
}, k = class extends O {
|
|
471
497
|
value;
|
|
472
498
|
encodingWidth;
|
|
473
499
|
constructor(e, t) {
|
|
@@ -476,10 +502,10 @@ var D = class e {
|
|
|
476
502
|
this.encodingWidth = t?.encodingWidth;
|
|
477
503
|
}
|
|
478
504
|
_encodeTo(e, t) {
|
|
479
|
-
|
|
505
|
+
E(e, 0, this.value, this.encodingWidth);
|
|
480
506
|
}
|
|
481
507
|
_toCDN(e, t) {
|
|
482
|
-
let n =
|
|
508
|
+
let n = x(e, this.encodingWidth, () => b(this.value)), r = this.value;
|
|
483
509
|
switch (e?.intFormat) {
|
|
484
510
|
case "hex": return `0x${r.toString(16)}${n}`;
|
|
485
511
|
case "octal": return `0o${r.toString(8)}${n}`;
|
|
@@ -491,7 +517,7 @@ var D = class e {
|
|
|
491
517
|
let t = e?.integerAs ?? "auto";
|
|
492
518
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
493
519
|
}
|
|
494
|
-
},
|
|
520
|
+
}, A = class extends O {
|
|
495
521
|
argument;
|
|
496
522
|
encodingWidth;
|
|
497
523
|
constructor(e, t) {
|
|
@@ -505,10 +531,10 @@ var D = class e {
|
|
|
505
531
|
return -1n - this.argument;
|
|
506
532
|
}
|
|
507
533
|
_encodeTo(e, t) {
|
|
508
|
-
|
|
534
|
+
E(e, 1, this.argument, this.encodingWidth);
|
|
509
535
|
}
|
|
510
536
|
_toCDN(e, t) {
|
|
511
|
-
let n =
|
|
537
|
+
let n = x(e, this.encodingWidth, () => b(this.argument)), r = this.argument + 1n;
|
|
512
538
|
switch (e?.intFormat) {
|
|
513
539
|
case "hex": return `-0x${r.toString(16)}${n}`;
|
|
514
540
|
case "octal": return `-0o${r.toString(8)}${n}`;
|
|
@@ -520,8 +546,8 @@ var D = class e {
|
|
|
520
546
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
521
547
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
522
548
|
}
|
|
523
|
-
},
|
|
524
|
-
function
|
|
549
|
+
}, ze = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
550
|
+
function Be(e) {
|
|
525
551
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
526
552
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
527
553
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -539,29 +565,30 @@ function Re(e) {
|
|
|
539
565
|
let l = c * 2 ** o;
|
|
540
566
|
return t ? -l : l;
|
|
541
567
|
}
|
|
542
|
-
function
|
|
568
|
+
function Ve(e) {
|
|
543
569
|
if (isNaN(e)) return "NaN";
|
|
544
570
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
545
571
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
546
572
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
547
|
-
|
|
548
|
-
let r =
|
|
573
|
+
ze.setFloat64(0, n, !1);
|
|
574
|
+
let r = ze.getUint32(0, !1), i = ze.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;
|
|
549
575
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
550
576
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
551
577
|
return t ? `-${p}` : p;
|
|
552
578
|
}
|
|
553
579
|
//#endregion
|
|
554
580
|
//#region src/ast/CborFloat.ts
|
|
555
|
-
var
|
|
581
|
+
var j = class extends O {
|
|
556
582
|
value;
|
|
557
583
|
precision;
|
|
558
584
|
ednSource;
|
|
585
|
+
rawBits;
|
|
559
586
|
constructor(e, t) {
|
|
560
|
-
super(), this.value = e, this.precision = t?.precision;
|
|
587
|
+
super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits;
|
|
561
588
|
}
|
|
562
589
|
_encodeTo(e, t) {
|
|
563
|
-
let n = this.precision ??
|
|
564
|
-
n === "half" ? (e.writeByte(249), e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), e.writeFloat32(this.value)) : (e.writeByte(251), e.writeFloat64(this.value));
|
|
590
|
+
let n = this.precision ?? D(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
|
|
591
|
+
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));
|
|
565
592
|
}
|
|
566
593
|
_toCDN(e, t) {
|
|
567
594
|
let n = e?.encodingIndicators ?? "auto";
|
|
@@ -569,18 +596,18 @@ var A = class extends D {
|
|
|
569
596
|
if (n === "never") return this.ednSource.replace(/_[0-3i]$/, "");
|
|
570
597
|
if (n === "always") {
|
|
571
598
|
if (/_[0-3i]$/.test(this.ednSource)) return this.ednSource;
|
|
572
|
-
let e = this.precision ??
|
|
599
|
+
let e = this.precision ?? D(this.value), t = e === "half" ? "_1" : e === "single" ? "_2" : "_3";
|
|
573
600
|
return this.ednSource + t;
|
|
574
601
|
}
|
|
575
602
|
return this.ednSource;
|
|
576
603
|
}
|
|
577
|
-
let r =
|
|
578
|
-
return (e?.floatFormat === "hex" ?
|
|
604
|
+
let r = D(this.value);
|
|
605
|
+
return (e?.floatFormat === "hex" ? Ve(this.value) : Ce(this.value)) + we(this.value, this.precision, r, n);
|
|
579
606
|
}
|
|
580
607
|
_toJS(e) {
|
|
581
608
|
return this.value;
|
|
582
609
|
}
|
|
583
|
-
},
|
|
610
|
+
}, M = class extends O {
|
|
584
611
|
tag;
|
|
585
612
|
content;
|
|
586
613
|
encodingWidth;
|
|
@@ -589,52 +616,59 @@ var A = class extends D {
|
|
|
589
616
|
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
590
617
|
}
|
|
591
618
|
_encodeTo(e, t) {
|
|
592
|
-
|
|
619
|
+
E(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
593
620
|
}
|
|
594
621
|
_toCDN(e, t) {
|
|
595
|
-
let n =
|
|
622
|
+
let n = x(e, this.encodingWidth, () => b(this.tag));
|
|
596
623
|
return `${this.tag}${n}(${this.content._toCDN(e, t)})`;
|
|
597
624
|
}
|
|
598
|
-
_toHexDump(e,
|
|
599
|
-
let
|
|
625
|
+
_toHexDump(e, n) {
|
|
626
|
+
let r = [{
|
|
600
627
|
depth: e,
|
|
601
|
-
hex: ((
|
|
628
|
+
hex: t(Fe(6, this.tag, this.encodingWidth)),
|
|
602
629
|
comment: `Tag ${this.tag}`
|
|
603
630
|
}];
|
|
604
|
-
return
|
|
605
|
-
...
|
|
631
|
+
return r.push(...this.content._toHexDump(e + 1, {
|
|
632
|
+
...n,
|
|
606
633
|
appStrings: !1
|
|
607
|
-
})),
|
|
634
|
+
})), r;
|
|
608
635
|
}
|
|
609
636
|
_toJS(e) {
|
|
610
637
|
let t = this.content._toJS(e);
|
|
611
|
-
return e?.stripTags ? t :
|
|
638
|
+
return e?.stripTags ? t : m.set(t, this.tag);
|
|
612
639
|
}
|
|
613
|
-
},
|
|
640
|
+
}, N = class extends O {
|
|
614
641
|
indefiniteLength = !1;
|
|
615
642
|
value;
|
|
616
643
|
ednEncoding;
|
|
617
644
|
encodingWidth;
|
|
618
645
|
ednSource;
|
|
646
|
+
ednParts;
|
|
619
647
|
constructor(e, t) {
|
|
620
|
-
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
648
|
+
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednParts = t?.ednParts;
|
|
621
649
|
}
|
|
622
650
|
_encodeTo(e, t) {
|
|
623
|
-
|
|
651
|
+
E(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
624
652
|
}
|
|
625
653
|
_toCDN(e, t) {
|
|
654
|
+
if (e?.preserveConcatenation && this.ednParts !== void 0 && this.ednParts.length > 1) {
|
|
655
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
|
|
656
|
+
e?.appStrings === !1 && r !== "hex" && (r = "hex");
|
|
657
|
+
let i = this.ednParts.map((t) => e?.preserveByteString && t.source !== void 0 ? t.source : he(t.bytes, r, e?.sqstr));
|
|
658
|
+
return i[i.length - 1] += n, te(i, ee(e), t);
|
|
659
|
+
}
|
|
626
660
|
if (e?.preserveByteString && this.ednSource !== void 0) {
|
|
627
661
|
if (/_[0-3i]$/.test(this.ednSource)) return (e?.encodingIndicators ?? "auto") === "never" ? this.ednSource.replace(/_[0-3i]$/, "") : this.ednSource;
|
|
628
|
-
let t =
|
|
662
|
+
let t = x(e, this.encodingWidth, () => b(BigInt(this.value.length)));
|
|
629
663
|
return this.ednSource + t;
|
|
630
664
|
}
|
|
631
|
-
let n =
|
|
632
|
-
return e?.appStrings === !1 && r !== "hex" && (r = "hex"),
|
|
665
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
|
|
666
|
+
return e?.appStrings === !1 && r !== "hex" && (r = "hex"), he(this.value, r, e?.sqstr) + n;
|
|
633
667
|
}
|
|
634
668
|
_toJS(e) {
|
|
635
669
|
return this.value;
|
|
636
670
|
}
|
|
637
|
-
},
|
|
671
|
+
}, P = class extends O {
|
|
638
672
|
indefiniteLength = !0;
|
|
639
673
|
chunks;
|
|
640
674
|
constructor(e) {
|
|
@@ -649,12 +683,12 @@ var A = class extends D {
|
|
|
649
683
|
if ((e?.encodingIndicators ?? "auto") === "never") {
|
|
650
684
|
let t = this.chunks.reduce((e, t) => e + t.value.length, 0), n = new Uint8Array(t), r = 0;
|
|
651
685
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
652
|
-
return new
|
|
686
|
+
return new N(n)._toCDN(e, 0);
|
|
653
687
|
}
|
|
654
688
|
return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
655
689
|
}
|
|
656
690
|
_toHexDump(e, t) {
|
|
657
|
-
let
|
|
691
|
+
let r = [{
|
|
658
692
|
depth: e,
|
|
659
693
|
hex: n(95),
|
|
660
694
|
comment: "Start indefinite-length byte string"
|
|
@@ -671,7 +705,7 @@ var A = class extends D {
|
|
|
671
705
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
672
706
|
return n;
|
|
673
707
|
}
|
|
674
|
-
},
|
|
708
|
+
}, F = class extends O {
|
|
675
709
|
indefiniteLength = !0;
|
|
676
710
|
chunks;
|
|
677
711
|
constructor(e) {
|
|
@@ -683,10 +717,10 @@ var A = class extends D {
|
|
|
683
717
|
e.writeByte(255);
|
|
684
718
|
}
|
|
685
719
|
_toCDN(e, t) {
|
|
686
|
-
return (e?.encodingIndicators ?? "auto") === "never" ? new
|
|
720
|
+
return (e?.encodingIndicators ?? "auto") === "never" ? new B(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
687
721
|
}
|
|
688
722
|
_toHexDump(e, t) {
|
|
689
|
-
let
|
|
723
|
+
let r = [{
|
|
690
724
|
depth: e,
|
|
691
725
|
hex: n(127),
|
|
692
726
|
comment: "Start indefinite-length text string"
|
|
@@ -701,7 +735,7 @@ var A = class extends D {
|
|
|
701
735
|
_toJS(e) {
|
|
702
736
|
return this.chunks.map((e) => e.value).join("");
|
|
703
737
|
}
|
|
704
|
-
},
|
|
738
|
+
}, I = class extends O {
|
|
705
739
|
items;
|
|
706
740
|
indefiniteLength;
|
|
707
741
|
encodingWidth;
|
|
@@ -715,47 +749,45 @@ var A = class extends D {
|
|
|
715
749
|
e.writeByte(255);
|
|
716
750
|
return;
|
|
717
751
|
}
|
|
718
|
-
|
|
752
|
+
E(e, 4, this.items.length, this.encodingWidth);
|
|
719
753
|
for (let n of this.items) n._encode(e, t);
|
|
720
754
|
}
|
|
721
755
|
_toCDN(e, t) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
}
|
|
736
|
-
return r && h.push(...ce(this, f, i)), `${m}\n${h.join("\n")}\n${p}]`;
|
|
756
|
+
return se({
|
|
757
|
+
node: this,
|
|
758
|
+
options: e,
|
|
759
|
+
depth: t,
|
|
760
|
+
openChar: "[",
|
|
761
|
+
closeChar: "]",
|
|
762
|
+
count: this.items.length,
|
|
763
|
+
indefiniteLength: this.indefiniteLength,
|
|
764
|
+
encodingWidth: this.encodingWidth,
|
|
765
|
+
hasEntryComments: () => this.items.some(ne),
|
|
766
|
+
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
767
|
+
entryLeadingNode: (e) => this.items[e],
|
|
768
|
+
entryTrailing: (e, t) => y(this.items[e], t)
|
|
769
|
+
});
|
|
737
770
|
}
|
|
738
|
-
_toHexDump(e,
|
|
739
|
-
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
771
|
+
_toHexDump(e, r) {
|
|
740
772
|
if (this.indefiniteLength) {
|
|
741
|
-
let
|
|
773
|
+
let t = [{
|
|
742
774
|
depth: e,
|
|
743
775
|
hex: n(159),
|
|
744
776
|
comment: "Start indefinite-length array"
|
|
745
777
|
}];
|
|
746
|
-
for (let n of this.items)
|
|
747
|
-
return
|
|
778
|
+
for (let n of this.items) t.push(...n._toHexDump(e + 1, r));
|
|
779
|
+
return t.push({
|
|
748
780
|
depth: e,
|
|
749
781
|
hex: n(255),
|
|
750
782
|
comment: "\"break\""
|
|
751
|
-
}),
|
|
783
|
+
}), t;
|
|
752
784
|
}
|
|
753
785
|
let i = [{
|
|
754
786
|
depth: e,
|
|
755
|
-
hex:
|
|
787
|
+
hex: t(Fe(4, BigInt(this.items.length), this.encodingWidth)),
|
|
756
788
|
comment: `Array of length ${this.items.length}`
|
|
757
789
|
}];
|
|
758
|
-
for (let
|
|
790
|
+
for (let t of this.items) i.push(...t._toHexDump(e + 1, r));
|
|
759
791
|
return i;
|
|
760
792
|
}
|
|
761
793
|
_toJS(e) {
|
|
@@ -767,11 +799,11 @@ var A = class extends D {
|
|
|
767
799
|
} : void 0, r = this.items.map((e) => e._toJS(n)), i = 0;
|
|
768
800
|
for (let n = 0; n < this.items.length; n++) {
|
|
769
801
|
let a = n - i, o = this.items[n]._toJS(e), s = t.call(r, String(n), o);
|
|
770
|
-
s ===
|
|
802
|
+
s === h || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
|
|
771
803
|
}
|
|
772
804
|
return r;
|
|
773
805
|
}
|
|
774
|
-
},
|
|
806
|
+
}, L = class extends O {
|
|
775
807
|
entries;
|
|
776
808
|
indefiniteLength;
|
|
777
809
|
encodingWidth;
|
|
@@ -785,51 +817,55 @@ var A = class extends D {
|
|
|
785
817
|
e.writeByte(255);
|
|
786
818
|
return;
|
|
787
819
|
}
|
|
788
|
-
|
|
820
|
+
E(e, 5, this.entries.length, this.encodingWidth);
|
|
789
821
|
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
790
822
|
}
|
|
791
823
|
_toCDN(e, t) {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
824
|
+
return se({
|
|
825
|
+
node: this,
|
|
826
|
+
options: e,
|
|
827
|
+
depth: t,
|
|
828
|
+
openChar: "{",
|
|
829
|
+
closeChar: "}",
|
|
830
|
+
count: this.entries.length,
|
|
831
|
+
indefiniteLength: this.indefiniteLength,
|
|
832
|
+
encodingWidth: this.encodingWidth,
|
|
833
|
+
hasEntryComments: () => this.entries.some(([e, t]) => ne(e) || ne(t)),
|
|
834
|
+
renderEntry: (n, r) => {
|
|
835
|
+
let [i, a] = this.entries[n];
|
|
836
|
+
return `${i._toCDN(e, t + 1)}${r}${a._toCDN(e, t + 1)}`;
|
|
837
|
+
},
|
|
838
|
+
entryLeadingNode: (e) => this.entries[e][0],
|
|
839
|
+
entryTrailing: (e, t) => {
|
|
840
|
+
let [n, r] = this.entries[e];
|
|
841
|
+
return He([
|
|
842
|
+
...n.comments?.trailing ?? [],
|
|
843
|
+
...r.comments?.leading ?? [],
|
|
844
|
+
...r.comments?.trailing ?? []
|
|
845
|
+
], t);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
811
848
|
}
|
|
812
|
-
_toHexDump(e,
|
|
813
|
-
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
849
|
+
_toHexDump(e, r) {
|
|
814
850
|
if (this.indefiniteLength) {
|
|
815
|
-
let
|
|
851
|
+
let t = [{
|
|
816
852
|
depth: e,
|
|
817
853
|
hex: n(191),
|
|
818
854
|
comment: "Start indefinite-length map"
|
|
819
855
|
}];
|
|
820
|
-
for (let [n, i] of this.entries)
|
|
821
|
-
return
|
|
856
|
+
for (let [n, i] of this.entries) t.push(...n._toHexDump(e + 1, r)), t.push(...i._toHexDump(e + 1, r));
|
|
857
|
+
return t.push({
|
|
822
858
|
depth: e,
|
|
823
859
|
hex: n(255),
|
|
824
860
|
comment: "\"break\""
|
|
825
|
-
}),
|
|
861
|
+
}), t;
|
|
826
862
|
}
|
|
827
863
|
let i = [{
|
|
828
864
|
depth: e,
|
|
829
|
-
hex:
|
|
865
|
+
hex: t(Fe(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
830
866
|
comment: `Map of length ${this.entries.length}`
|
|
831
867
|
}];
|
|
832
|
-
for (let [
|
|
868
|
+
for (let [t, n] of this.entries) i.push(...t._toHexDump(e + 1, r)), i.push(...n._toHexDump(e + 1, r));
|
|
833
869
|
return i;
|
|
834
870
|
}
|
|
835
871
|
_toJS(e) {
|
|
@@ -839,17 +875,17 @@ var A = class extends D {
|
|
|
839
875
|
let r = e?.undefinedOmits;
|
|
840
876
|
for (let e = 0; e < n.length; e++) {
|
|
841
877
|
let [i, a] = n[e], o = t.call(n, i, a);
|
|
842
|
-
o ===
|
|
878
|
+
o === h || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
|
|
843
879
|
}
|
|
844
880
|
return n;
|
|
845
881
|
};
|
|
846
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
882
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof B) ? (() => {
|
|
847
883
|
let n = e ? {
|
|
848
884
|
...e,
|
|
849
885
|
reviver: void 0
|
|
850
886
|
} : void 0, r = {};
|
|
851
887
|
for (let [e, t] of this.entries) {
|
|
852
|
-
let i = e instanceof
|
|
888
|
+
let i = e instanceof B ? e.value : e.toCDN(), a = t._toJS(n);
|
|
853
889
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
854
890
|
value: a,
|
|
855
891
|
writable: !0,
|
|
@@ -861,13 +897,13 @@ var A = class extends D {
|
|
|
861
897
|
let i = /* @__PURE__ */ new Map();
|
|
862
898
|
for (let e = 0; e < this.entries.length; e++) {
|
|
863
899
|
let [t] = this.entries[e];
|
|
864
|
-
i.set(t instanceof
|
|
900
|
+
i.set(t instanceof B ? t.value : t.toCDN(), e);
|
|
865
901
|
}
|
|
866
902
|
for (let n = 0; n < this.entries.length; n++) {
|
|
867
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
903
|
+
let [a, o] = this.entries[n], s = a instanceof B ? a.value : a.toCDN();
|
|
868
904
|
if (i.get(s) !== n) continue;
|
|
869
905
|
let c = o._toJS(e), l = t.call(r, s, c);
|
|
870
|
-
l ===
|
|
906
|
+
l === h || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
871
907
|
value: l,
|
|
872
908
|
writable: !0,
|
|
873
909
|
enumerable: !0,
|
|
@@ -878,12 +914,12 @@ var A = class extends D {
|
|
|
878
914
|
})() : n();
|
|
879
915
|
}
|
|
880
916
|
};
|
|
881
|
-
function
|
|
917
|
+
function He(e, t) {
|
|
882
918
|
return e.length === 0 ? "" : " " + e.map((e) => v(e, t).trimEnd()).join(" ");
|
|
883
919
|
}
|
|
884
920
|
//#endregion
|
|
885
921
|
//#region src/ast/CborSimple.ts
|
|
886
|
-
var
|
|
922
|
+
var R = class e extends O {
|
|
887
923
|
value;
|
|
888
924
|
constructor(e) {
|
|
889
925
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
@@ -915,55 +951,55 @@ var L = class e extends D {
|
|
|
915
951
|
case 21: return !0;
|
|
916
952
|
case 22: return null;
|
|
917
953
|
case 23: return;
|
|
918
|
-
default: return new
|
|
954
|
+
default: return new g(this.value);
|
|
919
955
|
}
|
|
920
956
|
}
|
|
921
|
-
},
|
|
957
|
+
}, Ue = class extends O {
|
|
922
958
|
items;
|
|
923
959
|
encodingWidth;
|
|
924
960
|
constructor(e, t) {
|
|
925
961
|
super(), this.items = e, this.encodingWidth = t?.encodingWidth;
|
|
926
962
|
}
|
|
927
963
|
_content(e) {
|
|
928
|
-
let t = new
|
|
964
|
+
let t = new Me();
|
|
929
965
|
for (let n of this.items) n._encode(t, e);
|
|
930
966
|
return t.finish();
|
|
931
967
|
}
|
|
932
968
|
_encodeTo(e, t) {
|
|
933
969
|
let n = this._content(t);
|
|
934
|
-
|
|
970
|
+
E(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
935
971
|
}
|
|
936
972
|
_toCDN(e, t) {
|
|
937
|
-
let n =
|
|
973
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this._content(e).length)));
|
|
938
974
|
if (this.items.length === 0) return `<<>>${n}`;
|
|
939
|
-
let r =
|
|
975
|
+
let r = ee(e), { inlineSep: i, multilineSep: a, trailSep: o } = oe(e, r === null);
|
|
940
976
|
if (r === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(i)}>>${n}`;
|
|
941
977
|
let s = _(r, t + 1), c = _(r, t), l = this.items.map((n) => `${s}${n._toCDN(e, t + 1)}`), u = l.length - 1;
|
|
942
978
|
return `<<\n${l.map((e, t) => t < u ? `${e}${a}` : `${e}${o}`).join("\n")}\n${c}>>${n}`;
|
|
943
979
|
}
|
|
944
|
-
_toHexDump(e,
|
|
945
|
-
let
|
|
980
|
+
_toHexDump(e, n) {
|
|
981
|
+
let r = this._content().length, i = [{
|
|
946
982
|
depth: e,
|
|
947
|
-
hex:
|
|
983
|
+
hex: t(Fe(2, BigInt(r), this.encodingWidth)),
|
|
948
984
|
comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
|
|
949
985
|
}];
|
|
950
|
-
for (let
|
|
986
|
+
for (let t of this.items) i.push(...t._toHexDump(e + 1, n));
|
|
951
987
|
return i;
|
|
952
988
|
}
|
|
953
989
|
_toJS(e) {
|
|
954
990
|
return this._content();
|
|
955
991
|
}
|
|
956
|
-
},
|
|
992
|
+
}, We = 999n, Ge = class extends M {
|
|
957
993
|
constructor(e, t) {
|
|
958
|
-
let n = t.length === 1 && t[0] instanceof
|
|
959
|
-
super(
|
|
994
|
+
let n = t.length === 1 && t[0] instanceof B ? t[0] : new I(t);
|
|
995
|
+
super(We, new I([new B(e), n]));
|
|
960
996
|
}
|
|
961
997
|
_toCDN(e, t) {
|
|
962
998
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
963
999
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
964
|
-
return i instanceof
|
|
1000
|
+
return i instanceof B ? `${r}${xe(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
965
1001
|
}
|
|
966
|
-
},
|
|
1002
|
+
}, Ke = class extends O {
|
|
967
1003
|
inner;
|
|
968
1004
|
ednSource;
|
|
969
1005
|
constructor(e, t) {
|
|
@@ -979,15 +1015,15 @@ var L = class e extends D {
|
|
|
979
1015
|
_toJS(e) {
|
|
980
1016
|
return this.inner._toJS(e);
|
|
981
1017
|
}
|
|
982
|
-
},
|
|
1018
|
+
}, qe = 888n, z = class extends M {
|
|
983
1019
|
constructor(e) {
|
|
984
|
-
e === void 0 ? super(
|
|
1020
|
+
e === void 0 ? super(qe, R.NULL) : super(qe, new I(e));
|
|
985
1021
|
}
|
|
986
1022
|
_toCDN(e, t) {
|
|
987
|
-
return this.content instanceof
|
|
1023
|
+
return this.content instanceof R ? "..." : this.content instanceof I ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
988
1024
|
}
|
|
989
|
-
},
|
|
990
|
-
function
|
|
1025
|
+
}, Je = 2n, Ye = 3n, Xe = 18446744073709551615n, Ze = -18446744073709551616n;
|
|
1026
|
+
function Qe(e) {
|
|
991
1027
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
992
1028
|
if (e === 0n) return /* @__PURE__ */ new Uint8Array();
|
|
993
1029
|
let t = e.toString(16);
|
|
@@ -996,16 +1032,16 @@ function Xe(e) {
|
|
|
996
1032
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
997
1033
|
return n;
|
|
998
1034
|
}
|
|
999
|
-
function
|
|
1035
|
+
function $e(e) {
|
|
1000
1036
|
let t = 0n;
|
|
1001
1037
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1002
1038
|
return t;
|
|
1003
1039
|
}
|
|
1004
|
-
var
|
|
1040
|
+
var et = class extends M {
|
|
1005
1041
|
bigValue;
|
|
1006
1042
|
constructor(e) {
|
|
1007
|
-
if (e <=
|
|
1008
|
-
super(
|
|
1043
|
+
if (e <= Xe) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1044
|
+
super(Je, new N(Qe(e))), this.bigValue = e;
|
|
1009
1045
|
}
|
|
1010
1046
|
_toCDN(e, t) {
|
|
1011
1047
|
return this.bigValue.toString();
|
|
@@ -1013,11 +1049,11 @@ var Qe = class extends j {
|
|
|
1013
1049
|
_toJS(e) {
|
|
1014
1050
|
return this.bigValue;
|
|
1015
1051
|
}
|
|
1016
|
-
},
|
|
1052
|
+
}, tt = class extends M {
|
|
1017
1053
|
bigValue;
|
|
1018
1054
|
constructor(e) {
|
|
1019
|
-
if (e >=
|
|
1020
|
-
super(
|
|
1055
|
+
if (e >= Ze) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1056
|
+
super(Ye, new N(Qe(-1n - e))), this.bigValue = e;
|
|
1021
1057
|
}
|
|
1022
1058
|
_toCDN(e, t) {
|
|
1023
1059
|
return this.bigValue.toString();
|
|
@@ -1025,25 +1061,25 @@ var Qe = class extends j {
|
|
|
1025
1061
|
_toJS(e) {
|
|
1026
1062
|
return this.bigValue;
|
|
1027
1063
|
}
|
|
1028
|
-
},
|
|
1029
|
-
function
|
|
1030
|
-
let
|
|
1031
|
-
offset:
|
|
1032
|
-
skipRS:
|
|
1033
|
-
}),
|
|
1034
|
-
return
|
|
1064
|
+
}, nt = new TextEncoder(), rt = new TextDecoder("utf-8", { fatal: !0 }), it = new TextDecoder("utf-8", { fatal: !1 });
|
|
1065
|
+
function at(e, t) {
|
|
1066
|
+
let n = new a(e, {
|
|
1067
|
+
offset: t?.offset,
|
|
1068
|
+
skipRS: t?._skipRS
|
|
1069
|
+
}), r = new _t(n, t ?? {}).parse();
|
|
1070
|
+
return t?.preserveComments && ut(r, n.comments, e), r;
|
|
1035
1071
|
}
|
|
1036
|
-
function
|
|
1072
|
+
function ot(e) {
|
|
1037
1073
|
let t = e, n;
|
|
1038
1074
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1039
1075
|
numStr: t,
|
|
1040
1076
|
rawSuffix: n
|
|
1041
1077
|
};
|
|
1042
1078
|
}
|
|
1043
|
-
function
|
|
1079
|
+
function st(e) {
|
|
1044
1080
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1045
1081
|
}
|
|
1046
|
-
function
|
|
1082
|
+
function ct(e, t) {
|
|
1047
1083
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1048
1084
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1049
1085
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1067,14 +1103,14 @@ function ot(e, t) {
|
|
|
1067
1103
|
};
|
|
1068
1104
|
let n = e, r;
|
|
1069
1105
|
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) ? {
|
|
1070
|
-
value:
|
|
1106
|
+
value: Be(n),
|
|
1071
1107
|
precision: r
|
|
1072
1108
|
} : {
|
|
1073
1109
|
value: parseFloat(n),
|
|
1074
1110
|
precision: r
|
|
1075
1111
|
};
|
|
1076
1112
|
}
|
|
1077
|
-
function
|
|
1113
|
+
function lt(e, t) {
|
|
1078
1114
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1079
1115
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1080
1116
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -1111,49 +1147,65 @@ function st(e, t) {
|
|
|
1111
1147
|
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1112
1148
|
return l;
|
|
1113
1149
|
}
|
|
1114
|
-
function
|
|
1150
|
+
function ut(e, t, n) {
|
|
1115
1151
|
if (t.length === 0) return;
|
|
1116
|
-
let r =
|
|
1117
|
-
for (let
|
|
1118
|
-
let
|
|
1119
|
-
|
|
1120
|
-
|
|
1152
|
+
let r = dt(e), i = pt(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;
|
|
1153
|
+
for (let t of s) {
|
|
1154
|
+
let r = { ...t }, s = 0, u = o.length;
|
|
1155
|
+
for (; s < u;) {
|
|
1156
|
+
let e = s + u >> 1;
|
|
1157
|
+
o[e].end <= t.start ? s = e + 1 : u = e;
|
|
1158
|
+
}
|
|
1159
|
+
let d = s > 0 ? o[s - 1] : void 0, f = d ? n.slice(d.end, t.start) : "";
|
|
1160
|
+
if (d && i(d.end) === t.line && !f.includes(":")) {
|
|
1161
|
+
ft(d.node, "trailing", r);
|
|
1121
1162
|
continue;
|
|
1122
1163
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1164
|
+
for (; l < a.length && a[l].start < t.start;) {
|
|
1165
|
+
let e = a[l++];
|
|
1166
|
+
for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
|
|
1167
|
+
c.push(e);
|
|
1168
|
+
}
|
|
1169
|
+
for (; c.length > 0 && c[c.length - 1].end <= t.start;) c.pop();
|
|
1170
|
+
let p = c.length > 0 ? c[c.length - 1] : void 0;
|
|
1171
|
+
for (s = 0, u = a.length; s < u;) {
|
|
1172
|
+
let e = s + u >> 1;
|
|
1173
|
+
a[e].start < t.end ? s = e + 1 : u = e;
|
|
1174
|
+
}
|
|
1175
|
+
let m = s < a.length ? a[s] : void 0;
|
|
1176
|
+
if ((!p || m && m.end <= p.end) && m) {
|
|
1177
|
+
ft(m.node, "leading", r);
|
|
1126
1178
|
continue;
|
|
1127
1179
|
}
|
|
1128
|
-
|
|
1180
|
+
ft(p?.node ?? e, "dangling", r);
|
|
1129
1181
|
}
|
|
1130
1182
|
}
|
|
1131
|
-
function
|
|
1183
|
+
function dt(e) {
|
|
1132
1184
|
let t = [], n = (e) => {
|
|
1133
1185
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1134
1186
|
node: e,
|
|
1135
1187
|
start: e.start,
|
|
1136
1188
|
end: e.end
|
|
1137
|
-
}), e instanceof
|
|
1189
|
+
}), e instanceof I || e instanceof Ue) {
|
|
1138
1190
|
for (let t of e.items) n(t);
|
|
1139
1191
|
return;
|
|
1140
1192
|
}
|
|
1141
|
-
if (e instanceof
|
|
1193
|
+
if (e instanceof L) {
|
|
1142
1194
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1143
1195
|
return;
|
|
1144
1196
|
}
|
|
1145
|
-
if (e instanceof
|
|
1197
|
+
if (e instanceof P || e instanceof F) {
|
|
1146
1198
|
for (let t of e.chunks) n(t);
|
|
1147
1199
|
return;
|
|
1148
1200
|
}
|
|
1149
|
-
e instanceof
|
|
1201
|
+
e instanceof M && n(e.content);
|
|
1150
1202
|
};
|
|
1151
1203
|
return n(e), t;
|
|
1152
1204
|
}
|
|
1153
|
-
function
|
|
1205
|
+
function ft(e, t, n) {
|
|
1154
1206
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1155
1207
|
}
|
|
1156
|
-
function
|
|
1208
|
+
function pt(e) {
|
|
1157
1209
|
let t = [0];
|
|
1158
1210
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1159
1211
|
return (n) => {
|
|
@@ -1167,15 +1219,15 @@ function dt(e) {
|
|
|
1167
1219
|
return a + 1;
|
|
1168
1220
|
};
|
|
1169
1221
|
}
|
|
1170
|
-
var
|
|
1171
|
-
["b32",
|
|
1172
|
-
["h32",
|
|
1173
|
-
["float",
|
|
1174
|
-
["same",
|
|
1175
|
-
["hash",
|
|
1176
|
-
["uuid",
|
|
1177
|
-
["UUID",
|
|
1178
|
-
]),
|
|
1222
|
+
var mt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, ht = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, gt = /* @__PURE__ */ new Map([
|
|
1223
|
+
["b32", mt("b32")],
|
|
1224
|
+
["h32", mt("h32")],
|
|
1225
|
+
["float", mt("float")],
|
|
1226
|
+
["same", mt("same")],
|
|
1227
|
+
["hash", ht("hash", "@cbortech/hash-extension")],
|
|
1228
|
+
["uuid", ht("uuid", "@cbortech/uuid-extension")],
|
|
1229
|
+
["UUID", ht("uuid", "@cbortech/uuid-extension")]
|
|
1230
|
+
]), _t = class {
|
|
1179
1231
|
t;
|
|
1180
1232
|
_options;
|
|
1181
1233
|
extByPrefix;
|
|
@@ -1183,23 +1235,25 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1183
1235
|
unresolvedExtension;
|
|
1184
1236
|
_pendingWarnings = [];
|
|
1185
1237
|
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1186
|
-
constructor(
|
|
1187
|
-
this.t =
|
|
1188
|
-
for (let e of [...Z, ...
|
|
1238
|
+
constructor(e, t) {
|
|
1239
|
+
this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
|
|
1240
|
+
for (let e of [...Z, ...t.extensions ?? []]) {
|
|
1189
1241
|
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1190
1242
|
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1191
1243
|
}
|
|
1192
|
-
this.t.onEscapeWarning = (t, n,
|
|
1193
|
-
let
|
|
1194
|
-
message:
|
|
1195
|
-
offset:
|
|
1196
|
-
line:
|
|
1197
|
-
column: i
|
|
1244
|
+
this.t.onEscapeWarning = (e, t, n, i, a) => {
|
|
1245
|
+
let o = {
|
|
1246
|
+
message: e,
|
|
1247
|
+
offset: t,
|
|
1248
|
+
line: n,
|
|
1249
|
+
column: i,
|
|
1250
|
+
endOffset: a
|
|
1198
1251
|
};
|
|
1199
|
-
if (this._pendingWarnings.push(
|
|
1200
|
-
offset:
|
|
1201
|
-
line:
|
|
1202
|
-
column: i
|
|
1252
|
+
if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${n}, column ${i}: ${e}`), this._options.strict !== !1) throw new r(e, {
|
|
1253
|
+
offset: t,
|
|
1254
|
+
line: n,
|
|
1255
|
+
column: i,
|
|
1256
|
+
endOffset: a
|
|
1203
1257
|
});
|
|
1204
1258
|
};
|
|
1205
1259
|
}
|
|
@@ -1233,12 +1287,12 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1233
1287
|
case "BYTES_HEX":
|
|
1234
1288
|
case "SQSTR":
|
|
1235
1289
|
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1236
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1237
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1238
|
-
case "TRUE": return this.t.consume(), new
|
|
1239
|
-
case "FALSE": return this.t.consume(), new
|
|
1240
|
-
case "NULL": return this.t.consume(), new
|
|
1241
|
-
case "UNDEFINED": return this.t.consume(), new
|
|
1290
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new P([]);
|
|
1291
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new F([]);
|
|
1292
|
+
case "TRUE": return this.t.consume(), new R(21);
|
|
1293
|
+
case "FALSE": return this.t.consume(), new R(20);
|
|
1294
|
+
case "NULL": return this.t.consume(), new R(22);
|
|
1295
|
+
case "UNDEFINED": return this.t.consume(), new R(23);
|
|
1242
1296
|
case "SIMPLE": return this.parseSimple();
|
|
1243
1297
|
case "LBRACKET": return this.parseArray();
|
|
1244
1298
|
case "LBRACE": return this.parseMap();
|
|
@@ -1253,21 +1307,21 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1253
1307
|
}
|
|
1254
1308
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1255
1309
|
if (!r?.parseAppString) {
|
|
1256
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1310
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, [new B(e.value)]);
|
|
1257
1311
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1258
1312
|
}
|
|
1259
1313
|
{
|
|
1260
1314
|
let i = this._pendingWarnings.length;
|
|
1261
1315
|
try {
|
|
1262
1316
|
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1263
|
-
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof
|
|
1317
|
+
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof N && Object.getPrototypeOf(i) === N.prototype && i.ednSource === void 0 ? new N(i.value, {
|
|
1264
1318
|
ednEncoding: i.ednEncoding,
|
|
1265
1319
|
encodingWidth: i.encodingWidth,
|
|
1266
1320
|
ednSource: e.raw + n
|
|
1267
|
-
}) : (i instanceof
|
|
1321
|
+
}) : (i instanceof j && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1268
1322
|
} catch (t) {
|
|
1269
1323
|
if (this._options.strict !== !1) throw t;
|
|
1270
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1324
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ge(e.appPrefix, [new B(e.value)]);
|
|
1271
1325
|
}
|
|
1272
1326
|
}
|
|
1273
1327
|
}
|
|
@@ -1285,7 +1339,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1285
1339
|
this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
|
|
1286
1340
|
let i = this.extByPrefix.get(e.appPrefix);
|
|
1287
1341
|
if (!i) {
|
|
1288
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1342
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, t);
|
|
1289
1343
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1290
1344
|
}
|
|
1291
1345
|
i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
@@ -1295,61 +1349,61 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1295
1349
|
let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
|
|
1296
1350
|
n !== void 0 && this._applyEiToResult(a, n, r ?? e);
|
|
1297
1351
|
let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1298
|
-
if (a instanceof
|
|
1299
|
-
else if (i.preserveAppSeqSource) return new
|
|
1352
|
+
if (a instanceof j) a.ednSource === void 0 && (a.ednSource = o);
|
|
1353
|
+
else if (i.preserveAppSeqSource) return new Ke(a, o);
|
|
1300
1354
|
return a;
|
|
1301
1355
|
} catch (n) {
|
|
1302
1356
|
if (this._options.strict !== !1) throw n;
|
|
1303
|
-
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new
|
|
1357
|
+
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new Ge(e.appPrefix, t);
|
|
1304
1358
|
}
|
|
1305
1359
|
}
|
|
1306
1360
|
}
|
|
1307
1361
|
case "ELLIPSIS": {
|
|
1308
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1309
|
-
let e = [new
|
|
1362
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new z();
|
|
1363
|
+
let e = [new z()];
|
|
1310
1364
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1311
|
-
return new
|
|
1365
|
+
return new z(e);
|
|
1312
1366
|
}
|
|
1313
1367
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1314
1368
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1315
1369
|
}
|
|
1316
1370
|
}
|
|
1317
1371
|
parseIntegerOrTag() {
|
|
1318
|
-
let e = this.t.consume(), { numStr: t, rawSuffix: n } =
|
|
1319
|
-
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new
|
|
1320
|
-
if (i < -18446744073709551616n) return new
|
|
1372
|
+
let e = this.t.consume(), { numStr: t, rawSuffix: n } = ot(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = st(t);
|
|
1373
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new et(i);
|
|
1374
|
+
if (i < -18446744073709551616n) return new tt(i);
|
|
1321
1375
|
if (r !== void 0) {
|
|
1322
1376
|
let t = i >= 0n ? i : -(i + 1n);
|
|
1323
1377
|
r = this._validateEncodingFit(t, r, e);
|
|
1324
1378
|
}
|
|
1325
|
-
let a = i >= 0n ? new
|
|
1379
|
+
let a = i >= 0n ? new k(i, r === void 0 ? void 0 : { encodingWidth: r }) : new A(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1326
1380
|
if (this.t.peek().type === "LPAREN") {
|
|
1327
|
-
a instanceof
|
|
1381
|
+
a instanceof k || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1328
1382
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
1329
1383
|
this.expect("RPAREN");
|
|
1330
1384
|
let i = a.value, o = this.extByTag.get(i);
|
|
1331
1385
|
if (o?.parseTag) {
|
|
1332
1386
|
let e = o.parseTag(i, n);
|
|
1333
|
-
if (e !== void 0) return e instanceof
|
|
1387
|
+
if (e !== void 0) return e instanceof M && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
|
|
1334
1388
|
}
|
|
1335
|
-
let s = new
|
|
1389
|
+
let s = new M(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1336
1390
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
1337
1391
|
}
|
|
1338
1392
|
return a;
|
|
1339
1393
|
}
|
|
1340
1394
|
parseFloat() {
|
|
1341
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1395
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = ct(e.value, t);
|
|
1342
1396
|
if (r === "half" || r === "single") {
|
|
1343
|
-
let e = r === "half" ? S(
|
|
1397
|
+
let e = r === "half" ? C(S(n)) : Math.fround(n);
|
|
1344
1398
|
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`);
|
|
1345
1399
|
}
|
|
1346
|
-
return new
|
|
1400
|
+
return new j(n, r === void 0 ? void 0 : { precision: r });
|
|
1347
1401
|
}
|
|
1348
1402
|
parseString() {
|
|
1349
1403
|
let e = this.t.consume();
|
|
1350
1404
|
if (this.t.peek().type !== "PLUS") {
|
|
1351
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1352
|
-
return new
|
|
1405
|
+
let t = this.consumeEncodingIndicator(() => BigInt(nt.encode(e.value).length));
|
|
1406
|
+
return new B(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1353
1407
|
}
|
|
1354
1408
|
let t = !1, n = [{ text: e.value }];
|
|
1355
1409
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -1358,36 +1412,50 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1358
1412
|
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push({ text: e.value })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({ text: this._decodeUtf8(this._decodeBytesToken(e), e) })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1359
1413
|
}
|
|
1360
1414
|
if (!t) {
|
|
1361
|
-
let e = n.map((e) => "text" in e ? e.text : "").join(""),
|
|
1362
|
-
return new
|
|
1415
|
+
let e = n.map((e) => "text" in e ? e.text : ""), t = e.join(""), r = this.consumeEncodingIndicator(() => BigInt(nt.encode(t).length));
|
|
1416
|
+
return new B(t, {
|
|
1417
|
+
ednParts: e,
|
|
1418
|
+
...r === void 0 ? {} : { encodingWidth: r }
|
|
1419
|
+
});
|
|
1363
1420
|
}
|
|
1364
1421
|
let r = [], i = "";
|
|
1365
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
1366
|
-
return i !== "" && r.push(new
|
|
1422
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new B(i)), i = ""), r.push(new z())) : i += e.text;
|
|
1423
|
+
return i !== "" && r.push(new B(i)), new z(r);
|
|
1367
1424
|
}
|
|
1368
1425
|
_isBytesToken(e) {
|
|
1369
1426
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
1370
1427
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1428
|
+
_hexToBytes(t, n) {
|
|
1429
|
+
try {
|
|
1430
|
+
return e(t);
|
|
1431
|
+
} catch (e) {
|
|
1432
|
+
if (e instanceof r || !(e instanceof SyntaxError)) throw e;
|
|
1433
|
+
this._fail(e.message, n);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
_decodeBytesToken(e) {
|
|
1437
|
+
let t = (t) => this._warnOrFail(t, e);
|
|
1438
|
+
switch (e.type) {
|
|
1439
|
+
case "SQSTR": {
|
|
1440
|
+
let t = e._sqstrBytes;
|
|
1441
|
+
return t === void 0 ? this._hexToBytes(e.value, e) : t;
|
|
1442
|
+
}
|
|
1443
|
+
case "BYTES_HEX": return this._hexToBytes(e.value, e);
|
|
1376
1444
|
case "BYTES_B64": try {
|
|
1377
|
-
return
|
|
1378
|
-
} catch (
|
|
1379
|
-
if (
|
|
1380
|
-
this._fail(
|
|
1445
|
+
return lt(e.value, t);
|
|
1446
|
+
} catch (t) {
|
|
1447
|
+
if (t instanceof r || !(t instanceof SyntaxError)) throw t;
|
|
1448
|
+
this._fail(t.message, e);
|
|
1381
1449
|
}
|
|
1382
|
-
default: this._fail("expected byte string token",
|
|
1450
|
+
default: this._fail("expected byte string token", e);
|
|
1383
1451
|
}
|
|
1384
1452
|
}
|
|
1385
1453
|
_decodeUtf8(e, t) {
|
|
1386
|
-
if (this._options.allowInvalidUtf8) return
|
|
1454
|
+
if (this._options.allowInvalidUtf8) return it.decode(e);
|
|
1387
1455
|
try {
|
|
1388
|
-
return
|
|
1456
|
+
return rt.decode(e);
|
|
1389
1457
|
} catch {
|
|
1390
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1458
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), it.decode(e);
|
|
1391
1459
|
}
|
|
1392
1460
|
}
|
|
1393
1461
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -1396,60 +1464,70 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1396
1464
|
_parseBytesConcat(e, t, n) {
|
|
1397
1465
|
if (this.t.peek().type !== "PLUS") {
|
|
1398
1466
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1399
|
-
return new
|
|
1467
|
+
return new N(e, {
|
|
1400
1468
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1401
1469
|
ednSource: n,
|
|
1402
1470
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
1403
1471
|
});
|
|
1404
1472
|
}
|
|
1405
|
-
let r = !1, i = [{
|
|
1473
|
+
let r = !1, i = [{
|
|
1474
|
+
bytes: e,
|
|
1475
|
+
source: n
|
|
1476
|
+
}];
|
|
1406
1477
|
for (; this.t.peek().type === "PLUS";) {
|
|
1407
1478
|
this.t.consume();
|
|
1408
1479
|
let e = this.t.peek();
|
|
1409
1480
|
if (e.type === "ELLIPSIS") this.t.consume(), i.push({ ellipsis: !0 }), r = !0;
|
|
1410
1481
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1411
1482
|
this.t.consume();
|
|
1412
|
-
let t = this._buildBytesElidedItems(e.value);
|
|
1413
|
-
for (let e of t) e instanceof
|
|
1414
|
-
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
|
|
1483
|
+
let t = this._buildBytesElidedItems(e.value, e);
|
|
1484
|
+
for (let e of t) e instanceof z ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof N && i.push({ bytes: e.value });
|
|
1485
|
+
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
|
|
1486
|
+
bytes: this._decodeBytesToken(e),
|
|
1487
|
+
source: e.raw
|
|
1488
|
+
})) : 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: nt.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1415
1489
|
}
|
|
1416
1490
|
if (!r) {
|
|
1417
|
-
let e = i.map((e) => "bytes" in e ? e
|
|
1418
|
-
return new
|
|
1491
|
+
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));
|
|
1492
|
+
return new N(n, {
|
|
1493
|
+
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1494
|
+
ednParts: e,
|
|
1495
|
+
...r === void 0 ? {} : { encodingWidth: r }
|
|
1496
|
+
});
|
|
1419
1497
|
}
|
|
1420
1498
|
let a = [], o = [], s = () => {
|
|
1421
|
-
o.length > 0 && (a.push(new
|
|
1499
|
+
o.length > 0 && (a.push(new N(this._concatBytes([...o]))), o.length = 0);
|
|
1422
1500
|
};
|
|
1423
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
1424
|
-
return s(), new
|
|
1501
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new z())) : o.push(e.bytes);
|
|
1502
|
+
return s(), new z(a);
|
|
1425
1503
|
}
|
|
1426
1504
|
_parseHexElidedConcat(e) {
|
|
1427
|
-
let t = this._buildBytesElidedItems(e.value);
|
|
1505
|
+
let t = this._buildBytesElidedItems(e.value, e);
|
|
1428
1506
|
for (; this.t.peek().type === "PLUS";) {
|
|
1429
1507
|
this.t.consume();
|
|
1430
1508
|
let e = this.t.peek();
|
|
1431
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
1509
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new z());
|
|
1432
1510
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1433
1511
|
this.t.consume();
|
|
1434
|
-
let n = this._buildBytesElidedItems(e.value);
|
|
1512
|
+
let n = this._buildBytesElidedItems(e.value, e);
|
|
1435
1513
|
this._mergeFirstBytesItem(t, n);
|
|
1436
1514
|
} else if (this._isBytesToken(e.type)) {
|
|
1437
1515
|
this.t.consume();
|
|
1438
1516
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
1439
|
-
r instanceof
|
|
1517
|
+
r instanceof N ? t[t.length - 1] = new N(this._concatBytes([r.value, n])) : t.push(new N(n));
|
|
1440
1518
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1441
1519
|
}
|
|
1442
|
-
return new
|
|
1520
|
+
return new z(t);
|
|
1443
1521
|
}
|
|
1444
|
-
_buildBytesElidedItems(e) {
|
|
1445
|
-
let
|
|
1446
|
-
for (let e = 0; e <
|
|
1447
|
-
return
|
|
1522
|
+
_buildBytesElidedItems(e, t) {
|
|
1523
|
+
let n = e.split("..."), r = [];
|
|
1524
|
+
for (let e = 0; e < n.length; e++) e > 0 && r.push(new z()), n[e].length > 0 && r.push(new N(this._hexToBytes(n[e], t)));
|
|
1525
|
+
return r;
|
|
1448
1526
|
}
|
|
1449
1527
|
_mergeFirstBytesItem(e, t) {
|
|
1450
1528
|
if (t.length === 0) return;
|
|
1451
1529
|
let n = e[e.length - 1], r = t[0];
|
|
1452
|
-
n instanceof
|
|
1530
|
+
n instanceof N && r instanceof N ? (e[e.length - 1] = new N(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
1453
1531
|
}
|
|
1454
1532
|
_concatBytes(e) {
|
|
1455
1533
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1460,8 +1538,8 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1460
1538
|
this.t.consume(), this.expect("LPAREN");
|
|
1461
1539
|
let e = this.t.peek();
|
|
1462
1540
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1463
|
-
let { numStr: t } =
|
|
1464
|
-
return this.expect("RPAREN"), new
|
|
1541
|
+
let { numStr: t } = ot(e.value), n = Number(st(t));
|
|
1542
|
+
return this.expect("RPAREN"), new R(n);
|
|
1465
1543
|
}
|
|
1466
1544
|
parseEmbeddedCBOR() {
|
|
1467
1545
|
this.t.consume();
|
|
@@ -1478,7 +1556,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1478
1556
|
let e = this.t.consume();
|
|
1479
1557
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1480
1558
|
}
|
|
1481
|
-
return new
|
|
1559
|
+
return new Ue(e, { encodingWidth: t });
|
|
1482
1560
|
}
|
|
1483
1561
|
parseArray() {
|
|
1484
1562
|
this.t.consume();
|
|
@@ -1492,7 +1570,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1492
1570
|
i.push(this.parseValue());
|
|
1493
1571
|
}
|
|
1494
1572
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1495
|
-
let a = new
|
|
1573
|
+
let a = new I(i, {
|
|
1496
1574
|
indefiniteLength: e,
|
|
1497
1575
|
encodingWidth: t
|
|
1498
1576
|
});
|
|
@@ -1513,7 +1591,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1513
1591
|
i.push([e, t]);
|
|
1514
1592
|
}
|
|
1515
1593
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1516
|
-
let a = new
|
|
1594
|
+
let a = new L(i, {
|
|
1517
1595
|
indefiniteLength: e,
|
|
1518
1596
|
encodingWidth: t
|
|
1519
1597
|
});
|
|
@@ -1537,16 +1615,16 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1537
1615
|
}
|
|
1538
1616
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1539
1617
|
let r = n[0];
|
|
1540
|
-
if (r instanceof
|
|
1541
|
-
let e = new
|
|
1542
|
-
if (e instanceof
|
|
1618
|
+
if (r instanceof N) {
|
|
1619
|
+
let e = new P(n.map((e, t) => {
|
|
1620
|
+
if (e instanceof N) return e;
|
|
1543
1621
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1544
1622
|
}));
|
|
1545
1623
|
return t.length > 0 && (e.warnings = t), e;
|
|
1546
1624
|
}
|
|
1547
|
-
if (r instanceof
|
|
1548
|
-
let e = new
|
|
1549
|
-
if (e instanceof
|
|
1625
|
+
if (r instanceof B) {
|
|
1626
|
+
let e = new F(n.map((e, t) => {
|
|
1627
|
+
if (e instanceof B) return e;
|
|
1550
1628
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1551
1629
|
}));
|
|
1552
1630
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -1564,47 +1642,47 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1564
1642
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1565
1643
|
}
|
|
1566
1644
|
_applyEiToResult(e, t, n) {
|
|
1567
|
-
if (e instanceof
|
|
1645
|
+
if (e instanceof j) {
|
|
1568
1646
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1569
1647
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1570
1648
|
else if (e.precision !== r) {
|
|
1571
1649
|
if (r !== "double") {
|
|
1572
|
-
let t = r === "half" ? S(
|
|
1650
|
+
let t = r === "half" ? C(S(e.value)) : Math.fround(e.value);
|
|
1573
1651
|
!Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
|
|
1574
1652
|
}
|
|
1575
1653
|
e.precision = r;
|
|
1576
1654
|
}
|
|
1577
|
-
} else if (e instanceof
|
|
1655
|
+
} else if (e instanceof k) {
|
|
1578
1656
|
if (e.encodingWidth === void 0) {
|
|
1579
1657
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
1580
1658
|
r !== void 0 && (e.encodingWidth = r);
|
|
1581
1659
|
}
|
|
1582
|
-
} else if (e instanceof
|
|
1660
|
+
} else if (e instanceof A) {
|
|
1583
1661
|
if (e.encodingWidth === void 0) {
|
|
1584
1662
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1585
1663
|
r !== void 0 && (e.encodingWidth = r);
|
|
1586
1664
|
}
|
|
1587
|
-
} else if (e instanceof
|
|
1665
|
+
} else if (e instanceof N) {
|
|
1588
1666
|
if (e.encodingWidth === void 0) {
|
|
1589
1667
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1590
1668
|
r !== void 0 && (e.encodingWidth = r);
|
|
1591
1669
|
}
|
|
1592
|
-
} else if (e instanceof
|
|
1670
|
+
} else if (e instanceof B) {
|
|
1593
1671
|
if (e.encodingWidth === void 0) {
|
|
1594
|
-
let r = this._validateEncodingFit(BigInt(
|
|
1672
|
+
let r = this._validateEncodingFit(BigInt(nt.encode(e.value).length), t, n);
|
|
1595
1673
|
r !== void 0 && (e.encodingWidth = r);
|
|
1596
1674
|
}
|
|
1597
|
-
} else if (e instanceof
|
|
1675
|
+
} else if (e instanceof I) {
|
|
1598
1676
|
if (e.encodingWidth === void 0) {
|
|
1599
1677
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1600
1678
|
r !== void 0 && (e.encodingWidth = r);
|
|
1601
1679
|
}
|
|
1602
|
-
} else if (e instanceof
|
|
1680
|
+
} else if (e instanceof L) {
|
|
1603
1681
|
if (e.encodingWidth === void 0) {
|
|
1604
1682
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1605
1683
|
r !== void 0 && (e.encodingWidth = r);
|
|
1606
1684
|
}
|
|
1607
|
-
} else if (e instanceof
|
|
1685
|
+
} else if (e instanceof M) {
|
|
1608
1686
|
if (e.encodingWidth === void 0) {
|
|
1609
1687
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1610
1688
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -1612,7 +1690,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1612
1690
|
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
1613
1691
|
}
|
|
1614
1692
|
_validateEncodingFit(e, t, n) {
|
|
1615
|
-
let r =
|
|
1693
|
+
let r = Pe(t);
|
|
1616
1694
|
if (e <= r) return t;
|
|
1617
1695
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
1618
1696
|
this._warnOrFail(i, n);
|
|
@@ -1636,77 +1714,109 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1636
1714
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1637
1715
|
}
|
|
1638
1716
|
_hintMissingExtension(e, t) {
|
|
1639
|
-
let n =
|
|
1717
|
+
let n = gt.get(e);
|
|
1640
1718
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1641
1719
|
this._hintedPrefixes.add(e);
|
|
1642
1720
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
1643
1721
|
this._options.onWarning ? this._options.onWarning({
|
|
1644
1722
|
message: r,
|
|
1645
|
-
|
|
1646
|
-
line: t.line,
|
|
1647
|
-
column: t.col
|
|
1723
|
+
...vt(t)
|
|
1648
1724
|
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
1649
1725
|
}
|
|
1650
1726
|
_warn(e, t) {
|
|
1651
1727
|
let n = { message: e };
|
|
1652
|
-
if (t !== void 0 && (n
|
|
1728
|
+
if (t !== void 0 && Object.assign(n, vt(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
|
|
1653
1729
|
else if (!this._options.silent) {
|
|
1654
1730
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
1655
1731
|
console.warn(`CDN strict violation${n}: ${e}`);
|
|
1656
1732
|
}
|
|
1657
1733
|
}
|
|
1658
|
-
_fail(
|
|
1659
|
-
throw new e
|
|
1660
|
-
offset: n.offset,
|
|
1661
|
-
line: n.line,
|
|
1662
|
-
column: n.col,
|
|
1663
|
-
endOffset: n.endOffset
|
|
1664
|
-
} : void 0);
|
|
1734
|
+
_fail(e, t) {
|
|
1735
|
+
throw new r(e, t ? vt(t) : void 0);
|
|
1665
1736
|
}
|
|
1666
|
-
}
|
|
1737
|
+
};
|
|
1738
|
+
function vt(e) {
|
|
1739
|
+
return {
|
|
1740
|
+
offset: e.offset,
|
|
1741
|
+
line: e.line,
|
|
1742
|
+
column: e.col,
|
|
1743
|
+
endOffset: e.endOffset
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
//#endregion
|
|
1747
|
+
//#region src/ast/CborTextString.ts
|
|
1748
|
+
var yt = new TextEncoder(), bt = !1, B = class extends O {
|
|
1667
1749
|
indefiniteLength = !1;
|
|
1668
1750
|
value;
|
|
1669
1751
|
encodingWidth;
|
|
1752
|
+
ednParts;
|
|
1670
1753
|
constructor(e, t) {
|
|
1671
|
-
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
1754
|
+
super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts;
|
|
1672
1755
|
}
|
|
1673
1756
|
_encodeTo(e, t) {
|
|
1674
|
-
|
|
1675
|
-
T(e, 3, n.length, this.encodingWidth), e.writeBytes(n);
|
|
1757
|
+
e.writeTextString(3, this.value, this.encodingWidth);
|
|
1676
1758
|
}
|
|
1677
1759
|
_toCDN(e, t) {
|
|
1678
|
-
let n =
|
|
1679
|
-
return
|
|
1760
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(yt.encode(this.value).length)));
|
|
1761
|
+
return xt(this.value, n, e, t, this.ednParts);
|
|
1680
1762
|
}
|
|
1681
1763
|
_toJS(e) {
|
|
1682
1764
|
return this.value;
|
|
1683
1765
|
}
|
|
1684
1766
|
};
|
|
1685
|
-
function
|
|
1686
|
-
let
|
|
1687
|
-
if (
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1767
|
+
function xt(e, t, n, r, i) {
|
|
1768
|
+
let { cdn: a, newline: o } = Ct(n), s = ee(n), c = n?.preserveConcatenation && i !== void 0 && i.length > 1 ? i : void 0;
|
|
1769
|
+
if (s === null) return c === void 0 ? Se(e) + t : St(c.map((e) => ({
|
|
1770
|
+
text: e,
|
|
1771
|
+
contentDepth: 0
|
|
1772
|
+
})), t, null, r);
|
|
1773
|
+
if (!a && !o && c === void 0) return Se(e) + t;
|
|
1774
|
+
let l = a ? Et(e) : null;
|
|
1775
|
+
if (l === null && c !== void 0) {
|
|
1776
|
+
let e = [];
|
|
1777
|
+
for (let t of c) if (o) {
|
|
1778
|
+
let n = /* @__PURE__ */ new Map();
|
|
1779
|
+
for (let { point: e, contentDepth: r } of Tt(t, 0)) n.set(e, r);
|
|
1780
|
+
e.push(...Pt(t, n));
|
|
1781
|
+
} else e.push({
|
|
1782
|
+
text: t,
|
|
1783
|
+
contentDepth: 0
|
|
1784
|
+
});
|
|
1785
|
+
return St(e, t, s, r);
|
|
1786
|
+
}
|
|
1787
|
+
let u = /* @__PURE__ */ new Map();
|
|
1788
|
+
if (l !== null) for (let { point: e, contentDepth: t } of l) u.set(e, t);
|
|
1789
|
+
if (o) {
|
|
1790
|
+
let t = l === null ? Tt(e, 0) : Dt(e);
|
|
1791
|
+
for (let { point: e, contentDepth: n } of t) u.has(e) || u.set(e, n);
|
|
1792
|
+
}
|
|
1793
|
+
let d = Pt(e, u);
|
|
1794
|
+
return d.length <= 1 ? Se(e) + t : St(d, t, s, r);
|
|
1795
|
+
}
|
|
1796
|
+
function St(e, t, n, r) {
|
|
1797
|
+
let i = e.map(({ text: n }, r) => {
|
|
1798
|
+
let i = Se(n);
|
|
1799
|
+
return r === e.length - 1 ? i + t : i;
|
|
1800
|
+
});
|
|
1801
|
+
if (n === null) return i.join(" + ");
|
|
1802
|
+
let a = i[0];
|
|
1803
|
+
for (let t = 1; t < i.length; t++) {
|
|
1804
|
+
let o = _(n, r + 1 + e[t].contentDepth);
|
|
1805
|
+
a += ` +\n${o}${i[t]}`;
|
|
1806
|
+
}
|
|
1807
|
+
return a;
|
|
1808
|
+
}
|
|
1809
|
+
function Ct(e) {
|
|
1810
|
+
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? wt(e?.textStringFormat ?? []) : [];
|
|
1811
|
+
return {
|
|
1812
|
+
cdn: e?.splitCdn ?? t.includes("cdn"),
|
|
1813
|
+
newline: e?.splitNewline ?? t.includes("newline")
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
function wt(e) {
|
|
1817
|
+
return e.map((e) => e === "cboredn" ? (bt || (bt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1818
|
+
}
|
|
1819
|
+
function Tt(e, t) {
|
|
1710
1820
|
let n = [];
|
|
1711
1821
|
for (let r = 0; r < e.length; r++) {
|
|
1712
1822
|
let i = e[r];
|
|
@@ -1723,75 +1833,75 @@ function bt(e, t) {
|
|
|
1723
1833
|
}
|
|
1724
1834
|
return n;
|
|
1725
1835
|
}
|
|
1726
|
-
function
|
|
1836
|
+
function Et(e) {
|
|
1727
1837
|
try {
|
|
1728
|
-
|
|
1838
|
+
at(e);
|
|
1729
1839
|
} catch {
|
|
1730
1840
|
return null;
|
|
1731
1841
|
}
|
|
1732
|
-
let
|
|
1842
|
+
let t = [], n = new a(e), r = 0, i = null, o = !1, s = 0;
|
|
1733
1843
|
for (;;) {
|
|
1734
|
-
let
|
|
1735
|
-
if (
|
|
1844
|
+
let a = n.consume();
|
|
1845
|
+
if (a.type === "EOF") break;
|
|
1736
1846
|
let c = !1;
|
|
1737
|
-
if (o || (o = !0,
|
|
1738
|
-
point:
|
|
1739
|
-
contentDepth:
|
|
1740
|
-
})),
|
|
1741
|
-
if (
|
|
1742
|
-
|
|
1847
|
+
if (o || (o = !0, a.offset > 0 && Mt(n.comments, 0, a.offset) && t.push({
|
|
1848
|
+
point: a.offset,
|
|
1849
|
+
contentDepth: r
|
|
1850
|
+
})), i !== null) {
|
|
1851
|
+
if (i.kind === "opener" && kt.has(a.type)) {
|
|
1852
|
+
i.point = a.endOffset, s = a.endOffset;
|
|
1743
1853
|
continue;
|
|
1744
|
-
} else
|
|
1745
|
-
point:
|
|
1746
|
-
contentDepth:
|
|
1854
|
+
} else i.kind === "opener" && jt.has(a.type) && Nt(e, i.point, a.offset) ? c = !0 : t.push({
|
|
1855
|
+
point: a.offset,
|
|
1856
|
+
contentDepth: i.contentDepth
|
|
1747
1857
|
});
|
|
1748
|
-
|
|
1858
|
+
i = null;
|
|
1749
1859
|
}
|
|
1750
|
-
|
|
1751
|
-
point:
|
|
1752
|
-
contentDepth:
|
|
1860
|
+
At.has(a.type) ? (r++, i = {
|
|
1861
|
+
point: a.endOffset,
|
|
1862
|
+
contentDepth: r,
|
|
1753
1863
|
kind: "opener"
|
|
1754
|
-
}) :
|
|
1755
|
-
point:
|
|
1756
|
-
contentDepth:
|
|
1757
|
-
})) :
|
|
1758
|
-
point:
|
|
1759
|
-
contentDepth:
|
|
1864
|
+
}) : jt.has(a.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
1865
|
+
point: a.offset,
|
|
1866
|
+
contentDepth: r
|
|
1867
|
+
})) : a.type === "COMMA" && (i = {
|
|
1868
|
+
point: a.endOffset,
|
|
1869
|
+
contentDepth: r,
|
|
1760
1870
|
kind: "comma"
|
|
1761
|
-
}), s =
|
|
1871
|
+
}), s = a.endOffset;
|
|
1762
1872
|
}
|
|
1763
|
-
let c =
|
|
1764
|
-
return c !== void 0 &&
|
|
1873
|
+
let c = n.comments.find((e) => e.start >= s);
|
|
1874
|
+
return c !== void 0 && t.push({
|
|
1765
1875
|
point: c.start,
|
|
1766
|
-
contentDepth:
|
|
1767
|
-
}),
|
|
1876
|
+
contentDepth: r
|
|
1877
|
+
}), t;
|
|
1768
1878
|
}
|
|
1769
|
-
function
|
|
1770
|
-
let
|
|
1879
|
+
function Dt(e) {
|
|
1880
|
+
let t = [], n = new a(e), r = 0;
|
|
1771
1881
|
for (;;) {
|
|
1772
|
-
let
|
|
1773
|
-
if (
|
|
1774
|
-
if (
|
|
1775
|
-
else if (
|
|
1776
|
-
else if (
|
|
1777
|
-
if (
|
|
1778
|
-
let
|
|
1779
|
-
for (let e of
|
|
1780
|
-
point:
|
|
1781
|
-
contentDepth:
|
|
1882
|
+
let i = n.consume();
|
|
1883
|
+
if (i.type === "EOF") break;
|
|
1884
|
+
if (At.has(i.type)) r++;
|
|
1885
|
+
else if (jt.has(i.type)) r = Math.max(0, r - 1);
|
|
1886
|
+
else if (i.type !== "COMMA") {
|
|
1887
|
+
if (i.type === "TSTR") {
|
|
1888
|
+
let n = e.slice(i.offset, i.endOffset);
|
|
1889
|
+
for (let e of Ot(n)) t.push({
|
|
1890
|
+
point: i.offset + e,
|
|
1891
|
+
contentDepth: r + 1
|
|
1782
1892
|
});
|
|
1783
|
-
} else if (
|
|
1784
|
-
let
|
|
1785
|
-
for (let { point: e } of
|
|
1786
|
-
point:
|
|
1787
|
-
contentDepth:
|
|
1893
|
+
} else if (i.type === "RAWSTRING") {
|
|
1894
|
+
let n = e.slice(i.offset, i.endOffset);
|
|
1895
|
+
for (let { point: e } of Tt(n, 0)) t.push({
|
|
1896
|
+
point: i.offset + e,
|
|
1897
|
+
contentDepth: r + 1
|
|
1788
1898
|
});
|
|
1789
1899
|
}
|
|
1790
1900
|
}
|
|
1791
1901
|
}
|
|
1792
|
-
return
|
|
1902
|
+
return t;
|
|
1793
1903
|
}
|
|
1794
|
-
function
|
|
1904
|
+
function Ot(e) {
|
|
1795
1905
|
let t = [], n = 1, r = e.length - 1;
|
|
1796
1906
|
for (; n < r;) {
|
|
1797
1907
|
let r = e[n];
|
|
@@ -1807,24 +1917,24 @@ function Ct(e) {
|
|
|
1807
1917
|
}
|
|
1808
1918
|
return t;
|
|
1809
1919
|
}
|
|
1810
|
-
var
|
|
1920
|
+
var kt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), At = /* @__PURE__ */ new Set([
|
|
1811
1921
|
"LBRACKET",
|
|
1812
1922
|
"LBRACE",
|
|
1813
1923
|
"LPAREN",
|
|
1814
1924
|
"LT_LT"
|
|
1815
|
-
]),
|
|
1925
|
+
]), jt = /* @__PURE__ */ new Set([
|
|
1816
1926
|
"RBRACKET",
|
|
1817
1927
|
"RBRACE",
|
|
1818
1928
|
"RPAREN",
|
|
1819
1929
|
"GT_GT"
|
|
1820
1930
|
]);
|
|
1821
|
-
function
|
|
1931
|
+
function Mt(e, t, n) {
|
|
1822
1932
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
1823
1933
|
}
|
|
1824
|
-
function
|
|
1934
|
+
function Nt(e, t, n) {
|
|
1825
1935
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
1826
1936
|
}
|
|
1827
|
-
function
|
|
1937
|
+
function Pt(e, t) {
|
|
1828
1938
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
1829
1939
|
if (n.length === 0) return [{
|
|
1830
1940
|
text: e,
|
|
@@ -1842,7 +1952,7 @@ function kt(e, t) {
|
|
|
1842
1952
|
}
|
|
1843
1953
|
//#endregion
|
|
1844
1954
|
//#region src/extensions/dt.ts
|
|
1845
|
-
function
|
|
1955
|
+
function V(e) {
|
|
1846
1956
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
1847
1957
|
let t = Math.round(e * 1e3);
|
|
1848
1958
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -1850,17 +1960,17 @@ function B(e) {
|
|
|
1850
1960
|
for (; s.length < 3;) s += "0";
|
|
1851
1961
|
return `${i}.${s}Z`;
|
|
1852
1962
|
}
|
|
1853
|
-
var
|
|
1854
|
-
function
|
|
1963
|
+
var Ft = new TextDecoder("utf-8", { fatal: !0 });
|
|
1964
|
+
function It(e) {
|
|
1855
1965
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
1856
1966
|
let t = e[0];
|
|
1857
|
-
if (t instanceof
|
|
1858
|
-
if (t instanceof
|
|
1967
|
+
if (t instanceof B) return t.value;
|
|
1968
|
+
if (t instanceof N) return Ft.decode(t.value);
|
|
1859
1969
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
1860
1970
|
}
|
|
1861
|
-
var
|
|
1862
|
-
function
|
|
1863
|
-
if (!
|
|
1971
|
+
var Lt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
1972
|
+
function Rt(e, t) {
|
|
1973
|
+
if (!Lt.test(e)) {
|
|
1864
1974
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
1865
1975
|
if (t) t(n);
|
|
1866
1976
|
else throw SyntaxError(n);
|
|
@@ -1871,93 +1981,93 @@ function Nt(e, t) {
|
|
|
1871
1981
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
1872
1982
|
if (i === void 0) {
|
|
1873
1983
|
let e = a / 1e3;
|
|
1874
|
-
return e >= 0 ? new
|
|
1984
|
+
return e >= 0 ? new Bt(BigInt(e)) : new Vt(BigInt(e));
|
|
1875
1985
|
}
|
|
1876
|
-
return new
|
|
1986
|
+
return new Ht(a / 1e3 + i);
|
|
1877
1987
|
}
|
|
1878
|
-
var
|
|
1988
|
+
var zt = 1n, Bt = class extends k {
|
|
1879
1989
|
constructor(e, t) {
|
|
1880
1990
|
super(e, t);
|
|
1881
1991
|
}
|
|
1882
1992
|
_toCDN(e, t) {
|
|
1883
1993
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1884
|
-
let n =
|
|
1885
|
-
return `dt'${
|
|
1994
|
+
let n = x(e, this.encodingWidth, () => b(this.value));
|
|
1995
|
+
return `dt'${V(Number(this.value))}'${n}`;
|
|
1886
1996
|
}
|
|
1887
|
-
},
|
|
1997
|
+
}, Vt = class extends A {
|
|
1888
1998
|
constructor(e, t) {
|
|
1889
1999
|
super(e, t);
|
|
1890
2000
|
}
|
|
1891
2001
|
_toCDN(e, t) {
|
|
1892
2002
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1893
|
-
let n =
|
|
1894
|
-
return `dt'${
|
|
2003
|
+
let n = x(e, this.encodingWidth, () => b(this.argument));
|
|
2004
|
+
return `dt'${V(Number(this.value))}'${n}`;
|
|
1895
2005
|
}
|
|
1896
|
-
},
|
|
2006
|
+
}, Ht = class extends j {
|
|
1897
2007
|
constructor(e, t) {
|
|
1898
2008
|
super(e, t);
|
|
1899
2009
|
}
|
|
1900
2010
|
_toCDN(e, t) {
|
|
1901
2011
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1902
|
-
let n =
|
|
1903
|
-
return `dt'${
|
|
2012
|
+
let n = D(this.value), r = we(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
2013
|
+
return `dt'${V(this.value)}'${r}`;
|
|
1904
2014
|
}
|
|
1905
|
-
},
|
|
2015
|
+
}, Ut = class extends M {
|
|
1906
2016
|
constructor(e, t) {
|
|
1907
|
-
super(
|
|
2017
|
+
super(zt, typeof e == "string" ? Rt(e) : e, t);
|
|
1908
2018
|
}
|
|
1909
2019
|
_toCDN(e, t) {
|
|
1910
2020
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1911
2021
|
let n = this.content;
|
|
1912
|
-
if (n instanceof
|
|
2022
|
+
if (n instanceof j ? n.precision !== void 0 && n.precision !== D(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
1913
2023
|
...e,
|
|
1914
2024
|
appStrings: !1
|
|
1915
2025
|
}, t);
|
|
1916
|
-
let r = n instanceof
|
|
1917
|
-
return `DT'${
|
|
2026
|
+
let r = n instanceof j ? n.value : Number(n.value), i = x(e, this.encodingWidth, () => b(zt));
|
|
2027
|
+
return `DT'${V(r)}'${i}`;
|
|
1918
2028
|
}
|
|
1919
|
-
},
|
|
2029
|
+
}, Wt = class extends Ut {
|
|
1920
2030
|
constructor(e, t) {
|
|
1921
2031
|
super(e, t);
|
|
1922
2032
|
}
|
|
1923
2033
|
_toJS(e) {
|
|
1924
|
-
let t = this.content, n = t instanceof
|
|
2034
|
+
let t = this.content, n = t instanceof j ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
1925
2035
|
return new Date(n);
|
|
1926
2036
|
}
|
|
1927
2037
|
};
|
|
1928
|
-
function
|
|
2038
|
+
function Gt(e) {
|
|
1929
2039
|
let t = e?.jsDate ?? !1;
|
|
1930
2040
|
function n(e) {
|
|
1931
|
-
return t ? new
|
|
2041
|
+
return t ? new Wt(e) : new Ut(e);
|
|
1932
2042
|
}
|
|
1933
2043
|
let r = {
|
|
1934
2044
|
appStringPrefixes: ["dt", "DT"],
|
|
1935
|
-
tagNumbers: [
|
|
2045
|
+
tagNumbers: [zt],
|
|
1936
2046
|
parseAppString(e, t, r) {
|
|
1937
|
-
return e === "DT" ? n(t) :
|
|
2047
|
+
return e === "DT" ? n(t) : Rt(t, r);
|
|
1938
2048
|
},
|
|
1939
2049
|
parseAppSequence(e, t, r) {
|
|
1940
|
-
let i =
|
|
1941
|
-
return e === "DT" ? n(i) :
|
|
2050
|
+
let i = It(t);
|
|
2051
|
+
return e === "DT" ? n(i) : Rt(i, r);
|
|
1942
2052
|
},
|
|
1943
2053
|
parseTag(e, n) {
|
|
1944
2054
|
if (e !== 1n) return;
|
|
1945
2055
|
let r;
|
|
1946
|
-
if (n instanceof
|
|
1947
|
-
else if (n instanceof
|
|
1948
|
-
else if (n instanceof
|
|
2056
|
+
if (n instanceof k) r = new Bt(n.value, { encodingWidth: n.encodingWidth });
|
|
2057
|
+
else if (n instanceof A) r = new Vt(n.value, { encodingWidth: n.encodingWidth });
|
|
2058
|
+
else if (n instanceof j) r = new Ht(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
1949
2059
|
else return;
|
|
1950
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
2060
|
+
return r.start = n.start, r.end = n.end, t ? new Wt(r) : new Ut(r);
|
|
1951
2061
|
}
|
|
1952
2062
|
};
|
|
1953
2063
|
return t && (r.fromJS = (e, t) => {
|
|
1954
|
-
if (e instanceof Date) return new
|
|
2064
|
+
if (e instanceof Date) return new Wt(V(e.getTime() / 1e3));
|
|
1955
2065
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
1956
2066
|
}
|
|
1957
|
-
var
|
|
2067
|
+
var Kt = Gt(), qt = Gt({ jsDate: !0 });
|
|
1958
2068
|
//#endregion
|
|
1959
2069
|
//#region src/utils/ip.ts
|
|
1960
|
-
function
|
|
2070
|
+
function Jt(e) {
|
|
1961
2071
|
let t = e.split(".");
|
|
1962
2072
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
1963
2073
|
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
@@ -1970,11 +2080,11 @@ function Ut(e) {
|
|
|
1970
2080
|
}
|
|
1971
2081
|
return n;
|
|
1972
2082
|
}
|
|
1973
|
-
function
|
|
2083
|
+
function Yt(e) {
|
|
1974
2084
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
1975
2085
|
if (e === "::") return t;
|
|
1976
2086
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1977
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2087
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Jt(i[2]));
|
|
1978
2088
|
let a = n.split("::");
|
|
1979
2089
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
1980
2090
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -1991,11 +2101,11 @@ function Wt(e) {
|
|
|
1991
2101
|
}
|
|
1992
2102
|
return r && t.set(r, 12), t;
|
|
1993
2103
|
}
|
|
1994
|
-
function
|
|
2104
|
+
function Xt(e) {
|
|
1995
2105
|
return Array.from(e).join(".");
|
|
1996
2106
|
}
|
|
1997
|
-
function
|
|
1998
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2107
|
+
function Zt(e) {
|
|
2108
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Xt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
1999
2109
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2000
2110
|
let i = -1, a = 0, o = 0;
|
|
2001
2111
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2009,29 +2119,29 @@ function Kt(e) {
|
|
|
2009
2119
|
}
|
|
2010
2120
|
//#endregion
|
|
2011
2121
|
//#region src/extensions/ip.ts
|
|
2012
|
-
var
|
|
2013
|
-
function
|
|
2122
|
+
var Qt = "ip", H = "IP", U = 52n, $t = 54n, en = new TextDecoder("utf-8", { fatal: !0 });
|
|
2123
|
+
function tn(e) {
|
|
2014
2124
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2015
2125
|
let t = e[0];
|
|
2016
|
-
if (t instanceof
|
|
2017
|
-
if (t instanceof
|
|
2126
|
+
if (t instanceof B) return t.value;
|
|
2127
|
+
if (t instanceof N) return en.decode(t.value);
|
|
2018
2128
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2019
2129
|
}
|
|
2020
|
-
function
|
|
2130
|
+
function nn(e) {
|
|
2021
2131
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2022
|
-
bytes:
|
|
2132
|
+
bytes: Jt(e),
|
|
2023
2133
|
isV4: !0
|
|
2024
2134
|
} : {
|
|
2025
|
-
bytes:
|
|
2135
|
+
bytes: Yt(e),
|
|
2026
2136
|
isV4: !1
|
|
2027
2137
|
};
|
|
2028
2138
|
}
|
|
2029
|
-
function
|
|
2030
|
-
if (e.length === 4) return
|
|
2031
|
-
if (e.length === 16) return
|
|
2139
|
+
function rn(e) {
|
|
2140
|
+
if (e.length === 4) return Xt(e);
|
|
2141
|
+
if (e.length === 16) return Zt(e);
|
|
2032
2142
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2033
2143
|
}
|
|
2034
|
-
function
|
|
2144
|
+
function an(e, t) {
|
|
2035
2145
|
let n = new Uint8Array(e.length);
|
|
2036
2146
|
n.set(e);
|
|
2037
2147
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2041,86 +2151,86 @@ function $t(e, t) {
|
|
|
2041
2151
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2042
2152
|
return n.slice(0, a);
|
|
2043
2153
|
}
|
|
2044
|
-
function
|
|
2154
|
+
function on(e, t) {
|
|
2045
2155
|
let n = new Uint8Array(t);
|
|
2046
2156
|
return n.set(e), n;
|
|
2047
2157
|
}
|
|
2048
|
-
var
|
|
2158
|
+
var sn = class extends N {
|
|
2049
2159
|
_toCDN(e, t) {
|
|
2050
2160
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2051
|
-
let n =
|
|
2052
|
-
return `${
|
|
2161
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this.value.length)));
|
|
2162
|
+
return `${Qt}'${rn(this.value)}'${n}`;
|
|
2053
2163
|
}
|
|
2054
|
-
},
|
|
2164
|
+
}, cn = class extends I {
|
|
2055
2165
|
_isV4;
|
|
2056
2166
|
constructor(e, t, n) {
|
|
2057
|
-
super([new
|
|
2167
|
+
super([new k(BigInt(e)), new N(t)]), this._isV4 = n;
|
|
2058
2168
|
}
|
|
2059
2169
|
_toCDN(e, t) {
|
|
2060
2170
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2061
2171
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2062
|
-
return `${
|
|
2172
|
+
return `${Qt}'${rn(on(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2063
2173
|
}
|
|
2064
|
-
},
|
|
2174
|
+
}, ln = class extends M {
|
|
2065
2175
|
constructor(e, t) {
|
|
2066
2176
|
super(e, t);
|
|
2067
2177
|
}
|
|
2068
2178
|
_toCDN(e, t) {
|
|
2069
2179
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2070
|
-
let n = this.tag ===
|
|
2071
|
-
if (r instanceof
|
|
2180
|
+
let n = this.tag === U ? 4 : 16, r = this.content;
|
|
2181
|
+
if (r instanceof N) {
|
|
2072
2182
|
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2073
|
-
let n =
|
|
2074
|
-
return `${
|
|
2183
|
+
let n = x(e, this.encodingWidth, () => b(this.tag));
|
|
2184
|
+
return `${H}'${rn(r.value)}'${n}`;
|
|
2075
2185
|
}
|
|
2076
|
-
if (r instanceof
|
|
2186
|
+
if (r instanceof I && r.items.length === 2 && r.items[0] instanceof k && r.items[1] instanceof N) {
|
|
2077
2187
|
if (r.encodingWidth !== void 0 || r.items[0].encodingWidth !== void 0 || r.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2078
|
-
let i = Number(r.items[0].value), a =
|
|
2079
|
-
return `${
|
|
2188
|
+
let i = Number(r.items[0].value), a = on(r.items[1].value, n), o = x(e, this.encodingWidth, () => b(this.tag));
|
|
2189
|
+
return `${H}'${rn(a)}/${i}'${o}`;
|
|
2080
2190
|
}
|
|
2081
2191
|
return super._toCDN(e, t);
|
|
2082
2192
|
}
|
|
2083
2193
|
};
|
|
2084
|
-
function
|
|
2194
|
+
function un(e, t) {
|
|
2085
2195
|
let n = t.indexOf("/");
|
|
2086
2196
|
if (n === -1) {
|
|
2087
|
-
let { bytes: n, isV4: r } =
|
|
2088
|
-
return e ===
|
|
2197
|
+
let { bytes: n, isV4: r } = nn(t);
|
|
2198
|
+
return e === H ? new ln(r ? U : $t, new N(n)) : new sn(n);
|
|
2089
2199
|
}
|
|
2090
2200
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2091
2201
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2092
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2202
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = nn(r), c = s ? 32 : 128;
|
|
2093
2203
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2094
|
-
let l =
|
|
2095
|
-
return e ===
|
|
2204
|
+
let l = an(o, a);
|
|
2205
|
+
return e === H ? new ln(s ? U : $t, new I([new k(BigInt(a)), new N(l)])) : new cn(a, l, s);
|
|
2096
2206
|
}
|
|
2097
|
-
var
|
|
2098
|
-
appStringPrefixes: [
|
|
2099
|
-
tagNumbers: [
|
|
2207
|
+
var dn = {
|
|
2208
|
+
appStringPrefixes: [Qt, H],
|
|
2209
|
+
tagNumbers: [U, $t],
|
|
2100
2210
|
parseAppString(e, t) {
|
|
2101
|
-
return
|
|
2211
|
+
return un(e, t);
|
|
2102
2212
|
},
|
|
2103
2213
|
parseAppSequence(e, t) {
|
|
2104
|
-
return
|
|
2214
|
+
return un(e, tn(t));
|
|
2105
2215
|
},
|
|
2106
2216
|
parseTag(e, t) {
|
|
2107
|
-
if (!(e !==
|
|
2217
|
+
if (!(e !== U && e !== $t) && (t instanceof N || t instanceof I)) return new ln(e, t);
|
|
2108
2218
|
}
|
|
2109
|
-
},
|
|
2110
|
-
tagNumbers: [
|
|
2219
|
+
}, fn = 18446744073709551615n, pn = -18446744073709551616n, mn = {
|
|
2220
|
+
tagNumbers: [Je, Ye],
|
|
2111
2221
|
parseTag(e, t) {
|
|
2112
|
-
if (t instanceof
|
|
2222
|
+
if (t instanceof N) {
|
|
2113
2223
|
if (e === 2n) {
|
|
2114
|
-
let e =
|
|
2115
|
-
return e >
|
|
2224
|
+
let e = $e(t.value);
|
|
2225
|
+
return e > fn ? new et(e) : void 0;
|
|
2116
2226
|
}
|
|
2117
2227
|
if (e === 3n) {
|
|
2118
|
-
let e = -1n -
|
|
2119
|
-
return e <
|
|
2228
|
+
let e = -1n - $e(t.value);
|
|
2229
|
+
return e < pn ? new tt(e) : void 0;
|
|
2120
2230
|
}
|
|
2121
2231
|
}
|
|
2122
2232
|
}
|
|
2123
|
-
},
|
|
2233
|
+
}, hn = "cri", gn = "CRI", _n = 99n, vn = /* @__PURE__ */ new Map([
|
|
2124
2234
|
["coap", -1n],
|
|
2125
2235
|
["coaps", -2n],
|
|
2126
2236
|
["http", -3n],
|
|
@@ -2131,47 +2241,47 @@ var on = {
|
|
|
2131
2241
|
["coaps+tcp", -8n],
|
|
2132
2242
|
["coap+ws", -25n],
|
|
2133
2243
|
["coaps+ws", -26n]
|
|
2134
|
-
]),
|
|
2135
|
-
function
|
|
2244
|
+
]), yn = new Map([...vn.entries()].map(([e, t]) => [t, e]));
|
|
2245
|
+
function W(e) {
|
|
2136
2246
|
try {
|
|
2137
2247
|
return decodeURIComponent(e);
|
|
2138
2248
|
} catch {
|
|
2139
2249
|
return e;
|
|
2140
2250
|
}
|
|
2141
2251
|
}
|
|
2142
|
-
var
|
|
2143
|
-
function
|
|
2144
|
-
return Array.from(
|
|
2252
|
+
var bn = new TextEncoder(), xn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2253
|
+
function Sn(e) {
|
|
2254
|
+
return Array.from(bn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2145
2255
|
}
|
|
2146
|
-
function
|
|
2256
|
+
function G(e, t) {
|
|
2147
2257
|
let n = "";
|
|
2148
|
-
for (let r of e) n += t(r) ? r :
|
|
2258
|
+
for (let r of e) n += t(r) ? r : Sn(r);
|
|
2149
2259
|
return n;
|
|
2150
2260
|
}
|
|
2151
|
-
function
|
|
2261
|
+
function Cn(e) {
|
|
2152
2262
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2153
2263
|
}
|
|
2154
|
-
function
|
|
2264
|
+
function wn(e) {
|
|
2155
2265
|
return /[!$&'()*+,;=]/.test(e);
|
|
2156
2266
|
}
|
|
2157
|
-
function
|
|
2158
|
-
return
|
|
2267
|
+
function Tn(e) {
|
|
2268
|
+
return Cn(e) || wn(e) || e === ":" || e === "@";
|
|
2159
2269
|
}
|
|
2160
|
-
function
|
|
2161
|
-
return (
|
|
2270
|
+
function En(e) {
|
|
2271
|
+
return (Tn(e) || e === "/" || e === "?") && e !== "&";
|
|
2162
2272
|
}
|
|
2163
|
-
function
|
|
2164
|
-
return
|
|
2273
|
+
function Dn(e) {
|
|
2274
|
+
return Tn(e) || e === "/" || e === "?";
|
|
2165
2275
|
}
|
|
2166
|
-
function
|
|
2167
|
-
return
|
|
2276
|
+
function On(e) {
|
|
2277
|
+
return Cn(e) || wn(e) || e === ":";
|
|
2168
2278
|
}
|
|
2169
|
-
function
|
|
2170
|
-
return
|
|
2279
|
+
function kn(e) {
|
|
2280
|
+
return Cn(e) || wn(e);
|
|
2171
2281
|
}
|
|
2172
|
-
function
|
|
2282
|
+
function An(e) {
|
|
2173
2283
|
let t = [], n = e, r = n.indexOf("@");
|
|
2174
|
-
r >= 0 && (t.push(
|
|
2284
|
+
r >= 0 && (t.push(R.FALSE), t.push(new B(W(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2175
2285
|
let i, a = null;
|
|
2176
2286
|
if (n.startsWith("[")) {
|
|
2177
2287
|
let e = n.indexOf("]");
|
|
@@ -2180,243 +2290,249 @@ function Tn(e) {
|
|
|
2180
2290
|
let r = n.slice(e + 1);
|
|
2181
2291
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2182
2292
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2183
|
-
t.push(new
|
|
2293
|
+
t.push(new N(Yt(i)));
|
|
2184
2294
|
} else {
|
|
2185
2295
|
let e = n.lastIndexOf(":");
|
|
2186
|
-
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
|
|
2187
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2296
|
+
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new N(Jt(i)));
|
|
2297
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new B(e));
|
|
2188
2298
|
}
|
|
2189
2299
|
if (a !== null && a !== "") {
|
|
2190
2300
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2191
2301
|
let e = parseInt(a, 10);
|
|
2192
2302
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2193
|
-
t.push(new
|
|
2303
|
+
t.push(new k(BigInt(e)));
|
|
2194
2304
|
}
|
|
2195
|
-
return new
|
|
2305
|
+
return new I(t);
|
|
2196
2306
|
}
|
|
2197
|
-
function
|
|
2307
|
+
function jn(e) {
|
|
2198
2308
|
let t = e.items, n = 0, r = "";
|
|
2199
|
-
if (n < t.length && t[n] instanceof
|
|
2309
|
+
if (n < t.length && t[n] instanceof R && t[n].value === 20) {
|
|
2200
2310
|
n++;
|
|
2201
2311
|
let e = t[n++];
|
|
2202
|
-
r +=
|
|
2312
|
+
r += G(e.value, On) + "@";
|
|
2203
2313
|
}
|
|
2204
2314
|
if (n >= t.length) return r;
|
|
2205
2315
|
let i = t[n];
|
|
2206
|
-
if (i instanceof
|
|
2316
|
+
if (i instanceof N) {
|
|
2207
2317
|
n++;
|
|
2208
2318
|
let { length: e } = i.value;
|
|
2209
|
-
if (e === 4) r +=
|
|
2210
|
-
else if (e === 16) r += "[" +
|
|
2319
|
+
if (e === 4) r += Xt(i.value);
|
|
2320
|
+
else if (e === 16) r += "[" + Zt(i.value) + "]";
|
|
2211
2321
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2212
|
-
n < t.length && t[n] instanceof
|
|
2322
|
+
n < t.length && t[n] instanceof B && (r += `%25${G(t[n++].value, kn)}`);
|
|
2213
2323
|
} else {
|
|
2214
2324
|
let e = [];
|
|
2215
|
-
for (; n < t.length && t[n] instanceof
|
|
2325
|
+
for (; n < t.length && t[n] instanceof B;) e.push(G(t[n++].value, kn));
|
|
2216
2326
|
r += e.join(".");
|
|
2217
2327
|
}
|
|
2218
|
-
return n < t.length && t[n] instanceof
|
|
2328
|
+
return n < t.length && t[n] instanceof k && (r += ":" + t[n].value.toString()), r;
|
|
2219
2329
|
}
|
|
2220
|
-
function
|
|
2330
|
+
function Mn(e) {
|
|
2221
2331
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2222
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2223
|
-
authority:
|
|
2332
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new B(W(e)))) : (r = t, i = []), {
|
|
2333
|
+
authority: An(r),
|
|
2224
2334
|
pathSegments: i
|
|
2225
2335
|
};
|
|
2226
2336
|
}
|
|
2227
|
-
function
|
|
2337
|
+
function Nn(e) {
|
|
2228
2338
|
let t = e, n = null, r = t.indexOf("#");
|
|
2229
|
-
r >= 0 && (n =
|
|
2339
|
+
r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
|
|
2230
2340
|
let i = null, a = t.indexOf("?");
|
|
2231
2341
|
if (a >= 0) {
|
|
2232
2342
|
let e = t.slice(a + 1);
|
|
2233
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2343
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new B(W(e)));
|
|
2234
2344
|
}
|
|
2235
2345
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2236
2346
|
if (s) {
|
|
2237
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2238
|
-
if (o.push(n === void 0 ? new
|
|
2239
|
-
let { authority: e, pathSegments: n } =
|
|
2240
|
-
o.push(e, new
|
|
2347
|
+
let e = s[1].toLowerCase(), t = s[2], n = vn.get(e);
|
|
2348
|
+
if (o.push(n === void 0 ? new B(e) : new A(n)), t.startsWith("//")) {
|
|
2349
|
+
let { authority: e, pathSegments: n } = Mn(t);
|
|
2350
|
+
o.push(e, new I(n));
|
|
2241
2351
|
} else if (t.startsWith("/")) {
|
|
2242
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2243
|
-
o.push(
|
|
2352
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
2353
|
+
o.push(R.NULL, new I(e));
|
|
2244
2354
|
} else {
|
|
2245
|
-
let e = t.split("/").map((e) => new
|
|
2246
|
-
o.push(
|
|
2355
|
+
let e = t.split("/").map((e) => new B(W(e)));
|
|
2356
|
+
o.push(R.TRUE, new I(e));
|
|
2247
2357
|
}
|
|
2248
2358
|
} else if (t.startsWith("//")) {
|
|
2249
|
-
let { authority: e, pathSegments: n } =
|
|
2250
|
-
o.push(
|
|
2359
|
+
let { authority: e, pathSegments: n } = Mn(t);
|
|
2360
|
+
o.push(R.FALSE, e, new I(n));
|
|
2251
2361
|
} else if (t.startsWith("/")) {
|
|
2252
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2253
|
-
o.push(
|
|
2254
|
-
} else if (t === "") o.push(new
|
|
2362
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
2363
|
+
o.push(R.TRUE, new I(e));
|
|
2364
|
+
} else if (t === "") o.push(new k(0n));
|
|
2255
2365
|
else {
|
|
2256
2366
|
let n = 1n, r = t, i = !1;
|
|
2257
2367
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2258
2368
|
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)}`);
|
|
2259
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2260
|
-
o.push(new
|
|
2369
|
+
let a = r === "" ? [] : r.split("/").map((e) => new B(W(e)));
|
|
2370
|
+
o.push(new k(n), new I(a));
|
|
2261
2371
|
}
|
|
2262
|
-
if (i !== null && o.push(new
|
|
2372
|
+
if (i !== null && o.push(new I(i)), n !== null && (i === null && o.push(R.NULL), o.push(new B(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2263
2373
|
let e = o[o.length - 1];
|
|
2264
|
-
e instanceof
|
|
2374
|
+
e instanceof I && e.items.length === 0 && o.pop();
|
|
2265
2375
|
}
|
|
2266
|
-
return o.length === 1 && o[0] instanceof
|
|
2376
|
+
return o.length === 1 && o[0] instanceof k && o[0].value === 0n ? [] : o;
|
|
2267
2377
|
}
|
|
2268
|
-
function
|
|
2378
|
+
function K(e, t) {
|
|
2269
2379
|
let n = t, r = "";
|
|
2270
2380
|
if (n < e.length) {
|
|
2271
2381
|
let t = e[n];
|
|
2272
|
-
if (t instanceof
|
|
2382
|
+
if (t instanceof I) {
|
|
2273
2383
|
if (n++, t.items.length > 0) {
|
|
2274
2384
|
let e = t.items.map((e) => {
|
|
2275
|
-
if (!(e instanceof
|
|
2276
|
-
return
|
|
2385
|
+
if (!(e instanceof B)) throw Error("cri: query item must be a text string");
|
|
2386
|
+
return G(e.value, En);
|
|
2277
2387
|
});
|
|
2278
2388
|
r += "?" + e.join("&");
|
|
2279
2389
|
}
|
|
2280
|
-
} else t instanceof
|
|
2390
|
+
} else t instanceof R && t.value === 22 && n++;
|
|
2281
2391
|
}
|
|
2282
|
-
return n < e.length && e[n] instanceof
|
|
2392
|
+
return n < e.length && e[n] instanceof B && (r += "#" + G(e[n].value, Dn)), r;
|
|
2283
2393
|
}
|
|
2284
|
-
function
|
|
2394
|
+
function Pn(e) {
|
|
2285
2395
|
return e.items.map((e) => {
|
|
2286
|
-
if (!(e instanceof
|
|
2287
|
-
return
|
|
2396
|
+
if (!(e instanceof B)) throw Error("cri: path segment must be a text string");
|
|
2397
|
+
return G(e.value, Tn);
|
|
2288
2398
|
});
|
|
2289
2399
|
}
|
|
2290
|
-
function
|
|
2400
|
+
function Fn(e) {
|
|
2291
2401
|
if (e.length === 0) return "";
|
|
2292
2402
|
let t = 0, n = e[t++];
|
|
2293
|
-
if (n instanceof
|
|
2403
|
+
if (n instanceof A || n instanceof B) {
|
|
2294
2404
|
let r;
|
|
2295
|
-
if (n instanceof
|
|
2296
|
-
let e =
|
|
2405
|
+
if (n instanceof A) {
|
|
2406
|
+
let e = yn.get(n.value);
|
|
2297
2407
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2298
2408
|
r = e + ":";
|
|
2299
2409
|
} else r = n.value + ":";
|
|
2300
2410
|
if (t >= e.length) return r;
|
|
2301
2411
|
let i = e[t++], a = "", o = !1;
|
|
2302
|
-
if (i instanceof
|
|
2303
|
-
else if (i instanceof
|
|
2412
|
+
if (i instanceof I) a = "//" + jn(i), o = !0;
|
|
2413
|
+
else if (i instanceof R) if (i.value === 22) o = !0;
|
|
2304
2414
|
else if (i.value === 21) o = !1;
|
|
2305
2415
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2306
2416
|
else throw Error("cri: unexpected type for authority element");
|
|
2307
2417
|
let s = "";
|
|
2308
|
-
if (t < e.length && e[t] instanceof
|
|
2418
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2309
2419
|
let n = e[t++];
|
|
2310
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2420
|
+
n.items.length > 0 && (s = (o ? "/" : "") + Pn(n).join("/"));
|
|
2311
2421
|
}
|
|
2312
|
-
return r + a + s +
|
|
2422
|
+
return r + a + s + K(e, t);
|
|
2313
2423
|
}
|
|
2314
|
-
if (n instanceof
|
|
2315
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2316
|
-
let n =
|
|
2317
|
-
if (t < e.length && e[t] instanceof
|
|
2424
|
+
if (n instanceof R && n.value === 20) {
|
|
2425
|
+
if (t >= e.length || !(e[t] instanceof I)) throw Error("cri: network-path reference requires an authority array");
|
|
2426
|
+
let n = jn(e[t++]), r = "";
|
|
2427
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2318
2428
|
let n = e[t++];
|
|
2319
|
-
n.items.length > 0 && (r = "/" +
|
|
2429
|
+
n.items.length > 0 && (r = "/" + Pn(n).join("/"));
|
|
2320
2430
|
}
|
|
2321
|
-
return "//" + n + r +
|
|
2431
|
+
return "//" + n + r + K(e, t);
|
|
2322
2432
|
}
|
|
2323
|
-
if (n instanceof
|
|
2433
|
+
if (n instanceof R && n.value === 21) {
|
|
2324
2434
|
let n = "/";
|
|
2325
|
-
if (t < e.length && e[t] instanceof
|
|
2435
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2326
2436
|
let r = e[t++];
|
|
2327
|
-
n = "/" +
|
|
2437
|
+
n = "/" + Pn(r).join("/");
|
|
2328
2438
|
}
|
|
2329
|
-
return n +
|
|
2439
|
+
return n + K(e, t);
|
|
2330
2440
|
}
|
|
2331
|
-
if (n instanceof
|
|
2441
|
+
if (n instanceof k) {
|
|
2332
2442
|
let r = n.value;
|
|
2333
|
-
if (r === 0n) return
|
|
2443
|
+
if (r === 0n) return K(e, t);
|
|
2334
2444
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2335
|
-
if (t < e.length && e[t] instanceof
|
|
2445
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2336
2446
|
let n = e[t++];
|
|
2337
2447
|
if (n.items.length > 0) {
|
|
2338
|
-
let e =
|
|
2448
|
+
let e = Pn(n);
|
|
2339
2449
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2340
2450
|
} else a = i === "" ? "./" : i;
|
|
2341
2451
|
} else a = i === "" ? "./" : i;
|
|
2342
|
-
return a +
|
|
2452
|
+
return a + K(e, t);
|
|
2343
2453
|
}
|
|
2344
2454
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2345
2455
|
}
|
|
2346
|
-
var
|
|
2456
|
+
var In = class extends I {
|
|
2347
2457
|
_toCDN(e, t) {
|
|
2348
2458
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2349
2459
|
try {
|
|
2350
|
-
let t =
|
|
2351
|
-
return `${
|
|
2460
|
+
let t = x(e, this.encodingWidth, () => b(BigInt(this.items.length)));
|
|
2461
|
+
return `${hn}'${Fn(this.items)}'${t}`;
|
|
2352
2462
|
} catch {
|
|
2353
2463
|
return super._toCDN(e, t);
|
|
2354
2464
|
}
|
|
2355
2465
|
}
|
|
2356
|
-
},
|
|
2466
|
+
}, Ln = class extends M {
|
|
2357
2467
|
constructor(e) {
|
|
2358
|
-
super(
|
|
2468
|
+
super(_n, e);
|
|
2359
2469
|
}
|
|
2360
2470
|
_toCDN(e, t) {
|
|
2361
2471
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2362
2472
|
try {
|
|
2363
2473
|
let n = this.content;
|
|
2364
2474
|
if (n.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2365
|
-
let r =
|
|
2366
|
-
return `${
|
|
2475
|
+
let r = x(e, this.encodingWidth, () => b(_n));
|
|
2476
|
+
return `${gn}'${Fn(n.items)}'${r}`;
|
|
2367
2477
|
} catch {
|
|
2368
2478
|
return super._toCDN(e, t);
|
|
2369
2479
|
}
|
|
2370
2480
|
}
|
|
2371
2481
|
};
|
|
2372
|
-
function
|
|
2482
|
+
function Rn(e) {
|
|
2373
2483
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2374
2484
|
let t = e[0];
|
|
2375
|
-
if (t instanceof
|
|
2376
|
-
if (t instanceof
|
|
2485
|
+
if (t instanceof B) return t.value;
|
|
2486
|
+
if (t instanceof N) return xn.decode(t.value);
|
|
2377
2487
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2378
2488
|
}
|
|
2379
|
-
function
|
|
2380
|
-
let n = new
|
|
2381
|
-
return e ===
|
|
2489
|
+
function zn(e, t) {
|
|
2490
|
+
let n = new In(Nn(t));
|
|
2491
|
+
return e === gn ? new Ln(n) : n;
|
|
2382
2492
|
}
|
|
2383
|
-
var
|
|
2384
|
-
appStringPrefixes: [
|
|
2385
|
-
tagNumbers: [
|
|
2493
|
+
var Bn = {
|
|
2494
|
+
appStringPrefixes: [hn, gn],
|
|
2495
|
+
tagNumbers: [_n],
|
|
2386
2496
|
parseAppString(e, t) {
|
|
2387
|
-
return
|
|
2497
|
+
return zn(e, t);
|
|
2388
2498
|
},
|
|
2389
2499
|
parseAppSequence(e, t) {
|
|
2390
|
-
return
|
|
2500
|
+
return zn(e, Rn(t));
|
|
2391
2501
|
},
|
|
2392
2502
|
parseTag(e, t) {
|
|
2393
|
-
if (e !== 99n || !(t instanceof
|
|
2394
|
-
let n = new
|
|
2503
|
+
if (e !== 99n || !(t instanceof I)) return;
|
|
2504
|
+
let n = new In(t.items, {
|
|
2395
2505
|
indefiniteLength: t.indefiniteLength,
|
|
2396
2506
|
encodingWidth: t.encodingWidth
|
|
2397
2507
|
});
|
|
2398
|
-
return n.start = t.start, n.end = t.end, new
|
|
2508
|
+
return n.start = t.start, n.end = t.end, new Ln(n);
|
|
2399
2509
|
}
|
|
2400
2510
|
};
|
|
2401
2511
|
//#endregion
|
|
2402
2512
|
//#region src/cbor/decoder.ts
|
|
2403
|
-
function
|
|
2513
|
+
function Vn(e, t) {
|
|
2404
2514
|
if (e === 24 && t <= 23n) return 0;
|
|
2405
2515
|
if (e === 25 && t <= 255n) return 1;
|
|
2406
2516
|
if (e === 26 && t <= 65535n) return 2;
|
|
2407
2517
|
if (e === 27 && t <= 4294967295n) return 3;
|
|
2408
2518
|
}
|
|
2409
|
-
|
|
2519
|
+
function Hn(e, t) {
|
|
2520
|
+
if (e === 24 && t <= 23) return 0;
|
|
2521
|
+
if (e === 25 && t <= 255) return 1;
|
|
2522
|
+
if (e === 26 && t <= 65535) return 2;
|
|
2523
|
+
if (e === 27 && t <= 4294967295) return 3;
|
|
2524
|
+
}
|
|
2525
|
+
var Un = new TextDecoder("utf-8", {
|
|
2410
2526
|
fatal: !0,
|
|
2411
2527
|
ignoreBOM: !0
|
|
2412
|
-
}),
|
|
2528
|
+
}), Wn = new TextDecoder("utf-8", {
|
|
2413
2529
|
fatal: !1,
|
|
2414
2530
|
ignoreBOM: !0
|
|
2415
2531
|
});
|
|
2416
2532
|
function q(e) {
|
|
2417
2533
|
throw Error(`CBOR decode error: ${e}`);
|
|
2418
2534
|
}
|
|
2419
|
-
function
|
|
2535
|
+
function Gn(e, t, n) {
|
|
2420
2536
|
let r = {
|
|
2421
2537
|
message: e,
|
|
2422
2538
|
offset: t
|
|
@@ -2424,71 +2540,63 @@ function Rn(e, t, n) {
|
|
|
2424
2540
|
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}`);
|
|
2425
2541
|
return r;
|
|
2426
2542
|
}
|
|
2427
|
-
function
|
|
2543
|
+
function J(e, t) {
|
|
2428
2544
|
e.warnings ??= [], e.warnings.push(t);
|
|
2429
2545
|
}
|
|
2430
|
-
function
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
return t;
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
if (e instanceof
|
|
2437
|
-
if (e instanceof k) return ["n", String(e.value)];
|
|
2438
|
-
if (e instanceof z) return ["t", e.value];
|
|
2439
|
-
if (e instanceof P) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2440
|
-
if (e instanceof M) return ["b", Bn(e.value)];
|
|
2441
|
-
if (e instanceof N) {
|
|
2546
|
+
function Y(e) {
|
|
2547
|
+
if (e instanceof k) return ["u", String(e.value)];
|
|
2548
|
+
if (e instanceof A) return ["n", String(e.value)];
|
|
2549
|
+
if (e instanceof B) return ["t", e.value];
|
|
2550
|
+
if (e instanceof F) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2551
|
+
if (e instanceof N) return ["b", i(e.value)];
|
|
2552
|
+
if (e instanceof P) {
|
|
2442
2553
|
let t = "";
|
|
2443
|
-
for (let n of e.chunks) t +=
|
|
2554
|
+
for (let n of e.chunks) t += i(n.value);
|
|
2444
2555
|
return ["b", t];
|
|
2445
2556
|
}
|
|
2446
|
-
if (e instanceof
|
|
2447
|
-
if (e instanceof
|
|
2448
|
-
if (e instanceof
|
|
2449
|
-
if (e instanceof
|
|
2450
|
-
let t = e.entries.map(([e, t]) => [
|
|
2557
|
+
if (e instanceof j) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2558
|
+
if (e instanceof R) return ["s", e.value];
|
|
2559
|
+
if (e instanceof I) return ["A", e.items.map(Y)];
|
|
2560
|
+
if (e instanceof L) {
|
|
2561
|
+
let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
|
|
2451
2562
|
if (t.length <= 1) return ["M", t];
|
|
2452
2563
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2453
2564
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2454
2565
|
}
|
|
2455
|
-
|
|
2566
|
+
return e instanceof M ? [
|
|
2456
2567
|
"G",
|
|
2457
2568
|
String(e.tag),
|
|
2458
|
-
|
|
2459
|
-
];
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
return
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
if (e instanceof
|
|
2466
|
-
if (e instanceof k) return "n" + e.value;
|
|
2467
|
-
if (e instanceof z) return "t" + e.value;
|
|
2468
|
-
if (e instanceof P) {
|
|
2569
|
+
Y(e.content)
|
|
2570
|
+
] : ["c", i(e.toCBOR())];
|
|
2571
|
+
}
|
|
2572
|
+
function Kn(e) {
|
|
2573
|
+
if (e instanceof k) return "u" + e.value;
|
|
2574
|
+
if (e instanceof A) return "n" + e.value;
|
|
2575
|
+
if (e instanceof B) return "t" + e.value;
|
|
2576
|
+
if (e instanceof F) {
|
|
2469
2577
|
let t = "t";
|
|
2470
2578
|
for (let n of e.chunks) t += n.value;
|
|
2471
2579
|
return t;
|
|
2472
2580
|
}
|
|
2473
|
-
if (e instanceof
|
|
2474
|
-
if (e instanceof
|
|
2581
|
+
if (e instanceof N) return "b" + i(e.value);
|
|
2582
|
+
if (e instanceof P) {
|
|
2475
2583
|
let t = "b";
|
|
2476
|
-
for (let n of e.chunks) t +=
|
|
2584
|
+
for (let n of e.chunks) t += i(n.value);
|
|
2477
2585
|
return t;
|
|
2478
2586
|
}
|
|
2479
|
-
return e instanceof
|
|
2587
|
+
return e instanceof j ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof R ? "s" + e.value : JSON.stringify(Y(e));
|
|
2480
2588
|
}
|
|
2481
|
-
var
|
|
2482
|
-
function
|
|
2483
|
-
return
|
|
2589
|
+
var qn = Array.from({ length: 24 }, (e, t) => BigInt(t)), Jn;
|
|
2590
|
+
function Yn() {
|
|
2591
|
+
return Jn ??= Z.filter((e) => e.parseTag !== void 0);
|
|
2484
2592
|
}
|
|
2485
|
-
function
|
|
2593
|
+
function Xn(e, t) {
|
|
2486
2594
|
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
2487
2595
|
return String.fromCharCode.apply(null, e);
|
|
2488
2596
|
}
|
|
2489
|
-
function
|
|
2597
|
+
function Zn(e, t, n) {
|
|
2490
2598
|
if (n <= 23) return {
|
|
2491
|
-
value:
|
|
2599
|
+
value: qn[n],
|
|
2492
2600
|
nextOffset: t
|
|
2493
2601
|
};
|
|
2494
2602
|
switch (n) {
|
|
@@ -2511,7 +2619,36 @@ function Y(e, t, n) {
|
|
|
2511
2619
|
default: q(`reserved additional info value: ${n}`);
|
|
2512
2620
|
}
|
|
2513
2621
|
}
|
|
2514
|
-
function
|
|
2622
|
+
function Qn(e, t, n) {
|
|
2623
|
+
if (n <= 23) return {
|
|
2624
|
+
value: n,
|
|
2625
|
+
nextOffset: t
|
|
2626
|
+
};
|
|
2627
|
+
switch (n) {
|
|
2628
|
+
case 24: return t + 1 > e.byteLength && q("unexpected end of input"), {
|
|
2629
|
+
value: e.getUint8(t),
|
|
2630
|
+
nextOffset: t + 1
|
|
2631
|
+
};
|
|
2632
|
+
case 25: return t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
2633
|
+
value: e.getUint16(t, !1),
|
|
2634
|
+
nextOffset: t + 2
|
|
2635
|
+
};
|
|
2636
|
+
case 26: return t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
2637
|
+
value: e.getUint32(t, !1),
|
|
2638
|
+
nextOffset: t + 4
|
|
2639
|
+
};
|
|
2640
|
+
case 27: {
|
|
2641
|
+
t + 8 > e.byteLength && q("unexpected end of input");
|
|
2642
|
+
let n = e.getUint32(t, !1), r = e.getUint32(t + 4, !1);
|
|
2643
|
+
return {
|
|
2644
|
+
value: n * 4294967296 + r,
|
|
2645
|
+
nextOffset: t + 8
|
|
2646
|
+
};
|
|
2647
|
+
}
|
|
2648
|
+
default: q(`reserved additional info value: ${n}`);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
function $n(e, t, n, r, i, a) {
|
|
2515
2652
|
let o = [], s = t;
|
|
2516
2653
|
for (;;) {
|
|
2517
2654
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
@@ -2526,67 +2663,70 @@ function Kn(e, t, n, r, i, a) {
|
|
|
2526
2663
|
nextOffset: s
|
|
2527
2664
|
};
|
|
2528
2665
|
}
|
|
2529
|
-
function
|
|
2530
|
-
let i =
|
|
2531
|
-
t.has(i) && n.push(
|
|
2666
|
+
function er(e, t, n, r) {
|
|
2667
|
+
let i = Kn(e);
|
|
2668
|
+
t.has(i) && n.push(Gn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2532
2669
|
}
|
|
2533
2670
|
function X(e, t, n, r) {
|
|
2534
|
-
let i = t, a =
|
|
2671
|
+
let i = t, a = nr(e, t, n, r);
|
|
2535
2672
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2536
2673
|
}
|
|
2537
|
-
function
|
|
2674
|
+
function tr(e, t, n) {
|
|
2675
|
+
return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
|
|
2676
|
+
}
|
|
2677
|
+
function nr(e, t, n, r) {
|
|
2538
2678
|
t >= e.byteLength && q("unexpected end of input");
|
|
2539
2679
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2540
2680
|
switch (a) {
|
|
2541
2681
|
case 0: {
|
|
2542
|
-
let { value: n, nextOffset: r } =
|
|
2682
|
+
let { value: n, nextOffset: r } = Zn(e, t, o);
|
|
2543
2683
|
return {
|
|
2544
|
-
value: new
|
|
2684
|
+
value: new k(n, { encodingWidth: Vn(o, n) }),
|
|
2545
2685
|
nextOffset: r
|
|
2546
2686
|
};
|
|
2547
2687
|
}
|
|
2548
2688
|
case 1: {
|
|
2549
|
-
let { value: n, nextOffset: r } =
|
|
2689
|
+
let { value: n, nextOffset: r } = Zn(e, t, o), i = Vn(o, n);
|
|
2550
2690
|
return {
|
|
2551
|
-
value: new
|
|
2691
|
+
value: new A(-1n - n, { encodingWidth: i }),
|
|
2552
2692
|
nextOffset: r
|
|
2553
2693
|
};
|
|
2554
2694
|
}
|
|
2555
2695
|
case 2: {
|
|
2556
2696
|
if (o === 31) {
|
|
2557
|
-
let { chunks: i, nextOffset: a } =
|
|
2697
|
+
let { chunks: i, nextOffset: a } = $n(e, t, n, r, "byte string", (e) => e instanceof N);
|
|
2558
2698
|
return {
|
|
2559
|
-
value: new
|
|
2699
|
+
value: new P(i),
|
|
2560
2700
|
nextOffset: a
|
|
2561
2701
|
};
|
|
2562
2702
|
}
|
|
2563
|
-
let { value: i, nextOffset: a } =
|
|
2564
|
-
return a +
|
|
2565
|
-
value: new
|
|
2566
|
-
nextOffset: a +
|
|
2703
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i);
|
|
2704
|
+
return a + i > e.byteLength && q("byte string extends beyond input"), {
|
|
2705
|
+
value: new N(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
2706
|
+
nextOffset: a + i
|
|
2567
2707
|
};
|
|
2568
2708
|
}
|
|
2569
2709
|
case 3: {
|
|
2570
2710
|
if (o === 31) {
|
|
2571
|
-
let { chunks: i, nextOffset: a } =
|
|
2711
|
+
let { chunks: i, nextOffset: a } = $n(e, t, n, r, "text string", (e) => e instanceof B);
|
|
2572
2712
|
return {
|
|
2573
|
-
value: new
|
|
2713
|
+
value: new F(i),
|
|
2574
2714
|
nextOffset: a
|
|
2575
2715
|
};
|
|
2576
2716
|
}
|
|
2577
|
-
let { value: i, nextOffset: a } =
|
|
2578
|
-
a +
|
|
2579
|
-
let
|
|
2580
|
-
if (
|
|
2717
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i);
|
|
2718
|
+
a + i > e.byteLength && q("text string extends beyond input");
|
|
2719
|
+
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? Xn(c, i) : void 0;
|
|
2720
|
+
if (d !== void 0) l = d;
|
|
2581
2721
|
else try {
|
|
2582
|
-
|
|
2722
|
+
l = Un.decode(c);
|
|
2583
2723
|
} catch {
|
|
2584
|
-
|
|
2724
|
+
u = Gn("invalid UTF-8 sequence in text string", a, n), l = Wn.decode(c);
|
|
2585
2725
|
}
|
|
2586
|
-
let
|
|
2587
|
-
return
|
|
2588
|
-
value:
|
|
2589
|
-
nextOffset: a +
|
|
2726
|
+
let f = new B(l, { encodingWidth: s });
|
|
2727
|
+
return u && J(f, u), {
|
|
2728
|
+
value: f,
|
|
2729
|
+
nextOffset: a + i
|
|
2590
2730
|
};
|
|
2591
2731
|
}
|
|
2592
2732
|
case 4: {
|
|
@@ -2601,18 +2741,18 @@ function Jn(e, t, n, r) {
|
|
|
2601
2741
|
i.push(t.value), a = t.nextOffset;
|
|
2602
2742
|
}
|
|
2603
2743
|
return {
|
|
2604
|
-
value: new
|
|
2744
|
+
value: new I(i, { indefiniteLength: !0 }),
|
|
2605
2745
|
nextOffset: a
|
|
2606
2746
|
};
|
|
2607
2747
|
}
|
|
2608
|
-
let { value: i, nextOffset: a } =
|
|
2609
|
-
for (let t = 0; t <
|
|
2610
|
-
let t = X(e,
|
|
2611
|
-
|
|
2748
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i), c = [], l = a;
|
|
2749
|
+
for (let t = 0; t < i; t++) {
|
|
2750
|
+
let t = X(e, l, n, r);
|
|
2751
|
+
c.push(t.value), l = t.nextOffset;
|
|
2612
2752
|
}
|
|
2613
2753
|
return {
|
|
2614
|
-
value: new
|
|
2615
|
-
nextOffset:
|
|
2754
|
+
value: new I(c, { encodingWidth: s }),
|
|
2755
|
+
nextOffset: l
|
|
2616
2756
|
};
|
|
2617
2757
|
}
|
|
2618
2758
|
case 5: {
|
|
@@ -2624,106 +2764,130 @@ function Jn(e, t, n, r) {
|
|
|
2624
2764
|
break;
|
|
2625
2765
|
}
|
|
2626
2766
|
let t = X(e, s, n, r);
|
|
2627
|
-
|
|
2767
|
+
er(t.value, a, o, n), s = t.nextOffset;
|
|
2628
2768
|
let c = X(e, s, n, r);
|
|
2629
2769
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2630
2770
|
}
|
|
2631
|
-
let c = new
|
|
2632
|
-
for (let e of o)
|
|
2771
|
+
let c = new L(i, { indefiniteLength: !0 });
|
|
2772
|
+
for (let e of o) J(c, e);
|
|
2633
2773
|
return {
|
|
2634
2774
|
value: c,
|
|
2635
2775
|
nextOffset: s
|
|
2636
2776
|
};
|
|
2637
2777
|
}
|
|
2638
|
-
let { value: i, nextOffset: a } =
|
|
2639
|
-
for (let t = 0; t <
|
|
2640
|
-
let t = X(e,
|
|
2641
|
-
|
|
2642
|
-
let i = X(e,
|
|
2643
|
-
|
|
2778
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
2779
|
+
for (let t = 0; t < i; t++) {
|
|
2780
|
+
let t = X(e, d, n, r);
|
|
2781
|
+
er(t.value, l, u, n), d = t.nextOffset;
|
|
2782
|
+
let i = X(e, d, n, r);
|
|
2783
|
+
d = i.nextOffset, c.push([t.value, i.value]);
|
|
2644
2784
|
}
|
|
2645
|
-
let
|
|
2646
|
-
for (let e of
|
|
2785
|
+
let f = new L(c, { encodingWidth: s });
|
|
2786
|
+
for (let e of u) J(f, e);
|
|
2647
2787
|
return {
|
|
2648
|
-
value:
|
|
2649
|
-
nextOffset:
|
|
2788
|
+
value: f,
|
|
2789
|
+
nextOffset: d
|
|
2650
2790
|
};
|
|
2651
2791
|
}
|
|
2652
2792
|
case 6: {
|
|
2653
2793
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2654
|
-
let { value: i, nextOffset: a } =
|
|
2794
|
+
let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i), c = X(e, a, n, r);
|
|
2655
2795
|
for (let e of r) {
|
|
2656
2796
|
let t = e.parseTag(i, c.value, n);
|
|
2657
|
-
if (t !== void 0) return t instanceof
|
|
2797
|
+
if (t !== void 0) return t instanceof M && s !== void 0 && (t.encodingWidth = s), {
|
|
2658
2798
|
value: t,
|
|
2659
2799
|
nextOffset: c.nextOffset
|
|
2660
2800
|
};
|
|
2661
2801
|
}
|
|
2662
2802
|
return {
|
|
2663
|
-
value: new
|
|
2803
|
+
value: new M(i, c.value, { encodingWidth: s }),
|
|
2664
2804
|
nextOffset: c.nextOffset
|
|
2665
2805
|
};
|
|
2666
2806
|
}
|
|
2667
2807
|
case 7:
|
|
2668
2808
|
if (o <= 19) return {
|
|
2669
|
-
value: new
|
|
2809
|
+
value: new R(o),
|
|
2670
2810
|
nextOffset: t
|
|
2671
2811
|
};
|
|
2672
2812
|
if (o === 20) return {
|
|
2673
|
-
value: new
|
|
2813
|
+
value: new R(20),
|
|
2674
2814
|
nextOffset: t
|
|
2675
2815
|
};
|
|
2676
2816
|
if (o === 21) return {
|
|
2677
|
-
value: new
|
|
2817
|
+
value: new R(21),
|
|
2678
2818
|
nextOffset: t
|
|
2679
2819
|
};
|
|
2680
2820
|
if (o === 22) return {
|
|
2681
|
-
value: new
|
|
2821
|
+
value: new R(22),
|
|
2682
2822
|
nextOffset: t
|
|
2683
2823
|
};
|
|
2684
2824
|
if (o === 23) return {
|
|
2685
|
-
value: new
|
|
2825
|
+
value: new R(23),
|
|
2686
2826
|
nextOffset: t
|
|
2687
2827
|
};
|
|
2688
2828
|
if (o === 24) {
|
|
2689
2829
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
2690
2830
|
let r = e.getUint8(t);
|
|
2691
2831
|
if (r < 32) {
|
|
2692
|
-
let e =
|
|
2693
|
-
return
|
|
2832
|
+
let e = Gn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new R(r);
|
|
2833
|
+
return J(i, e), {
|
|
2694
2834
|
value: i,
|
|
2695
2835
|
nextOffset: t + 1
|
|
2696
2836
|
};
|
|
2697
2837
|
}
|
|
2698
2838
|
return {
|
|
2699
|
-
value: new
|
|
2839
|
+
value: new R(r),
|
|
2700
2840
|
nextOffset: t + 1
|
|
2701
2841
|
};
|
|
2702
2842
|
}
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2843
|
+
if (o === 25) {
|
|
2844
|
+
t + 2 > e.byteLength && q("unexpected end of input");
|
|
2845
|
+
let n = C(e.getUint16(t, !1));
|
|
2846
|
+
return {
|
|
2847
|
+
value: new j(n, {
|
|
2848
|
+
precision: "half",
|
|
2849
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 2) : void 0
|
|
2850
|
+
}),
|
|
2851
|
+
nextOffset: t + 2
|
|
2852
|
+
};
|
|
2853
|
+
}
|
|
2854
|
+
if (o === 26) {
|
|
2855
|
+
t + 4 > e.byteLength && q("unexpected end of input");
|
|
2856
|
+
let n = e.getFloat32(t, !1);
|
|
2857
|
+
return {
|
|
2858
|
+
value: new j(n, {
|
|
2859
|
+
precision: "single",
|
|
2860
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 4) : void 0
|
|
2861
|
+
}),
|
|
2862
|
+
nextOffset: t + 4
|
|
2863
|
+
};
|
|
2864
|
+
}
|
|
2865
|
+
if (o === 27) {
|
|
2866
|
+
t + 8 > e.byteLength && q("unexpected end of input");
|
|
2867
|
+
let n = e.getFloat64(t, !1);
|
|
2868
|
+
return {
|
|
2869
|
+
value: new j(n, {
|
|
2870
|
+
precision: "double",
|
|
2871
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 8) : void 0
|
|
2872
|
+
}),
|
|
2873
|
+
nextOffset: t + 8
|
|
2874
|
+
};
|
|
2875
|
+
}
|
|
2876
|
+
return o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item");
|
|
2713
2877
|
}
|
|
2714
2878
|
return q(`unknown major type: ${a}`);
|
|
2715
2879
|
}
|
|
2716
|
-
function
|
|
2880
|
+
function rr(e) {
|
|
2717
2881
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2718
2882
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2719
2883
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2720
2884
|
}
|
|
2721
|
-
function
|
|
2722
|
-
let n =
|
|
2885
|
+
function ir(e, t) {
|
|
2886
|
+
let n = rr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2723
2887
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
2724
|
-
let a = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...
|
|
2888
|
+
let a = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...Yn()] : Yn(), { value: o, nextOffset: s } = X(r, i, t, a);
|
|
2725
2889
|
if (!t?.allowTrailing && s !== r.byteLength) {
|
|
2726
|
-
|
|
2890
|
+
J(o, Gn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
|
|
2727
2891
|
let e = {
|
|
2728
2892
|
strict: !1,
|
|
2729
2893
|
silent: !0
|
|
@@ -2734,15 +2898,15 @@ function Xn(e, t) {
|
|
|
2734
2898
|
}
|
|
2735
2899
|
//#endregion
|
|
2736
2900
|
//#region src/extensions/cbordata.ts
|
|
2737
|
-
var
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2901
|
+
var ar = 24n, Z = [
|
|
2902
|
+
Kt,
|
|
2903
|
+
dn,
|
|
2904
|
+
mn,
|
|
2905
|
+
Bn,
|
|
2742
2906
|
{
|
|
2743
|
-
tagNumbers: [
|
|
2907
|
+
tagNumbers: [ar],
|
|
2744
2908
|
parseTag(e, t, n) {
|
|
2745
|
-
if (e !== 24n || !(t instanceof
|
|
2909
|
+
if (e !== 24n || !(t instanceof N)) return;
|
|
2746
2910
|
let r = n ? {
|
|
2747
2911
|
extensions: n.extensions,
|
|
2748
2912
|
strict: n.strict,
|
|
@@ -2750,65 +2914,76 @@ var Zn = 24n, Z = [
|
|
|
2750
2914
|
silent: n.silent
|
|
2751
2915
|
} : void 0;
|
|
2752
2916
|
try {
|
|
2753
|
-
return new
|
|
2917
|
+
return new M(ar, new Ue([ir(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2754
2918
|
} catch (e) {
|
|
2755
2919
|
if (r?.strict !== !1) throw e;
|
|
2756
2920
|
return;
|
|
2757
2921
|
}
|
|
2758
2922
|
}
|
|
2759
2923
|
}
|
|
2760
|
-
];
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2924
|
+
], or;
|
|
2925
|
+
function sr() {
|
|
2926
|
+
return or ??= {
|
|
2927
|
+
fromJS: Z.filter((e) => e.fromJS !== void 0),
|
|
2928
|
+
parseTag: Z.filter((e) => e.parseTag !== void 0)
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
function cr(e) {
|
|
2932
|
+
let t = e?.extensions, n = sr();
|
|
2933
|
+
return t?.length ? {
|
|
2934
|
+
fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
|
|
2935
|
+
parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
|
|
2936
|
+
} : n;
|
|
2937
|
+
}
|
|
2938
|
+
function lr(e, t) {
|
|
2764
2939
|
if (t?.replacer) {
|
|
2765
|
-
let { replacer: n, ...r } = t, i =
|
|
2766
|
-
return i ===
|
|
2940
|
+
let { replacer: n, ...r } = t, i = dr(e, n, r.extensions, r.undefinedOmits);
|
|
2941
|
+
return i === h ? R.UNDEFINED : lr(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2767
2942
|
}
|
|
2768
|
-
return
|
|
2943
|
+
return Q(e, t, !0, cr(t));
|
|
2769
2944
|
}
|
|
2770
|
-
function
|
|
2771
|
-
for (let n of
|
|
2945
|
+
function Q(e, t, n, r) {
|
|
2946
|
+
for (let n of r.fromJS) {
|
|
2772
2947
|
let r = n.fromJS(e, t ?? {});
|
|
2773
2948
|
if (r !== void 0) return r;
|
|
2774
2949
|
}
|
|
2775
|
-
if (n && typeof e == "object" && e &&
|
|
2776
|
-
let n = e[
|
|
2777
|
-
for (let e of
|
|
2778
|
-
let t = e.parseTag(n,
|
|
2950
|
+
if (n && typeof e == "object" && e && m.symbol in e) {
|
|
2951
|
+
let n = e[m.symbol], i = Q(e, t, !1, r);
|
|
2952
|
+
for (let e of r.parseTag) {
|
|
2953
|
+
let t = e.parseTag(n, i);
|
|
2779
2954
|
if (t !== void 0) return t;
|
|
2780
2955
|
}
|
|
2781
|
-
return new
|
|
2782
|
-
}
|
|
2783
|
-
if (e instanceof
|
|
2784
|
-
if (e instanceof
|
|
2785
|
-
if (e instanceof
|
|
2786
|
-
if (e === null) return
|
|
2787
|
-
if (e === void 0) return
|
|
2788
|
-
if (e === !0) return
|
|
2789
|
-
if (e === !1) return
|
|
2790
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
2791
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
2792
|
-
if (typeof e == "string") return new
|
|
2793
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return
|
|
2794
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
2795
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
2796
|
-
if (e instanceof $) return new
|
|
2797
|
-
if (Array.isArray(e)) return new
|
|
2956
|
+
return new M(n, i);
|
|
2957
|
+
}
|
|
2958
|
+
if (e instanceof m.Null) return R.NULL;
|
|
2959
|
+
if (e instanceof m.Undefined) return R.UNDEFINED;
|
|
2960
|
+
if (e instanceof g) return new R(e.value);
|
|
2961
|
+
if (e === null) return R.NULL;
|
|
2962
|
+
if (e === void 0) return R.UNDEFINED;
|
|
2963
|
+
if (e === !0) return R.TRUE;
|
|
2964
|
+
if (e === !1) return R.FALSE;
|
|
2965
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new et(e) : e < -18446744073709551616n ? new tt(e) : e >= 0n ? new k(e) : new A(e);
|
|
2966
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new k(BigInt(e)) : new A(BigInt(e)) : new j(e);
|
|
2967
|
+
if (typeof e == "string") return new B(e);
|
|
2968
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Q(e.valueOf(), t, !1, r);
|
|
2969
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new N(new Uint8Array(e));
|
|
2970
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new I(Array.from(e, (e) => new k(BigInt(e)))) : new N(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
2971
|
+
if (e instanceof $) return new L([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
|
|
2972
|
+
if (Array.isArray(e)) return new I(e.map((e) => Q(e, t, !0, r)));
|
|
2798
2973
|
if (typeof e == "object") {
|
|
2799
2974
|
let n = [];
|
|
2800
|
-
for (let [
|
|
2801
|
-
return new
|
|
2975
|
+
for (let [i, a] of Object.entries(e)) n.push([new B(i), Q(a, t, !0, r)]);
|
|
2976
|
+
return new L(n);
|
|
2802
2977
|
}
|
|
2803
2978
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2804
2979
|
}
|
|
2805
|
-
function
|
|
2806
|
-
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
|
|
2980
|
+
function ur(e) {
|
|
2981
|
+
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;
|
|
2807
2982
|
}
|
|
2808
|
-
function
|
|
2809
|
-
let i = [...n ?? [], ...Z];
|
|
2983
|
+
function dr(e, t, n, r) {
|
|
2984
|
+
let i = [...n ?? [], ...Z].filter((e) => e.isJSType !== void 0);
|
|
2810
2985
|
function a(e) {
|
|
2811
|
-
return e ===
|
|
2986
|
+
return e === h || r === !0 && e === void 0;
|
|
2812
2987
|
}
|
|
2813
2988
|
if (Array.isArray(t)) {
|
|
2814
2989
|
let n = t.map(String);
|
|
@@ -2816,7 +2991,7 @@ function er(e, t, n, r) {
|
|
|
2816
2991
|
if (typeof e != "object" || !e) return e;
|
|
2817
2992
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
2818
2993
|
if (Array.isArray(e)) return e.map(r);
|
|
2819
|
-
if (
|
|
2994
|
+
if (m.symbol in e || ur(e) || i.some((t) => t.isJSType(e))) return e;
|
|
2820
2995
|
let t = Object.getPrototypeOf(e);
|
|
2821
2996
|
if (t === Object.prototype || t === null) {
|
|
2822
2997
|
let t = e.toJSON;
|
|
@@ -2838,7 +3013,7 @@ function er(e, t, n, r) {
|
|
|
2838
3013
|
}
|
|
2839
3014
|
}
|
|
2840
3015
|
if (e = o.call(n, t, e), typeof e == "object" && e) {
|
|
2841
|
-
if (
|
|
3016
|
+
if (m.symbol in e) return e;
|
|
2842
3017
|
if (e instanceof $) {
|
|
2843
3018
|
let t = new $();
|
|
2844
3019
|
for (let [n, r] of e) {
|
|
@@ -2851,7 +3026,7 @@ function er(e, t, n, r) {
|
|
|
2851
3026
|
let r = s(t, String(n), e);
|
|
2852
3027
|
return a(r) ? null : r;
|
|
2853
3028
|
});
|
|
2854
|
-
if (
|
|
3029
|
+
if (ur(e) || i.some((t) => t.isJSType(e))) return e;
|
|
2855
3030
|
let t = {};
|
|
2856
3031
|
for (let n of Object.keys(e)) {
|
|
2857
3032
|
let r = s(e[n], n, e);
|
|
@@ -2869,7 +3044,7 @@ var $ = class extends Array {
|
|
|
2869
3044
|
toJSON() {
|
|
2870
3045
|
let e = {};
|
|
2871
3046
|
for (let [t, n] of this) {
|
|
2872
|
-
let r = typeof t == "string" ? t :
|
|
3047
|
+
let r = typeof t == "string" ? t : lr(t).toCDN();
|
|
2873
3048
|
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
2874
3049
|
value: n,
|
|
2875
3050
|
writable: !0,
|
|
@@ -2881,6 +3056,6 @@ var $ = class extends Array {
|
|
|
2881
3056
|
}
|
|
2882
3057
|
};
|
|
2883
3058
|
//#endregion
|
|
2884
|
-
export {
|
|
3059
|
+
export { S as C, s as D, o as E, m as O, C as S, h as T, M as _, qt as a, k as b, tt as c, R as d, L as f, N as g, P as h, ir as i, c as k, et as l, F as m, dr as n, B as o, I as p, lr as r, at as s, $ as t, Ue as u, j as v, g as w, O as x, A as y };
|
|
2885
3060
|
|
|
2886
|
-
//# sourceMappingURL=mapEntries-
|
|
3061
|
+
//# sourceMappingURL=mapEntries-CYvdsAfP.js.map
|