@cbortech/cbor 0.25.9 → 0.25.10
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 +28 -4
- package/README.md +28 -4
- 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.d.ts +1 -1
- package/dist/index.js +83 -75
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-B-INYL6l.cjs +11 -0
- package/dist/mapEntries-B-INYL6l.cjs.map +1 -0
- package/dist/{mapEntries-I8f0WuwK.js → mapEntries-B8riGPMD.js} +1027 -867
- package/dist/mapEntries-B8riGPMD.js.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 +56 -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,45 +93,26 @@ 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 _(e) {
|
|
122
100
|
let t = e?.indent;
|
|
123
101
|
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
124
102
|
}
|
|
125
|
-
function
|
|
103
|
+
function v(e, t) {
|
|
126
104
|
return e.repeat(t);
|
|
127
105
|
}
|
|
128
|
-
function
|
|
106
|
+
function ee(e, t, n) {
|
|
107
|
+
return t === null ? e.join(" + ") : e.join(` +\n${v(t, n + 1)}`);
|
|
108
|
+
}
|
|
109
|
+
function te(e) {
|
|
129
110
|
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
130
111
|
}
|
|
131
|
-
function
|
|
112
|
+
function ne(e) {
|
|
132
113
|
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
133
114
|
}
|
|
134
|
-
function
|
|
115
|
+
function y(e, t) {
|
|
135
116
|
if (!t) return e.text;
|
|
136
117
|
let { marker: n, text: r } = e;
|
|
137
118
|
if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
|
|
@@ -142,17 +123,17 @@ function v(e, t) {
|
|
|
142
123
|
}
|
|
143
124
|
return r;
|
|
144
125
|
}
|
|
145
|
-
function
|
|
146
|
-
return (e.comments?.leading ?? []).map((e) => t +
|
|
126
|
+
function re(e, t, n) {
|
|
127
|
+
return (e.comments?.leading ?? []).map((e) => t + y(e, n));
|
|
147
128
|
}
|
|
148
|
-
function
|
|
129
|
+
function b(e, t) {
|
|
149
130
|
let n = e.comments?.trailing ?? [];
|
|
150
|
-
return n.length === 0 ? "" : " " + n.map((e) =>
|
|
131
|
+
return n.length === 0 ? "" : " " + n.map((e) => y(e, t)).join(" ");
|
|
151
132
|
}
|
|
152
|
-
function
|
|
153
|
-
return (e.comments?.dangling ?? []).map((e) => t +
|
|
133
|
+
function ie(e, t, n) {
|
|
134
|
+
return (e.comments?.dangling ?? []).map((e) => t + y(e, n));
|
|
154
135
|
}
|
|
155
|
-
function
|
|
136
|
+
function ae(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 oe(e) {
|
|
146
|
+
let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = _(t), s = t?.preserveComments, c = typeof s == "string" ? s : void 0, l = s && (ne(e.node) || e.hasEntryComments());
|
|
147
|
+
o === null && l && (o = " ");
|
|
148
|
+
let { inlineSep: u, multilineSep: d, trailSep: f, colSep: p } = ae(t, o === null), m = e.indefiniteLength ? "" : S(t, e.encodingWidth, () => x(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 ee = v(o, n + 1), te = v(o, n), y = e.indefiniteLength ? g ? `${r}_ ` : r : `${r}${h}`, b = [];
|
|
155
|
+
for (let t = 0; t < a; t++) {
|
|
156
|
+
s && b.push(...re(e.entryLeadingNode(t), ee, c));
|
|
157
|
+
let n = t < a - 1 ? d : f;
|
|
158
|
+
b.push(`${ee}${e.renderEntry(t, p)}${n}${s ? e.entryTrailing(t, c) : ""}`);
|
|
159
|
+
}
|
|
160
|
+
return s && b.push(...ie(e.node, ee, c)), `${y}\n${b.join("\n")}\n${te}${i}`;
|
|
161
|
+
}
|
|
162
|
+
var se = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
|
|
163
|
+
function ce(e) {
|
|
164
|
+
if (se) 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 le(e) {
|
|
170
|
+
if (se) 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 ue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", de = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
179
|
+
function fe(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 pe(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 me(e, t, n) {
|
|
194
192
|
if (n === "string") {
|
|
195
|
-
let t =
|
|
196
|
-
if (t != null) return
|
|
193
|
+
let t = ge(e);
|
|
194
|
+
if (t != null) return ye(t);
|
|
197
195
|
}
|
|
198
196
|
if (n === "printable-string" || n === void 0) {
|
|
199
|
-
let t =
|
|
200
|
-
if (t != null && !
|
|
197
|
+
let t = ge(e);
|
|
198
|
+
if (t != null && !pe(t)) return ye(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'${ce(e)}'`;
|
|
202
|
+
case "base64url": return `b64'${le(e)}'`;
|
|
203
|
+
case "base32": return `b32'${fe(e, ue)}'`;
|
|
204
|
+
case "base32hex": return `h32'${fe(e, de)}'`;
|
|
205
|
+
default: return `h'${i(e)}'`;
|
|
208
206
|
}
|
|
209
207
|
}
|
|
210
|
-
var
|
|
211
|
-
function
|
|
208
|
+
var he = new TextDecoder("utf-8", { fatal: !0 });
|
|
209
|
+
function ge(e) {
|
|
212
210
|
try {
|
|
213
|
-
return
|
|
211
|
+
return he.decode(e);
|
|
214
212
|
} catch {
|
|
215
213
|
return null;
|
|
216
214
|
}
|
|
217
215
|
}
|
|
218
|
-
function
|
|
216
|
+
function _e(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 ve(e, t) {
|
|
226
224
|
let n = t.codePointAt(0);
|
|
227
|
-
if (!
|
|
225
|
+
if (!_e(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 ye(e) {
|
|
251
|
+
return ve(e, "'");
|
|
254
252
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
253
|
+
function be(e) {
|
|
254
|
+
return ve(e, "'");
|
|
257
255
|
}
|
|
258
|
-
function
|
|
259
|
-
return
|
|
256
|
+
function xe(e) {
|
|
257
|
+
return ve(e, "\"");
|
|
260
258
|
}
|
|
261
|
-
function
|
|
259
|
+
function Se(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 Ce(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 x(e) {
|
|
274
272
|
return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
|
|
275
273
|
}
|
|
276
|
-
function
|
|
274
|
+
function S(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 we = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Te = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
281
|
+
function C(e) {
|
|
282
|
+
Te.setFloat64(0, e, !1);
|
|
283
|
+
let t = Te.getUint32(0, !1), n = Te.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 w(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 Ee = we ? (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, C(n), r);
|
|
312
|
+
}, T = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), E = new Uint8Array(T.buffer), De = new TextEncoder(), Oe = typeof De.encodeInto == "function";
|
|
313
|
+
function ke(e) {
|
|
314
|
+
return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
|
|
315
|
+
}
|
|
316
|
+
function Ae(e) {
|
|
317
|
+
return e === "i" ? 1 : [
|
|
318
|
+
2,
|
|
319
|
+
3,
|
|
320
|
+
5,
|
|
321
|
+
9
|
|
322
|
+
][e];
|
|
323
|
+
}
|
|
324
|
+
var je = 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
|
+
T.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(E, this.len), this.len += 8;
|
|
346
356
|
}
|
|
347
357
|
writeFloat16(e) {
|
|
348
|
-
|
|
358
|
+
Ee(T, 0, e, !1), this._ensure(2);
|
|
349
359
|
let t = this.buf;
|
|
350
|
-
t[this.len++] =
|
|
360
|
+
t[this.len++] = E[0], t[this.len++] = E[1];
|
|
351
361
|
}
|
|
352
362
|
writeFloat32(e) {
|
|
353
|
-
|
|
363
|
+
T.setFloat32(0, e, !1), this._ensure(4);
|
|
354
364
|
let t = this.buf;
|
|
355
|
-
t[this.len++] =
|
|
365
|
+
t[this.len++] = E[0], t[this.len++] = E[1], t[this.len++] = E[2], t[this.len++] = E[3];
|
|
356
366
|
}
|
|
357
367
|
writeFloat64(e) {
|
|
358
|
-
|
|
368
|
+
T.setFloat64(0, e, !1), this._ensure(8), this.buf.set(E, this.len), this.len += 8;
|
|
369
|
+
}
|
|
370
|
+
writeTextString(e, t, n) {
|
|
371
|
+
if (!Oe) {
|
|
372
|
+
let r = De.encode(t);
|
|
373
|
+
D(this, e, r.length, n), this.writeBytes(r);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
let r = n === void 0 ? ke(t.length) : Ae(n);
|
|
377
|
+
this._ensure(9 + 3 * t.length);
|
|
378
|
+
let { written: i } = De.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? ke(i) : r;
|
|
379
|
+
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), D(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
|
+
}, Me = [
|
|
364
385
|
255n,
|
|
365
386
|
65535n,
|
|
366
387
|
4294967295n,
|
|
367
388
|
18446744073709551615n
|
|
368
389
|
];
|
|
369
|
-
function
|
|
370
|
-
return e === "i" ? 23n :
|
|
390
|
+
function Ne(e) {
|
|
391
|
+
return e === "i" ? 23n : Me[e];
|
|
371
392
|
}
|
|
372
|
-
function
|
|
393
|
+
function D(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 > Me[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Me[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
|
|
394
|
-
}
|
|
395
|
-
var Pe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
396
|
-
function Fe(e) {
|
|
397
|
-
return Object.is(S(x(e)), e);
|
|
412
|
+
function Pe(e, t, n) {
|
|
413
|
+
let r = new je(9);
|
|
414
|
+
return D(r, e, t, n), r.finish();
|
|
398
415
|
}
|
|
416
|
+
var Fe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
399
417
|
function Ie(e) {
|
|
400
|
-
return
|
|
418
|
+
return Object.is(w(C(e)), e);
|
|
419
|
+
}
|
|
420
|
+
function Le(e) {
|
|
421
|
+
return Fe.setFloat32(0, e, !1), Object.is(Fe.getFloat32(0, !1), e);
|
|
401
422
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
423
|
+
function O(e) {
|
|
424
|
+
return Ie(e) ? "half" : Le(e) ? "single" : "double";
|
|
404
425
|
}
|
|
405
426
|
//#endregion
|
|
406
427
|
//#region src/ast/CborItem.ts
|
|
407
|
-
var
|
|
428
|
+
var k = 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 je();
|
|
418
439
|
return this._encode(n, t), n.finish();
|
|
419
440
|
}
|
|
420
441
|
toCDN(e) {
|
|
@@ -423,7 +444,7 @@ var D = class e {
|
|
|
423
444
|
...e
|
|
424
445
|
} : e, n = this._toCDN(t, 0), r = t?.preserveComments;
|
|
425
446
|
if (!r) return n;
|
|
426
|
-
let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) =>
|
|
447
|
+
let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) => y(e, i)) ?? [], o = this.comments?.trailing ?? [], s = o.length === 0 ? n : `${n} ${o.map((e) => y(e, i).trimEnd()).join(" ")}`;
|
|
427
448
|
return [...a, s].join("\n");
|
|
428
449
|
}
|
|
429
450
|
toEDN(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 je();
|
|
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
|
+
}, A = class extends k {
|
|
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
|
+
D(e, 0, this.value, this.encodingWidth);
|
|
480
506
|
}
|
|
481
507
|
_toCDN(e, t) {
|
|
482
|
-
let n =
|
|
508
|
+
let n = S(e, this.encodingWidth, () => x(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
|
+
}, j = class extends k {
|
|
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
|
+
D(e, 1, this.argument, this.encodingWidth);
|
|
509
535
|
}
|
|
510
536
|
_toCDN(e, t) {
|
|
511
|
-
let n =
|
|
537
|
+
let n = S(e, this.encodingWidth, () => x(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
|
+
}, Re = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
550
|
+
function ze(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 Be(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
|
+
Re.setFloat64(0, n, !1);
|
|
574
|
+
let r = Re.getUint32(0, !1), i = Re.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 M = class extends k {
|
|
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 ?? O(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 ?? O(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 = O(this.value);
|
|
605
|
+
return (e?.floatFormat === "hex" ? Be(this.value) : Se(this.value)) + Ce(this.value, this.precision, r, n);
|
|
579
606
|
}
|
|
580
607
|
_toJS(e) {
|
|
581
608
|
return this.value;
|
|
582
609
|
}
|
|
583
|
-
},
|
|
610
|
+
}, N = class extends k {
|
|
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
|
+
D(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
593
620
|
}
|
|
594
621
|
_toCDN(e, t) {
|
|
595
|
-
let n =
|
|
622
|
+
let n = S(e, this.encodingWidth, () => x(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(Pe(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
|
+
}, P = class extends k {
|
|
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
|
+
D(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 = S(e, this.encodingWidth, () => x(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 : me(t.bytes, r, e?.sqstr));
|
|
658
|
+
return i[i.length - 1] += n, ee(i, _(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 = S(e, this.encodingWidth, () => x(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 = S(e, this.encodingWidth, () => x(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
|
|
666
|
+
return e?.appStrings === !1 && r !== "hex" && (r = "hex"), me(this.value, r, e?.sqstr) + n;
|
|
633
667
|
}
|
|
634
668
|
_toJS(e) {
|
|
635
669
|
return this.value;
|
|
636
670
|
}
|
|
637
|
-
},
|
|
671
|
+
}, F = class extends k {
|
|
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 P(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
|
+
}, I = class extends k {
|
|
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 V(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
|
+
}, L = class extends k {
|
|
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
|
+
D(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 oe({
|
|
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(te),
|
|
766
|
+
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
767
|
+
entryLeadingNode: (e) => this.items[e],
|
|
768
|
+
entryTrailing: (e, t) => b(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(Pe(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
|
+
}, R = class extends k {
|
|
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
|
+
D(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 oe({
|
|
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]) => te(e) || te(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 Ve([
|
|
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(Pe(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 V) ? (() => {
|
|
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 V ? 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 V ? 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 V ? 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
|
|
882
|
-
return e.length === 0 ? "" : " " + e.map((e) =>
|
|
917
|
+
function Ve(e, t) {
|
|
918
|
+
return e.length === 0 ? "" : " " + e.map((e) => y(e, t).trimEnd()).join(" ");
|
|
883
919
|
}
|
|
884
920
|
//#endregion
|
|
885
921
|
//#region src/ast/CborSimple.ts
|
|
886
|
-
var
|
|
922
|
+
var z = class e extends k {
|
|
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
|
+
}, He = class extends k {
|
|
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 je();
|
|
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
|
+
D(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
935
971
|
}
|
|
936
972
|
_toCDN(e, t) {
|
|
937
|
-
let n =
|
|
973
|
+
let n = S(e, this.encodingWidth, () => x(BigInt(this._content(e).length)));
|
|
938
974
|
if (this.items.length === 0) return `<<>>${n}`;
|
|
939
|
-
let r =
|
|
975
|
+
let r = _(e), { inlineSep: i, multilineSep: a, trailSep: o } = ae(e, r === null);
|
|
940
976
|
if (r === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(i)}>>${n}`;
|
|
941
|
-
let s =
|
|
977
|
+
let s = v(r, t + 1), c = v(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(Pe(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
|
+
}, Ue = 999n, We = class extends N {
|
|
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 V ? t[0] : new L(t);
|
|
995
|
+
super(Ue, new L([new V(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 V ? `${r}${be(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
965
1001
|
}
|
|
966
|
-
},
|
|
1002
|
+
}, Ge = class extends k {
|
|
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
|
+
}, Ke = 888n, B = class extends N {
|
|
983
1019
|
constructor(e) {
|
|
984
|
-
e === void 0 ? super(
|
|
1020
|
+
e === void 0 ? super(Ke, z.NULL) : super(Ke, new L(e));
|
|
985
1021
|
}
|
|
986
1022
|
_toCDN(e, t) {
|
|
987
|
-
return this.content instanceof
|
|
1023
|
+
return this.content instanceof z ? "..." : this.content instanceof L ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
988
1024
|
}
|
|
989
|
-
},
|
|
990
|
-
function
|
|
1025
|
+
}, qe = 2n, Je = 3n, Ye = 18446744073709551615n, Xe = -18446744073709551616n;
|
|
1026
|
+
function Ze(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 Qe(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 $e = class extends N {
|
|
1005
1041
|
bigValue;
|
|
1006
1042
|
constructor(e) {
|
|
1007
|
-
if (e <=
|
|
1008
|
-
super(
|
|
1043
|
+
if (e <= Ye) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1044
|
+
super(qe, new P(Ze(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
|
+
}, et = class extends N {
|
|
1017
1053
|
bigValue;
|
|
1018
1054
|
constructor(e) {
|
|
1019
|
-
if (e >=
|
|
1020
|
-
super(
|
|
1055
|
+
if (e >= Xe) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1056
|
+
super(Je, new P(Ze(-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
|
+
}, tt = new TextEncoder(), nt = new TextDecoder("utf-8", { fatal: !0 }), rt = new TextDecoder("utf-8", { fatal: !1 });
|
|
1065
|
+
function it(e, t) {
|
|
1066
|
+
let n = new a(e, {
|
|
1067
|
+
offset: t?.offset,
|
|
1068
|
+
skipRS: t?._skipRS
|
|
1069
|
+
}), r = new gt(n, t ?? {}).parse();
|
|
1070
|
+
return t?.preserveComments && lt(r, n.comments, e), r;
|
|
1035
1071
|
}
|
|
1036
|
-
function
|
|
1072
|
+
function at(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 ot(e) {
|
|
1044
1080
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1045
1081
|
}
|
|
1046
|
-
function
|
|
1082
|
+
function st(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: ze(n),
|
|
1071
1107
|
precision: r
|
|
1072
1108
|
} : {
|
|
1073
1109
|
value: parseFloat(n),
|
|
1074
1110
|
precision: r
|
|
1075
1111
|
};
|
|
1076
1112
|
}
|
|
1077
|
-
function
|
|
1113
|
+
function ct(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 lt(e, t, n) {
|
|
1115
1151
|
if (t.length === 0) return;
|
|
1116
|
-
let r =
|
|
1117
|
-
for (let
|
|
1118
|
-
let
|
|
1119
|
-
|
|
1120
|
-
|
|
1152
|
+
let r = ut(e), i = ft(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
|
+
dt(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
|
+
dt(m.node, "leading", r);
|
|
1126
1178
|
continue;
|
|
1127
1179
|
}
|
|
1128
|
-
|
|
1180
|
+
dt(p?.node ?? e, "dangling", r);
|
|
1129
1181
|
}
|
|
1130
1182
|
}
|
|
1131
|
-
function
|
|
1183
|
+
function ut(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 L || e instanceof He) {
|
|
1138
1190
|
for (let t of e.items) n(t);
|
|
1139
1191
|
return;
|
|
1140
1192
|
}
|
|
1141
|
-
if (e instanceof
|
|
1193
|
+
if (e instanceof R) {
|
|
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 F || e instanceof I) {
|
|
1146
1198
|
for (let t of e.chunks) n(t);
|
|
1147
1199
|
return;
|
|
1148
1200
|
}
|
|
1149
|
-
e instanceof
|
|
1201
|
+
e instanceof N && n(e.content);
|
|
1150
1202
|
};
|
|
1151
1203
|
return n(e), t;
|
|
1152
1204
|
}
|
|
1153
|
-
function
|
|
1205
|
+
function dt(e, t, n) {
|
|
1154
1206
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1155
1207
|
}
|
|
1156
|
-
function
|
|
1208
|
+
function ft(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 pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, mt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, ht = /* @__PURE__ */ new Map([
|
|
1223
|
+
["b32", pt("b32")],
|
|
1224
|
+
["h32", pt("h32")],
|
|
1225
|
+
["float", pt("float")],
|
|
1226
|
+
["same", pt("same")],
|
|
1227
|
+
["hash", mt("hash", "@cbortech/hash-extension")],
|
|
1228
|
+
["uuid", mt("uuid", "@cbortech/uuid-extension")],
|
|
1229
|
+
["UUID", mt("uuid", "@cbortech/uuid-extension")]
|
|
1230
|
+
]), gt = 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 F([]);
|
|
1291
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new I([]);
|
|
1292
|
+
case "TRUE": return this.t.consume(), new z(21);
|
|
1293
|
+
case "FALSE": return this.t.consume(), new z(20);
|
|
1294
|
+
case "NULL": return this.t.consume(), new z(22);
|
|
1295
|
+
case "UNDEFINED": return this.t.consume(), new z(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 We(e.appPrefix, [new V(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 P && Object.getPrototypeOf(i) === P.prototype && i.ednSource === void 0 ? new P(i.value, {
|
|
1264
1318
|
ednEncoding: i.ednEncoding,
|
|
1265
1319
|
encodingWidth: i.encodingWidth,
|
|
1266
1320
|
ednSource: e.raw + n
|
|
1267
|
-
}) : (i instanceof
|
|
1321
|
+
}) : (i instanceof M && 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 We(e.appPrefix, [new V(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 We(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 M) a.ednSource === void 0 && (a.ednSource = o);
|
|
1353
|
+
else if (i.preserveAppSeqSource) return new Ge(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 We(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 B();
|
|
1363
|
+
let e = [new B()];
|
|
1310
1364
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1311
|
-
return new
|
|
1365
|
+
return new B(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 } = at(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = ot(t);
|
|
1373
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new $e(i);
|
|
1374
|
+
if (i < -18446744073709551616n) return new et(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 A(i, r === void 0 ? void 0 : { encodingWidth: r }) : new j(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1326
1380
|
if (this.t.peek().type === "LPAREN") {
|
|
1327
|
-
a instanceof
|
|
1381
|
+
a instanceof A || 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 N && 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 N(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 } = st(e.value, t);
|
|
1342
1396
|
if (r === "half" || r === "single") {
|
|
1343
|
-
let e = r === "half" ?
|
|
1397
|
+
let e = r === "half" ? w(C(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 M(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(tt.encode(e.value).length));
|
|
1406
|
+
return new V(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(tt.encode(t).length));
|
|
1416
|
+
return new V(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 V(i)), i = ""), r.push(new B())) : i += e.text;
|
|
1423
|
+
return i !== "" && r.push(new V(i)), new B(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 ct(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 rt.decode(e);
|
|
1387
1455
|
try {
|
|
1388
|
-
return
|
|
1456
|
+
return nt.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), rt.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 P(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 B ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof P && 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: tt.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 P(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 P(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 B())) : o.push(e.bytes);
|
|
1502
|
+
return s(), new B(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 B());
|
|
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 P ? t[t.length - 1] = new P(this._concatBytes([r.value, n])) : t.push(new P(n));
|
|
1440
1518
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1441
1519
|
}
|
|
1442
|
-
return new
|
|
1520
|
+
return new B(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 B()), n[e].length > 0 && r.push(new P(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 P && r instanceof P ? (e[e.length - 1] = new P(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 } = at(e.value), n = Number(ot(t));
|
|
1542
|
+
return this.expect("RPAREN"), new z(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 He(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 L(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 R(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 P) {
|
|
1619
|
+
let e = new F(n.map((e, t) => {
|
|
1620
|
+
if (e instanceof P) 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 V) {
|
|
1626
|
+
let e = new I(n.map((e, t) => {
|
|
1627
|
+
if (e instanceof V) 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 M) {
|
|
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" ?
|
|
1650
|
+
let t = r === "half" ? w(C(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 A) {
|
|
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 j) {
|
|
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 P) {
|
|
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 V) {
|
|
1593
1671
|
if (e.encodingWidth === void 0) {
|
|
1594
|
-
let r = this._validateEncodingFit(BigInt(
|
|
1672
|
+
let r = this._validateEncodingFit(BigInt(tt.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 L) {
|
|
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 R) {
|
|
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 N) {
|
|
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 = Ne(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,94 @@ 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 = ht.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
|
+
..._t(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, _t(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 ? _t(t) : void 0);
|
|
1665
1736
|
}
|
|
1666
|
-
}
|
|
1737
|
+
};
|
|
1738
|
+
function _t(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 vt = new TextEncoder(), yt = !1, V = class extends k {
|
|
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
|
-
|
|
1760
|
+
let n = S(e, this.encodingWidth, () => x(BigInt(vt.encode(this.value).length)));
|
|
1761
|
+
if (e?.preserveConcatenation && this.ednParts !== void 0 && this.ednParts.length > 1) {
|
|
1762
|
+
let r = this.ednParts.map((e) => xe(e));
|
|
1763
|
+
return r[r.length - 1] += n, ee(r, _(e), t);
|
|
1764
|
+
}
|
|
1765
|
+
return bt(this.value, n, e, t);
|
|
1680
1766
|
}
|
|
1681
1767
|
_toJS(e) {
|
|
1682
1768
|
return this.value;
|
|
1683
1769
|
}
|
|
1684
1770
|
};
|
|
1685
|
-
function
|
|
1686
|
-
let i =
|
|
1687
|
-
if (i.length === 0 || a === null) return
|
|
1771
|
+
function bt(e, t, n, r) {
|
|
1772
|
+
let i = xt(n), a = _(n);
|
|
1773
|
+
if (i.length === 0 || a === null) return xe(e) + t;
|
|
1688
1774
|
let o = /* @__PURE__ */ new Map(), s = null;
|
|
1689
|
-
if (i.includes("cdn") && (s =
|
|
1775
|
+
if (i.includes("cdn") && (s = wt(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
|
|
1690
1776
|
if (i.includes("newline")) {
|
|
1691
|
-
let t = s === null ?
|
|
1777
|
+
let t = s === null ? Ct(e, 0) : Tt(e);
|
|
1692
1778
|
for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
|
|
1693
1779
|
}
|
|
1694
|
-
let c =
|
|
1695
|
-
if (c.length <= 1) return
|
|
1780
|
+
let c = Mt(e, o);
|
|
1781
|
+
if (c.length <= 1) return xe(e) + t;
|
|
1696
1782
|
let l = c.map(({ text: e }, n) => {
|
|
1697
|
-
let r =
|
|
1783
|
+
let r = xe(e);
|
|
1698
1784
|
return n === c.length - 1 ? r + t : r;
|
|
1699
1785
|
}), u = l[0];
|
|
1700
1786
|
for (let e = 1; e < l.length; e++) {
|
|
1701
|
-
let t =
|
|
1787
|
+
let t = v(a, r + 1 + c[e].contentDepth);
|
|
1702
1788
|
u += ` +\n${t}${l[e]}`;
|
|
1703
1789
|
}
|
|
1704
1790
|
return u;
|
|
1705
1791
|
}
|
|
1706
|
-
function
|
|
1707
|
-
|
|
1792
|
+
function xt(e) {
|
|
1793
|
+
switch (e?.textStringSplit) {
|
|
1794
|
+
case "none": return [];
|
|
1795
|
+
case "newline": return ["newline"];
|
|
1796
|
+
case "cdn": return ["cdn"];
|
|
1797
|
+
case "cdn+newline": return ["cdn", "newline"];
|
|
1798
|
+
case void 0: return St(e?.textStringFormat ?? []);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
function St(e) {
|
|
1802
|
+
return e.map((e) => e === "cboredn" ? (yt || (yt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1708
1803
|
}
|
|
1709
|
-
function
|
|
1804
|
+
function Ct(e, t) {
|
|
1710
1805
|
let n = [];
|
|
1711
1806
|
for (let r = 0; r < e.length; r++) {
|
|
1712
1807
|
let i = e[r];
|
|
@@ -1723,75 +1818,75 @@ function bt(e, t) {
|
|
|
1723
1818
|
}
|
|
1724
1819
|
return n;
|
|
1725
1820
|
}
|
|
1726
|
-
function
|
|
1821
|
+
function wt(e) {
|
|
1727
1822
|
try {
|
|
1728
|
-
|
|
1823
|
+
it(e);
|
|
1729
1824
|
} catch {
|
|
1730
1825
|
return null;
|
|
1731
1826
|
}
|
|
1732
|
-
let
|
|
1827
|
+
let t = [], n = new a(e), r = 0, i = null, o = !1, s = 0;
|
|
1733
1828
|
for (;;) {
|
|
1734
|
-
let
|
|
1735
|
-
if (
|
|
1829
|
+
let a = n.consume();
|
|
1830
|
+
if (a.type === "EOF") break;
|
|
1736
1831
|
let c = !1;
|
|
1737
|
-
if (o || (o = !0,
|
|
1738
|
-
point:
|
|
1739
|
-
contentDepth:
|
|
1740
|
-
})),
|
|
1741
|
-
if (
|
|
1742
|
-
|
|
1832
|
+
if (o || (o = !0, a.offset > 0 && At(n.comments, 0, a.offset) && t.push({
|
|
1833
|
+
point: a.offset,
|
|
1834
|
+
contentDepth: r
|
|
1835
|
+
})), i !== null) {
|
|
1836
|
+
if (i.kind === "opener" && Dt.has(a.type)) {
|
|
1837
|
+
i.point = a.endOffset, s = a.endOffset;
|
|
1743
1838
|
continue;
|
|
1744
|
-
} else
|
|
1745
|
-
point:
|
|
1746
|
-
contentDepth:
|
|
1839
|
+
} else i.kind === "opener" && kt.has(a.type) && jt(e, i.point, a.offset) ? c = !0 : t.push({
|
|
1840
|
+
point: a.offset,
|
|
1841
|
+
contentDepth: i.contentDepth
|
|
1747
1842
|
});
|
|
1748
|
-
|
|
1843
|
+
i = null;
|
|
1749
1844
|
}
|
|
1750
|
-
|
|
1751
|
-
point:
|
|
1752
|
-
contentDepth:
|
|
1845
|
+
Ot.has(a.type) ? (r++, i = {
|
|
1846
|
+
point: a.endOffset,
|
|
1847
|
+
contentDepth: r,
|
|
1753
1848
|
kind: "opener"
|
|
1754
|
-
}) :
|
|
1755
|
-
point:
|
|
1756
|
-
contentDepth:
|
|
1757
|
-
})) :
|
|
1758
|
-
point:
|
|
1759
|
-
contentDepth:
|
|
1849
|
+
}) : kt.has(a.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
1850
|
+
point: a.offset,
|
|
1851
|
+
contentDepth: r
|
|
1852
|
+
})) : a.type === "COMMA" && (i = {
|
|
1853
|
+
point: a.endOffset,
|
|
1854
|
+
contentDepth: r,
|
|
1760
1855
|
kind: "comma"
|
|
1761
|
-
}), s =
|
|
1856
|
+
}), s = a.endOffset;
|
|
1762
1857
|
}
|
|
1763
|
-
let c =
|
|
1764
|
-
return c !== void 0 &&
|
|
1858
|
+
let c = n.comments.find((e) => e.start >= s);
|
|
1859
|
+
return c !== void 0 && t.push({
|
|
1765
1860
|
point: c.start,
|
|
1766
|
-
contentDepth:
|
|
1767
|
-
}),
|
|
1861
|
+
contentDepth: r
|
|
1862
|
+
}), t;
|
|
1768
1863
|
}
|
|
1769
|
-
function
|
|
1770
|
-
let
|
|
1864
|
+
function Tt(e) {
|
|
1865
|
+
let t = [], n = new a(e), r = 0;
|
|
1771
1866
|
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:
|
|
1867
|
+
let i = n.consume();
|
|
1868
|
+
if (i.type === "EOF") break;
|
|
1869
|
+
if (Ot.has(i.type)) r++;
|
|
1870
|
+
else if (kt.has(i.type)) r = Math.max(0, r - 1);
|
|
1871
|
+
else if (i.type !== "COMMA") {
|
|
1872
|
+
if (i.type === "TSTR") {
|
|
1873
|
+
let n = e.slice(i.offset, i.endOffset);
|
|
1874
|
+
for (let e of Et(n)) t.push({
|
|
1875
|
+
point: i.offset + e,
|
|
1876
|
+
contentDepth: r + 1
|
|
1782
1877
|
});
|
|
1783
|
-
} else if (
|
|
1784
|
-
let
|
|
1785
|
-
for (let { point: e } of
|
|
1786
|
-
point:
|
|
1787
|
-
contentDepth:
|
|
1878
|
+
} else if (i.type === "RAWSTRING") {
|
|
1879
|
+
let n = e.slice(i.offset, i.endOffset);
|
|
1880
|
+
for (let { point: e } of Ct(n, 0)) t.push({
|
|
1881
|
+
point: i.offset + e,
|
|
1882
|
+
contentDepth: r + 1
|
|
1788
1883
|
});
|
|
1789
1884
|
}
|
|
1790
1885
|
}
|
|
1791
1886
|
}
|
|
1792
|
-
return
|
|
1887
|
+
return t;
|
|
1793
1888
|
}
|
|
1794
|
-
function
|
|
1889
|
+
function Et(e) {
|
|
1795
1890
|
let t = [], n = 1, r = e.length - 1;
|
|
1796
1891
|
for (; n < r;) {
|
|
1797
1892
|
let r = e[n];
|
|
@@ -1807,24 +1902,24 @@ function Ct(e) {
|
|
|
1807
1902
|
}
|
|
1808
1903
|
return t;
|
|
1809
1904
|
}
|
|
1810
|
-
var
|
|
1905
|
+
var Dt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Ot = /* @__PURE__ */ new Set([
|
|
1811
1906
|
"LBRACKET",
|
|
1812
1907
|
"LBRACE",
|
|
1813
1908
|
"LPAREN",
|
|
1814
1909
|
"LT_LT"
|
|
1815
|
-
]),
|
|
1910
|
+
]), kt = /* @__PURE__ */ new Set([
|
|
1816
1911
|
"RBRACKET",
|
|
1817
1912
|
"RBRACE",
|
|
1818
1913
|
"RPAREN",
|
|
1819
1914
|
"GT_GT"
|
|
1820
1915
|
]);
|
|
1821
|
-
function
|
|
1916
|
+
function At(e, t, n) {
|
|
1822
1917
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
1823
1918
|
}
|
|
1824
|
-
function
|
|
1919
|
+
function jt(e, t, n) {
|
|
1825
1920
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
1826
1921
|
}
|
|
1827
|
-
function
|
|
1922
|
+
function Mt(e, t) {
|
|
1828
1923
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
1829
1924
|
if (n.length === 0) return [{
|
|
1830
1925
|
text: e,
|
|
@@ -1842,7 +1937,7 @@ function kt(e, t) {
|
|
|
1842
1937
|
}
|
|
1843
1938
|
//#endregion
|
|
1844
1939
|
//#region src/extensions/dt.ts
|
|
1845
|
-
function
|
|
1940
|
+
function Nt(e) {
|
|
1846
1941
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
1847
1942
|
let t = Math.round(e * 1e3);
|
|
1848
1943
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -1850,17 +1945,17 @@ function B(e) {
|
|
|
1850
1945
|
for (; s.length < 3;) s += "0";
|
|
1851
1946
|
return `${i}.${s}Z`;
|
|
1852
1947
|
}
|
|
1853
|
-
var
|
|
1854
|
-
function
|
|
1948
|
+
var Pt = new TextDecoder("utf-8", { fatal: !0 });
|
|
1949
|
+
function Ft(e) {
|
|
1855
1950
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
1856
1951
|
let t = e[0];
|
|
1857
|
-
if (t instanceof
|
|
1858
|
-
if (t instanceof
|
|
1952
|
+
if (t instanceof V) return t.value;
|
|
1953
|
+
if (t instanceof P) return Pt.decode(t.value);
|
|
1859
1954
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
1860
1955
|
}
|
|
1861
|
-
var
|
|
1862
|
-
function
|
|
1863
|
-
if (!
|
|
1956
|
+
var It = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
1957
|
+
function Lt(e, t) {
|
|
1958
|
+
if (!It.test(e)) {
|
|
1864
1959
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
1865
1960
|
if (t) t(n);
|
|
1866
1961
|
else throw SyntaxError(n);
|
|
@@ -1871,93 +1966,93 @@ function Nt(e, t) {
|
|
|
1871
1966
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
1872
1967
|
if (i === void 0) {
|
|
1873
1968
|
let e = a / 1e3;
|
|
1874
|
-
return e >= 0 ? new
|
|
1969
|
+
return e >= 0 ? new zt(BigInt(e)) : new Bt(BigInt(e));
|
|
1875
1970
|
}
|
|
1876
|
-
return new
|
|
1971
|
+
return new Vt(a / 1e3 + i);
|
|
1877
1972
|
}
|
|
1878
|
-
var
|
|
1973
|
+
var Rt = 1n, zt = class extends A {
|
|
1879
1974
|
constructor(e, t) {
|
|
1880
1975
|
super(e, t);
|
|
1881
1976
|
}
|
|
1882
1977
|
_toCDN(e, t) {
|
|
1883
1978
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1884
|
-
let n =
|
|
1885
|
-
return `dt'${
|
|
1979
|
+
let n = S(e, this.encodingWidth, () => x(this.value));
|
|
1980
|
+
return `dt'${Nt(Number(this.value))}'${n}`;
|
|
1886
1981
|
}
|
|
1887
|
-
},
|
|
1982
|
+
}, Bt = class extends j {
|
|
1888
1983
|
constructor(e, t) {
|
|
1889
1984
|
super(e, t);
|
|
1890
1985
|
}
|
|
1891
1986
|
_toCDN(e, t) {
|
|
1892
1987
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1893
|
-
let n =
|
|
1894
|
-
return `dt'${
|
|
1988
|
+
let n = S(e, this.encodingWidth, () => x(this.argument));
|
|
1989
|
+
return `dt'${Nt(Number(this.value))}'${n}`;
|
|
1895
1990
|
}
|
|
1896
|
-
},
|
|
1991
|
+
}, Vt = class extends M {
|
|
1897
1992
|
constructor(e, t) {
|
|
1898
1993
|
super(e, t);
|
|
1899
1994
|
}
|
|
1900
1995
|
_toCDN(e, t) {
|
|
1901
1996
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1902
|
-
let n =
|
|
1903
|
-
return `dt'${
|
|
1997
|
+
let n = O(this.value), r = Ce(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
1998
|
+
return `dt'${Nt(this.value)}'${r}`;
|
|
1904
1999
|
}
|
|
1905
|
-
},
|
|
2000
|
+
}, Ht = class extends N {
|
|
1906
2001
|
constructor(e, t) {
|
|
1907
|
-
super(
|
|
2002
|
+
super(Rt, typeof e == "string" ? Lt(e) : e, t);
|
|
1908
2003
|
}
|
|
1909
2004
|
_toCDN(e, t) {
|
|
1910
2005
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1911
2006
|
let n = this.content;
|
|
1912
|
-
if (n instanceof
|
|
2007
|
+
if (n instanceof M ? n.precision !== void 0 && n.precision !== O(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
1913
2008
|
...e,
|
|
1914
2009
|
appStrings: !1
|
|
1915
2010
|
}, t);
|
|
1916
|
-
let r = n instanceof
|
|
1917
|
-
return `DT'${
|
|
2011
|
+
let r = n instanceof M ? n.value : Number(n.value), i = S(e, this.encodingWidth, () => x(Rt));
|
|
2012
|
+
return `DT'${Nt(r)}'${i}`;
|
|
1918
2013
|
}
|
|
1919
|
-
},
|
|
2014
|
+
}, Ut = class extends Ht {
|
|
1920
2015
|
constructor(e, t) {
|
|
1921
2016
|
super(e, t);
|
|
1922
2017
|
}
|
|
1923
2018
|
_toJS(e) {
|
|
1924
|
-
let t = this.content, n = t instanceof
|
|
2019
|
+
let t = this.content, n = t instanceof M ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
1925
2020
|
return new Date(n);
|
|
1926
2021
|
}
|
|
1927
2022
|
};
|
|
1928
|
-
function
|
|
2023
|
+
function Wt(e) {
|
|
1929
2024
|
let t = e?.jsDate ?? !1;
|
|
1930
2025
|
function n(e) {
|
|
1931
|
-
return t ? new
|
|
2026
|
+
return t ? new Ut(e) : new Ht(e);
|
|
1932
2027
|
}
|
|
1933
2028
|
let r = {
|
|
1934
2029
|
appStringPrefixes: ["dt", "DT"],
|
|
1935
|
-
tagNumbers: [
|
|
2030
|
+
tagNumbers: [Rt],
|
|
1936
2031
|
parseAppString(e, t, r) {
|
|
1937
|
-
return e === "DT" ? n(t) :
|
|
2032
|
+
return e === "DT" ? n(t) : Lt(t, r);
|
|
1938
2033
|
},
|
|
1939
2034
|
parseAppSequence(e, t, r) {
|
|
1940
|
-
let i =
|
|
1941
|
-
return e === "DT" ? n(i) :
|
|
2035
|
+
let i = Ft(t);
|
|
2036
|
+
return e === "DT" ? n(i) : Lt(i, r);
|
|
1942
2037
|
},
|
|
1943
2038
|
parseTag(e, n) {
|
|
1944
2039
|
if (e !== 1n) return;
|
|
1945
2040
|
let r;
|
|
1946
|
-
if (n instanceof
|
|
1947
|
-
else if (n instanceof
|
|
1948
|
-
else if (n instanceof
|
|
2041
|
+
if (n instanceof A) r = new zt(n.value, { encodingWidth: n.encodingWidth });
|
|
2042
|
+
else if (n instanceof j) r = new Bt(n.value, { encodingWidth: n.encodingWidth });
|
|
2043
|
+
else if (n instanceof M) r = new Vt(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
1949
2044
|
else return;
|
|
1950
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
2045
|
+
return r.start = n.start, r.end = n.end, t ? new Ut(r) : new Ht(r);
|
|
1951
2046
|
}
|
|
1952
2047
|
};
|
|
1953
2048
|
return t && (r.fromJS = (e, t) => {
|
|
1954
|
-
if (e instanceof Date) return new
|
|
2049
|
+
if (e instanceof Date) return new Ut(Nt(e.getTime() / 1e3));
|
|
1955
2050
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
1956
2051
|
}
|
|
1957
|
-
var
|
|
2052
|
+
var Gt = Wt(), Kt = Wt({ jsDate: !0 });
|
|
1958
2053
|
//#endregion
|
|
1959
2054
|
//#region src/utils/ip.ts
|
|
1960
|
-
function
|
|
2055
|
+
function qt(e) {
|
|
1961
2056
|
let t = e.split(".");
|
|
1962
2057
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
1963
2058
|
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
@@ -1970,11 +2065,11 @@ function Ut(e) {
|
|
|
1970
2065
|
}
|
|
1971
2066
|
return n;
|
|
1972
2067
|
}
|
|
1973
|
-
function
|
|
2068
|
+
function Jt(e) {
|
|
1974
2069
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
1975
2070
|
if (e === "::") return t;
|
|
1976
2071
|
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 =
|
|
2072
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = qt(i[2]));
|
|
1978
2073
|
let a = n.split("::");
|
|
1979
2074
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
1980
2075
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -1991,11 +2086,11 @@ function Wt(e) {
|
|
|
1991
2086
|
}
|
|
1992
2087
|
return r && t.set(r, 12), t;
|
|
1993
2088
|
}
|
|
1994
|
-
function
|
|
2089
|
+
function Yt(e) {
|
|
1995
2090
|
return Array.from(e).join(".");
|
|
1996
2091
|
}
|
|
1997
|
-
function
|
|
1998
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2092
|
+
function Xt(e) {
|
|
2093
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Yt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
1999
2094
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2000
2095
|
let i = -1, a = 0, o = 0;
|
|
2001
2096
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2009,29 +2104,29 @@ function Kt(e) {
|
|
|
2009
2104
|
}
|
|
2010
2105
|
//#endregion
|
|
2011
2106
|
//#region src/extensions/ip.ts
|
|
2012
|
-
var
|
|
2013
|
-
function
|
|
2107
|
+
var Zt = "ip", H = "IP", U = 52n, Qt = 54n, $t = new TextDecoder("utf-8", { fatal: !0 });
|
|
2108
|
+
function en(e) {
|
|
2014
2109
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2015
2110
|
let t = e[0];
|
|
2016
|
-
if (t instanceof
|
|
2017
|
-
if (t instanceof
|
|
2111
|
+
if (t instanceof V) return t.value;
|
|
2112
|
+
if (t instanceof P) return $t.decode(t.value);
|
|
2018
2113
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2019
2114
|
}
|
|
2020
|
-
function
|
|
2115
|
+
function tn(e) {
|
|
2021
2116
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2022
|
-
bytes:
|
|
2117
|
+
bytes: qt(e),
|
|
2023
2118
|
isV4: !0
|
|
2024
2119
|
} : {
|
|
2025
|
-
bytes:
|
|
2120
|
+
bytes: Jt(e),
|
|
2026
2121
|
isV4: !1
|
|
2027
2122
|
};
|
|
2028
2123
|
}
|
|
2029
|
-
function
|
|
2030
|
-
if (e.length === 4) return
|
|
2031
|
-
if (e.length === 16) return
|
|
2124
|
+
function nn(e) {
|
|
2125
|
+
if (e.length === 4) return Yt(e);
|
|
2126
|
+
if (e.length === 16) return Xt(e);
|
|
2032
2127
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2033
2128
|
}
|
|
2034
|
-
function
|
|
2129
|
+
function rn(e, t) {
|
|
2035
2130
|
let n = new Uint8Array(e.length);
|
|
2036
2131
|
n.set(e);
|
|
2037
2132
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2041,86 +2136,86 @@ function $t(e, t) {
|
|
|
2041
2136
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2042
2137
|
return n.slice(0, a);
|
|
2043
2138
|
}
|
|
2044
|
-
function
|
|
2139
|
+
function an(e, t) {
|
|
2045
2140
|
let n = new Uint8Array(t);
|
|
2046
2141
|
return n.set(e), n;
|
|
2047
2142
|
}
|
|
2048
|
-
var
|
|
2143
|
+
var on = class extends P {
|
|
2049
2144
|
_toCDN(e, t) {
|
|
2050
2145
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2051
|
-
let n =
|
|
2052
|
-
return `${
|
|
2146
|
+
let n = S(e, this.encodingWidth, () => x(BigInt(this.value.length)));
|
|
2147
|
+
return `${Zt}'${nn(this.value)}'${n}`;
|
|
2053
2148
|
}
|
|
2054
|
-
},
|
|
2149
|
+
}, sn = class extends L {
|
|
2055
2150
|
_isV4;
|
|
2056
2151
|
constructor(e, t, n) {
|
|
2057
|
-
super([new
|
|
2152
|
+
super([new A(BigInt(e)), new P(t)]), this._isV4 = n;
|
|
2058
2153
|
}
|
|
2059
2154
|
_toCDN(e, t) {
|
|
2060
2155
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2061
2156
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2062
|
-
return `${
|
|
2157
|
+
return `${Zt}'${nn(an(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2063
2158
|
}
|
|
2064
|
-
},
|
|
2159
|
+
}, cn = class extends N {
|
|
2065
2160
|
constructor(e, t) {
|
|
2066
2161
|
super(e, t);
|
|
2067
2162
|
}
|
|
2068
2163
|
_toCDN(e, t) {
|
|
2069
2164
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2070
|
-
let n = this.tag ===
|
|
2071
|
-
if (r instanceof
|
|
2165
|
+
let n = this.tag === U ? 4 : 16, r = this.content;
|
|
2166
|
+
if (r instanceof P) {
|
|
2072
2167
|
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2073
|
-
let n =
|
|
2074
|
-
return `${
|
|
2168
|
+
let n = S(e, this.encodingWidth, () => x(this.tag));
|
|
2169
|
+
return `${H}'${nn(r.value)}'${n}`;
|
|
2075
2170
|
}
|
|
2076
|
-
if (r instanceof
|
|
2171
|
+
if (r instanceof L && r.items.length === 2 && r.items[0] instanceof A && r.items[1] instanceof P) {
|
|
2077
2172
|
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 `${
|
|
2173
|
+
let i = Number(r.items[0].value), a = an(r.items[1].value, n), o = S(e, this.encodingWidth, () => x(this.tag));
|
|
2174
|
+
return `${H}'${nn(a)}/${i}'${o}`;
|
|
2080
2175
|
}
|
|
2081
2176
|
return super._toCDN(e, t);
|
|
2082
2177
|
}
|
|
2083
2178
|
};
|
|
2084
|
-
function
|
|
2179
|
+
function ln(e, t) {
|
|
2085
2180
|
let n = t.indexOf("/");
|
|
2086
2181
|
if (n === -1) {
|
|
2087
|
-
let { bytes: n, isV4: r } =
|
|
2088
|
-
return e ===
|
|
2182
|
+
let { bytes: n, isV4: r } = tn(t);
|
|
2183
|
+
return e === H ? new cn(r ? U : Qt, new P(n)) : new on(n);
|
|
2089
2184
|
}
|
|
2090
2185
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2091
2186
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2092
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2187
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = tn(r), c = s ? 32 : 128;
|
|
2093
2188
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2094
|
-
let l =
|
|
2095
|
-
return e ===
|
|
2189
|
+
let l = rn(o, a);
|
|
2190
|
+
return e === H ? new cn(s ? U : Qt, new L([new A(BigInt(a)), new P(l)])) : new sn(a, l, s);
|
|
2096
2191
|
}
|
|
2097
|
-
var
|
|
2098
|
-
appStringPrefixes: [
|
|
2099
|
-
tagNumbers: [
|
|
2192
|
+
var un = {
|
|
2193
|
+
appStringPrefixes: [Zt, H],
|
|
2194
|
+
tagNumbers: [U, Qt],
|
|
2100
2195
|
parseAppString(e, t) {
|
|
2101
|
-
return
|
|
2196
|
+
return ln(e, t);
|
|
2102
2197
|
},
|
|
2103
2198
|
parseAppSequence(e, t) {
|
|
2104
|
-
return
|
|
2199
|
+
return ln(e, en(t));
|
|
2105
2200
|
},
|
|
2106
2201
|
parseTag(e, t) {
|
|
2107
|
-
if (!(e !==
|
|
2202
|
+
if (!(e !== U && e !== Qt) && (t instanceof P || t instanceof L)) return new cn(e, t);
|
|
2108
2203
|
}
|
|
2109
|
-
},
|
|
2110
|
-
tagNumbers: [
|
|
2204
|
+
}, dn = 18446744073709551615n, fn = -18446744073709551616n, pn = {
|
|
2205
|
+
tagNumbers: [qe, Je],
|
|
2111
2206
|
parseTag(e, t) {
|
|
2112
|
-
if (t instanceof
|
|
2207
|
+
if (t instanceof P) {
|
|
2113
2208
|
if (e === 2n) {
|
|
2114
|
-
let e =
|
|
2115
|
-
return e >
|
|
2209
|
+
let e = Qe(t.value);
|
|
2210
|
+
return e > dn ? new $e(e) : void 0;
|
|
2116
2211
|
}
|
|
2117
2212
|
if (e === 3n) {
|
|
2118
|
-
let e = -1n -
|
|
2119
|
-
return e <
|
|
2213
|
+
let e = -1n - Qe(t.value);
|
|
2214
|
+
return e < fn ? new et(e) : void 0;
|
|
2120
2215
|
}
|
|
2121
2216
|
}
|
|
2122
2217
|
}
|
|
2123
|
-
},
|
|
2218
|
+
}, mn = "cri", hn = "CRI", gn = 99n, _n = /* @__PURE__ */ new Map([
|
|
2124
2219
|
["coap", -1n],
|
|
2125
2220
|
["coaps", -2n],
|
|
2126
2221
|
["http", -3n],
|
|
@@ -2131,47 +2226,47 @@ var on = {
|
|
|
2131
2226
|
["coaps+tcp", -8n],
|
|
2132
2227
|
["coap+ws", -25n],
|
|
2133
2228
|
["coaps+ws", -26n]
|
|
2134
|
-
]),
|
|
2135
|
-
function
|
|
2229
|
+
]), vn = new Map([..._n.entries()].map(([e, t]) => [t, e]));
|
|
2230
|
+
function W(e) {
|
|
2136
2231
|
try {
|
|
2137
2232
|
return decodeURIComponent(e);
|
|
2138
2233
|
} catch {
|
|
2139
2234
|
return e;
|
|
2140
2235
|
}
|
|
2141
2236
|
}
|
|
2142
|
-
var
|
|
2143
|
-
function
|
|
2144
|
-
return Array.from(
|
|
2237
|
+
var yn = new TextEncoder(), bn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2238
|
+
function xn(e) {
|
|
2239
|
+
return Array.from(yn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2145
2240
|
}
|
|
2146
|
-
function
|
|
2241
|
+
function G(e, t) {
|
|
2147
2242
|
let n = "";
|
|
2148
|
-
for (let r of e) n += t(r) ? r :
|
|
2243
|
+
for (let r of e) n += t(r) ? r : xn(r);
|
|
2149
2244
|
return n;
|
|
2150
2245
|
}
|
|
2151
|
-
function
|
|
2246
|
+
function Sn(e) {
|
|
2152
2247
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2153
2248
|
}
|
|
2154
|
-
function
|
|
2249
|
+
function Cn(e) {
|
|
2155
2250
|
return /[!$&'()*+,;=]/.test(e);
|
|
2156
2251
|
}
|
|
2157
|
-
function
|
|
2158
|
-
return
|
|
2252
|
+
function wn(e) {
|
|
2253
|
+
return Sn(e) || Cn(e) || e === ":" || e === "@";
|
|
2159
2254
|
}
|
|
2160
|
-
function
|
|
2161
|
-
return (
|
|
2255
|
+
function Tn(e) {
|
|
2256
|
+
return (wn(e) || e === "/" || e === "?") && e !== "&";
|
|
2162
2257
|
}
|
|
2163
|
-
function
|
|
2164
|
-
return
|
|
2258
|
+
function En(e) {
|
|
2259
|
+
return wn(e) || e === "/" || e === "?";
|
|
2165
2260
|
}
|
|
2166
|
-
function
|
|
2167
|
-
return
|
|
2261
|
+
function Dn(e) {
|
|
2262
|
+
return Sn(e) || Cn(e) || e === ":";
|
|
2168
2263
|
}
|
|
2169
|
-
function
|
|
2170
|
-
return
|
|
2264
|
+
function On(e) {
|
|
2265
|
+
return Sn(e) || Cn(e);
|
|
2171
2266
|
}
|
|
2172
|
-
function
|
|
2267
|
+
function kn(e) {
|
|
2173
2268
|
let t = [], n = e, r = n.indexOf("@");
|
|
2174
|
-
r >= 0 && (t.push(
|
|
2269
|
+
r >= 0 && (t.push(z.FALSE), t.push(new V(W(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2175
2270
|
let i, a = null;
|
|
2176
2271
|
if (n.startsWith("[")) {
|
|
2177
2272
|
let e = n.indexOf("]");
|
|
@@ -2180,243 +2275,249 @@ function Tn(e) {
|
|
|
2180
2275
|
let r = n.slice(e + 1);
|
|
2181
2276
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2182
2277
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2183
|
-
t.push(new
|
|
2278
|
+
t.push(new P(Jt(i)));
|
|
2184
2279
|
} else {
|
|
2185
2280
|
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
|
|
2281
|
+
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 P(qt(i)));
|
|
2282
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new V(e));
|
|
2188
2283
|
}
|
|
2189
2284
|
if (a !== null && a !== "") {
|
|
2190
2285
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2191
2286
|
let e = parseInt(a, 10);
|
|
2192
2287
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2193
|
-
t.push(new
|
|
2288
|
+
t.push(new A(BigInt(e)));
|
|
2194
2289
|
}
|
|
2195
|
-
return new
|
|
2290
|
+
return new L(t);
|
|
2196
2291
|
}
|
|
2197
|
-
function
|
|
2292
|
+
function An(e) {
|
|
2198
2293
|
let t = e.items, n = 0, r = "";
|
|
2199
|
-
if (n < t.length && t[n] instanceof
|
|
2294
|
+
if (n < t.length && t[n] instanceof z && t[n].value === 20) {
|
|
2200
2295
|
n++;
|
|
2201
2296
|
let e = t[n++];
|
|
2202
|
-
r +=
|
|
2297
|
+
r += G(e.value, Dn) + "@";
|
|
2203
2298
|
}
|
|
2204
2299
|
if (n >= t.length) return r;
|
|
2205
2300
|
let i = t[n];
|
|
2206
|
-
if (i instanceof
|
|
2301
|
+
if (i instanceof P) {
|
|
2207
2302
|
n++;
|
|
2208
2303
|
let { length: e } = i.value;
|
|
2209
|
-
if (e === 4) r +=
|
|
2210
|
-
else if (e === 16) r += "[" +
|
|
2304
|
+
if (e === 4) r += Yt(i.value);
|
|
2305
|
+
else if (e === 16) r += "[" + Xt(i.value) + "]";
|
|
2211
2306
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2212
|
-
n < t.length && t[n] instanceof
|
|
2307
|
+
n < t.length && t[n] instanceof V && (r += `%25${G(t[n++].value, On)}`);
|
|
2213
2308
|
} else {
|
|
2214
2309
|
let e = [];
|
|
2215
|
-
for (; n < t.length && t[n] instanceof
|
|
2310
|
+
for (; n < t.length && t[n] instanceof V;) e.push(G(t[n++].value, On));
|
|
2216
2311
|
r += e.join(".");
|
|
2217
2312
|
}
|
|
2218
|
-
return n < t.length && t[n] instanceof
|
|
2313
|
+
return n < t.length && t[n] instanceof A && (r += ":" + t[n].value.toString()), r;
|
|
2219
2314
|
}
|
|
2220
|
-
function
|
|
2315
|
+
function jn(e) {
|
|
2221
2316
|
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:
|
|
2317
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new V(W(e)))) : (r = t, i = []), {
|
|
2318
|
+
authority: kn(r),
|
|
2224
2319
|
pathSegments: i
|
|
2225
2320
|
};
|
|
2226
2321
|
}
|
|
2227
|
-
function
|
|
2322
|
+
function Mn(e) {
|
|
2228
2323
|
let t = e, n = null, r = t.indexOf("#");
|
|
2229
|
-
r >= 0 && (n =
|
|
2324
|
+
r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
|
|
2230
2325
|
let i = null, a = t.indexOf("?");
|
|
2231
2326
|
if (a >= 0) {
|
|
2232
2327
|
let e = t.slice(a + 1);
|
|
2233
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2328
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new V(W(e)));
|
|
2234
2329
|
}
|
|
2235
2330
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2236
2331
|
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
|
|
2332
|
+
let e = s[1].toLowerCase(), t = s[2], n = _n.get(e);
|
|
2333
|
+
if (o.push(n === void 0 ? new V(e) : new j(n)), t.startsWith("//")) {
|
|
2334
|
+
let { authority: e, pathSegments: n } = jn(t);
|
|
2335
|
+
o.push(e, new L(n));
|
|
2241
2336
|
} else if (t.startsWith("/")) {
|
|
2242
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2243
|
-
o.push(
|
|
2337
|
+
let e = t.slice(1).split("/").map((e) => new V(W(e)));
|
|
2338
|
+
o.push(z.NULL, new L(e));
|
|
2244
2339
|
} else {
|
|
2245
|
-
let e = t.split("/").map((e) => new
|
|
2246
|
-
o.push(
|
|
2340
|
+
let e = t.split("/").map((e) => new V(W(e)));
|
|
2341
|
+
o.push(z.TRUE, new L(e));
|
|
2247
2342
|
}
|
|
2248
2343
|
} else if (t.startsWith("//")) {
|
|
2249
|
-
let { authority: e, pathSegments: n } =
|
|
2250
|
-
o.push(
|
|
2344
|
+
let { authority: e, pathSegments: n } = jn(t);
|
|
2345
|
+
o.push(z.FALSE, e, new L(n));
|
|
2251
2346
|
} else if (t.startsWith("/")) {
|
|
2252
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2253
|
-
o.push(
|
|
2254
|
-
} else if (t === "") o.push(new
|
|
2347
|
+
let e = t.slice(1).split("/").map((e) => new V(W(e)));
|
|
2348
|
+
o.push(z.TRUE, new L(e));
|
|
2349
|
+
} else if (t === "") o.push(new A(0n));
|
|
2255
2350
|
else {
|
|
2256
2351
|
let n = 1n, r = t, i = !1;
|
|
2257
2352
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2258
2353
|
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
|
|
2354
|
+
let a = r === "" ? [] : r.split("/").map((e) => new V(W(e)));
|
|
2355
|
+
o.push(new A(n), new L(a));
|
|
2261
2356
|
}
|
|
2262
|
-
if (i !== null && o.push(new
|
|
2357
|
+
if (i !== null && o.push(new L(i)), n !== null && (i === null && o.push(z.NULL), o.push(new V(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2263
2358
|
let e = o[o.length - 1];
|
|
2264
|
-
e instanceof
|
|
2359
|
+
e instanceof L && e.items.length === 0 && o.pop();
|
|
2265
2360
|
}
|
|
2266
|
-
return o.length === 1 && o[0] instanceof
|
|
2361
|
+
return o.length === 1 && o[0] instanceof A && o[0].value === 0n ? [] : o;
|
|
2267
2362
|
}
|
|
2268
|
-
function
|
|
2363
|
+
function K(e, t) {
|
|
2269
2364
|
let n = t, r = "";
|
|
2270
2365
|
if (n < e.length) {
|
|
2271
2366
|
let t = e[n];
|
|
2272
|
-
if (t instanceof
|
|
2367
|
+
if (t instanceof L) {
|
|
2273
2368
|
if (n++, t.items.length > 0) {
|
|
2274
2369
|
let e = t.items.map((e) => {
|
|
2275
|
-
if (!(e instanceof
|
|
2276
|
-
return
|
|
2370
|
+
if (!(e instanceof V)) throw Error("cri: query item must be a text string");
|
|
2371
|
+
return G(e.value, Tn);
|
|
2277
2372
|
});
|
|
2278
2373
|
r += "?" + e.join("&");
|
|
2279
2374
|
}
|
|
2280
|
-
} else t instanceof
|
|
2375
|
+
} else t instanceof z && t.value === 22 && n++;
|
|
2281
2376
|
}
|
|
2282
|
-
return n < e.length && e[n] instanceof
|
|
2377
|
+
return n < e.length && e[n] instanceof V && (r += "#" + G(e[n].value, En)), r;
|
|
2283
2378
|
}
|
|
2284
|
-
function
|
|
2379
|
+
function Nn(e) {
|
|
2285
2380
|
return e.items.map((e) => {
|
|
2286
|
-
if (!(e instanceof
|
|
2287
|
-
return
|
|
2381
|
+
if (!(e instanceof V)) throw Error("cri: path segment must be a text string");
|
|
2382
|
+
return G(e.value, wn);
|
|
2288
2383
|
});
|
|
2289
2384
|
}
|
|
2290
|
-
function
|
|
2385
|
+
function Pn(e) {
|
|
2291
2386
|
if (e.length === 0) return "";
|
|
2292
2387
|
let t = 0, n = e[t++];
|
|
2293
|
-
if (n instanceof
|
|
2388
|
+
if (n instanceof j || n instanceof V) {
|
|
2294
2389
|
let r;
|
|
2295
|
-
if (n instanceof
|
|
2296
|
-
let e =
|
|
2390
|
+
if (n instanceof j) {
|
|
2391
|
+
let e = vn.get(n.value);
|
|
2297
2392
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2298
2393
|
r = e + ":";
|
|
2299
2394
|
} else r = n.value + ":";
|
|
2300
2395
|
if (t >= e.length) return r;
|
|
2301
2396
|
let i = e[t++], a = "", o = !1;
|
|
2302
|
-
if (i instanceof
|
|
2303
|
-
else if (i instanceof
|
|
2397
|
+
if (i instanceof L) a = "//" + An(i), o = !0;
|
|
2398
|
+
else if (i instanceof z) if (i.value === 22) o = !0;
|
|
2304
2399
|
else if (i.value === 21) o = !1;
|
|
2305
2400
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2306
2401
|
else throw Error("cri: unexpected type for authority element");
|
|
2307
2402
|
let s = "";
|
|
2308
|
-
if (t < e.length && e[t] instanceof
|
|
2403
|
+
if (t < e.length && e[t] instanceof L) {
|
|
2309
2404
|
let n = e[t++];
|
|
2310
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2405
|
+
n.items.length > 0 && (s = (o ? "/" : "") + Nn(n).join("/"));
|
|
2311
2406
|
}
|
|
2312
|
-
return r + a + s +
|
|
2407
|
+
return r + a + s + K(e, t);
|
|
2313
2408
|
}
|
|
2314
|
-
if (n instanceof
|
|
2315
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2316
|
-
let n =
|
|
2317
|
-
if (t < e.length && e[t] instanceof
|
|
2409
|
+
if (n instanceof z && n.value === 20) {
|
|
2410
|
+
if (t >= e.length || !(e[t] instanceof L)) throw Error("cri: network-path reference requires an authority array");
|
|
2411
|
+
let n = An(e[t++]), r = "";
|
|
2412
|
+
if (t < e.length && e[t] instanceof L) {
|
|
2318
2413
|
let n = e[t++];
|
|
2319
|
-
n.items.length > 0 && (r = "/" +
|
|
2414
|
+
n.items.length > 0 && (r = "/" + Nn(n).join("/"));
|
|
2320
2415
|
}
|
|
2321
|
-
return "//" + n + r +
|
|
2416
|
+
return "//" + n + r + K(e, t);
|
|
2322
2417
|
}
|
|
2323
|
-
if (n instanceof
|
|
2418
|
+
if (n instanceof z && n.value === 21) {
|
|
2324
2419
|
let n = "/";
|
|
2325
|
-
if (t < e.length && e[t] instanceof
|
|
2420
|
+
if (t < e.length && e[t] instanceof L) {
|
|
2326
2421
|
let r = e[t++];
|
|
2327
|
-
n = "/" +
|
|
2422
|
+
n = "/" + Nn(r).join("/");
|
|
2328
2423
|
}
|
|
2329
|
-
return n +
|
|
2424
|
+
return n + K(e, t);
|
|
2330
2425
|
}
|
|
2331
|
-
if (n instanceof
|
|
2426
|
+
if (n instanceof A) {
|
|
2332
2427
|
let r = n.value;
|
|
2333
|
-
if (r === 0n) return
|
|
2428
|
+
if (r === 0n) return K(e, t);
|
|
2334
2429
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2335
|
-
if (t < e.length && e[t] instanceof
|
|
2430
|
+
if (t < e.length && e[t] instanceof L) {
|
|
2336
2431
|
let n = e[t++];
|
|
2337
2432
|
if (n.items.length > 0) {
|
|
2338
|
-
let e =
|
|
2433
|
+
let e = Nn(n);
|
|
2339
2434
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2340
2435
|
} else a = i === "" ? "./" : i;
|
|
2341
2436
|
} else a = i === "" ? "./" : i;
|
|
2342
|
-
return a +
|
|
2437
|
+
return a + K(e, t);
|
|
2343
2438
|
}
|
|
2344
2439
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2345
2440
|
}
|
|
2346
|
-
var
|
|
2441
|
+
var Fn = class extends L {
|
|
2347
2442
|
_toCDN(e, t) {
|
|
2348
2443
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2349
2444
|
try {
|
|
2350
|
-
let t =
|
|
2351
|
-
return `${
|
|
2445
|
+
let t = S(e, this.encodingWidth, () => x(BigInt(this.items.length)));
|
|
2446
|
+
return `${mn}'${Pn(this.items)}'${t}`;
|
|
2352
2447
|
} catch {
|
|
2353
2448
|
return super._toCDN(e, t);
|
|
2354
2449
|
}
|
|
2355
2450
|
}
|
|
2356
|
-
},
|
|
2451
|
+
}, In = class extends N {
|
|
2357
2452
|
constructor(e) {
|
|
2358
|
-
super(
|
|
2453
|
+
super(gn, e);
|
|
2359
2454
|
}
|
|
2360
2455
|
_toCDN(e, t) {
|
|
2361
2456
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2362
2457
|
try {
|
|
2363
2458
|
let n = this.content;
|
|
2364
2459
|
if (n.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2365
|
-
let r =
|
|
2366
|
-
return `${
|
|
2460
|
+
let r = S(e, this.encodingWidth, () => x(gn));
|
|
2461
|
+
return `${hn}'${Pn(n.items)}'${r}`;
|
|
2367
2462
|
} catch {
|
|
2368
2463
|
return super._toCDN(e, t);
|
|
2369
2464
|
}
|
|
2370
2465
|
}
|
|
2371
2466
|
};
|
|
2372
|
-
function
|
|
2467
|
+
function Ln(e) {
|
|
2373
2468
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2374
2469
|
let t = e[0];
|
|
2375
|
-
if (t instanceof
|
|
2376
|
-
if (t instanceof
|
|
2470
|
+
if (t instanceof V) return t.value;
|
|
2471
|
+
if (t instanceof P) return bn.decode(t.value);
|
|
2377
2472
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2378
2473
|
}
|
|
2379
|
-
function
|
|
2380
|
-
let n = new
|
|
2381
|
-
return e ===
|
|
2474
|
+
function Rn(e, t) {
|
|
2475
|
+
let n = new Fn(Mn(t));
|
|
2476
|
+
return e === hn ? new In(n) : n;
|
|
2382
2477
|
}
|
|
2383
|
-
var
|
|
2384
|
-
appStringPrefixes: [
|
|
2385
|
-
tagNumbers: [
|
|
2478
|
+
var zn = {
|
|
2479
|
+
appStringPrefixes: [mn, hn],
|
|
2480
|
+
tagNumbers: [gn],
|
|
2386
2481
|
parseAppString(e, t) {
|
|
2387
|
-
return
|
|
2482
|
+
return Rn(e, t);
|
|
2388
2483
|
},
|
|
2389
2484
|
parseAppSequence(e, t) {
|
|
2390
|
-
return
|
|
2485
|
+
return Rn(e, Ln(t));
|
|
2391
2486
|
},
|
|
2392
2487
|
parseTag(e, t) {
|
|
2393
|
-
if (e !== 99n || !(t instanceof
|
|
2394
|
-
let n = new
|
|
2488
|
+
if (e !== 99n || !(t instanceof L)) return;
|
|
2489
|
+
let n = new Fn(t.items, {
|
|
2395
2490
|
indefiniteLength: t.indefiniteLength,
|
|
2396
2491
|
encodingWidth: t.encodingWidth
|
|
2397
2492
|
});
|
|
2398
|
-
return n.start = t.start, n.end = t.end, new
|
|
2493
|
+
return n.start = t.start, n.end = t.end, new In(n);
|
|
2399
2494
|
}
|
|
2400
2495
|
};
|
|
2401
2496
|
//#endregion
|
|
2402
2497
|
//#region src/cbor/decoder.ts
|
|
2403
|
-
function
|
|
2498
|
+
function Bn(e, t) {
|
|
2404
2499
|
if (e === 24 && t <= 23n) return 0;
|
|
2405
2500
|
if (e === 25 && t <= 255n) return 1;
|
|
2406
2501
|
if (e === 26 && t <= 65535n) return 2;
|
|
2407
2502
|
if (e === 27 && t <= 4294967295n) return 3;
|
|
2408
2503
|
}
|
|
2409
|
-
|
|
2504
|
+
function Vn(e, t) {
|
|
2505
|
+
if (e === 24 && t <= 23) return 0;
|
|
2506
|
+
if (e === 25 && t <= 255) return 1;
|
|
2507
|
+
if (e === 26 && t <= 65535) return 2;
|
|
2508
|
+
if (e === 27 && t <= 4294967295) return 3;
|
|
2509
|
+
}
|
|
2510
|
+
var Hn = new TextDecoder("utf-8", {
|
|
2410
2511
|
fatal: !0,
|
|
2411
2512
|
ignoreBOM: !0
|
|
2412
|
-
}),
|
|
2513
|
+
}), Un = new TextDecoder("utf-8", {
|
|
2413
2514
|
fatal: !1,
|
|
2414
2515
|
ignoreBOM: !0
|
|
2415
2516
|
});
|
|
2416
2517
|
function q(e) {
|
|
2417
2518
|
throw Error(`CBOR decode error: ${e}`);
|
|
2418
2519
|
}
|
|
2419
|
-
function
|
|
2520
|
+
function Wn(e, t, n) {
|
|
2420
2521
|
let r = {
|
|
2421
2522
|
message: e,
|
|
2422
2523
|
offset: t
|
|
@@ -2424,71 +2525,63 @@ function Rn(e, t, n) {
|
|
|
2424
2525
|
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
2526
|
return r;
|
|
2426
2527
|
}
|
|
2427
|
-
function
|
|
2528
|
+
function J(e, t) {
|
|
2428
2529
|
e.warnings ??= [], e.warnings.push(t);
|
|
2429
2530
|
}
|
|
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) {
|
|
2531
|
+
function Y(e) {
|
|
2532
|
+
if (e instanceof A) return ["u", String(e.value)];
|
|
2533
|
+
if (e instanceof j) return ["n", String(e.value)];
|
|
2534
|
+
if (e instanceof V) return ["t", e.value];
|
|
2535
|
+
if (e instanceof I) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2536
|
+
if (e instanceof P) return ["b", i(e.value)];
|
|
2537
|
+
if (e instanceof F) {
|
|
2442
2538
|
let t = "";
|
|
2443
|
-
for (let n of e.chunks) t +=
|
|
2539
|
+
for (let n of e.chunks) t += i(n.value);
|
|
2444
2540
|
return ["b", t];
|
|
2445
2541
|
}
|
|
2446
|
-
if (e instanceof
|
|
2447
|
-
if (e instanceof
|
|
2448
|
-
if (e instanceof
|
|
2449
|
-
if (e instanceof
|
|
2450
|
-
let t = e.entries.map(([e, t]) => [
|
|
2542
|
+
if (e instanceof M) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2543
|
+
if (e instanceof z) return ["s", e.value];
|
|
2544
|
+
if (e instanceof L) return ["A", e.items.map(Y)];
|
|
2545
|
+
if (e instanceof R) {
|
|
2546
|
+
let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
|
|
2451
2547
|
if (t.length <= 1) return ["M", t];
|
|
2452
2548
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2453
2549
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2454
2550
|
}
|
|
2455
|
-
|
|
2551
|
+
return e instanceof N ? [
|
|
2456
2552
|
"G",
|
|
2457
2553
|
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) {
|
|
2554
|
+
Y(e.content)
|
|
2555
|
+
] : ["c", i(e.toCBOR())];
|
|
2556
|
+
}
|
|
2557
|
+
function Gn(e) {
|
|
2558
|
+
if (e instanceof A) return "u" + e.value;
|
|
2559
|
+
if (e instanceof j) return "n" + e.value;
|
|
2560
|
+
if (e instanceof V) return "t" + e.value;
|
|
2561
|
+
if (e instanceof I) {
|
|
2469
2562
|
let t = "t";
|
|
2470
2563
|
for (let n of e.chunks) t += n.value;
|
|
2471
2564
|
return t;
|
|
2472
2565
|
}
|
|
2473
|
-
if (e instanceof
|
|
2474
|
-
if (e instanceof
|
|
2566
|
+
if (e instanceof P) return "b" + i(e.value);
|
|
2567
|
+
if (e instanceof F) {
|
|
2475
2568
|
let t = "b";
|
|
2476
|
-
for (let n of e.chunks) t +=
|
|
2569
|
+
for (let n of e.chunks) t += i(n.value);
|
|
2477
2570
|
return t;
|
|
2478
2571
|
}
|
|
2479
|
-
return e instanceof
|
|
2572
|
+
return e instanceof M ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof z ? "s" + e.value : JSON.stringify(Y(e));
|
|
2480
2573
|
}
|
|
2481
|
-
var
|
|
2482
|
-
function
|
|
2483
|
-
return
|
|
2574
|
+
var Kn = Array.from({ length: 24 }, (e, t) => BigInt(t)), qn;
|
|
2575
|
+
function Jn() {
|
|
2576
|
+
return qn ??= Z.filter((e) => e.parseTag !== void 0);
|
|
2484
2577
|
}
|
|
2485
|
-
function
|
|
2578
|
+
function Yn(e, t) {
|
|
2486
2579
|
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
2487
2580
|
return String.fromCharCode.apply(null, e);
|
|
2488
2581
|
}
|
|
2489
|
-
function
|
|
2582
|
+
function Xn(e, t, n) {
|
|
2490
2583
|
if (n <= 23) return {
|
|
2491
|
-
value:
|
|
2584
|
+
value: Kn[n],
|
|
2492
2585
|
nextOffset: t
|
|
2493
2586
|
};
|
|
2494
2587
|
switch (n) {
|
|
@@ -2511,7 +2604,36 @@ function Y(e, t, n) {
|
|
|
2511
2604
|
default: q(`reserved additional info value: ${n}`);
|
|
2512
2605
|
}
|
|
2513
2606
|
}
|
|
2514
|
-
function
|
|
2607
|
+
function Zn(e, t, n) {
|
|
2608
|
+
if (n <= 23) return {
|
|
2609
|
+
value: n,
|
|
2610
|
+
nextOffset: t
|
|
2611
|
+
};
|
|
2612
|
+
switch (n) {
|
|
2613
|
+
case 24: return t + 1 > e.byteLength && q("unexpected end of input"), {
|
|
2614
|
+
value: e.getUint8(t),
|
|
2615
|
+
nextOffset: t + 1
|
|
2616
|
+
};
|
|
2617
|
+
case 25: return t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
2618
|
+
value: e.getUint16(t, !1),
|
|
2619
|
+
nextOffset: t + 2
|
|
2620
|
+
};
|
|
2621
|
+
case 26: return t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
2622
|
+
value: e.getUint32(t, !1),
|
|
2623
|
+
nextOffset: t + 4
|
|
2624
|
+
};
|
|
2625
|
+
case 27: {
|
|
2626
|
+
t + 8 > e.byteLength && q("unexpected end of input");
|
|
2627
|
+
let n = e.getUint32(t, !1), r = e.getUint32(t + 4, !1);
|
|
2628
|
+
return {
|
|
2629
|
+
value: n * 4294967296 + r,
|
|
2630
|
+
nextOffset: t + 8
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
default: q(`reserved additional info value: ${n}`);
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
function Qn(e, t, n, r, i, a) {
|
|
2515
2637
|
let o = [], s = t;
|
|
2516
2638
|
for (;;) {
|
|
2517
2639
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
@@ -2526,67 +2648,70 @@ function Kn(e, t, n, r, i, a) {
|
|
|
2526
2648
|
nextOffset: s
|
|
2527
2649
|
};
|
|
2528
2650
|
}
|
|
2529
|
-
function
|
|
2530
|
-
let i =
|
|
2531
|
-
t.has(i) && n.push(
|
|
2651
|
+
function $n(e, t, n, r) {
|
|
2652
|
+
let i = Gn(e);
|
|
2653
|
+
t.has(i) && n.push(Wn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2532
2654
|
}
|
|
2533
2655
|
function X(e, t, n, r) {
|
|
2534
|
-
let i = t, a =
|
|
2656
|
+
let i = t, a = tr(e, t, n, r);
|
|
2535
2657
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2536
2658
|
}
|
|
2537
|
-
function
|
|
2659
|
+
function er(e, t, n) {
|
|
2660
|
+
return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
|
|
2661
|
+
}
|
|
2662
|
+
function tr(e, t, n, r) {
|
|
2538
2663
|
t >= e.byteLength && q("unexpected end of input");
|
|
2539
2664
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2540
2665
|
switch (a) {
|
|
2541
2666
|
case 0: {
|
|
2542
|
-
let { value: n, nextOffset: r } =
|
|
2667
|
+
let { value: n, nextOffset: r } = Xn(e, t, o);
|
|
2543
2668
|
return {
|
|
2544
|
-
value: new
|
|
2669
|
+
value: new A(n, { encodingWidth: Bn(o, n) }),
|
|
2545
2670
|
nextOffset: r
|
|
2546
2671
|
};
|
|
2547
2672
|
}
|
|
2548
2673
|
case 1: {
|
|
2549
|
-
let { value: n, nextOffset: r } =
|
|
2674
|
+
let { value: n, nextOffset: r } = Xn(e, t, o), i = Bn(o, n);
|
|
2550
2675
|
return {
|
|
2551
|
-
value: new
|
|
2676
|
+
value: new j(-1n - n, { encodingWidth: i }),
|
|
2552
2677
|
nextOffset: r
|
|
2553
2678
|
};
|
|
2554
2679
|
}
|
|
2555
2680
|
case 2: {
|
|
2556
2681
|
if (o === 31) {
|
|
2557
|
-
let { chunks: i, nextOffset: a } =
|
|
2682
|
+
let { chunks: i, nextOffset: a } = Qn(e, t, n, r, "byte string", (e) => e instanceof P);
|
|
2558
2683
|
return {
|
|
2559
|
-
value: new
|
|
2684
|
+
value: new F(i),
|
|
2560
2685
|
nextOffset: a
|
|
2561
2686
|
};
|
|
2562
2687
|
}
|
|
2563
|
-
let { value: i, nextOffset: a } =
|
|
2564
|
-
return a +
|
|
2565
|
-
value: new
|
|
2566
|
-
nextOffset: a +
|
|
2688
|
+
let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i);
|
|
2689
|
+
return a + i > e.byteLength && q("byte string extends beyond input"), {
|
|
2690
|
+
value: new P(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
2691
|
+
nextOffset: a + i
|
|
2567
2692
|
};
|
|
2568
2693
|
}
|
|
2569
2694
|
case 3: {
|
|
2570
2695
|
if (o === 31) {
|
|
2571
|
-
let { chunks: i, nextOffset: a } =
|
|
2696
|
+
let { chunks: i, nextOffset: a } = Qn(e, t, n, r, "text string", (e) => e instanceof V);
|
|
2572
2697
|
return {
|
|
2573
|
-
value: new
|
|
2698
|
+
value: new I(i),
|
|
2574
2699
|
nextOffset: a
|
|
2575
2700
|
};
|
|
2576
2701
|
}
|
|
2577
|
-
let { value: i, nextOffset: a } =
|
|
2578
|
-
a +
|
|
2579
|
-
let
|
|
2580
|
-
if (
|
|
2702
|
+
let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i);
|
|
2703
|
+
a + i > e.byteLength && q("text string extends beyond input");
|
|
2704
|
+
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? Yn(c, i) : void 0;
|
|
2705
|
+
if (d !== void 0) l = d;
|
|
2581
2706
|
else try {
|
|
2582
|
-
|
|
2707
|
+
l = Hn.decode(c);
|
|
2583
2708
|
} catch {
|
|
2584
|
-
|
|
2709
|
+
u = Wn("invalid UTF-8 sequence in text string", a, n), l = Un.decode(c);
|
|
2585
2710
|
}
|
|
2586
|
-
let
|
|
2587
|
-
return
|
|
2588
|
-
value:
|
|
2589
|
-
nextOffset: a +
|
|
2711
|
+
let f = new V(l, { encodingWidth: s });
|
|
2712
|
+
return u && J(f, u), {
|
|
2713
|
+
value: f,
|
|
2714
|
+
nextOffset: a + i
|
|
2590
2715
|
};
|
|
2591
2716
|
}
|
|
2592
2717
|
case 4: {
|
|
@@ -2601,18 +2726,18 @@ function Jn(e, t, n, r) {
|
|
|
2601
2726
|
i.push(t.value), a = t.nextOffset;
|
|
2602
2727
|
}
|
|
2603
2728
|
return {
|
|
2604
|
-
value: new
|
|
2729
|
+
value: new L(i, { indefiniteLength: !0 }),
|
|
2605
2730
|
nextOffset: a
|
|
2606
2731
|
};
|
|
2607
2732
|
}
|
|
2608
|
-
let { value: i, nextOffset: a } =
|
|
2609
|
-
for (let t = 0; t <
|
|
2610
|
-
let t = X(e,
|
|
2611
|
-
|
|
2733
|
+
let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i), c = [], l = a;
|
|
2734
|
+
for (let t = 0; t < i; t++) {
|
|
2735
|
+
let t = X(e, l, n, r);
|
|
2736
|
+
c.push(t.value), l = t.nextOffset;
|
|
2612
2737
|
}
|
|
2613
2738
|
return {
|
|
2614
|
-
value: new
|
|
2615
|
-
nextOffset:
|
|
2739
|
+
value: new L(c, { encodingWidth: s }),
|
|
2740
|
+
nextOffset: l
|
|
2616
2741
|
};
|
|
2617
2742
|
}
|
|
2618
2743
|
case 5: {
|
|
@@ -2624,106 +2749,130 @@ function Jn(e, t, n, r) {
|
|
|
2624
2749
|
break;
|
|
2625
2750
|
}
|
|
2626
2751
|
let t = X(e, s, n, r);
|
|
2627
|
-
|
|
2752
|
+
$n(t.value, a, o, n), s = t.nextOffset;
|
|
2628
2753
|
let c = X(e, s, n, r);
|
|
2629
2754
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2630
2755
|
}
|
|
2631
|
-
let c = new
|
|
2632
|
-
for (let e of o)
|
|
2756
|
+
let c = new R(i, { indefiniteLength: !0 });
|
|
2757
|
+
for (let e of o) J(c, e);
|
|
2633
2758
|
return {
|
|
2634
2759
|
value: c,
|
|
2635
2760
|
nextOffset: s
|
|
2636
2761
|
};
|
|
2637
2762
|
}
|
|
2638
|
-
let { value: i, nextOffset: a } =
|
|
2639
|
-
for (let t = 0; t <
|
|
2640
|
-
let t = X(e,
|
|
2641
|
-
|
|
2642
|
-
let i = X(e,
|
|
2643
|
-
|
|
2763
|
+
let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
2764
|
+
for (let t = 0; t < i; t++) {
|
|
2765
|
+
let t = X(e, d, n, r);
|
|
2766
|
+
$n(t.value, l, u, n), d = t.nextOffset;
|
|
2767
|
+
let i = X(e, d, n, r);
|
|
2768
|
+
d = i.nextOffset, c.push([t.value, i.value]);
|
|
2644
2769
|
}
|
|
2645
|
-
let
|
|
2646
|
-
for (let e of
|
|
2770
|
+
let f = new R(c, { encodingWidth: s });
|
|
2771
|
+
for (let e of u) J(f, e);
|
|
2647
2772
|
return {
|
|
2648
|
-
value:
|
|
2649
|
-
nextOffset:
|
|
2773
|
+
value: f,
|
|
2774
|
+
nextOffset: d
|
|
2650
2775
|
};
|
|
2651
2776
|
}
|
|
2652
2777
|
case 6: {
|
|
2653
2778
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2654
|
-
let { value: i, nextOffset: a } =
|
|
2779
|
+
let { value: i, nextOffset: a } = Xn(e, t, o), s = Bn(o, i), c = X(e, a, n, r);
|
|
2655
2780
|
for (let e of r) {
|
|
2656
2781
|
let t = e.parseTag(i, c.value, n);
|
|
2657
|
-
if (t !== void 0) return t instanceof
|
|
2782
|
+
if (t !== void 0) return t instanceof N && s !== void 0 && (t.encodingWidth = s), {
|
|
2658
2783
|
value: t,
|
|
2659
2784
|
nextOffset: c.nextOffset
|
|
2660
2785
|
};
|
|
2661
2786
|
}
|
|
2662
2787
|
return {
|
|
2663
|
-
value: new
|
|
2788
|
+
value: new N(i, c.value, { encodingWidth: s }),
|
|
2664
2789
|
nextOffset: c.nextOffset
|
|
2665
2790
|
};
|
|
2666
2791
|
}
|
|
2667
2792
|
case 7:
|
|
2668
2793
|
if (o <= 19) return {
|
|
2669
|
-
value: new
|
|
2794
|
+
value: new z(o),
|
|
2670
2795
|
nextOffset: t
|
|
2671
2796
|
};
|
|
2672
2797
|
if (o === 20) return {
|
|
2673
|
-
value: new
|
|
2798
|
+
value: new z(20),
|
|
2674
2799
|
nextOffset: t
|
|
2675
2800
|
};
|
|
2676
2801
|
if (o === 21) return {
|
|
2677
|
-
value: new
|
|
2802
|
+
value: new z(21),
|
|
2678
2803
|
nextOffset: t
|
|
2679
2804
|
};
|
|
2680
2805
|
if (o === 22) return {
|
|
2681
|
-
value: new
|
|
2806
|
+
value: new z(22),
|
|
2682
2807
|
nextOffset: t
|
|
2683
2808
|
};
|
|
2684
2809
|
if (o === 23) return {
|
|
2685
|
-
value: new
|
|
2810
|
+
value: new z(23),
|
|
2686
2811
|
nextOffset: t
|
|
2687
2812
|
};
|
|
2688
2813
|
if (o === 24) {
|
|
2689
2814
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
2690
2815
|
let r = e.getUint8(t);
|
|
2691
2816
|
if (r < 32) {
|
|
2692
|
-
let e =
|
|
2693
|
-
return
|
|
2817
|
+
let e = Wn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new z(r);
|
|
2818
|
+
return J(i, e), {
|
|
2694
2819
|
value: i,
|
|
2695
2820
|
nextOffset: t + 1
|
|
2696
2821
|
};
|
|
2697
2822
|
}
|
|
2698
2823
|
return {
|
|
2699
|
-
value: new
|
|
2824
|
+
value: new z(r),
|
|
2700
2825
|
nextOffset: t + 1
|
|
2701
2826
|
};
|
|
2702
2827
|
}
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2828
|
+
if (o === 25) {
|
|
2829
|
+
t + 2 > e.byteLength && q("unexpected end of input");
|
|
2830
|
+
let n = w(e.getUint16(t, !1));
|
|
2831
|
+
return {
|
|
2832
|
+
value: new M(n, {
|
|
2833
|
+
precision: "half",
|
|
2834
|
+
rawBits: Number.isNaN(n) ? er(e, t, 2) : void 0
|
|
2835
|
+
}),
|
|
2836
|
+
nextOffset: t + 2
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
if (o === 26) {
|
|
2840
|
+
t + 4 > e.byteLength && q("unexpected end of input");
|
|
2841
|
+
let n = e.getFloat32(t, !1);
|
|
2842
|
+
return {
|
|
2843
|
+
value: new M(n, {
|
|
2844
|
+
precision: "single",
|
|
2845
|
+
rawBits: Number.isNaN(n) ? er(e, t, 4) : void 0
|
|
2846
|
+
}),
|
|
2847
|
+
nextOffset: t + 4
|
|
2848
|
+
};
|
|
2849
|
+
}
|
|
2850
|
+
if (o === 27) {
|
|
2851
|
+
t + 8 > e.byteLength && q("unexpected end of input");
|
|
2852
|
+
let n = e.getFloat64(t, !1);
|
|
2853
|
+
return {
|
|
2854
|
+
value: new M(n, {
|
|
2855
|
+
precision: "double",
|
|
2856
|
+
rawBits: Number.isNaN(n) ? er(e, t, 8) : void 0
|
|
2857
|
+
}),
|
|
2858
|
+
nextOffset: t + 8
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
return o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item");
|
|
2713
2862
|
}
|
|
2714
2863
|
return q(`unknown major type: ${a}`);
|
|
2715
2864
|
}
|
|
2716
|
-
function
|
|
2865
|
+
function nr(e) {
|
|
2717
2866
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2718
2867
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2719
2868
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2720
2869
|
}
|
|
2721
|
-
function
|
|
2722
|
-
let n =
|
|
2870
|
+
function rr(e, t) {
|
|
2871
|
+
let n = nr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2723
2872
|
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), ...
|
|
2873
|
+
let a = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...Jn()] : Jn(), { value: o, nextOffset: s } = X(r, i, t, a);
|
|
2725
2874
|
if (!t?.allowTrailing && s !== r.byteLength) {
|
|
2726
|
-
|
|
2875
|
+
J(o, Wn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
|
|
2727
2876
|
let e = {
|
|
2728
2877
|
strict: !1,
|
|
2729
2878
|
silent: !0
|
|
@@ -2734,15 +2883,15 @@ function Xn(e, t) {
|
|
|
2734
2883
|
}
|
|
2735
2884
|
//#endregion
|
|
2736
2885
|
//#region src/extensions/cbordata.ts
|
|
2737
|
-
var
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2886
|
+
var ir = 24n, Z = [
|
|
2887
|
+
Gt,
|
|
2888
|
+
un,
|
|
2889
|
+
pn,
|
|
2890
|
+
zn,
|
|
2742
2891
|
{
|
|
2743
|
-
tagNumbers: [
|
|
2892
|
+
tagNumbers: [ir],
|
|
2744
2893
|
parseTag(e, t, n) {
|
|
2745
|
-
if (e !== 24n || !(t instanceof
|
|
2894
|
+
if (e !== 24n || !(t instanceof P)) return;
|
|
2746
2895
|
let r = n ? {
|
|
2747
2896
|
extensions: n.extensions,
|
|
2748
2897
|
strict: n.strict,
|
|
@@ -2750,65 +2899,76 @@ var Zn = 24n, Z = [
|
|
|
2750
2899
|
silent: n.silent
|
|
2751
2900
|
} : void 0;
|
|
2752
2901
|
try {
|
|
2753
|
-
return new
|
|
2902
|
+
return new N(ir, new He([rr(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2754
2903
|
} catch (e) {
|
|
2755
2904
|
if (r?.strict !== !1) throw e;
|
|
2756
2905
|
return;
|
|
2757
2906
|
}
|
|
2758
2907
|
}
|
|
2759
2908
|
}
|
|
2760
|
-
];
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2909
|
+
], ar;
|
|
2910
|
+
function or() {
|
|
2911
|
+
return ar ??= {
|
|
2912
|
+
fromJS: Z.filter((e) => e.fromJS !== void 0),
|
|
2913
|
+
parseTag: Z.filter((e) => e.parseTag !== void 0)
|
|
2914
|
+
};
|
|
2915
|
+
}
|
|
2916
|
+
function sr(e) {
|
|
2917
|
+
let t = e?.extensions, n = or();
|
|
2918
|
+
return t?.length ? {
|
|
2919
|
+
fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
|
|
2920
|
+
parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
|
|
2921
|
+
} : n;
|
|
2922
|
+
}
|
|
2923
|
+
function cr(e, t) {
|
|
2764
2924
|
if (t?.replacer) {
|
|
2765
|
-
let { replacer: n, ...r } = t, i =
|
|
2766
|
-
return i ===
|
|
2925
|
+
let { replacer: n, ...r } = t, i = ur(e, n, r.extensions, r.undefinedOmits);
|
|
2926
|
+
return i === h ? z.UNDEFINED : cr(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2767
2927
|
}
|
|
2768
|
-
return
|
|
2928
|
+
return Q(e, t, !0, sr(t));
|
|
2769
2929
|
}
|
|
2770
|
-
function
|
|
2771
|
-
for (let n of
|
|
2930
|
+
function Q(e, t, n, r) {
|
|
2931
|
+
for (let n of r.fromJS) {
|
|
2772
2932
|
let r = n.fromJS(e, t ?? {});
|
|
2773
2933
|
if (r !== void 0) return r;
|
|
2774
2934
|
}
|
|
2775
|
-
if (n && typeof e == "object" && e &&
|
|
2776
|
-
let n = e[
|
|
2777
|
-
for (let e of
|
|
2778
|
-
let t = e.parseTag(n,
|
|
2935
|
+
if (n && typeof e == "object" && e && m.symbol in e) {
|
|
2936
|
+
let n = e[m.symbol], i = Q(e, t, !1, r);
|
|
2937
|
+
for (let e of r.parseTag) {
|
|
2938
|
+
let t = e.parseTag(n, i);
|
|
2779
2939
|
if (t !== void 0) return t;
|
|
2780
2940
|
}
|
|
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
|
|
2941
|
+
return new N(n, i);
|
|
2942
|
+
}
|
|
2943
|
+
if (e instanceof m.Null) return z.NULL;
|
|
2944
|
+
if (e instanceof m.Undefined) return z.UNDEFINED;
|
|
2945
|
+
if (e instanceof g) return new z(e.value);
|
|
2946
|
+
if (e === null) return z.NULL;
|
|
2947
|
+
if (e === void 0) return z.UNDEFINED;
|
|
2948
|
+
if (e === !0) return z.TRUE;
|
|
2949
|
+
if (e === !1) return z.FALSE;
|
|
2950
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new $e(e) : e < -18446744073709551616n ? new et(e) : e >= 0n ? new A(e) : new j(e);
|
|
2951
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new A(BigInt(e)) : new j(BigInt(e)) : new M(e);
|
|
2952
|
+
if (typeof e == "string") return new V(e);
|
|
2953
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Q(e.valueOf(), t, !1, r);
|
|
2954
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new P(new Uint8Array(e));
|
|
2955
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new L(Array.from(e, (e) => new A(BigInt(e)))) : new P(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
2956
|
+
if (e instanceof $) return new R([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
|
|
2957
|
+
if (Array.isArray(e)) return new L(e.map((e) => Q(e, t, !0, r)));
|
|
2798
2958
|
if (typeof e == "object") {
|
|
2799
2959
|
let n = [];
|
|
2800
|
-
for (let [
|
|
2801
|
-
return new
|
|
2960
|
+
for (let [i, a] of Object.entries(e)) n.push([new V(i), Q(a, t, !0, r)]);
|
|
2961
|
+
return new R(n);
|
|
2802
2962
|
}
|
|
2803
2963
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2804
2964
|
}
|
|
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
|
|
2965
|
+
function lr(e) {
|
|
2966
|
+
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
2967
|
}
|
|
2808
|
-
function
|
|
2809
|
-
let i = [...n ?? [], ...Z];
|
|
2968
|
+
function ur(e, t, n, r) {
|
|
2969
|
+
let i = [...n ?? [], ...Z].filter((e) => e.isJSType !== void 0);
|
|
2810
2970
|
function a(e) {
|
|
2811
|
-
return e ===
|
|
2971
|
+
return e === h || r === !0 && e === void 0;
|
|
2812
2972
|
}
|
|
2813
2973
|
if (Array.isArray(t)) {
|
|
2814
2974
|
let n = t.map(String);
|
|
@@ -2816,7 +2976,7 @@ function er(e, t, n, r) {
|
|
|
2816
2976
|
if (typeof e != "object" || !e) return e;
|
|
2817
2977
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
2818
2978
|
if (Array.isArray(e)) return e.map(r);
|
|
2819
|
-
if (
|
|
2979
|
+
if (m.symbol in e || lr(e) || i.some((t) => t.isJSType(e))) return e;
|
|
2820
2980
|
let t = Object.getPrototypeOf(e);
|
|
2821
2981
|
if (t === Object.prototype || t === null) {
|
|
2822
2982
|
let t = e.toJSON;
|
|
@@ -2838,7 +2998,7 @@ function er(e, t, n, r) {
|
|
|
2838
2998
|
}
|
|
2839
2999
|
}
|
|
2840
3000
|
if (e = o.call(n, t, e), typeof e == "object" && e) {
|
|
2841
|
-
if (
|
|
3001
|
+
if (m.symbol in e) return e;
|
|
2842
3002
|
if (e instanceof $) {
|
|
2843
3003
|
let t = new $();
|
|
2844
3004
|
for (let [n, r] of e) {
|
|
@@ -2851,7 +3011,7 @@ function er(e, t, n, r) {
|
|
|
2851
3011
|
let r = s(t, String(n), e);
|
|
2852
3012
|
return a(r) ? null : r;
|
|
2853
3013
|
});
|
|
2854
|
-
if (
|
|
3014
|
+
if (lr(e) || i.some((t) => t.isJSType(e))) return e;
|
|
2855
3015
|
let t = {};
|
|
2856
3016
|
for (let n of Object.keys(e)) {
|
|
2857
3017
|
let r = s(e[n], n, e);
|
|
@@ -2869,7 +3029,7 @@ var $ = class extends Array {
|
|
|
2869
3029
|
toJSON() {
|
|
2870
3030
|
let e = {};
|
|
2871
3031
|
for (let [t, n] of this) {
|
|
2872
|
-
let r = typeof t == "string" ? t :
|
|
3032
|
+
let r = typeof t == "string" ? t : cr(t).toCDN();
|
|
2873
3033
|
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
2874
3034
|
value: n,
|
|
2875
3035
|
writable: !0,
|
|
@@ -2881,6 +3041,6 @@ var $ = class extends Array {
|
|
|
2881
3041
|
}
|
|
2882
3042
|
};
|
|
2883
3043
|
//#endregion
|
|
2884
|
-
export {
|
|
3044
|
+
export { C, s as D, o as E, m as O, w as S, h as T, N as _, Kt as a, A as b, et as c, z as d, R as f, P as g, F as h, rr as i, c as k, $e as l, I as m, ur as n, V as o, L as p, cr as r, it as s, $ as t, He as u, M as v, g as w, k as x, j as y };
|
|
2885
3045
|
|
|
2886
|
-
//# sourceMappingURL=mapEntries-
|
|
3046
|
+
//# sourceMappingURL=mapEntries-B8riGPMD.js.map
|