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