@cbortech/cbor 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +35 -37
- package/README.md +35 -37
- package/dist/ast/CborArray.d.ts +3 -3
- package/dist/ast/CborBignum.d.ts +5 -5
- package/dist/ast/CborByteString.d.ts +2 -2
- package/dist/ast/CborEllipsis.d.ts +2 -2
- package/dist/ast/CborEmbeddedCBOR.d.ts +3 -3
- package/dist/ast/CborFloat.d.ts +2 -2
- package/dist/ast/CborIndefiniteByteString.d.ts +3 -3
- package/dist/ast/CborIndefiniteTextString.d.ts +3 -3
- package/dist/ast/CborItem.d.ts +16 -10
- package/dist/ast/CborMap.d.ts +3 -3
- package/dist/ast/CborNint.d.ts +2 -2
- package/dist/ast/CborSimple.d.ts +2 -2
- package/dist/ast/CborTag.d.ts +3 -3
- package/dist/ast/CborTextString.d.ts +2 -2
- package/dist/ast/CborUint.d.ts +2 -2
- package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/cbor.d.ts +44 -26
- package/dist/cdn/parser.d.ts +7 -0
- package/dist/{edn → cdn}/serialize-utils.d.ts +4 -4
- package/dist/cdn/serializer.d.ts +7 -0
- package/dist/{edn → cdn}/tokenizer.d.ts +3 -3
- package/dist/extensions/cri.d.ts +7 -7
- package/dist/extensions/dt.d.ts +9 -9
- package/dist/extensions/ip.d.ts +8 -8
- package/dist/extensions/types.d.ts +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -18
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-CNxwMt7o.cjs +31 -0
- package/dist/mapEntries-CNxwMt7o.cjs.map +1 -0
- package/dist/{mapEntries-D5MWtXqq.js → mapEntries-Da-2HMRf.js} +467 -461
- package/dist/mapEntries-Da-2HMRf.js.map +1 -0
- package/dist/simple.d.ts +2 -2
- package/dist/tag.d.ts +1 -1
- package/dist/types.d.ts +40 -24
- package/dist/utils/hexfloat.d.ts +2 -2
- package/package.json +9 -9
- package/dist/edn/parser.d.ts +0 -7
- package/dist/edn/serializer.d.ts +0 -7
- package/dist/mapEntries-D5MWtXqq.js.map +0 -1
- package/dist/mapEntries-bihZ3yks.cjs +0 -31
- package/dist/mapEntries-bihZ3yks.cjs.map +0 -1
|
@@ -104,15 +104,18 @@ var c = class {
|
|
|
104
104
|
} : e;
|
|
105
105
|
return this._toCBOR(t);
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
toCDN(e) {
|
|
108
108
|
let t = this._defaults ? {
|
|
109
109
|
...this._defaults,
|
|
110
110
|
...e
|
|
111
|
-
} : e, n = this.
|
|
111
|
+
} : e, n = this._toCDN(t, 0);
|
|
112
112
|
if (!t?.preserveComments) return n;
|
|
113
113
|
let r = this.comments?.leading?.map((e) => e.text) ?? [], i = this.comments?.trailing ?? [], a = i.length === 0 ? n : `${n} ${i.map((e) => e.text.trimEnd()).join(" ")}`;
|
|
114
114
|
return [...r, a].join("\n");
|
|
115
115
|
}
|
|
116
|
+
toEDN(e) {
|
|
117
|
+
return this.toCDN(e);
|
|
118
|
+
}
|
|
116
119
|
toJS(e) {
|
|
117
120
|
let t = this._defaults ? {
|
|
118
121
|
...this._defaults,
|
|
@@ -133,7 +136,7 @@ var c = class {
|
|
|
133
136
|
return [{
|
|
134
137
|
depth: e,
|
|
135
138
|
hex: Array.from(this._toCBOR(), (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "),
|
|
136
|
-
comment: this.
|
|
139
|
+
comment: this._toCDN(t, 0)
|
|
137
140
|
}];
|
|
138
141
|
}
|
|
139
142
|
}, f = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, p = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
@@ -238,7 +241,7 @@ var g = class extends d {
|
|
|
238
241
|
_toCBOR(e) {
|
|
239
242
|
return m(0, this.value, this.encodingWidth);
|
|
240
243
|
}
|
|
241
|
-
|
|
244
|
+
_toCDN(e, t) {
|
|
242
245
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.value;
|
|
243
246
|
switch (e?.intFormat) {
|
|
244
247
|
case "hex": return `0x${r.toString(16)}${n}`;
|
|
@@ -267,7 +270,7 @@ var g = class extends d {
|
|
|
267
270
|
_toCBOR(e) {
|
|
268
271
|
return m(1, this.argument, this.encodingWidth);
|
|
269
272
|
}
|
|
270
|
-
|
|
273
|
+
_toCDN(e, t) {
|
|
271
274
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.argument + 1n;
|
|
272
275
|
switch (e?.intFormat) {
|
|
273
276
|
case "hex": return `-0x${r.toString(16)}${n}`;
|
|
@@ -282,7 +285,7 @@ var g = class extends d {
|
|
|
282
285
|
}
|
|
283
286
|
};
|
|
284
287
|
//#endregion
|
|
285
|
-
//#region src/
|
|
288
|
+
//#region src/cdn/serialize-utils.ts
|
|
286
289
|
function v(e) {
|
|
287
290
|
let t = e?.indent;
|
|
288
291
|
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
@@ -290,23 +293,23 @@ function v(e) {
|
|
|
290
293
|
function y(e, t) {
|
|
291
294
|
return e.repeat(t);
|
|
292
295
|
}
|
|
293
|
-
function
|
|
296
|
+
function se(e) {
|
|
294
297
|
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
295
298
|
}
|
|
296
|
-
function
|
|
299
|
+
function ce(e) {
|
|
297
300
|
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
298
301
|
}
|
|
299
|
-
function
|
|
302
|
+
function le(e, t) {
|
|
300
303
|
return (e.comments?.leading ?? []).map((e) => t + e.text);
|
|
301
304
|
}
|
|
302
|
-
function
|
|
305
|
+
function ue(e) {
|
|
303
306
|
let t = e.comments?.trailing ?? [];
|
|
304
307
|
return t.length === 0 ? "" : " " + t.map((e) => e.text).join(" ");
|
|
305
308
|
}
|
|
306
|
-
function
|
|
309
|
+
function de(e, t) {
|
|
307
310
|
return (e.comments?.dangling ?? []).map((e) => t + e.text);
|
|
308
311
|
}
|
|
309
|
-
function
|
|
312
|
+
function fe(e, t = !1) {
|
|
310
313
|
let n = e?.commas ?? "comma", r = n !== "none";
|
|
311
314
|
return {
|
|
312
315
|
inlineSep: r ? t ? "," : ", " : " ",
|
|
@@ -315,18 +318,18 @@ function x(e, t = !1) {
|
|
|
315
318
|
colSep: t ? ":" : ": "
|
|
316
319
|
};
|
|
317
320
|
}
|
|
318
|
-
function
|
|
321
|
+
function pe(e) {
|
|
319
322
|
return typeof e.toHex == "function" ? e.toHex() : Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
320
323
|
}
|
|
321
|
-
var
|
|
322
|
-
function
|
|
323
|
-
if (
|
|
324
|
+
var me = typeof new Uint8Array().toBase64 == "function";
|
|
325
|
+
function he(e) {
|
|
326
|
+
if (me) return e.toBase64({ omitPadding: !0 });
|
|
324
327
|
let t = "";
|
|
325
328
|
for (let n of e) t += String.fromCharCode(n);
|
|
326
329
|
return btoa(t).replace(/=/g, "");
|
|
327
330
|
}
|
|
328
|
-
function
|
|
329
|
-
if (
|
|
331
|
+
function ge(e) {
|
|
332
|
+
if (me) return e.toBase64({
|
|
330
333
|
alphabet: "base64url",
|
|
331
334
|
omitPadding: !0
|
|
332
335
|
});
|
|
@@ -334,44 +337,44 @@ function me(e) {
|
|
|
334
337
|
for (let n of e) t += String.fromCharCode(n);
|
|
335
338
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
336
339
|
}
|
|
337
|
-
var
|
|
338
|
-
function
|
|
340
|
+
var _e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", ve = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
341
|
+
function ye(e, t) {
|
|
339
342
|
let n = "", r = 0, i = 0;
|
|
340
343
|
for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
|
|
341
344
|
return i > 0 && (n += t[r << 5 - i & 31]), n;
|
|
342
345
|
}
|
|
343
|
-
function
|
|
346
|
+
function be(e) {
|
|
344
347
|
for (let t of e) {
|
|
345
348
|
let e = t.codePointAt(0);
|
|
346
349
|
if (e < 32 || e === 127) return !0;
|
|
347
350
|
}
|
|
348
351
|
return !1;
|
|
349
352
|
}
|
|
350
|
-
function
|
|
353
|
+
function xe(e, t, n) {
|
|
351
354
|
if (n === "string") {
|
|
352
|
-
let t =
|
|
353
|
-
if (t != null) return
|
|
355
|
+
let t = Se(e);
|
|
356
|
+
if (t != null) return we(t);
|
|
354
357
|
}
|
|
355
358
|
if (n === "printable-string" || n === void 0) {
|
|
356
|
-
let t =
|
|
357
|
-
if (t != null && !
|
|
359
|
+
let t = Se(e);
|
|
360
|
+
if (t != null && !be(t)) return we(t);
|
|
358
361
|
}
|
|
359
362
|
switch (t) {
|
|
360
|
-
case "base64": return `b64'${
|
|
361
|
-
case "base64url": return `b64'${
|
|
362
|
-
case "base32": return `b32'${
|
|
363
|
-
case "base32hex": return `h32'${
|
|
364
|
-
default: return `h'${
|
|
363
|
+
case "base64": return `b64'${he(e)}'`;
|
|
364
|
+
case "base64url": return `b64'${ge(e)}'`;
|
|
365
|
+
case "base32": return `b32'${ye(e, _e)}'`;
|
|
366
|
+
case "base32hex": return `h32'${ye(e, ve)}'`;
|
|
367
|
+
default: return `h'${pe(e)}'`;
|
|
365
368
|
}
|
|
366
369
|
}
|
|
367
|
-
function
|
|
370
|
+
function Se(e) {
|
|
368
371
|
try {
|
|
369
372
|
return new TextDecoder("utf-8", { fatal: !0 }).decode(e);
|
|
370
373
|
} catch {
|
|
371
374
|
return null;
|
|
372
375
|
}
|
|
373
376
|
}
|
|
374
|
-
function
|
|
377
|
+
function Ce(e, t) {
|
|
375
378
|
let n = t.codePointAt(0), r = t;
|
|
376
379
|
for (let i of e) {
|
|
377
380
|
let e = i.codePointAt(0);
|
|
@@ -396,29 +399,29 @@ function xe(e, t) {
|
|
|
396
399
|
}
|
|
397
400
|
return r + t;
|
|
398
401
|
}
|
|
399
|
-
function Se(e) {
|
|
400
|
-
return xe(e, "'");
|
|
401
|
-
}
|
|
402
|
-
function Ce(e) {
|
|
403
|
-
return xe(e, "'");
|
|
404
|
-
}
|
|
405
402
|
function we(e) {
|
|
406
|
-
return
|
|
403
|
+
return Ce(e, "'");
|
|
407
404
|
}
|
|
408
405
|
function Te(e) {
|
|
406
|
+
return Ce(e, "'");
|
|
407
|
+
}
|
|
408
|
+
function b(e) {
|
|
409
|
+
return Ce(e, "\"");
|
|
410
|
+
}
|
|
411
|
+
function Ee(e) {
|
|
409
412
|
if (isNaN(e)) return "NaN";
|
|
410
413
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
411
414
|
if (Object.is(e, -0)) return "-0.0";
|
|
412
415
|
let t = e.toString();
|
|
413
416
|
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
414
417
|
}
|
|
415
|
-
function
|
|
418
|
+
function De(e, t, n) {
|
|
416
419
|
return t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
417
420
|
}
|
|
418
421
|
//#endregion
|
|
419
422
|
//#region src/utils/hexfloat.ts
|
|
420
|
-
var
|
|
421
|
-
function
|
|
423
|
+
var Oe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
424
|
+
function ke(e) {
|
|
422
425
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
423
426
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
424
427
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -436,20 +439,20 @@ function Oe(e) {
|
|
|
436
439
|
let l = c * 2 ** o;
|
|
437
440
|
return t ? -l : l;
|
|
438
441
|
}
|
|
439
|
-
function
|
|
442
|
+
function Ae(e) {
|
|
440
443
|
if (isNaN(e)) return "NaN";
|
|
441
444
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
442
445
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
443
446
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
444
|
-
|
|
445
|
-
let r =
|
|
447
|
+
Oe.setFloat64(0, n, !1);
|
|
448
|
+
let r = Oe.getUint32(0, !1), i = Oe.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;
|
|
446
449
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
447
450
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
448
451
|
return t ? `-${p}` : p;
|
|
449
452
|
}
|
|
450
453
|
//#endregion
|
|
451
454
|
//#region src/ast/CborFloat.ts
|
|
452
|
-
var
|
|
455
|
+
var x = class extends d {
|
|
453
456
|
value;
|
|
454
457
|
precision;
|
|
455
458
|
constructor(e, t) {
|
|
@@ -468,14 +471,14 @@ var S = class extends d {
|
|
|
468
471
|
let n = new Uint8Array(9);
|
|
469
472
|
return n[0] = 251, new DataView(n.buffer).setFloat64(1, this.value, !1), n;
|
|
470
473
|
}
|
|
471
|
-
|
|
474
|
+
_toCDN(e, t) {
|
|
472
475
|
let n = oe(this.value);
|
|
473
|
-
return (e?.floatFormat === "hex" ?
|
|
476
|
+
return (e?.floatFormat === "hex" ? Ae(this.value) : Ee(this.value)) + De(this.value, this.precision, n);
|
|
474
477
|
}
|
|
475
478
|
_toJS(e) {
|
|
476
479
|
return this.value;
|
|
477
480
|
}
|
|
478
|
-
},
|
|
481
|
+
}, S = class extends d {
|
|
479
482
|
tag;
|
|
480
483
|
content;
|
|
481
484
|
encodingWidth;
|
|
@@ -486,9 +489,9 @@ var S = class extends d {
|
|
|
486
489
|
_toCBOR(e) {
|
|
487
490
|
return h([m(6, this.tag, this.encodingWidth), this.content._toCBOR(e)]);
|
|
488
491
|
}
|
|
489
|
-
|
|
492
|
+
_toCDN(e, t) {
|
|
490
493
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
491
|
-
return `${this.tag}${n}(${this.content.
|
|
494
|
+
return `${this.tag}${n}(${this.content._toCDN(e, t)})`;
|
|
492
495
|
}
|
|
493
496
|
_toHexDump(e, t) {
|
|
494
497
|
let n = [{
|
|
@@ -504,8 +507,8 @@ var S = class extends d {
|
|
|
504
507
|
}
|
|
505
508
|
};
|
|
506
509
|
//#endregion
|
|
507
|
-
//#region src/
|
|
508
|
-
function
|
|
510
|
+
//#region src/cdn/tokenizer.ts
|
|
511
|
+
function je(e, t) {
|
|
509
512
|
let n = 1, r = 1;
|
|
510
513
|
for (let i = 0; i < t; i++) e[i] === "\n" ? (n++, r = 1) : r++;
|
|
511
514
|
return {
|
|
@@ -513,7 +516,7 @@ function Ae(e, t) {
|
|
|
513
516
|
col: r
|
|
514
517
|
};
|
|
515
518
|
}
|
|
516
|
-
var
|
|
519
|
+
var Me = class {
|
|
517
520
|
input;
|
|
518
521
|
pos;
|
|
519
522
|
line;
|
|
@@ -525,7 +528,7 @@ var je = class {
|
|
|
525
528
|
this.input = e;
|
|
526
529
|
let n = t?.offset ?? 0;
|
|
527
530
|
if (!Number.isInteger(n) || n < 0 || n > e.length) throw RangeError(`EDN parse offset must be an integer between 0 and ${e.length}`);
|
|
528
|
-
let r =
|
|
531
|
+
let r = je(e, n);
|
|
529
532
|
this.pos = n, this.line = r.line, this.col = r.col, this._lastConsumedEndOffset = n;
|
|
530
533
|
}
|
|
531
534
|
peek() {
|
|
@@ -1387,7 +1390,7 @@ var je = class {
|
|
|
1387
1390
|
}
|
|
1388
1391
|
this._fail(`unknown identifier ${JSON.stringify(n)}`, e, t);
|
|
1389
1392
|
}
|
|
1390
|
-
},
|
|
1393
|
+
}, C = class extends d {
|
|
1391
1394
|
indefiniteLength = !1;
|
|
1392
1395
|
value;
|
|
1393
1396
|
ednEncoding;
|
|
@@ -1399,16 +1402,16 @@ var je = class {
|
|
|
1399
1402
|
_toCBOR(e) {
|
|
1400
1403
|
return h([m(2, BigInt(this.value.length), this.encodingWidth), this.value]);
|
|
1401
1404
|
}
|
|
1402
|
-
|
|
1405
|
+
_toCDN(e, t) {
|
|
1403
1406
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
1404
1407
|
if (e?.preserveByteString && this.ednSource !== void 0) return this.ednSource + n;
|
|
1405
1408
|
let r = e?.bstrEncoding ?? this.ednEncoding;
|
|
1406
|
-
return
|
|
1409
|
+
return xe(this.value, r, e?.sqstr) + n;
|
|
1407
1410
|
}
|
|
1408
1411
|
_toJS(e) {
|
|
1409
1412
|
return this.value;
|
|
1410
1413
|
}
|
|
1411
|
-
},
|
|
1414
|
+
}, w = class extends d {
|
|
1412
1415
|
indefiniteLength = !0;
|
|
1413
1416
|
chunks;
|
|
1414
1417
|
constructor(e) {
|
|
@@ -1419,8 +1422,8 @@ var je = class {
|
|
|
1419
1422
|
for (let n of this.chunks) t.push(n._toCBOR(e));
|
|
1420
1423
|
return t.push(new Uint8Array([255])), h(t);
|
|
1421
1424
|
}
|
|
1422
|
-
|
|
1423
|
-
return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t.
|
|
1425
|
+
_toCDN(e, t) {
|
|
1426
|
+
return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
1424
1427
|
}
|
|
1425
1428
|
_toHexDump(e, t) {
|
|
1426
1429
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = [{
|
|
@@ -1440,7 +1443,7 @@ var je = class {
|
|
|
1440
1443
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
1441
1444
|
return n;
|
|
1442
1445
|
}
|
|
1443
|
-
},
|
|
1446
|
+
}, T = class extends d {
|
|
1444
1447
|
indefiniteLength = !0;
|
|
1445
1448
|
chunks;
|
|
1446
1449
|
constructor(e) {
|
|
@@ -1451,8 +1454,8 @@ var je = class {
|
|
|
1451
1454
|
for (let n of this.chunks) t.push(n._toCBOR(e));
|
|
1452
1455
|
return t.push(new Uint8Array([255])), h(t);
|
|
1453
1456
|
}
|
|
1454
|
-
|
|
1455
|
-
return this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t.
|
|
1457
|
+
_toCDN(e, t) {
|
|
1458
|
+
return this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
1456
1459
|
}
|
|
1457
1460
|
_toHexDump(e, t) {
|
|
1458
1461
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = [{
|
|
@@ -1470,7 +1473,7 @@ var je = class {
|
|
|
1470
1473
|
_toJS(e) {
|
|
1471
1474
|
return this.chunks.map((e) => e.value).join("");
|
|
1472
1475
|
}
|
|
1473
|
-
},
|
|
1476
|
+
}, E = class extends d {
|
|
1474
1477
|
items;
|
|
1475
1478
|
indefiniteLength;
|
|
1476
1479
|
encodingWidth;
|
|
@@ -1487,22 +1490,22 @@ var je = class {
|
|
|
1487
1490
|
for (let n of this.items) t.push(n._toCBOR(e));
|
|
1488
1491
|
return h(t);
|
|
1489
1492
|
}
|
|
1490
|
-
|
|
1491
|
-
let n = v(e), r = e?.preserveComments, i = r && (
|
|
1493
|
+
_toCDN(e, t) {
|
|
1494
|
+
let n = v(e), r = e?.preserveComments, i = r && (ce(this) || this.items.some(se));
|
|
1492
1495
|
n === null && i && (n = " ");
|
|
1493
|
-
let { inlineSep: a, multilineSep: o, trailSep: s } =
|
|
1496
|
+
let { inlineSep: a, multilineSep: o, trailSep: s } = fe(e, n === null), c = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "";
|
|
1494
1497
|
if (n === null || this.items.length === 0 && !i) {
|
|
1495
|
-
let n = this.items.map((n) => n.
|
|
1498
|
+
let n = this.items.map((n) => n._toCDN(e, t + 1)).join(a);
|
|
1496
1499
|
return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${c}${n}]`;
|
|
1497
1500
|
}
|
|
1498
1501
|
let l = y(n, t + 1), u = y(n, t), d = this.indefiniteLength ? "[_ " : `[${c}`, f = [];
|
|
1499
1502
|
for (let n = 0; n < this.items.length; n++) {
|
|
1500
1503
|
let i = this.items[n];
|
|
1501
|
-
r && f.push(...
|
|
1504
|
+
r && f.push(...le(i, l));
|
|
1502
1505
|
let a = n < this.items.length - 1 ? o : s;
|
|
1503
|
-
f.push(`${l}${i.
|
|
1506
|
+
f.push(`${l}${i._toCDN(e, t + 1)}${a}${r ? ue(i) : ""}`);
|
|
1504
1507
|
}
|
|
1505
|
-
return r && f.push(...
|
|
1508
|
+
return r && f.push(...de(this, l)), `${d}\n${f.join("\n")}\n${u}]`;
|
|
1506
1509
|
}
|
|
1507
1510
|
_toHexDump(e, t) {
|
|
1508
1511
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -1540,7 +1543,7 @@ var je = class {
|
|
|
1540
1543
|
}
|
|
1541
1544
|
return r;
|
|
1542
1545
|
}
|
|
1543
|
-
},
|
|
1546
|
+
}, D = class extends d {
|
|
1544
1547
|
entries;
|
|
1545
1548
|
indefiniteLength;
|
|
1546
1549
|
encodingWidth;
|
|
@@ -1557,26 +1560,26 @@ var je = class {
|
|
|
1557
1560
|
for (let [n, r] of this.entries) t.push(n._toCBOR(e), r._toCBOR(e));
|
|
1558
1561
|
return h(t);
|
|
1559
1562
|
}
|
|
1560
|
-
|
|
1561
|
-
let n = v(e), r = e?.preserveComments, i = r && (
|
|
1563
|
+
_toCDN(e, t) {
|
|
1564
|
+
let n = v(e), r = e?.preserveComments, i = r && (ce(this) || this.entries.some(([e, t]) => se(e) || se(t)));
|
|
1562
1565
|
n === null && i && (n = " ");
|
|
1563
|
-
let { inlineSep: a, multilineSep: o, trailSep: s, colSep: c } =
|
|
1566
|
+
let { inlineSep: a, multilineSep: o, trailSep: s, colSep: c } = fe(e, n === null), l = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "", u = this.indefiniteLength ? "{_ " : `{${l}`;
|
|
1564
1567
|
if (n === null || this.entries.length === 0 && !i) {
|
|
1565
|
-
let n = this.entries.map(([n, r]) => `${n.
|
|
1568
|
+
let n = this.entries.map(([n, r]) => `${n._toCDN(e, t + 1)}${c}${r._toCDN(e, t + 1)}`).join(a);
|
|
1566
1569
|
return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${l}${n}}`;
|
|
1567
1570
|
}
|
|
1568
1571
|
let d = y(n, t + 1), f = y(n, t), p = [];
|
|
1569
1572
|
for (let n = 0; n < this.entries.length; n++) {
|
|
1570
1573
|
let [i, a] = this.entries[n];
|
|
1571
|
-
r && p.push(...
|
|
1572
|
-
let l = n < this.entries.length - 1 ? o : s, u = r ?
|
|
1574
|
+
r && p.push(...le(i, d));
|
|
1575
|
+
let l = n < this.entries.length - 1 ? o : s, u = r ? Ne([
|
|
1573
1576
|
...i.comments?.trailing ?? [],
|
|
1574
1577
|
...a.comments?.leading ?? [],
|
|
1575
1578
|
...a.comments?.trailing ?? []
|
|
1576
1579
|
]) : "";
|
|
1577
|
-
p.push(`${d}${i.
|
|
1580
|
+
p.push(`${d}${i._toCDN(e, t + 1)}${c}${a._toCDN(e, t + 1)}${l}${u}`);
|
|
1578
1581
|
}
|
|
1579
|
-
return r && p.push(...
|
|
1582
|
+
return r && p.push(...de(this, d)), `${u}\n${p.join("\n")}\n${f}}`;
|
|
1580
1583
|
}
|
|
1581
1584
|
_toHexDump(e, t) {
|
|
1582
1585
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -1612,13 +1615,13 @@ var je = class {
|
|
|
1612
1615
|
}
|
|
1613
1616
|
return n;
|
|
1614
1617
|
};
|
|
1615
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
1618
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof N) ? (() => {
|
|
1616
1619
|
let n = e ? {
|
|
1617
1620
|
...e,
|
|
1618
1621
|
reviver: void 0
|
|
1619
1622
|
} : void 0, r = {};
|
|
1620
1623
|
for (let [e, t] of this.entries) {
|
|
1621
|
-
let i = e instanceof
|
|
1624
|
+
let i = e instanceof N ? e.value : e.toCDN(), a = t._toJS(n);
|
|
1622
1625
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
1623
1626
|
value: a,
|
|
1624
1627
|
writable: !0,
|
|
@@ -1630,10 +1633,10 @@ var je = class {
|
|
|
1630
1633
|
let i = /* @__PURE__ */ new Map();
|
|
1631
1634
|
for (let e = 0; e < this.entries.length; e++) {
|
|
1632
1635
|
let [t] = this.entries[e];
|
|
1633
|
-
i.set(t instanceof
|
|
1636
|
+
i.set(t instanceof N ? t.value : t.toCDN(), e);
|
|
1634
1637
|
}
|
|
1635
1638
|
for (let n = 0; n < this.entries.length; n++) {
|
|
1636
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
1639
|
+
let [a, o] = this.entries[n], s = a instanceof N ? a.value : a.toCDN();
|
|
1637
1640
|
if (i.get(s) !== n) continue;
|
|
1638
1641
|
let c = o._toJS(e), u = t.call(r, s, c);
|
|
1639
1642
|
u === l || e?.undefinedOmits && u === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
@@ -1647,12 +1650,12 @@ var je = class {
|
|
|
1647
1650
|
})() : n();
|
|
1648
1651
|
}
|
|
1649
1652
|
};
|
|
1650
|
-
function
|
|
1653
|
+
function Ne(e) {
|
|
1651
1654
|
return e.length === 0 ? "" : " " + e.map((e) => e.text.trimEnd()).join(" ");
|
|
1652
1655
|
}
|
|
1653
1656
|
//#endregion
|
|
1654
1657
|
//#region src/ast/CborSimple.ts
|
|
1655
|
-
var
|
|
1658
|
+
var O = class e extends d {
|
|
1656
1659
|
value;
|
|
1657
1660
|
constructor(e) {
|
|
1658
1661
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
@@ -1665,7 +1668,7 @@ var k = class e extends d {
|
|
|
1665
1668
|
_toCBOR(e) {
|
|
1666
1669
|
return this.value <= 23 ? new Uint8Array([224 | this.value]) : new Uint8Array([248, this.value]);
|
|
1667
1670
|
}
|
|
1668
|
-
|
|
1671
|
+
_toCDN(e, t) {
|
|
1669
1672
|
switch (this.value) {
|
|
1670
1673
|
case 20: return "false";
|
|
1671
1674
|
case 21: return "true";
|
|
@@ -1683,7 +1686,7 @@ var k = class e extends d {
|
|
|
1683
1686
|
default: return new u(this.value);
|
|
1684
1687
|
}
|
|
1685
1688
|
}
|
|
1686
|
-
},
|
|
1689
|
+
}, k = class extends d {
|
|
1687
1690
|
items;
|
|
1688
1691
|
constructor(e) {
|
|
1689
1692
|
super(), this.items = e;
|
|
@@ -1695,11 +1698,11 @@ var k = class e extends d {
|
|
|
1695
1698
|
let t = this._content(e);
|
|
1696
1699
|
return h([m(2, BigInt(t.length)), t]);
|
|
1697
1700
|
}
|
|
1698
|
-
|
|
1701
|
+
_toCDN(e, t) {
|
|
1699
1702
|
if (this.items.length === 0) return "<<>>";
|
|
1700
|
-
let n = v(e), { inlineSep: r, multilineSep: i, trailSep: a } =
|
|
1701
|
-
if (n === null) return `<<${this.items.map((n) => n.
|
|
1702
|
-
let o = y(n, t + 1), s = y(n, t), c = this.items.map((n) => `${o}${n.
|
|
1703
|
+
let n = v(e), { inlineSep: r, multilineSep: i, trailSep: a } = fe(e, n === null);
|
|
1704
|
+
if (n === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(r)}>>`;
|
|
1705
|
+
let o = y(n, t + 1), s = y(n, t), c = this.items.map((n) => `${o}${n._toCDN(e, t + 1)}`), l = c.length - 1;
|
|
1703
1706
|
return `<<\n${c.map((e, t) => t < l ? `${e}${i}` : `${e}${a}`).join("\n")}\n${s}>>`;
|
|
1704
1707
|
}
|
|
1705
1708
|
_toHexDump(e, t) {
|
|
@@ -1714,24 +1717,24 @@ var k = class e extends d {
|
|
|
1714
1717
|
_toJS(e) {
|
|
1715
1718
|
return this._content();
|
|
1716
1719
|
}
|
|
1717
|
-
},
|
|
1720
|
+
}, Pe = 999n, Fe = class extends S {
|
|
1718
1721
|
constructor(e, t) {
|
|
1719
|
-
let n = t.length === 1 && t[0] instanceof
|
|
1720
|
-
super(
|
|
1722
|
+
let n = t.length === 1 && t[0] instanceof N ? t[0] : new E(t);
|
|
1723
|
+
super(Pe, new E([new N(e), n]));
|
|
1721
1724
|
}
|
|
1722
|
-
|
|
1725
|
+
_toCDN(e, t) {
|
|
1723
1726
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1724
|
-
return i instanceof
|
|
1727
|
+
return i instanceof N ? `${r}${Te(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1725
1728
|
}
|
|
1726
|
-
},
|
|
1729
|
+
}, Ie = 888n, A = class extends S {
|
|
1727
1730
|
constructor(e) {
|
|
1728
|
-
e === void 0 ? super(
|
|
1731
|
+
e === void 0 ? super(Ie, O.NULL) : super(Ie, new E(e));
|
|
1729
1732
|
}
|
|
1730
|
-
|
|
1731
|
-
return this.content instanceof
|
|
1733
|
+
_toCDN(e, t) {
|
|
1734
|
+
return this.content instanceof O ? "..." : this.content instanceof E ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
1732
1735
|
}
|
|
1733
|
-
},
|
|
1734
|
-
function
|
|
1736
|
+
}, Le = 2n, Re = 3n, ze = 18446744073709551615n, Be = -(ze + 1n);
|
|
1737
|
+
function Ve(e) {
|
|
1735
1738
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1736
1739
|
if (e === 0n) return new Uint8Array();
|
|
1737
1740
|
let t = e.toString(16);
|
|
@@ -1740,30 +1743,30 @@ function Be(e) {
|
|
|
1740
1743
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1741
1744
|
return n;
|
|
1742
1745
|
}
|
|
1743
|
-
function
|
|
1746
|
+
function He(e) {
|
|
1744
1747
|
let t = 0n;
|
|
1745
1748
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1746
1749
|
return t;
|
|
1747
1750
|
}
|
|
1748
|
-
var
|
|
1751
|
+
var j = class extends S {
|
|
1749
1752
|
bigValue;
|
|
1750
1753
|
constructor(e) {
|
|
1751
|
-
if (e <=
|
|
1752
|
-
super(
|
|
1754
|
+
if (e <= ze) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1755
|
+
super(Le, new C(Ve(e))), this.bigValue = e;
|
|
1753
1756
|
}
|
|
1754
|
-
|
|
1757
|
+
_toCDN(e, t) {
|
|
1755
1758
|
return this.bigValue.toString();
|
|
1756
1759
|
}
|
|
1757
1760
|
_toJS(e) {
|
|
1758
1761
|
return this.bigValue;
|
|
1759
1762
|
}
|
|
1760
|
-
},
|
|
1763
|
+
}, M = class extends S {
|
|
1761
1764
|
bigValue;
|
|
1762
1765
|
constructor(e) {
|
|
1763
|
-
if (e >=
|
|
1764
|
-
super(
|
|
1766
|
+
if (e >= Be) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1767
|
+
super(Re, new C(Ve(-1n - e))), this.bigValue = e;
|
|
1765
1768
|
}
|
|
1766
|
-
|
|
1769
|
+
_toCDN(e, t) {
|
|
1767
1770
|
return this.bigValue.toString();
|
|
1768
1771
|
}
|
|
1769
1772
|
_toJS(e) {
|
|
@@ -1771,12 +1774,12 @@ var M = class extends C {
|
|
|
1771
1774
|
}
|
|
1772
1775
|
};
|
|
1773
1776
|
//#endregion
|
|
1774
|
-
//#region src/
|
|
1775
|
-
function
|
|
1776
|
-
let n = new
|
|
1777
|
-
return t?.preserveComments &&
|
|
1777
|
+
//#region src/cdn/parser.ts
|
|
1778
|
+
function Ue(e, t) {
|
|
1779
|
+
let n = new Me(e, { offset: t?.offset }), r = new nt(n, t?.extensions, t?.unresolvedExtension, t?.allowInvalidUtf8, t?.allowTrailing).parse();
|
|
1780
|
+
return t?.preserveComments && Qe(r, n.comments, e), r;
|
|
1778
1781
|
}
|
|
1779
|
-
function
|
|
1782
|
+
function We(e) {
|
|
1780
1783
|
let t = e, n;
|
|
1781
1784
|
if (/[_][0-3i]$/.test(e)) {
|
|
1782
1785
|
let r = e[e.length - 1];
|
|
@@ -1787,10 +1790,10 @@ function Ue(e) {
|
|
|
1787
1790
|
encodingWidth: n
|
|
1788
1791
|
};
|
|
1789
1792
|
}
|
|
1790
|
-
function
|
|
1793
|
+
function Ge(e) {
|
|
1791
1794
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1792
1795
|
}
|
|
1793
|
-
function
|
|
1796
|
+
function Ke(e) {
|
|
1794
1797
|
if (e === "NaN") return {
|
|
1795
1798
|
value: NaN,
|
|
1796
1799
|
precision: void 0
|
|
@@ -1806,22 +1809,22 @@ function Ge(e) {
|
|
|
1806
1809
|
if (e.endsWith("_i") || e.endsWith("_0")) throw SyntaxError("EDN parse error: _0 and _i encoding indicators are not valid for floating-point values");
|
|
1807
1810
|
let t = e, n;
|
|
1808
1811
|
return e.endsWith("_1") ? (n = "half", t = e.slice(0, -2)) : e.endsWith("_2") ? (n = "single", t = e.slice(0, -2)) : e.endsWith("_3") && (n = "double", t = e.slice(0, -2)), /^-?0[xX]/.test(t) ? {
|
|
1809
|
-
value:
|
|
1812
|
+
value: ke(t),
|
|
1810
1813
|
precision: n
|
|
1811
1814
|
} : {
|
|
1812
1815
|
value: parseFloat(t),
|
|
1813
1816
|
precision: n
|
|
1814
1817
|
};
|
|
1815
1818
|
}
|
|
1816
|
-
function
|
|
1819
|
+
function qe(e) {
|
|
1817
1820
|
if (typeof Uint8Array.fromHex == "function") return Uint8Array.fromHex(e);
|
|
1818
1821
|
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
1819
1822
|
let t = new Uint8Array(e.length / 2);
|
|
1820
1823
|
for (let n = 0; n < e.length; n += 2) t[n / 2] = parseInt(e.slice(n, n + 2), 16);
|
|
1821
1824
|
return t;
|
|
1822
1825
|
}
|
|
1823
|
-
var
|
|
1824
|
-
function
|
|
1826
|
+
var Je = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", Ye = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
1827
|
+
function Xe(e, t) {
|
|
1825
1828
|
let n = e.replace(/=+$/, "").toUpperCase(), r = n.length % 8;
|
|
1826
1829
|
if (r === 1 || r === 3 || r === 6) throw SyntaxError(`invalid base32 length: ${n.length} characters`);
|
|
1827
1830
|
let i = new Uint8Array(128).fill(255);
|
|
@@ -1835,7 +1838,7 @@ function Ye(e, t) {
|
|
|
1835
1838
|
if (s > 0 && o & (1 << s) - 1) throw SyntaxError("non-zero trailing bits in base32 input");
|
|
1836
1839
|
return a;
|
|
1837
1840
|
}
|
|
1838
|
-
function
|
|
1841
|
+
function Ze(e) {
|
|
1839
1842
|
if (typeof Uint8Array.fromBase64 == "function") {
|
|
1840
1843
|
let t = /[-_]/.test(e) ? "base64url" : "base64";
|
|
1841
1844
|
return Uint8Array.fromBase64(e, {
|
|
@@ -1847,49 +1850,49 @@ function Xe(e) {
|
|
|
1847
1850
|
for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
|
|
1848
1851
|
return i;
|
|
1849
1852
|
}
|
|
1850
|
-
function
|
|
1853
|
+
function Qe(e, t, n) {
|
|
1851
1854
|
if (t.length === 0) return;
|
|
1852
|
-
let r =
|
|
1855
|
+
let r = $e(e), i = tt(n);
|
|
1853
1856
|
for (let a of t) {
|
|
1854
1857
|
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) : "";
|
|
1855
1858
|
if (o && i(o.end) === a.line && !s.includes(":")) {
|
|
1856
|
-
|
|
1859
|
+
et(o.node, "trailing", t);
|
|
1857
1860
|
continue;
|
|
1858
1861
|
}
|
|
1859
1862
|
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];
|
|
1860
1863
|
if ((!c || l && l.end <= c.end) && l) {
|
|
1861
|
-
|
|
1864
|
+
et(l.node, "leading", t);
|
|
1862
1865
|
continue;
|
|
1863
1866
|
}
|
|
1864
|
-
|
|
1867
|
+
et(c?.node ?? e, "dangling", t);
|
|
1865
1868
|
}
|
|
1866
1869
|
}
|
|
1867
|
-
function
|
|
1870
|
+
function $e(e) {
|
|
1868
1871
|
let t = [], n = (e) => {
|
|
1869
1872
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1870
1873
|
node: e,
|
|
1871
1874
|
start: e.start,
|
|
1872
1875
|
end: e.end
|
|
1873
|
-
}), e instanceof
|
|
1876
|
+
}), e instanceof E || e instanceof k) {
|
|
1874
1877
|
for (let t of e.items) n(t);
|
|
1875
1878
|
return;
|
|
1876
1879
|
}
|
|
1877
|
-
if (e instanceof
|
|
1880
|
+
if (e instanceof D) {
|
|
1878
1881
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1879
1882
|
return;
|
|
1880
1883
|
}
|
|
1881
|
-
if (e instanceof
|
|
1884
|
+
if (e instanceof w || e instanceof T) {
|
|
1882
1885
|
for (let t of e.chunks) n(t);
|
|
1883
1886
|
return;
|
|
1884
1887
|
}
|
|
1885
|
-
e instanceof
|
|
1888
|
+
e instanceof S && n(e.content);
|
|
1886
1889
|
};
|
|
1887
1890
|
return n(e), t;
|
|
1888
1891
|
}
|
|
1889
|
-
function
|
|
1892
|
+
function et(e, t, n) {
|
|
1890
1893
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1891
1894
|
}
|
|
1892
|
-
function
|
|
1895
|
+
function tt(e) {
|
|
1893
1896
|
let t = [0];
|
|
1894
1897
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1895
1898
|
return (n) => {
|
|
@@ -1903,7 +1906,7 @@ function $e(e) {
|
|
|
1903
1906
|
return a + 1;
|
|
1904
1907
|
};
|
|
1905
1908
|
}
|
|
1906
|
-
var
|
|
1909
|
+
var nt = class {
|
|
1907
1910
|
t;
|
|
1908
1911
|
allowInvalidUtf8;
|
|
1909
1912
|
allowTrailing;
|
|
@@ -1939,12 +1942,12 @@ var et = class {
|
|
|
1939
1942
|
case "BYTES_B64":
|
|
1940
1943
|
case "BYTES_B32":
|
|
1941
1944
|
case "BYTES_H32": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1942
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1943
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1944
|
-
case "TRUE": return this.t.consume(),
|
|
1945
|
-
case "FALSE": return this.t.consume(),
|
|
1946
|
-
case "NULL": return this.t.consume(),
|
|
1947
|
-
case "UNDEFINED": return this.t.consume(),
|
|
1945
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new w([]);
|
|
1946
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new T([]);
|
|
1947
|
+
case "TRUE": return this.t.consume(), O.TRUE;
|
|
1948
|
+
case "FALSE": return this.t.consume(), O.FALSE;
|
|
1949
|
+
case "NULL": return this.t.consume(), O.NULL;
|
|
1950
|
+
case "UNDEFINED": return this.t.consume(), O.UNDEFINED;
|
|
1948
1951
|
case "SIMPLE": return this.parseSimple();
|
|
1949
1952
|
case "LBRACKET": return this.parseArray();
|
|
1950
1953
|
case "LBRACE": return this.parseMap();
|
|
@@ -1954,7 +1957,7 @@ var et = class {
|
|
|
1954
1957
|
this.t.consume();
|
|
1955
1958
|
let t = this.extByPrefix.get(e.appPrefix);
|
|
1956
1959
|
if (!t?.parseAppString) {
|
|
1957
|
-
if (this.unresolvedExtension === "cpa999") return new
|
|
1960
|
+
if (this.unresolvedExtension === "cpa999") return new Fe(e.appPrefix, [new N(e.value)]);
|
|
1958
1961
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1959
1962
|
}
|
|
1960
1963
|
return t.parseAppString(e.appPrefix, e.value);
|
|
@@ -1966,25 +1969,25 @@ var et = class {
|
|
|
1966
1969
|
this.expect("GT_GT");
|
|
1967
1970
|
let n = this.extByPrefix.get(e.appPrefix);
|
|
1968
1971
|
if (!n) {
|
|
1969
|
-
if (this.unresolvedExtension === "cpa999") return new
|
|
1972
|
+
if (this.unresolvedExtension === "cpa999") return new Fe(e.appPrefix, t);
|
|
1970
1973
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1971
1974
|
}
|
|
1972
1975
|
return n.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e), n.parseAppSequence(e.appPrefix, t);
|
|
1973
1976
|
}
|
|
1974
1977
|
case "ELLIPSIS": {
|
|
1975
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1976
|
-
let e = [new
|
|
1978
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new A();
|
|
1979
|
+
let e = [new A()];
|
|
1977
1980
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1978
|
-
return new
|
|
1981
|
+
return new A(e);
|
|
1979
1982
|
}
|
|
1980
1983
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1981
1984
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1982
1985
|
}
|
|
1983
1986
|
}
|
|
1984
1987
|
parseIntegerOrTag() {
|
|
1985
|
-
let e = this.t.consume(), { numStr: t, encodingWidth: n } =
|
|
1986
|
-
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new
|
|
1987
|
-
if (i < -18446744073709551616n) return new
|
|
1988
|
+
let e = this.t.consume(), { numStr: t, encodingWidth: n } = We(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : n, i = Ge(t);
|
|
1989
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new j(i);
|
|
1990
|
+
if (i < -18446744073709551616n) return new M(i);
|
|
1988
1991
|
let a = i >= 0n ? new g(i, r === void 0 ? void 0 : { encodingWidth: r }) : new _(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1989
1992
|
if (this.t.peek().type === "LPAREN") {
|
|
1990
1993
|
a instanceof g || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
@@ -1995,19 +1998,19 @@ var et = class {
|
|
|
1995
1998
|
let e = i.parseTag(n, t);
|
|
1996
1999
|
if (e !== void 0) return e;
|
|
1997
2000
|
}
|
|
1998
|
-
return new
|
|
2001
|
+
return new S(n, t, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1999
2002
|
}
|
|
2000
2003
|
return a;
|
|
2001
2004
|
}
|
|
2002
2005
|
parseFloat() {
|
|
2003
|
-
let { value: e, precision: t } =
|
|
2004
|
-
return new
|
|
2006
|
+
let { value: e, precision: t } = Ke(this.t.consume().value);
|
|
2007
|
+
return new x(e, t === void 0 ? void 0 : { precision: t });
|
|
2005
2008
|
}
|
|
2006
2009
|
parseString() {
|
|
2007
2010
|
let e = this.t.consume();
|
|
2008
2011
|
if (this.t.peek().type !== "PLUS") {
|
|
2009
2012
|
let t = this.consumeEncodingIndicator();
|
|
2010
|
-
return new
|
|
2013
|
+
return new N(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
2011
2014
|
}
|
|
2012
2015
|
let t = !1, n = [{ text: e.value }];
|
|
2013
2016
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -2017,11 +2020,11 @@ var et = class {
|
|
|
2017
2020
|
}
|
|
2018
2021
|
if (!t) {
|
|
2019
2022
|
let e = this.consumeEncodingIndicator();
|
|
2020
|
-
return new
|
|
2023
|
+
return new N(n.map((e) => "text" in e ? e.text : "").join(""), e === void 0 ? void 0 : { encodingWidth: e });
|
|
2021
2024
|
}
|
|
2022
2025
|
let r = [], i = "";
|
|
2023
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
2024
|
-
return i !== "" && r.push(new
|
|
2026
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new N(i)), i = ""), r.push(new A())) : i += e.text;
|
|
2027
|
+
return i !== "" && r.push(new N(i)), new A(r);
|
|
2025
2028
|
}
|
|
2026
2029
|
_isBytesToken(e) {
|
|
2027
2030
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64" || e === "BYTES_B32" || e === "BYTES_H32";
|
|
@@ -2029,10 +2032,10 @@ var et = class {
|
|
|
2029
2032
|
_decodeBytesToken(e) {
|
|
2030
2033
|
switch (e.type) {
|
|
2031
2034
|
case "BYTES_HEX":
|
|
2032
|
-
case "SQSTR": return
|
|
2033
|
-
case "BYTES_B64": return
|
|
2034
|
-
case "BYTES_B32": return
|
|
2035
|
-
case "BYTES_H32": return
|
|
2035
|
+
case "SQSTR": return qe(e.value);
|
|
2036
|
+
case "BYTES_B64": return Ze(e.value);
|
|
2037
|
+
case "BYTES_B32": return Xe(e.value, Je);
|
|
2038
|
+
case "BYTES_H32": return Xe(e.value, Ye);
|
|
2036
2039
|
default: this._fail("expected byte string token", e);
|
|
2037
2040
|
}
|
|
2038
2041
|
}
|
|
@@ -2044,7 +2047,7 @@ var et = class {
|
|
|
2044
2047
|
this._fail("byte string in text concatenation is not valid UTF-8", t);
|
|
2045
2048
|
}
|
|
2046
2049
|
}
|
|
2047
|
-
|
|
2050
|
+
_tokenTypeToCdnEncoding(e) {
|
|
2048
2051
|
switch (e) {
|
|
2049
2052
|
case "BYTES_B64": return "base64";
|
|
2050
2053
|
case "BYTES_B32": return "base32";
|
|
@@ -2055,8 +2058,8 @@ var et = class {
|
|
|
2055
2058
|
_parseBytesConcat(e, t, n) {
|
|
2056
2059
|
if (this.t.peek().type !== "PLUS") {
|
|
2057
2060
|
let r = this.consumeEncodingIndicator();
|
|
2058
|
-
return new
|
|
2059
|
-
ednEncoding: this.
|
|
2061
|
+
return new C(e, {
|
|
2062
|
+
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
2060
2063
|
ednSource: n,
|
|
2061
2064
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
2062
2065
|
});
|
|
@@ -2069,25 +2072,25 @@ var et = class {
|
|
|
2069
2072
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
2070
2073
|
this.t.consume();
|
|
2071
2074
|
let t = this._buildBytesElidedItems(e.value);
|
|
2072
|
-
for (let e of t) e instanceof
|
|
2075
|
+
for (let e of t) e instanceof A ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof C && i.push({ bytes: e.value });
|
|
2073
2076
|
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), i.push({ bytes: new TextEncoder().encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2074
2077
|
}
|
|
2075
2078
|
if (!r) {
|
|
2076
2079
|
let e = this.consumeEncodingIndicator(), t = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array());
|
|
2077
|
-
return new
|
|
2080
|
+
return new C(this._concatBytes(t), e === void 0 ? void 0 : { encodingWidth: e });
|
|
2078
2081
|
}
|
|
2079
2082
|
let a = [], o = [], s = () => {
|
|
2080
|
-
o.length > 0 && (a.push(new
|
|
2083
|
+
o.length > 0 && (a.push(new C(this._concatBytes([...o]))), o.length = 0);
|
|
2081
2084
|
};
|
|
2082
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
2083
|
-
return s(), new
|
|
2085
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new A())) : o.push(e.bytes);
|
|
2086
|
+
return s(), new A(a);
|
|
2084
2087
|
}
|
|
2085
2088
|
_parseHexElidedConcat(e) {
|
|
2086
2089
|
let t = this._buildBytesElidedItems(e.value);
|
|
2087
2090
|
for (; this.t.peek().type === "PLUS";) {
|
|
2088
2091
|
this.t.consume();
|
|
2089
2092
|
let e = this.t.peek();
|
|
2090
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
2093
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new A());
|
|
2091
2094
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
2092
2095
|
this.t.consume();
|
|
2093
2096
|
let n = this._buildBytesElidedItems(e.value);
|
|
@@ -2095,20 +2098,20 @@ var et = class {
|
|
|
2095
2098
|
} else if (this._isBytesToken(e.type)) {
|
|
2096
2099
|
this.t.consume();
|
|
2097
2100
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
2098
|
-
r instanceof
|
|
2101
|
+
r instanceof C ? t[t.length - 1] = new C(this._concatBytes([r.value, n])) : t.push(new C(n));
|
|
2099
2102
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2100
2103
|
}
|
|
2101
|
-
return new
|
|
2104
|
+
return new A(t);
|
|
2102
2105
|
}
|
|
2103
2106
|
_buildBytesElidedItems(e) {
|
|
2104
2107
|
let t = e.split("..."), n = [];
|
|
2105
|
-
for (let e = 0; e < t.length; e++) e > 0 && n.push(new
|
|
2108
|
+
for (let e = 0; e < t.length; e++) e > 0 && n.push(new A()), t[e].length > 0 && n.push(new C(qe(t[e])));
|
|
2106
2109
|
return n;
|
|
2107
2110
|
}
|
|
2108
2111
|
_mergeFirstBytesItem(e, t) {
|
|
2109
2112
|
if (t.length === 0) return;
|
|
2110
2113
|
let n = e[e.length - 1], r = t[0];
|
|
2111
|
-
n instanceof
|
|
2114
|
+
n instanceof C && r instanceof C ? (e[e.length - 1] = new C(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
2112
2115
|
}
|
|
2113
2116
|
_concatBytes(e) {
|
|
2114
2117
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -2119,14 +2122,14 @@ var et = class {
|
|
|
2119
2122
|
this.t.consume(), this.expect("LPAREN");
|
|
2120
2123
|
let e = this.t.peek();
|
|
2121
2124
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
2122
|
-
let { numStr: t } =
|
|
2123
|
-
return this.expect("RPAREN"), new
|
|
2125
|
+
let { numStr: t } = We(e.value), n = Number(Ge(t));
|
|
2126
|
+
return this.expect("RPAREN"), new O(n);
|
|
2124
2127
|
}
|
|
2125
2128
|
parseEmbeddedCBOR() {
|
|
2126
2129
|
this.t.consume();
|
|
2127
2130
|
let e = [];
|
|
2128
2131
|
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());
|
|
2129
|
-
return this.expect("GT_GT"), new
|
|
2132
|
+
return this.expect("GT_GT"), new k(e);
|
|
2130
2133
|
}
|
|
2131
2134
|
parseArray() {
|
|
2132
2135
|
this.t.consume();
|
|
@@ -2138,7 +2141,7 @@ var et = class {
|
|
|
2138
2141
|
}
|
|
2139
2142
|
let n = [];
|
|
2140
2143
|
for (; this.t.peek().type !== "RBRACKET" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACKET"));) n.push(this.parseValue());
|
|
2141
|
-
return this.expect("RBRACKET"), new
|
|
2144
|
+
return this.expect("RBRACKET"), new E(n, {
|
|
2142
2145
|
indefiniteLength: e,
|
|
2143
2146
|
encodingWidth: t
|
|
2144
2147
|
});
|
|
@@ -2158,7 +2161,7 @@ var et = class {
|
|
|
2158
2161
|
let t = this.parseValue();
|
|
2159
2162
|
n.push([e, t]);
|
|
2160
2163
|
}
|
|
2161
|
-
return this.expect("RBRACE"), new
|
|
2164
|
+
return this.expect("RBRACE"), new D(n, {
|
|
2162
2165
|
indefiniteLength: e,
|
|
2163
2166
|
encodingWidth: t
|
|
2164
2167
|
});
|
|
@@ -2171,12 +2174,12 @@ var et = class {
|
|
|
2171
2174
|
for (; this.t.peek().type !== "RPAREN" && !(t.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RPAREN"));) t.push(this.parseValue());
|
|
2172
2175
|
this.expect("RPAREN"), t.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
2173
2176
|
let n = t[0];
|
|
2174
|
-
if (n instanceof
|
|
2175
|
-
if (e instanceof
|
|
2177
|
+
if (n instanceof C) return new w(t.map((e, t) => {
|
|
2178
|
+
if (e instanceof C) return e;
|
|
2176
2179
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
2177
2180
|
}));
|
|
2178
|
-
if (n instanceof
|
|
2179
|
-
if (e instanceof
|
|
2181
|
+
if (n instanceof N) return new T(t.map((e, t) => {
|
|
2182
|
+
if (e instanceof N) return e;
|
|
2180
2183
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
2181
2184
|
}));
|
|
2182
2185
|
this._fail("indefinite group chunks must be byte strings or text strings");
|
|
@@ -2195,7 +2198,7 @@ var et = class {
|
|
|
2195
2198
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
2196
2199
|
throw SyntaxError(`EDN parse error${n}: ${e}`);
|
|
2197
2200
|
}
|
|
2198
|
-
},
|
|
2201
|
+
}, rt = new TextEncoder(), it = !1, N = class extends d {
|
|
2199
2202
|
indefiniteLength = !1;
|
|
2200
2203
|
value;
|
|
2201
2204
|
encodingWidth;
|
|
@@ -2203,30 +2206,30 @@ var et = class {
|
|
|
2203
2206
|
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
2204
2207
|
}
|
|
2205
2208
|
_toCBOR(e) {
|
|
2206
|
-
let t =
|
|
2209
|
+
let t = rt.encode(this.value);
|
|
2207
2210
|
return h([m(3, BigInt(t.length), this.encodingWidth), t]);
|
|
2208
2211
|
}
|
|
2209
|
-
|
|
2212
|
+
_toCDN(e, t) {
|
|
2210
2213
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
2211
|
-
return
|
|
2214
|
+
return at(this.value, n, e, t);
|
|
2212
2215
|
}
|
|
2213
2216
|
_toJS(e) {
|
|
2214
2217
|
return this.value;
|
|
2215
2218
|
}
|
|
2216
2219
|
};
|
|
2217
|
-
function
|
|
2218
|
-
let i = n?.textStringFormat ?? [], a = v(n);
|
|
2219
|
-
if (i.length === 0 || a === null) return
|
|
2220
|
+
function at(e, t, n, r) {
|
|
2221
|
+
let i = ot(n?.textStringFormat ?? []), a = v(n);
|
|
2222
|
+
if (i.length === 0 || a === null) return b(e) + t;
|
|
2220
2223
|
let o = /* @__PURE__ */ new Map(), s = null;
|
|
2221
|
-
if (i.includes("
|
|
2224
|
+
if (i.includes("cdn") && (s = ct(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
|
|
2222
2225
|
if (i.includes("newline")) {
|
|
2223
|
-
let t = s === null ?
|
|
2226
|
+
let t = s === null ? st(e, 0) : lt(e);
|
|
2224
2227
|
for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
|
|
2225
2228
|
}
|
|
2226
|
-
let c =
|
|
2227
|
-
if (c.length <= 1) return
|
|
2229
|
+
let c = gt(e, o);
|
|
2230
|
+
if (c.length <= 1) return b(e) + t;
|
|
2228
2231
|
let l = c.map(({ text: e }, n) => {
|
|
2229
|
-
let r =
|
|
2232
|
+
let r = b(e);
|
|
2230
2233
|
return n === c.length - 1 ? r + t : r;
|
|
2231
2234
|
}), u = l[0];
|
|
2232
2235
|
for (let e = 1; e < l.length; e++) {
|
|
@@ -2235,7 +2238,10 @@ function nt(e, t, n, r) {
|
|
|
2235
2238
|
}
|
|
2236
2239
|
return u;
|
|
2237
2240
|
}
|
|
2238
|
-
function
|
|
2241
|
+
function ot(e) {
|
|
2242
|
+
return e.map((e) => e === "cboredn" ? (it || (it = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
2243
|
+
}
|
|
2244
|
+
function st(e, t) {
|
|
2239
2245
|
let n = [];
|
|
2240
2246
|
for (let r = 0; r < e.length; r++) {
|
|
2241
2247
|
let i = e[r];
|
|
@@ -2252,35 +2258,35 @@ function rt(e, t) {
|
|
|
2252
2258
|
}
|
|
2253
2259
|
return n;
|
|
2254
2260
|
}
|
|
2255
|
-
function
|
|
2261
|
+
function ct(e) {
|
|
2256
2262
|
try {
|
|
2257
|
-
|
|
2263
|
+
Ue(e);
|
|
2258
2264
|
} catch {
|
|
2259
2265
|
return null;
|
|
2260
2266
|
}
|
|
2261
|
-
let t = [], n = new
|
|
2267
|
+
let t = [], n = new Me(e), r = 0, i = null, a = !1, o = 0;
|
|
2262
2268
|
for (;;) {
|
|
2263
2269
|
let s = n.consume();
|
|
2264
2270
|
if (s.type === "EOF") break;
|
|
2265
2271
|
let c = !1;
|
|
2266
|
-
if (a || (a = !0, s.offset > 0 &&
|
|
2272
|
+
if (a || (a = !0, s.offset > 0 && mt(n.comments, 0, s.offset) && t.push({
|
|
2267
2273
|
point: s.offset,
|
|
2268
2274
|
contentDepth: r
|
|
2269
2275
|
})), i !== null) {
|
|
2270
|
-
if (i.kind === "opener" &&
|
|
2276
|
+
if (i.kind === "opener" && dt.has(s.type)) {
|
|
2271
2277
|
i.point = s.endOffset, o = s.endOffset;
|
|
2272
2278
|
continue;
|
|
2273
|
-
} else i.kind === "opener" &&
|
|
2279
|
+
} else i.kind === "opener" && pt.has(s.type) && ht(e, i.point, s.offset) ? c = !0 : t.push({
|
|
2274
2280
|
point: s.offset,
|
|
2275
2281
|
contentDepth: i.contentDepth
|
|
2276
2282
|
});
|
|
2277
2283
|
i = null;
|
|
2278
2284
|
}
|
|
2279
|
-
|
|
2285
|
+
ft.has(s.type) ? (r++, i = {
|
|
2280
2286
|
point: s.endOffset,
|
|
2281
2287
|
contentDepth: r,
|
|
2282
2288
|
kind: "opener"
|
|
2283
|
-
}) :
|
|
2289
|
+
}) : pt.has(s.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
2284
2290
|
point: s.offset,
|
|
2285
2291
|
contentDepth: r
|
|
2286
2292
|
})) : s.type === "COMMA" && (i = {
|
|
@@ -2295,16 +2301,16 @@ function it(e) {
|
|
|
2295
2301
|
contentDepth: r
|
|
2296
2302
|
}), t;
|
|
2297
2303
|
}
|
|
2298
|
-
function
|
|
2299
|
-
let t = [], n = new
|
|
2304
|
+
function lt(e) {
|
|
2305
|
+
let t = [], n = new Me(e), r = 0;
|
|
2300
2306
|
for (;;) {
|
|
2301
2307
|
let i = n.consume();
|
|
2302
2308
|
if (i.type === "EOF") break;
|
|
2303
|
-
if (
|
|
2304
|
-
else if (
|
|
2305
|
-
else if (i.type !== "COMMA" &&
|
|
2309
|
+
if (ft.has(i.type)) r++;
|
|
2310
|
+
else if (pt.has(i.type)) r = Math.max(0, r - 1);
|
|
2311
|
+
else if (i.type !== "COMMA" && ut.has(i.type)) {
|
|
2306
2312
|
let n = e.slice(i.offset, i.endOffset);
|
|
2307
|
-
for (let { point: e } of
|
|
2313
|
+
for (let { point: e } of st(n, 0)) t.push({
|
|
2308
2314
|
point: i.offset + e,
|
|
2309
2315
|
contentDepth: r + 1
|
|
2310
2316
|
});
|
|
@@ -2312,24 +2318,24 @@ function at(e) {
|
|
|
2312
2318
|
}
|
|
2313
2319
|
return t;
|
|
2314
2320
|
}
|
|
2315
|
-
var
|
|
2321
|
+
var ut = new Set(["TSTR", "RAWSTRING"]), dt = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), ft = new Set([
|
|
2316
2322
|
"LBRACKET",
|
|
2317
2323
|
"LBRACE",
|
|
2318
2324
|
"LPAREN",
|
|
2319
2325
|
"LT_LT"
|
|
2320
|
-
]),
|
|
2326
|
+
]), pt = new Set([
|
|
2321
2327
|
"RBRACKET",
|
|
2322
2328
|
"RBRACE",
|
|
2323
2329
|
"RPAREN",
|
|
2324
2330
|
"GT_GT"
|
|
2325
2331
|
]);
|
|
2326
|
-
function
|
|
2332
|
+
function mt(e, t, n) {
|
|
2327
2333
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
2328
2334
|
}
|
|
2329
|
-
function
|
|
2335
|
+
function ht(e, t, n) {
|
|
2330
2336
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
2331
2337
|
}
|
|
2332
|
-
function
|
|
2338
|
+
function gt(e, t) {
|
|
2333
2339
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2334
2340
|
if (n.length === 0) return [{
|
|
2335
2341
|
text: e,
|
|
@@ -2347,7 +2353,7 @@ function dt(e, t) {
|
|
|
2347
2353
|
}
|
|
2348
2354
|
//#endregion
|
|
2349
2355
|
//#region src/extensions/dt.ts
|
|
2350
|
-
function
|
|
2356
|
+
function P(e) {
|
|
2351
2357
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2352
2358
|
let t = Math.round(e * 1e3);
|
|
2353
2359
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -2355,96 +2361,96 @@ function L(e) {
|
|
|
2355
2361
|
for (; s.length < 3;) s += "0";
|
|
2356
2362
|
return `${i}.${s}Z`;
|
|
2357
2363
|
}
|
|
2358
|
-
function
|
|
2364
|
+
function _t(e) {
|
|
2359
2365
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2360
2366
|
let t = e[0];
|
|
2361
|
-
if (t instanceof
|
|
2362
|
-
if (t instanceof
|
|
2367
|
+
if (t instanceof N) return t.value;
|
|
2368
|
+
if (t instanceof C) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
|
|
2363
2369
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2364
2370
|
}
|
|
2365
|
-
function
|
|
2371
|
+
function vt(e) {
|
|
2366
2372
|
let t = e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i), n, r;
|
|
2367
2373
|
t ? (n = t[1] + t[3], r = parseFloat("0" + t[2])) : (n = e, r = void 0);
|
|
2368
2374
|
let i = Date.parse(n);
|
|
2369
2375
|
if (isNaN(i)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2370
2376
|
if (r === void 0) {
|
|
2371
2377
|
let e = i / 1e3;
|
|
2372
|
-
return e >= 0 ? new
|
|
2378
|
+
return e >= 0 ? new bt(BigInt(e)) : new xt(BigInt(e));
|
|
2373
2379
|
}
|
|
2374
|
-
return new
|
|
2380
|
+
return new St(i / 1e3 + r);
|
|
2375
2381
|
}
|
|
2376
|
-
var
|
|
2382
|
+
var yt = 1n, bt = class extends g {
|
|
2377
2383
|
constructor(e, t) {
|
|
2378
2384
|
super(e, t);
|
|
2379
2385
|
}
|
|
2380
|
-
|
|
2381
|
-
return e?.appStrings === !1 ? super.
|
|
2386
|
+
_toCDN(e, t) {
|
|
2387
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${P(Number(this.value))}'`;
|
|
2382
2388
|
}
|
|
2383
|
-
},
|
|
2389
|
+
}, xt = class extends _ {
|
|
2384
2390
|
constructor(e, t) {
|
|
2385
2391
|
super(e, t);
|
|
2386
2392
|
}
|
|
2387
|
-
|
|
2388
|
-
return e?.appStrings === !1 ? super.
|
|
2393
|
+
_toCDN(e, t) {
|
|
2394
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${P(Number(this.value))}'`;
|
|
2389
2395
|
}
|
|
2390
|
-
},
|
|
2396
|
+
}, St = class extends x {
|
|
2391
2397
|
constructor(e, t) {
|
|
2392
2398
|
super(e, t);
|
|
2393
2399
|
}
|
|
2394
|
-
|
|
2395
|
-
return e?.appStrings === !1 ? super.
|
|
2400
|
+
_toCDN(e, t) {
|
|
2401
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${P(this.value)}'`;
|
|
2396
2402
|
}
|
|
2397
|
-
},
|
|
2403
|
+
}, Ct = class extends S {
|
|
2398
2404
|
constructor(e, t) {
|
|
2399
|
-
super(
|
|
2405
|
+
super(yt, vt(e), t);
|
|
2400
2406
|
}
|
|
2401
|
-
|
|
2402
|
-
if (e?.appStrings === !1) return super.
|
|
2407
|
+
_toCDN(e, t) {
|
|
2408
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2403
2409
|
let n = this.content;
|
|
2404
|
-
return `DT'${
|
|
2410
|
+
return `DT'${P(n instanceof x ? n.value : Number(n.value))}'`;
|
|
2405
2411
|
}
|
|
2406
|
-
},
|
|
2412
|
+
}, wt = class extends Ct {
|
|
2407
2413
|
constructor(e, t) {
|
|
2408
2414
|
super(e, t);
|
|
2409
2415
|
}
|
|
2410
2416
|
_toJS(e) {
|
|
2411
|
-
let t = this.content, n = t instanceof
|
|
2417
|
+
let t = this.content, n = t instanceof x ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2412
2418
|
return new Date(n);
|
|
2413
2419
|
}
|
|
2414
2420
|
};
|
|
2415
|
-
function
|
|
2421
|
+
function Tt(e) {
|
|
2416
2422
|
let t = e?.jsDate ?? !1;
|
|
2417
2423
|
function n(e) {
|
|
2418
|
-
return t ? new
|
|
2424
|
+
return t ? new wt(e) : new Ct(e);
|
|
2419
2425
|
}
|
|
2420
2426
|
let r = {
|
|
2421
2427
|
appStringPrefixes: ["dt", "DT"],
|
|
2422
|
-
tagNumbers: [
|
|
2428
|
+
tagNumbers: [yt],
|
|
2423
2429
|
parseAppString(e, t) {
|
|
2424
|
-
return e === "DT" ? n(t) :
|
|
2430
|
+
return e === "DT" ? n(t) : vt(t);
|
|
2425
2431
|
},
|
|
2426
2432
|
parseAppSequence(e, t) {
|
|
2427
|
-
let r =
|
|
2428
|
-
return e === "DT" ? n(r) :
|
|
2433
|
+
let r = _t(t);
|
|
2434
|
+
return e === "DT" ? n(r) : vt(r);
|
|
2429
2435
|
},
|
|
2430
2436
|
parseTag(e, t) {
|
|
2431
2437
|
if (e !== 1n) return;
|
|
2432
2438
|
let r;
|
|
2433
2439
|
if (t instanceof g) r = Number(t.value);
|
|
2434
2440
|
else if (t instanceof _) r = Number(t.value);
|
|
2435
|
-
else if (t instanceof
|
|
2441
|
+
else if (t instanceof x) r = t.value;
|
|
2436
2442
|
else return;
|
|
2437
|
-
return n(
|
|
2443
|
+
return n(P(r));
|
|
2438
2444
|
}
|
|
2439
2445
|
};
|
|
2440
2446
|
return t && (r.fromJS = (e, t) => {
|
|
2441
|
-
if (e instanceof Date) return new
|
|
2447
|
+
if (e instanceof Date) return new wt(P(e.getTime() / 1e3));
|
|
2442
2448
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2443
2449
|
}
|
|
2444
|
-
var
|
|
2450
|
+
var Et = Tt(), Dt = Tt({ jsDate: !0 });
|
|
2445
2451
|
//#endregion
|
|
2446
2452
|
//#region src/utils/ip.ts
|
|
2447
|
-
function
|
|
2453
|
+
function F(e) {
|
|
2448
2454
|
let t = e.split(".");
|
|
2449
2455
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2450
2456
|
let n = new Uint8Array(4);
|
|
@@ -2457,11 +2463,11 @@ function St(e) {
|
|
|
2457
2463
|
}
|
|
2458
2464
|
return n;
|
|
2459
2465
|
}
|
|
2460
|
-
function
|
|
2466
|
+
function Ot(e) {
|
|
2461
2467
|
let t = new Uint8Array(16);
|
|
2462
2468
|
if (e === "::") return t;
|
|
2463
2469
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2464
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2470
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = F(i[2]));
|
|
2465
2471
|
let a = n.split("::");
|
|
2466
2472
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2467
2473
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2478,11 +2484,11 @@ function Ct(e) {
|
|
|
2478
2484
|
}
|
|
2479
2485
|
return r && t.set(r, 12), t;
|
|
2480
2486
|
}
|
|
2481
|
-
function
|
|
2487
|
+
function I(e) {
|
|
2482
2488
|
return Array.from(e).join(".");
|
|
2483
2489
|
}
|
|
2484
|
-
function
|
|
2485
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2490
|
+
function kt(e) {
|
|
2491
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? I(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2486
2492
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2487
2493
|
let i = -1, a = 0, o = 0;
|
|
2488
2494
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2496,29 +2502,29 @@ function Tt(e) {
|
|
|
2496
2502
|
}
|
|
2497
2503
|
//#endregion
|
|
2498
2504
|
//#region src/extensions/ip.ts
|
|
2499
|
-
var
|
|
2500
|
-
function
|
|
2505
|
+
var L = "ip", R = "IP", z = 52n, B = 54n;
|
|
2506
|
+
function At(e) {
|
|
2501
2507
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2502
2508
|
let t = e[0];
|
|
2503
|
-
if (t instanceof
|
|
2504
|
-
if (t instanceof
|
|
2509
|
+
if (t instanceof N) return t.value;
|
|
2510
|
+
if (t instanceof C) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
|
|
2505
2511
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2506
2512
|
}
|
|
2507
|
-
function
|
|
2513
|
+
function jt(e) {
|
|
2508
2514
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2509
|
-
bytes:
|
|
2515
|
+
bytes: F(e),
|
|
2510
2516
|
isV4: !0
|
|
2511
2517
|
} : {
|
|
2512
|
-
bytes:
|
|
2518
|
+
bytes: Ot(e),
|
|
2513
2519
|
isV4: !1
|
|
2514
2520
|
};
|
|
2515
2521
|
}
|
|
2516
|
-
function
|
|
2517
|
-
if (e.length === 4) return
|
|
2518
|
-
if (e.length === 16) return
|
|
2522
|
+
function V(e) {
|
|
2523
|
+
if (e.length === 4) return I(e);
|
|
2524
|
+
if (e.length === 16) return kt(e);
|
|
2519
2525
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2520
2526
|
}
|
|
2521
|
-
function
|
|
2527
|
+
function Mt(e, t) {
|
|
2522
2528
|
let n = new Uint8Array(e.length);
|
|
2523
2529
|
n.set(e);
|
|
2524
2530
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2528,79 +2534,79 @@ function kt(e, t) {
|
|
|
2528
2534
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2529
2535
|
return n.slice(0, a);
|
|
2530
2536
|
}
|
|
2531
|
-
function
|
|
2537
|
+
function Nt(e, t) {
|
|
2532
2538
|
let n = new Uint8Array(t);
|
|
2533
2539
|
return n.set(e), n;
|
|
2534
2540
|
}
|
|
2535
|
-
var
|
|
2536
|
-
|
|
2537
|
-
return e?.appStrings === !1 ? super.
|
|
2541
|
+
var Pt = class extends C {
|
|
2542
|
+
_toCDN(e, t) {
|
|
2543
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `${L}'${V(this.value)}'`;
|
|
2538
2544
|
}
|
|
2539
|
-
},
|
|
2545
|
+
}, Ft = class extends E {
|
|
2540
2546
|
_isV4;
|
|
2541
2547
|
constructor(e, t, n) {
|
|
2542
|
-
super([new g(BigInt(e)), new
|
|
2548
|
+
super([new g(BigInt(e)), new C(t)]), this._isV4 = n;
|
|
2543
2549
|
}
|
|
2544
|
-
|
|
2545
|
-
if (e?.appStrings === !1) return super.
|
|
2550
|
+
_toCDN(e, t) {
|
|
2551
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2546
2552
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2547
|
-
return `${
|
|
2553
|
+
return `${L}'${V(Nt(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2548
2554
|
}
|
|
2549
|
-
},
|
|
2555
|
+
}, H = class extends S {
|
|
2550
2556
|
constructor(e, t) {
|
|
2551
2557
|
super(e, t);
|
|
2552
2558
|
}
|
|
2553
|
-
|
|
2554
|
-
if (e?.appStrings === !1) return super.
|
|
2555
|
-
let n = this.tag ===
|
|
2556
|
-
if (r instanceof
|
|
2557
|
-
if (r instanceof
|
|
2559
|
+
_toCDN(e, t) {
|
|
2560
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2561
|
+
let n = this.tag === z ? 4 : 16, r = this.content;
|
|
2562
|
+
if (r instanceof C) return `${R}'${V(r.value)}'`;
|
|
2563
|
+
if (r instanceof E && r.items.length === 2 && r.items[0] instanceof g && r.items[1] instanceof C) {
|
|
2558
2564
|
let e = Number(r.items[0].value);
|
|
2559
|
-
return `${
|
|
2565
|
+
return `${R}'${V(Nt(r.items[1].value, n))}/${e}'`;
|
|
2560
2566
|
}
|
|
2561
|
-
return super.
|
|
2567
|
+
return super._toCDN(e, t);
|
|
2562
2568
|
}
|
|
2563
2569
|
};
|
|
2564
|
-
function
|
|
2570
|
+
function It(e, t) {
|
|
2565
2571
|
let n = t.indexOf("/");
|
|
2566
2572
|
if (n === -1) {
|
|
2567
|
-
let { bytes: n, isV4: r } =
|
|
2568
|
-
return e ===
|
|
2573
|
+
let { bytes: n, isV4: r } = jt(t);
|
|
2574
|
+
return e === R ? new H(r ? z : B, new C(n)) : new Pt(n);
|
|
2569
2575
|
}
|
|
2570
2576
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2571
2577
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2572
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2578
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = jt(r), c = s ? 32 : 128;
|
|
2573
2579
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2574
|
-
let l =
|
|
2575
|
-
return e ===
|
|
2580
|
+
let l = Mt(o, a);
|
|
2581
|
+
return e === R ? new H(s ? z : B, new E([new g(BigInt(a)), new C(l)])) : new Ft(a, l, s);
|
|
2576
2582
|
}
|
|
2577
|
-
var
|
|
2578
|
-
appStringPrefixes: [
|
|
2579
|
-
tagNumbers: [
|
|
2583
|
+
var Lt = {
|
|
2584
|
+
appStringPrefixes: [L, R],
|
|
2585
|
+
tagNumbers: [z, B],
|
|
2580
2586
|
parseAppString(e, t) {
|
|
2581
|
-
return
|
|
2587
|
+
return It(e, t);
|
|
2582
2588
|
},
|
|
2583
2589
|
parseAppSequence(e, t) {
|
|
2584
|
-
return
|
|
2590
|
+
return It(e, At(t));
|
|
2585
2591
|
},
|
|
2586
2592
|
parseTag(e, t) {
|
|
2587
|
-
if (!(e !==
|
|
2593
|
+
if (!(e !== z && e !== B) && (t instanceof C || t instanceof E)) return new H(e, t);
|
|
2588
2594
|
}
|
|
2589
|
-
},
|
|
2590
|
-
tagNumbers: [
|
|
2595
|
+
}, Rt = 18446744073709551615n, zt = -(Rt + 1n), Bt = {
|
|
2596
|
+
tagNumbers: [Le, Re],
|
|
2591
2597
|
parseTag(e, t) {
|
|
2592
|
-
if (t instanceof
|
|
2598
|
+
if (t instanceof C) {
|
|
2593
2599
|
if (e === 2n) {
|
|
2594
|
-
let e =
|
|
2595
|
-
return e >
|
|
2600
|
+
let e = He(t.value);
|
|
2601
|
+
return e > Rt ? new j(e) : void 0;
|
|
2596
2602
|
}
|
|
2597
2603
|
if (e === 3n) {
|
|
2598
|
-
let e = -1n -
|
|
2599
|
-
return e <
|
|
2604
|
+
let e = -1n - He(t.value);
|
|
2605
|
+
return e < zt ? new M(e) : void 0;
|
|
2600
2606
|
}
|
|
2601
2607
|
}
|
|
2602
2608
|
}
|
|
2603
|
-
},
|
|
2609
|
+
}, Vt = "cri", U = "CRI", Ht = 99n, Ut = new Map([
|
|
2604
2610
|
["coap", -1n],
|
|
2605
2611
|
["coaps", -2n],
|
|
2606
2612
|
["http", -3n],
|
|
@@ -2611,7 +2617,7 @@ var Pt = {
|
|
|
2611
2617
|
["coaps+tcp", -8n],
|
|
2612
2618
|
["coap+ws", -25n],
|
|
2613
2619
|
["coaps+ws", -26n]
|
|
2614
|
-
]),
|
|
2620
|
+
]), Wt = new Map([...Ut.entries()].map(([e, t]) => [t, e]));
|
|
2615
2621
|
function W(e) {
|
|
2616
2622
|
try {
|
|
2617
2623
|
return decodeURIComponent(e);
|
|
@@ -2619,38 +2625,38 @@ function W(e) {
|
|
|
2619
2625
|
return e;
|
|
2620
2626
|
}
|
|
2621
2627
|
}
|
|
2622
|
-
function
|
|
2628
|
+
function Gt(e) {
|
|
2623
2629
|
return Array.from(new TextEncoder().encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2624
2630
|
}
|
|
2625
2631
|
function G(e, t) {
|
|
2626
2632
|
let n = "";
|
|
2627
|
-
for (let r of e) n += t(r) ? r :
|
|
2633
|
+
for (let r of e) n += t(r) ? r : Gt(r);
|
|
2628
2634
|
return n;
|
|
2629
2635
|
}
|
|
2630
|
-
function Wt(e) {
|
|
2631
|
-
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2632
|
-
}
|
|
2633
|
-
function Gt(e) {
|
|
2634
|
-
return /[!$&'()*+,;=]/.test(e);
|
|
2635
|
-
}
|
|
2636
2636
|
function Kt(e) {
|
|
2637
|
-
return
|
|
2637
|
+
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2638
2638
|
}
|
|
2639
2639
|
function qt(e) {
|
|
2640
|
-
return (
|
|
2640
|
+
return /[!$&'()*+,;=]/.test(e);
|
|
2641
2641
|
}
|
|
2642
2642
|
function Jt(e) {
|
|
2643
|
-
return Kt(e) || e === "
|
|
2643
|
+
return Kt(e) || qt(e) || e === ":" || e === "@";
|
|
2644
2644
|
}
|
|
2645
2645
|
function Yt(e) {
|
|
2646
|
-
return
|
|
2646
|
+
return (Jt(e) || e === "/" || e === "?") && e !== "&";
|
|
2647
2647
|
}
|
|
2648
2648
|
function Xt(e) {
|
|
2649
|
-
return
|
|
2649
|
+
return Jt(e) || e === "/" || e === "?";
|
|
2650
2650
|
}
|
|
2651
2651
|
function Zt(e) {
|
|
2652
|
+
return Kt(e) || qt(e) || e === ":";
|
|
2653
|
+
}
|
|
2654
|
+
function Qt(e) {
|
|
2655
|
+
return Kt(e) || qt(e);
|
|
2656
|
+
}
|
|
2657
|
+
function $t(e) {
|
|
2652
2658
|
let t = [], n = e, r = n.indexOf("@");
|
|
2653
|
-
r >= 0 && (t.push(
|
|
2659
|
+
r >= 0 && (t.push(O.FALSE), t.push(new N(W(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2654
2660
|
let i, a = null;
|
|
2655
2661
|
if (n.startsWith("[")) {
|
|
2656
2662
|
let e = n.indexOf("]");
|
|
@@ -2659,11 +2665,11 @@ function Zt(e) {
|
|
|
2659
2665
|
let r = n.slice(e + 1);
|
|
2660
2666
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2661
2667
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2662
|
-
t.push(new
|
|
2668
|
+
t.push(new C(Ot(i)));
|
|
2663
2669
|
} else {
|
|
2664
2670
|
let e = n.lastIndexOf(":");
|
|
2665
|
-
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
|
|
2666
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2671
|
+
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 C(F(i)));
|
|
2672
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new N(e));
|
|
2667
2673
|
}
|
|
2668
2674
|
if (a !== null && a !== "") {
|
|
2669
2675
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
@@ -2671,76 +2677,76 @@ function Zt(e) {
|
|
|
2671
2677
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2672
2678
|
t.push(new g(BigInt(e)));
|
|
2673
2679
|
}
|
|
2674
|
-
return new
|
|
2680
|
+
return new E(t);
|
|
2675
2681
|
}
|
|
2676
|
-
function
|
|
2682
|
+
function en(e) {
|
|
2677
2683
|
let t = e.items, n = 0, r = "";
|
|
2678
|
-
if (n < t.length && t[n] instanceof
|
|
2684
|
+
if (n < t.length && t[n] instanceof O && t[n].value === 20) {
|
|
2679
2685
|
n++;
|
|
2680
2686
|
let e = t[n++];
|
|
2681
|
-
r += G(e.value,
|
|
2687
|
+
r += G(e.value, Zt) + "@";
|
|
2682
2688
|
}
|
|
2683
2689
|
if (n >= t.length) return r;
|
|
2684
2690
|
let i = t[n];
|
|
2685
|
-
if (i instanceof
|
|
2691
|
+
if (i instanceof C) {
|
|
2686
2692
|
n++;
|
|
2687
2693
|
let { length: e } = i.value;
|
|
2688
|
-
if (e === 4) r +=
|
|
2689
|
-
else if (e === 16) r += "[" +
|
|
2694
|
+
if (e === 4) r += I(i.value);
|
|
2695
|
+
else if (e === 16) r += "[" + kt(i.value) + "]";
|
|
2690
2696
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2691
|
-
n < t.length && t[n] instanceof
|
|
2697
|
+
n < t.length && t[n] instanceof N && (r += `%25${G(t[n++].value, Qt)}`);
|
|
2692
2698
|
} else {
|
|
2693
2699
|
let e = [];
|
|
2694
|
-
for (; n < t.length && t[n] instanceof
|
|
2700
|
+
for (; n < t.length && t[n] instanceof N;) e.push(G(t[n++].value, Qt));
|
|
2695
2701
|
r += e.join(".");
|
|
2696
2702
|
}
|
|
2697
2703
|
return n < t.length && t[n] instanceof g && (r += ":" + t[n].value.toString()), r;
|
|
2698
2704
|
}
|
|
2699
|
-
function
|
|
2705
|
+
function tn(e) {
|
|
2700
2706
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2701
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2702
|
-
authority:
|
|
2707
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new N(W(e)))) : (r = t, i = []), {
|
|
2708
|
+
authority: $t(r),
|
|
2703
2709
|
pathSegments: i
|
|
2704
2710
|
};
|
|
2705
2711
|
}
|
|
2706
|
-
function
|
|
2712
|
+
function nn(e) {
|
|
2707
2713
|
let t = e, n = null, r = t.indexOf("#");
|
|
2708
2714
|
r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
|
|
2709
2715
|
let i = null, a = t.indexOf("?");
|
|
2710
2716
|
if (a >= 0) {
|
|
2711
2717
|
let e = t.slice(a + 1);
|
|
2712
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2718
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new N(W(e)));
|
|
2713
2719
|
}
|
|
2714
2720
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2715
2721
|
if (s) {
|
|
2716
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2717
|
-
if (o.push(n === void 0 ? new
|
|
2718
|
-
let { authority: e, pathSegments: n } =
|
|
2719
|
-
o.push(e, new
|
|
2722
|
+
let e = s[1].toLowerCase(), t = s[2], n = Ut.get(e);
|
|
2723
|
+
if (o.push(n === void 0 ? new N(e) : new _(n)), t.startsWith("//")) {
|
|
2724
|
+
let { authority: e, pathSegments: n } = tn(t);
|
|
2725
|
+
o.push(e, new E(n));
|
|
2720
2726
|
} else if (t.startsWith("/")) {
|
|
2721
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2722
|
-
o.push(
|
|
2727
|
+
let e = t.slice(1).split("/").map((e) => new N(W(e)));
|
|
2728
|
+
o.push(O.NULL, new E(e));
|
|
2723
2729
|
} else {
|
|
2724
|
-
let e = t.split("/").map((e) => new
|
|
2725
|
-
o.push(
|
|
2730
|
+
let e = t.split("/").map((e) => new N(W(e)));
|
|
2731
|
+
o.push(O.TRUE, new E(e));
|
|
2726
2732
|
}
|
|
2727
2733
|
} else if (t.startsWith("//")) {
|
|
2728
|
-
let { authority: e, pathSegments: n } =
|
|
2729
|
-
o.push(
|
|
2734
|
+
let { authority: e, pathSegments: n } = tn(t);
|
|
2735
|
+
o.push(O.FALSE, e, new E(n));
|
|
2730
2736
|
} else if (t.startsWith("/")) {
|
|
2731
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2732
|
-
o.push(
|
|
2737
|
+
let e = t.slice(1).split("/").map((e) => new N(W(e)));
|
|
2738
|
+
o.push(O.TRUE, new E(e));
|
|
2733
2739
|
} else if (t === "") o.push(new g(0n));
|
|
2734
2740
|
else {
|
|
2735
2741
|
let n = 1n, r = t, i = !1;
|
|
2736
2742
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2737
2743
|
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)}`);
|
|
2738
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2739
|
-
o.push(new g(n), new
|
|
2744
|
+
let a = r === "" ? [] : r.split("/").map((e) => new N(W(e)));
|
|
2745
|
+
o.push(new g(n), new E(a));
|
|
2740
2746
|
}
|
|
2741
|
-
if (i !== null && o.push(new
|
|
2747
|
+
if (i !== null && o.push(new E(i)), n !== null && (i === null && o.push(O.NULL), o.push(new N(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2742
2748
|
let e = o[o.length - 1];
|
|
2743
|
-
e instanceof
|
|
2749
|
+
e instanceof E && e.items.length === 0 && o.pop();
|
|
2744
2750
|
}
|
|
2745
2751
|
return o.length === 1 && o[0] instanceof g && o[0].value === 0n ? [] : o;
|
|
2746
2752
|
}
|
|
@@ -2748,60 +2754,60 @@ function K(e, t) {
|
|
|
2748
2754
|
let n = t, r = "";
|
|
2749
2755
|
if (n < e.length) {
|
|
2750
2756
|
let t = e[n];
|
|
2751
|
-
if (t instanceof
|
|
2757
|
+
if (t instanceof E) {
|
|
2752
2758
|
if (n++, t.items.length > 0) {
|
|
2753
2759
|
let e = t.items.map((e) => {
|
|
2754
|
-
if (!(e instanceof
|
|
2755
|
-
return G(e.value,
|
|
2760
|
+
if (!(e instanceof N)) throw Error("cri: query item must be a text string");
|
|
2761
|
+
return G(e.value, Yt);
|
|
2756
2762
|
});
|
|
2757
2763
|
r += "?" + e.join("&");
|
|
2758
2764
|
}
|
|
2759
|
-
} else t instanceof
|
|
2765
|
+
} else t instanceof O && t.value === 22 && n++;
|
|
2760
2766
|
}
|
|
2761
|
-
return n < e.length && e[n] instanceof
|
|
2767
|
+
return n < e.length && e[n] instanceof N && (r += "#" + G(e[n].value, Xt)), r;
|
|
2762
2768
|
}
|
|
2763
2769
|
function q(e) {
|
|
2764
2770
|
return e.items.map((e) => {
|
|
2765
|
-
if (!(e instanceof
|
|
2766
|
-
return G(e.value,
|
|
2771
|
+
if (!(e instanceof N)) throw Error("cri: path segment must be a text string");
|
|
2772
|
+
return G(e.value, Jt);
|
|
2767
2773
|
});
|
|
2768
2774
|
}
|
|
2769
|
-
function
|
|
2775
|
+
function rn(e) {
|
|
2770
2776
|
if (e.length === 0) return "";
|
|
2771
2777
|
let t = 0, n = e[t++];
|
|
2772
|
-
if (n instanceof _ || n instanceof
|
|
2778
|
+
if (n instanceof _ || n instanceof N) {
|
|
2773
2779
|
let r;
|
|
2774
2780
|
if (n instanceof _) {
|
|
2775
|
-
let e =
|
|
2781
|
+
let e = Wt.get(n.value);
|
|
2776
2782
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2777
2783
|
r = e + ":";
|
|
2778
2784
|
} else r = n.value + ":";
|
|
2779
2785
|
if (t >= e.length) return r;
|
|
2780
2786
|
let i = e[t++], a = "", o = !1;
|
|
2781
|
-
if (i instanceof
|
|
2782
|
-
else if (i instanceof
|
|
2787
|
+
if (i instanceof E) a = "//" + en(i), o = !0;
|
|
2788
|
+
else if (i instanceof O) if (i.value === 22) o = !0;
|
|
2783
2789
|
else if (i.value === 21) o = !1;
|
|
2784
2790
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2785
2791
|
else throw Error("cri: unexpected type for authority element");
|
|
2786
2792
|
let s = "";
|
|
2787
|
-
if (t < e.length && e[t] instanceof
|
|
2793
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2788
2794
|
let n = e[t++];
|
|
2789
2795
|
n.items.length > 0 && (s = (o ? "/" : "") + q(n).join("/"));
|
|
2790
2796
|
}
|
|
2791
2797
|
return r + a + s + K(e, t);
|
|
2792
2798
|
}
|
|
2793
|
-
if (n instanceof
|
|
2794
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2795
|
-
let n =
|
|
2796
|
-
if (t < e.length && e[t] instanceof
|
|
2799
|
+
if (n instanceof O && n.value === 20) {
|
|
2800
|
+
if (t >= e.length || !(e[t] instanceof E)) throw Error("cri: network-path reference requires an authority array");
|
|
2801
|
+
let n = en(e[t++]), r = "";
|
|
2802
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2797
2803
|
let n = e[t++];
|
|
2798
2804
|
n.items.length > 0 && (r = "/" + q(n).join("/"));
|
|
2799
2805
|
}
|
|
2800
2806
|
return "//" + n + r + K(e, t);
|
|
2801
2807
|
}
|
|
2802
|
-
if (n instanceof
|
|
2808
|
+
if (n instanceof O && n.value === 21) {
|
|
2803
2809
|
let n = "/";
|
|
2804
|
-
if (t < e.length && e[t] instanceof
|
|
2810
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2805
2811
|
let r = e[t++];
|
|
2806
2812
|
n = "/" + q(r).join("/");
|
|
2807
2813
|
}
|
|
@@ -2811,7 +2817,7 @@ function tn(e) {
|
|
|
2811
2817
|
let r = n.value;
|
|
2812
2818
|
if (r === 0n) return K(e, t);
|
|
2813
2819
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2814
|
-
if (t < e.length && e[t] instanceof
|
|
2820
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2815
2821
|
let n = e[t++];
|
|
2816
2822
|
if (n.items.length > 0) {
|
|
2817
2823
|
let e = q(n);
|
|
@@ -2822,55 +2828,55 @@ function tn(e) {
|
|
|
2822
2828
|
}
|
|
2823
2829
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2824
2830
|
}
|
|
2825
|
-
var
|
|
2826
|
-
|
|
2827
|
-
if (e?.appStrings === !1) return super.
|
|
2831
|
+
var an = class extends E {
|
|
2832
|
+
_toCDN(e, t) {
|
|
2833
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2828
2834
|
try {
|
|
2829
|
-
return `${
|
|
2835
|
+
return `${Vt}'${rn(this.items)}'`;
|
|
2830
2836
|
} catch {
|
|
2831
|
-
return super.
|
|
2837
|
+
return super._toCDN(e, t);
|
|
2832
2838
|
}
|
|
2833
2839
|
}
|
|
2834
|
-
},
|
|
2840
|
+
}, on = class extends S {
|
|
2835
2841
|
constructor(e) {
|
|
2836
|
-
super(
|
|
2842
|
+
super(Ht, e);
|
|
2837
2843
|
}
|
|
2838
|
-
|
|
2839
|
-
if (e?.appStrings === !1) return super.
|
|
2844
|
+
_toCDN(e, t) {
|
|
2845
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2840
2846
|
try {
|
|
2841
|
-
return `${
|
|
2847
|
+
return `${U}'${rn(this.content.items)}'`;
|
|
2842
2848
|
} catch {
|
|
2843
|
-
return super.
|
|
2849
|
+
return super._toCDN(e, t);
|
|
2844
2850
|
}
|
|
2845
2851
|
}
|
|
2846
2852
|
};
|
|
2847
|
-
function
|
|
2853
|
+
function sn(e) {
|
|
2848
2854
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2849
2855
|
let t = e[0];
|
|
2850
|
-
if (t instanceof
|
|
2851
|
-
if (t instanceof
|
|
2856
|
+
if (t instanceof N) return t.value;
|
|
2857
|
+
if (t instanceof C) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
|
|
2852
2858
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2853
2859
|
}
|
|
2854
|
-
function
|
|
2855
|
-
let n = new nn(
|
|
2856
|
-
return e ===
|
|
2860
|
+
function cn(e, t) {
|
|
2861
|
+
let n = new an(nn(t));
|
|
2862
|
+
return e === U ? new on(n) : n;
|
|
2857
2863
|
}
|
|
2858
|
-
var
|
|
2859
|
-
appStringPrefixes: [
|
|
2860
|
-
tagNumbers: [
|
|
2864
|
+
var ln = {
|
|
2865
|
+
appStringPrefixes: [Vt, U],
|
|
2866
|
+
tagNumbers: [Ht],
|
|
2861
2867
|
parseAppString(e, t) {
|
|
2862
|
-
return
|
|
2868
|
+
return cn(e, t);
|
|
2863
2869
|
},
|
|
2864
2870
|
parseAppSequence(e, t) {
|
|
2865
|
-
return
|
|
2871
|
+
return cn(e, sn(t));
|
|
2866
2872
|
},
|
|
2867
2873
|
parseTag(e, t) {
|
|
2868
|
-
if (e === 99n && t instanceof
|
|
2874
|
+
if (e === 99n && t instanceof E) return new on(new an(t.items, {
|
|
2869
2875
|
indefiniteLength: t.indefiniteLength,
|
|
2870
2876
|
encodingWidth: t.encodingWidth
|
|
2871
2877
|
}));
|
|
2872
2878
|
}
|
|
2873
|
-
},
|
|
2879
|
+
}, un = new TextDecoder("utf-8", {
|
|
2874
2880
|
fatal: !0,
|
|
2875
2881
|
ignoreBOM: !0
|
|
2876
2882
|
});
|
|
@@ -2903,10 +2909,10 @@ function Y(e, t, n) {
|
|
|
2903
2909
|
}
|
|
2904
2910
|
}
|
|
2905
2911
|
function X(e, t, n) {
|
|
2906
|
-
let r = t, i =
|
|
2912
|
+
let r = t, i = dn(e, t, n);
|
|
2907
2913
|
return i.value.start = r, i.value.end = i.nextOffset, i;
|
|
2908
2914
|
}
|
|
2909
|
-
function
|
|
2915
|
+
function dn(e, t, n) {
|
|
2910
2916
|
t >= e.byteLength && J("unexpected end of input");
|
|
2911
2917
|
let r = e.getUint8(t++), i = r >> 5, a = r & 31;
|
|
2912
2918
|
switch (i) {
|
|
@@ -2933,16 +2939,16 @@ function ln(e, t, n) {
|
|
|
2933
2939
|
break;
|
|
2934
2940
|
}
|
|
2935
2941
|
let t = X(e, i, n);
|
|
2936
|
-
t.value instanceof
|
|
2942
|
+
t.value instanceof C || J("indefinite-length byte string chunk must be a definite byte string"), r.push(t.value), i = t.nextOffset;
|
|
2937
2943
|
}
|
|
2938
2944
|
return {
|
|
2939
|
-
value: new
|
|
2945
|
+
value: new w(r),
|
|
2940
2946
|
nextOffset: i
|
|
2941
2947
|
};
|
|
2942
2948
|
}
|
|
2943
2949
|
let { value: r, nextOffset: i } = Y(e, t, a), o = Number(r);
|
|
2944
2950
|
return i + o > e.byteLength && J("byte string extends beyond input"), {
|
|
2945
|
-
value: new
|
|
2951
|
+
value: new C(new Uint8Array(e.buffer, e.byteOffset + i, o).slice()),
|
|
2946
2952
|
nextOffset: i + o
|
|
2947
2953
|
};
|
|
2948
2954
|
}
|
|
@@ -2955,10 +2961,10 @@ function ln(e, t, n) {
|
|
|
2955
2961
|
break;
|
|
2956
2962
|
}
|
|
2957
2963
|
let t = X(e, i, n);
|
|
2958
|
-
t.value instanceof
|
|
2964
|
+
t.value instanceof N || J("indefinite-length text string chunk must be a definite text string"), r.push(t.value), i = t.nextOffset;
|
|
2959
2965
|
}
|
|
2960
2966
|
return {
|
|
2961
|
-
value: new
|
|
2967
|
+
value: new T(r),
|
|
2962
2968
|
nextOffset: i
|
|
2963
2969
|
};
|
|
2964
2970
|
}
|
|
@@ -2966,12 +2972,12 @@ function ln(e, t, n) {
|
|
|
2966
2972
|
i + o > e.byteLength && J("text string extends beyond input");
|
|
2967
2973
|
let s = new Uint8Array(e.buffer, e.byteOffset + i, o), c;
|
|
2968
2974
|
try {
|
|
2969
|
-
c =
|
|
2975
|
+
c = un.decode(s);
|
|
2970
2976
|
} catch {
|
|
2971
2977
|
J("invalid UTF-8 sequence in text string");
|
|
2972
2978
|
}
|
|
2973
2979
|
return {
|
|
2974
|
-
value: new
|
|
2980
|
+
value: new N(c),
|
|
2975
2981
|
nextOffset: i + o
|
|
2976
2982
|
};
|
|
2977
2983
|
}
|
|
@@ -2987,7 +2993,7 @@ function ln(e, t, n) {
|
|
|
2987
2993
|
r.push(t.value), i = t.nextOffset;
|
|
2988
2994
|
}
|
|
2989
2995
|
return {
|
|
2990
|
-
value: new
|
|
2996
|
+
value: new E(r, { indefiniteLength: !0 }),
|
|
2991
2997
|
nextOffset: i
|
|
2992
2998
|
};
|
|
2993
2999
|
}
|
|
@@ -2997,7 +3003,7 @@ function ln(e, t, n) {
|
|
|
2997
3003
|
s.push(t.value), c = t.nextOffset;
|
|
2998
3004
|
}
|
|
2999
3005
|
return {
|
|
3000
|
-
value: new
|
|
3006
|
+
value: new E(s),
|
|
3001
3007
|
nextOffset: c
|
|
3002
3008
|
};
|
|
3003
3009
|
}
|
|
@@ -3015,7 +3021,7 @@ function ln(e, t, n) {
|
|
|
3015
3021
|
i = a.nextOffset, r.push([t.value, a.value]);
|
|
3016
3022
|
}
|
|
3017
3023
|
return {
|
|
3018
|
-
value: new
|
|
3024
|
+
value: new D(r, { indefiniteLength: !0 }),
|
|
3019
3025
|
nextOffset: i
|
|
3020
3026
|
};
|
|
3021
3027
|
}
|
|
@@ -3027,7 +3033,7 @@ function ln(e, t, n) {
|
|
|
3027
3033
|
c = r.nextOffset, s.push([t.value, r.value]);
|
|
3028
3034
|
}
|
|
3029
3035
|
return {
|
|
3030
|
-
value: new
|
|
3036
|
+
value: new D(s),
|
|
3031
3037
|
nextOffset: c
|
|
3032
3038
|
};
|
|
3033
3039
|
}
|
|
@@ -3042,75 +3048,75 @@ function ln(e, t, n) {
|
|
|
3042
3048
|
};
|
|
3043
3049
|
}
|
|
3044
3050
|
return {
|
|
3045
|
-
value: new
|
|
3051
|
+
value: new S(r, o.value),
|
|
3046
3052
|
nextOffset: o.nextOffset
|
|
3047
3053
|
};
|
|
3048
3054
|
}
|
|
3049
3055
|
case 7:
|
|
3050
3056
|
if (a <= 19) return {
|
|
3051
|
-
value: new
|
|
3057
|
+
value: new O(a),
|
|
3052
3058
|
nextOffset: t
|
|
3053
3059
|
};
|
|
3054
3060
|
if (a === 20) return {
|
|
3055
|
-
value:
|
|
3061
|
+
value: O.FALSE,
|
|
3056
3062
|
nextOffset: t
|
|
3057
3063
|
};
|
|
3058
3064
|
if (a === 21) return {
|
|
3059
|
-
value:
|
|
3065
|
+
value: O.TRUE,
|
|
3060
3066
|
nextOffset: t
|
|
3061
3067
|
};
|
|
3062
3068
|
if (a === 22) return {
|
|
3063
|
-
value:
|
|
3069
|
+
value: O.NULL,
|
|
3064
3070
|
nextOffset: t
|
|
3065
3071
|
};
|
|
3066
3072
|
if (a === 23) return {
|
|
3067
|
-
value:
|
|
3073
|
+
value: O.UNDEFINED,
|
|
3068
3074
|
nextOffset: t
|
|
3069
3075
|
};
|
|
3070
3076
|
if (a === 24) {
|
|
3071
3077
|
t + 1 > e.byteLength && J("unexpected end of input");
|
|
3072
3078
|
let n = e.getUint8(t);
|
|
3073
3079
|
return n < 32 && J(`simple value ${n} must be encoded in initial byte (0–31 reserved for extended encoding)`), {
|
|
3074
|
-
value: new
|
|
3080
|
+
value: new O(n),
|
|
3075
3081
|
nextOffset: t + 1
|
|
3076
3082
|
};
|
|
3077
3083
|
}
|
|
3078
3084
|
return a === 25 ? (t + 2 > e.byteLength && J("unexpected end of input"), {
|
|
3079
|
-
value: new
|
|
3085
|
+
value: new x(te(e.getUint16(t, !1)), { precision: "half" }),
|
|
3080
3086
|
nextOffset: t + 2
|
|
3081
3087
|
}) : a === 26 ? (t + 4 > e.byteLength && J("unexpected end of input"), {
|
|
3082
|
-
value: new
|
|
3088
|
+
value: new x(e.getFloat32(t, !1), { precision: "single" }),
|
|
3083
3089
|
nextOffset: t + 4
|
|
3084
3090
|
}) : a === 27 ? (t + 8 > e.byteLength && J("unexpected end of input"), {
|
|
3085
|
-
value: new
|
|
3091
|
+
value: new x(e.getFloat64(t, !1), { precision: "double" }),
|
|
3086
3092
|
nextOffset: t + 8
|
|
3087
3093
|
}) : (a < 31 && J(`reserved additional info value in major type 7: ${a}`), J("unexpected break code outside indefinite-length item"));
|
|
3088
3094
|
}
|
|
3089
3095
|
return J(`unknown major type: ${i}`);
|
|
3090
3096
|
}
|
|
3091
|
-
function
|
|
3097
|
+
function fn(e) {
|
|
3092
3098
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
3093
3099
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
3094
3100
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
3095
3101
|
}
|
|
3096
|
-
function
|
|
3097
|
-
let n =
|
|
3102
|
+
function pn(e, t) {
|
|
3103
|
+
let n = fn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
3098
3104
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
3099
3105
|
let { value: a, nextOffset: o } = X(r, i, t);
|
|
3100
3106
|
return !t?.allowTrailing && o !== r.byteLength && J(`${r.byteLength - o} trailing byte(s) after end of CBOR item`), a;
|
|
3101
3107
|
}
|
|
3102
3108
|
//#endregion
|
|
3103
3109
|
//#region src/extensions/cbordata.ts
|
|
3104
|
-
var
|
|
3105
|
-
|
|
3106
|
-
Pt,
|
|
3110
|
+
var mn = 24n, Z = [
|
|
3111
|
+
Et,
|
|
3107
3112
|
Lt,
|
|
3108
|
-
|
|
3113
|
+
Bt,
|
|
3114
|
+
ln,
|
|
3109
3115
|
{
|
|
3110
|
-
tagNumbers: [
|
|
3116
|
+
tagNumbers: [mn],
|
|
3111
3117
|
parseTag(e, t) {
|
|
3112
|
-
if (e === 24n && t instanceof
|
|
3113
|
-
return new
|
|
3118
|
+
if (e === 24n && t instanceof C) try {
|
|
3119
|
+
return new S(mn, new k([pn(t.value)]));
|
|
3114
3120
|
} catch {
|
|
3115
3121
|
return;
|
|
3116
3122
|
}
|
|
@@ -3121,50 +3127,50 @@ var fn = 24n, Z = [
|
|
|
3121
3127
|
//#region src/js/fromJS.ts
|
|
3122
3128
|
function Q(e, t) {
|
|
3123
3129
|
if (t?.replacer) {
|
|
3124
|
-
let { replacer: n, ...r } = t, i =
|
|
3125
|
-
return i === l ?
|
|
3130
|
+
let { replacer: n, ...r } = t, i = _n(e, n, r.extensions, r.undefinedOmits);
|
|
3131
|
+
return i === l ? O.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3126
3132
|
}
|
|
3127
|
-
return
|
|
3133
|
+
return hn(e, t, !0);
|
|
3128
3134
|
}
|
|
3129
|
-
function
|
|
3135
|
+
function hn(e, t, n) {
|
|
3130
3136
|
for (let n of [...t?.extensions ?? [], ...Z]) if (n.fromJS) {
|
|
3131
3137
|
let r = n.fromJS(e, t ?? {});
|
|
3132
3138
|
if (r !== void 0) return r;
|
|
3133
3139
|
}
|
|
3134
3140
|
if (n && typeof e == "object" && e && c.symbol in e) {
|
|
3135
|
-
let n = e[c.symbol], r =
|
|
3141
|
+
let n = e[c.symbol], r = hn(e, t, !1);
|
|
3136
3142
|
for (let e of [...t?.extensions ?? [], ...Z]) if (e.parseTag) {
|
|
3137
3143
|
let t = e.parseTag(n, r);
|
|
3138
3144
|
if (t !== void 0) return t;
|
|
3139
3145
|
}
|
|
3140
|
-
return new
|
|
3141
|
-
}
|
|
3142
|
-
if (e instanceof c.Null) return
|
|
3143
|
-
if (e instanceof c.Undefined) return
|
|
3144
|
-
if (e instanceof u) return new
|
|
3145
|
-
if (e === null) return
|
|
3146
|
-
if (e === void 0) return
|
|
3147
|
-
if (e === !0) return
|
|
3148
|
-
if (e === !1) return
|
|
3149
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
3150
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new g(BigInt(e)) : new _(BigInt(e)) : new
|
|
3151
|
-
if (typeof e == "string") return new
|
|
3152
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return
|
|
3153
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
3154
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
3155
|
-
if (e instanceof $) return new
|
|
3156
|
-
if (Array.isArray(e)) return new
|
|
3146
|
+
return new S(n, r);
|
|
3147
|
+
}
|
|
3148
|
+
if (e instanceof c.Null) return O.NULL;
|
|
3149
|
+
if (e instanceof c.Undefined) return O.UNDEFINED;
|
|
3150
|
+
if (e instanceof u) return new O(e.value);
|
|
3151
|
+
if (e === null) return O.NULL;
|
|
3152
|
+
if (e === void 0) return O.UNDEFINED;
|
|
3153
|
+
if (e === !0) return O.TRUE;
|
|
3154
|
+
if (e === !1) return O.FALSE;
|
|
3155
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new j(e) : e < -18446744073709551616n ? new M(e) : e >= 0n ? new g(e) : new _(e);
|
|
3156
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new g(BigInt(e)) : new _(BigInt(e)) : new x(e);
|
|
3157
|
+
if (typeof e == "string") return new N(e);
|
|
3158
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return hn(e.valueOf(), t, !1);
|
|
3159
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new C(new Uint8Array(e));
|
|
3160
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new E(Array.from(e, (e) => new g(BigInt(e)))) : new C(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3161
|
+
if (e instanceof $) return new D([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
3162
|
+
if (Array.isArray(e)) return new E(e.map((e) => Q(e, t)));
|
|
3157
3163
|
if (typeof e == "object") {
|
|
3158
3164
|
let n = [];
|
|
3159
|
-
for (let [r, i] of Object.entries(e)) n.push([new
|
|
3160
|
-
return new
|
|
3165
|
+
for (let [r, i] of Object.entries(e)) n.push([new N(r), Q(i, t)]);
|
|
3166
|
+
return new D(n);
|
|
3161
3167
|
}
|
|
3162
3168
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3163
3169
|
}
|
|
3164
|
-
function
|
|
3170
|
+
function gn(e) {
|
|
3165
3171
|
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;
|
|
3166
3172
|
}
|
|
3167
|
-
function
|
|
3173
|
+
function _n(e, t, n, r) {
|
|
3168
3174
|
let i = [...n ?? [], ...Z];
|
|
3169
3175
|
function a(e) {
|
|
3170
3176
|
return e === l || r === !0 && e === void 0;
|
|
@@ -3175,7 +3181,7 @@ function hn(e, t, n, r) {
|
|
|
3175
3181
|
if (typeof e != "object" || !e) return e;
|
|
3176
3182
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
3177
3183
|
if (Array.isArray(e)) return e.map(r);
|
|
3178
|
-
if (c.symbol in e ||
|
|
3184
|
+
if (c.symbol in e || gn(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3179
3185
|
let t = Object.getPrototypeOf(e);
|
|
3180
3186
|
if (t === Object.prototype || t === null) {
|
|
3181
3187
|
let t = e.toJSON;
|
|
@@ -3210,7 +3216,7 @@ function hn(e, t, n, r) {
|
|
|
3210
3216
|
let r = s(t, String(n), e);
|
|
3211
3217
|
return a(r) ? null : r;
|
|
3212
3218
|
});
|
|
3213
|
-
if (
|
|
3219
|
+
if (gn(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3214
3220
|
let t = {};
|
|
3215
3221
|
for (let n of Object.keys(e)) {
|
|
3216
3222
|
let r = s(e[n], n, e);
|
|
@@ -3228,7 +3234,7 @@ var $ = class extends Array {
|
|
|
3228
3234
|
toJSON() {
|
|
3229
3235
|
let e = {};
|
|
3230
3236
|
for (let [t, n] of this) {
|
|
3231
|
-
let r = typeof t == "string" ? t : Q(t).
|
|
3237
|
+
let r = typeof t == "string" ? t : Q(t).toCDN();
|
|
3232
3238
|
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
3233
3239
|
value: n,
|
|
3234
3240
|
writable: !0,
|
|
@@ -3240,6 +3246,6 @@ var $ = class extends Array {
|
|
|
3240
3246
|
}
|
|
3241
3247
|
};
|
|
3242
3248
|
//#endregion
|
|
3243
|
-
export { l as C, n as D, c as E, u as S, t as T,
|
|
3249
|
+
export { l as C, n as D, c as E, u as S, t as T, S as _, Dt as a, g as b, M as c, O as d, D as f, C as g, w as h, pn as i, j as l, T as m, _n as n, N as o, E as p, Q as r, Ue as s, $ as t, k as u, x as v, e as w, d as x, _ as y };
|
|
3244
3250
|
|
|
3245
|
-
//# sourceMappingURL=mapEntries-
|
|
3251
|
+
//# sourceMappingURL=mapEntries-Da-2HMRf.js.map
|