@cbortech/cbor 0.25.4 → 0.25.6
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 +3 -1
- package/README.md +3 -1
- package/dist/ast/CborAppSeqResult.d.ts +4 -2
- package/dist/ast/CborArray.d.ts +1 -1
- package/dist/ast/CborByteString.d.ts +1 -1
- package/dist/ast/CborEmbeddedCBOR.d.ts +5 -2
- package/dist/ast/CborFloat.d.ts +1 -1
- package/dist/ast/CborMap.d.ts +1 -1
- package/dist/ast/CborNint.d.ts +1 -1
- package/dist/ast/CborTag.d.ts +1 -1
- package/dist/ast/CborTextString.d.ts +1 -1
- package/dist/ast/CborUint.d.ts +1 -1
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/cdn/serialize-utils.d.ts +14 -2
- package/dist/extensions/dt.d.ts +2 -2
- package/dist/extensions/types.d.ts +4 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +132 -61
- package/dist/index.js.map +1 -1
- package/dist/{mapEntries-D6BfG4-1.js → mapEntries-DDh7IS2M.js} +694 -571
- package/dist/mapEntries-DDh7IS2M.js.map +1 -0
- package/dist/mapEntries-DvugpzeP.cjs +12 -0
- package/dist/mapEntries-DvugpzeP.cjs.map +1 -0
- package/dist/types.d.ts +12 -0
- package/package.json +10 -9
- package/dist/mapEntries-Chd4Qmgv.cjs +0 -12
- package/dist/mapEntries-Chd4Qmgv.cjs.map +0 -1
- package/dist/mapEntries-D6BfG4-1.js.map +0 -1
|
@@ -95,16 +95,16 @@ var u = class {
|
|
|
95
95
|
}
|
|
96
96
|
}, p = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), m = new Int8Array(128).fill(-1);
|
|
97
97
|
for (let e = 0; e < 16; e++) m["0123456789abcdef".charCodeAt(e)] = e, m["0123456789ABCDEF".charCodeAt(e)] = e;
|
|
98
|
-
var
|
|
99
|
-
function
|
|
100
|
-
if (
|
|
98
|
+
var h = typeof Uint8Array.prototype.toHex == "function", ee = typeof Uint8Array.fromHex == "function", te = 256;
|
|
99
|
+
function ne(e) {
|
|
100
|
+
if (h) return e.toHex();
|
|
101
101
|
let t = "";
|
|
102
102
|
for (let n = 0; n < e.length; n++) t += p[e[n]];
|
|
103
103
|
return t;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function re(e) {
|
|
106
106
|
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
107
|
-
if (
|
|
107
|
+
if (ee && e.length >= te) return Uint8Array.fromHex(e);
|
|
108
108
|
let t = new Uint8Array(e.length / 2);
|
|
109
109
|
for (let n = 0, r = 0; n < e.length; n += 2, r++) {
|
|
110
110
|
let i = e.charCodeAt(n), a = e.charCodeAt(n + 1), o = i < 128 ? m[i] : -1, s = a < 128 ? m[a] : -1;
|
|
@@ -118,7 +118,7 @@ function ie(e) {
|
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/cdn/serialize-utils.ts
|
|
121
|
-
function
|
|
121
|
+
function ie(e) {
|
|
122
122
|
let t = e?.indent;
|
|
123
123
|
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
124
124
|
}
|
|
@@ -204,7 +204,7 @@ function ve(e, t, n) {
|
|
|
204
204
|
case "base64url": return `b64'${pe(e)}'`;
|
|
205
205
|
case "base32": return `b32'${ge(e, me)}'`;
|
|
206
206
|
case "base32hex": return `h32'${ge(e, he)}'`;
|
|
207
|
-
default: return `h'${
|
|
207
|
+
default: return `h'${ne(e)}'`;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
var ye = new TextDecoder("utf-8", { fatal: !0 });
|
|
@@ -265,13 +265,22 @@ function Ee(e) {
|
|
|
265
265
|
let t = e.toString();
|
|
266
266
|
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
267
267
|
}
|
|
268
|
-
function De(e, t, n) {
|
|
269
|
-
|
|
268
|
+
function De(e, t, n, r) {
|
|
269
|
+
if (r === "never") return "";
|
|
270
|
+
let i = t ?? n;
|
|
271
|
+
return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
272
|
+
}
|
|
273
|
+
function v(e) {
|
|
274
|
+
return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
|
|
275
|
+
}
|
|
276
|
+
function y(e, t, n) {
|
|
277
|
+
let r = e?.encodingIndicators ?? "auto";
|
|
278
|
+
return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
|
|
270
279
|
}
|
|
271
280
|
//#endregion
|
|
272
281
|
//#region src/utils/float16.ts
|
|
273
282
|
var Oe = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, ke = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
274
|
-
function
|
|
283
|
+
function b(e) {
|
|
275
284
|
ke.setFloat64(0, e, !1);
|
|
276
285
|
let t = ke.getUint32(0, !1), n = ke.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
277
286
|
if (i === 2047) {
|
|
@@ -294,15 +303,15 @@ function Ae(e) {
|
|
|
294
303
|
let u = o <= 0 ? 0 : o;
|
|
295
304
|
return r << 15 | u << 10 | s;
|
|
296
305
|
}
|
|
297
|
-
function
|
|
306
|
+
function x(e) {
|
|
298
307
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
299
308
|
return n === 31 ? r === 0 ? t ? -Infinity : Infinity : NaN : n === 0 ? r === 0 ? t ? -0 : 0 : (t ? -1 : 1) * 2 ** -14 * (r / 1024) : (t ? -1 : 1) * 2 ** (n - 15) * (1 + r / 1024);
|
|
300
309
|
}
|
|
301
|
-
var
|
|
310
|
+
var Ae = Oe ? (e, t, n, r) => {
|
|
302
311
|
e.setFloat16(t, n, r);
|
|
303
312
|
} : (e, t, n, r) => {
|
|
304
|
-
e.setUint16(t,
|
|
305
|
-
},
|
|
313
|
+
e.setUint16(t, b(n), r);
|
|
314
|
+
}, S = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), C = new Uint8Array(S.buffer), je = class {
|
|
306
315
|
buf;
|
|
307
316
|
len = 0;
|
|
308
317
|
constructor(e = 256) {
|
|
@@ -333,34 +342,34 @@ var Me = Oe ? (e, t, n, r) => {
|
|
|
333
342
|
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
334
343
|
}
|
|
335
344
|
writeBigUint64(e) {
|
|
336
|
-
|
|
345
|
+
S.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(C, this.len), this.len += 8;
|
|
337
346
|
}
|
|
338
347
|
writeFloat16(e) {
|
|
339
|
-
|
|
348
|
+
Ae(S, 0, e, !1), this._ensure(2);
|
|
340
349
|
let t = this.buf;
|
|
341
|
-
t[this.len++] =
|
|
350
|
+
t[this.len++] = C[0], t[this.len++] = C[1];
|
|
342
351
|
}
|
|
343
352
|
writeFloat32(e) {
|
|
344
|
-
|
|
353
|
+
S.setFloat32(0, e, !1), this._ensure(4);
|
|
345
354
|
let t = this.buf;
|
|
346
|
-
t[this.len++] =
|
|
355
|
+
t[this.len++] = C[0], t[this.len++] = C[1], t[this.len++] = C[2], t[this.len++] = C[3];
|
|
347
356
|
}
|
|
348
357
|
writeFloat64(e) {
|
|
349
|
-
|
|
358
|
+
S.setFloat64(0, e, !1), this._ensure(8), this.buf.set(C, this.len), this.len += 8;
|
|
350
359
|
}
|
|
351
360
|
finish() {
|
|
352
361
|
return this.buf.slice(0, this.len);
|
|
353
362
|
}
|
|
354
|
-
},
|
|
363
|
+
}, Me = [
|
|
355
364
|
255n,
|
|
356
365
|
65535n,
|
|
357
366
|
4294967295n,
|
|
358
367
|
18446744073709551615n
|
|
359
368
|
];
|
|
360
|
-
function
|
|
361
|
-
return e === "i" ? 23n :
|
|
369
|
+
function Ne(e) {
|
|
370
|
+
return e === "i" ? 23n : Me[e];
|
|
362
371
|
}
|
|
363
|
-
function
|
|
372
|
+
function w(e, t, n, r) {
|
|
364
373
|
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
365
374
|
n <= 23 ? e.writeByte(t << 5 | n) : n <= 255 ? (e.writeByte(t << 5 | 24), e.writeByte(n)) : n <= 65535 ? (e.writeByte(t << 5 | 25), e.writeUint16(n)) : (e.writeByte(t << 5 | 26), e.writeUint32(n));
|
|
366
375
|
return;
|
|
@@ -372,30 +381,30 @@ function x(e, t, n, r) {
|
|
|
372
381
|
e.writeByte(t << 5 | Number(i));
|
|
373
382
|
return;
|
|
374
383
|
}
|
|
375
|
-
if (i >
|
|
384
|
+
if (i > Me[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Me[r]})`);
|
|
376
385
|
let n = 24 + r;
|
|
377
386
|
e.writeByte(t << 5 | n), n === 24 ? e.writeByte(Number(i)) : n === 25 ? e.writeUint16(Number(i)) : n === 26 ? e.writeUint32(Number(i)) : e.writeBigUint64(i);
|
|
378
387
|
return;
|
|
379
388
|
}
|
|
380
389
|
i <= 23n ? e.writeByte(t << 5 | Number(i)) : i <= 255n ? (e.writeByte(t << 5 | 24), e.writeByte(Number(i))) : i <= 65535n ? (e.writeByte(t << 5 | 25), e.writeUint16(Number(i))) : i <= 4294967295n ? (e.writeByte(t << 5 | 26), e.writeUint32(Number(i))) : (e.writeByte(t << 5 | 27), e.writeBigUint64(i));
|
|
381
390
|
}
|
|
382
|
-
function
|
|
383
|
-
let r = new
|
|
384
|
-
return
|
|
391
|
+
function Pe(e, t, n) {
|
|
392
|
+
let r = new je(9);
|
|
393
|
+
return w(r, e, t, n), r.finish();
|
|
385
394
|
}
|
|
386
395
|
var Fe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
387
396
|
function Ie(e) {
|
|
388
|
-
return Object.is(
|
|
397
|
+
return Object.is(x(b(e)), e);
|
|
389
398
|
}
|
|
390
399
|
function Le(e) {
|
|
391
400
|
return Fe.setFloat32(0, e, !1), Object.is(Fe.getFloat32(0, !1), e);
|
|
392
401
|
}
|
|
393
|
-
function
|
|
402
|
+
function T(e) {
|
|
394
403
|
return Ie(e) ? "half" : Le(e) ? "single" : "double";
|
|
395
404
|
}
|
|
396
405
|
//#endregion
|
|
397
406
|
//#region src/ast/CborItem.ts
|
|
398
|
-
var
|
|
407
|
+
var E = class e {
|
|
399
408
|
start;
|
|
400
409
|
end;
|
|
401
410
|
comments;
|
|
@@ -405,7 +414,7 @@ var C = class e {
|
|
|
405
414
|
let t = this._defaults ? {
|
|
406
415
|
...this._defaults,
|
|
407
416
|
...e
|
|
408
|
-
} : e, n = new
|
|
417
|
+
} : e, n = new je();
|
|
409
418
|
return this._encode(n, t), n.finish();
|
|
410
419
|
}
|
|
411
420
|
toCDN(e) {
|
|
@@ -448,7 +457,7 @@ var C = class e {
|
|
|
448
457
|
t.writeBytes(this._toCBOR(n));
|
|
449
458
|
}
|
|
450
459
|
_toCBOR(e) {
|
|
451
|
-
let t = new
|
|
460
|
+
let t = new je();
|
|
452
461
|
return this._encodeTo(t, e), t.finish();
|
|
453
462
|
}
|
|
454
463
|
_toHexDump(e, t) {
|
|
@@ -458,7 +467,7 @@ var C = class e {
|
|
|
458
467
|
comment: this._toCDN(t, 0)
|
|
459
468
|
}];
|
|
460
469
|
}
|
|
461
|
-
},
|
|
470
|
+
}, D = class extends E {
|
|
462
471
|
value;
|
|
463
472
|
encodingWidth;
|
|
464
473
|
constructor(e, t) {
|
|
@@ -467,10 +476,10 @@ var C = class e {
|
|
|
467
476
|
this.encodingWidth = t?.encodingWidth;
|
|
468
477
|
}
|
|
469
478
|
_encodeTo(e, t) {
|
|
470
|
-
|
|
479
|
+
w(e, 0, this.value, this.encodingWidth);
|
|
471
480
|
}
|
|
472
481
|
_toCDN(e, t) {
|
|
473
|
-
let n = this.encodingWidth
|
|
482
|
+
let n = y(e, this.encodingWidth, () => v(this.value)), r = this.value;
|
|
474
483
|
switch (e?.intFormat) {
|
|
475
484
|
case "hex": return `0x${r.toString(16)}${n}`;
|
|
476
485
|
case "octal": return `0o${r.toString(8)}${n}`;
|
|
@@ -482,7 +491,7 @@ var C = class e {
|
|
|
482
491
|
let t = e?.integerAs ?? "auto";
|
|
483
492
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
484
493
|
}
|
|
485
|
-
},
|
|
494
|
+
}, O = class extends E {
|
|
486
495
|
argument;
|
|
487
496
|
encodingWidth;
|
|
488
497
|
constructor(e, t) {
|
|
@@ -496,10 +505,10 @@ var C = class e {
|
|
|
496
505
|
return -1n - this.argument;
|
|
497
506
|
}
|
|
498
507
|
_encodeTo(e, t) {
|
|
499
|
-
|
|
508
|
+
w(e, 1, this.argument, this.encodingWidth);
|
|
500
509
|
}
|
|
501
510
|
_toCDN(e, t) {
|
|
502
|
-
let n = this.encodingWidth
|
|
511
|
+
let n = y(e, this.encodingWidth, () => v(this.argument)), r = this.argument + 1n;
|
|
503
512
|
switch (e?.intFormat) {
|
|
504
513
|
case "hex": return `-0x${r.toString(16)}${n}`;
|
|
505
514
|
case "octal": return `-0o${r.toString(8)}${n}`;
|
|
@@ -511,8 +520,8 @@ var C = class e {
|
|
|
511
520
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
512
521
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
513
522
|
}
|
|
514
|
-
},
|
|
515
|
-
function
|
|
523
|
+
}, Re = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
524
|
+
function ze(e) {
|
|
516
525
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
517
526
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
518
527
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -530,20 +539,20 @@ function Be(e) {
|
|
|
530
539
|
let l = c * 2 ** o;
|
|
531
540
|
return t ? -l : l;
|
|
532
541
|
}
|
|
533
|
-
function
|
|
542
|
+
function Be(e) {
|
|
534
543
|
if (isNaN(e)) return "NaN";
|
|
535
544
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
536
545
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
537
546
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
538
|
-
|
|
539
|
-
let r =
|
|
547
|
+
Re.setFloat64(0, n, !1);
|
|
548
|
+
let r = Re.getUint32(0, !1), i = Re.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
|
|
540
549
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
541
550
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
542
551
|
return t ? `-${p}` : p;
|
|
543
552
|
}
|
|
544
553
|
//#endregion
|
|
545
554
|
//#region src/ast/CborFloat.ts
|
|
546
|
-
var
|
|
555
|
+
var k = class extends E {
|
|
547
556
|
value;
|
|
548
557
|
precision;
|
|
549
558
|
ednSource;
|
|
@@ -551,18 +560,27 @@ var E = class extends C {
|
|
|
551
560
|
super(), this.value = e, this.precision = t?.precision;
|
|
552
561
|
}
|
|
553
562
|
_encodeTo(e, t) {
|
|
554
|
-
let n = this.precision ??
|
|
563
|
+
let n = this.precision ?? T(this.value);
|
|
555
564
|
n === "half" ? (e.writeByte(249), e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), e.writeFloat32(this.value)) : (e.writeByte(251), e.writeFloat64(this.value));
|
|
556
565
|
}
|
|
557
566
|
_toCDN(e, t) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
567
|
+
let n = e?.encodingIndicators ?? "auto";
|
|
568
|
+
if (e?.appStrings !== !1 && this.ednSource !== void 0) {
|
|
569
|
+
if (n === "never") return this.ednSource.replace(/_[0-3i]$/, "");
|
|
570
|
+
if (n === "always") {
|
|
571
|
+
if (/_[0-3i]$/.test(this.ednSource)) return this.ednSource;
|
|
572
|
+
let e = this.precision ?? T(this.value), t = e === "half" ? "_1" : e === "single" ? "_2" : "_3";
|
|
573
|
+
return this.ednSource + t;
|
|
574
|
+
}
|
|
575
|
+
return this.ednSource;
|
|
576
|
+
}
|
|
577
|
+
let r = T(this.value);
|
|
578
|
+
return (e?.floatFormat === "hex" ? Be(this.value) : Ee(this.value)) + De(this.value, this.precision, r, n);
|
|
561
579
|
}
|
|
562
580
|
_toJS(e) {
|
|
563
581
|
return this.value;
|
|
564
582
|
}
|
|
565
|
-
},
|
|
583
|
+
}, A = class extends E {
|
|
566
584
|
tag;
|
|
567
585
|
content;
|
|
568
586
|
encodingWidth;
|
|
@@ -571,25 +589,28 @@ var E = class extends C {
|
|
|
571
589
|
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
572
590
|
}
|
|
573
591
|
_encodeTo(e, t) {
|
|
574
|
-
|
|
592
|
+
w(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
575
593
|
}
|
|
576
594
|
_toCDN(e, t) {
|
|
577
|
-
let n = this.encodingWidth
|
|
595
|
+
let n = y(e, this.encodingWidth, () => v(this.tag));
|
|
578
596
|
return `${this.tag}${n}(${this.content._toCDN(e, t)})`;
|
|
579
597
|
}
|
|
580
598
|
_toHexDump(e, t) {
|
|
581
599
|
let n = [{
|
|
582
600
|
depth: e,
|
|
583
|
-
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(
|
|
601
|
+
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(Pe(6, this.tag, this.encodingWidth)),
|
|
584
602
|
comment: `Tag ${this.tag}`
|
|
585
603
|
}];
|
|
586
|
-
return n.push(...this.content._toHexDump(e + 1,
|
|
604
|
+
return n.push(...this.content._toHexDump(e + 1, {
|
|
605
|
+
...t,
|
|
606
|
+
appStrings: !1
|
|
607
|
+
})), n;
|
|
587
608
|
}
|
|
588
609
|
_toJS(e) {
|
|
589
610
|
let t = this.content._toJS(e);
|
|
590
611
|
return e?.stripTags ? t : u.set(t, this.tag);
|
|
591
612
|
}
|
|
592
|
-
},
|
|
613
|
+
}, j = class extends E {
|
|
593
614
|
indefiniteLength = !1;
|
|
594
615
|
value;
|
|
595
616
|
ednEncoding;
|
|
@@ -599,18 +620,21 @@ var E = class extends C {
|
|
|
599
620
|
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
600
621
|
}
|
|
601
622
|
_encodeTo(e, t) {
|
|
602
|
-
|
|
623
|
+
w(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
603
624
|
}
|
|
604
625
|
_toCDN(e, t) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
626
|
+
if (e?.preserveByteString && this.ednSource !== void 0) {
|
|
627
|
+
if (/_[0-3i]$/.test(this.ednSource)) return (e?.encodingIndicators ?? "auto") === "never" ? this.ednSource.replace(/_[0-3i]$/, "") : this.ednSource;
|
|
628
|
+
let t = y(e, this.encodingWidth, () => v(BigInt(this.value.length)));
|
|
629
|
+
return this.ednSource + t;
|
|
630
|
+
}
|
|
631
|
+
let n = y(e, this.encodingWidth, () => v(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
|
|
608
632
|
return e?.appStrings === !1 && r !== "hex" && (r = "hex"), ve(this.value, r, e?.sqstr) + n;
|
|
609
633
|
}
|
|
610
634
|
_toJS(e) {
|
|
611
635
|
return this.value;
|
|
612
636
|
}
|
|
613
|
-
},
|
|
637
|
+
}, M = class extends E {
|
|
614
638
|
indefiniteLength = !0;
|
|
615
639
|
chunks;
|
|
616
640
|
constructor(e) {
|
|
@@ -642,7 +666,7 @@ var E = class extends C {
|
|
|
642
666
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
643
667
|
return n;
|
|
644
668
|
}
|
|
645
|
-
},
|
|
669
|
+
}, N = class extends E {
|
|
646
670
|
indefiniteLength = !0;
|
|
647
671
|
chunks;
|
|
648
672
|
constructor(e) {
|
|
@@ -672,7 +696,7 @@ var E = class extends C {
|
|
|
672
696
|
_toJS(e) {
|
|
673
697
|
return this.chunks.map((e) => e.value).join("");
|
|
674
698
|
}
|
|
675
|
-
},
|
|
699
|
+
}, P = class extends E {
|
|
676
700
|
items;
|
|
677
701
|
indefiniteLength;
|
|
678
702
|
encodingWidth;
|
|
@@ -686,25 +710,25 @@ var E = class extends C {
|
|
|
686
710
|
e.writeByte(255);
|
|
687
711
|
return;
|
|
688
712
|
}
|
|
689
|
-
|
|
713
|
+
w(e, 4, this.items.length, this.encodingWidth);
|
|
690
714
|
for (let n of this.items) n._encode(e, t);
|
|
691
715
|
}
|
|
692
716
|
_toCDN(e, t) {
|
|
693
|
-
let n =
|
|
717
|
+
let n = ie(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (oe(this) || this.items.some(ae));
|
|
694
718
|
n === null && a && (n = " ");
|
|
695
|
-
let { inlineSep: o, multilineSep: s, trailSep: c } = ue(e, n === null), l =
|
|
719
|
+
let { inlineSep: o, multilineSep: s, trailSep: c } = ue(e, n === null), l = this.indefiniteLength ? "" : y(e, this.encodingWidth, () => v(BigInt(this.items.length))), u = l ? l + " " : "";
|
|
696
720
|
if (n === null || this.items.length === 0 && !a) {
|
|
697
721
|
let n = this.items.map((n) => n._toCDN(e, t + 1)).join(o);
|
|
698
|
-
return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${
|
|
722
|
+
return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${u}${n}]`;
|
|
699
723
|
}
|
|
700
|
-
let
|
|
724
|
+
let d = g(n, t + 1), f = g(n, t), p = this.indefiniteLength ? "[_ " : `[${u}`, m = [];
|
|
701
725
|
for (let n = 0; n < this.items.length; n++) {
|
|
702
726
|
let a = this.items[n];
|
|
703
|
-
r &&
|
|
727
|
+
r && m.push(...se(a, d, i));
|
|
704
728
|
let o = n < this.items.length - 1 ? s : c;
|
|
705
|
-
|
|
729
|
+
m.push(`${d}${a._toCDN(e, t + 1)}${o}${r ? ce(a, i) : ""}`);
|
|
706
730
|
}
|
|
707
|
-
return r &&
|
|
731
|
+
return r && m.push(...le(this, d, i)), `${p}\n${m.join("\n")}\n${f}]`;
|
|
708
732
|
}
|
|
709
733
|
_toHexDump(e, t) {
|
|
710
734
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -723,7 +747,7 @@ var E = class extends C {
|
|
|
723
747
|
}
|
|
724
748
|
let i = [{
|
|
725
749
|
depth: e,
|
|
726
|
-
hex: r(
|
|
750
|
+
hex: r(Pe(4, BigInt(this.items.length), this.encodingWidth)),
|
|
727
751
|
comment: `Array of length ${this.items.length}`
|
|
728
752
|
}];
|
|
729
753
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -742,7 +766,7 @@ var E = class extends C {
|
|
|
742
766
|
}
|
|
743
767
|
return r;
|
|
744
768
|
}
|
|
745
|
-
},
|
|
769
|
+
}, F = class extends E {
|
|
746
770
|
entries;
|
|
747
771
|
indefiniteLength;
|
|
748
772
|
encodingWidth;
|
|
@@ -756,29 +780,29 @@ var E = class extends C {
|
|
|
756
780
|
e.writeByte(255);
|
|
757
781
|
return;
|
|
758
782
|
}
|
|
759
|
-
|
|
783
|
+
w(e, 5, this.entries.length, this.encodingWidth);
|
|
760
784
|
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
761
785
|
}
|
|
762
786
|
_toCDN(e, t) {
|
|
763
|
-
let n =
|
|
787
|
+
let n = ie(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (oe(this) || this.entries.some(([e, t]) => ae(e) || ae(t)));
|
|
764
788
|
n === null && a && (n = " ");
|
|
765
|
-
let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } = ue(e, n === null), u =
|
|
789
|
+
let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } = ue(e, n === null), u = this.indefiniteLength ? "" : y(e, this.encodingWidth, () => v(BigInt(this.entries.length))), d = u ? u + " " : "", f = this.indefiniteLength ? "{_ " : `{${d}`;
|
|
766
790
|
if (n === null || this.entries.length === 0 && !a) {
|
|
767
791
|
let n = this.entries.map(([n, r]) => `${n._toCDN(e, t + 1)}${l}${r._toCDN(e, t + 1)}`).join(o);
|
|
768
|
-
return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${
|
|
792
|
+
return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${d}${n}}`;
|
|
769
793
|
}
|
|
770
|
-
let
|
|
794
|
+
let p = g(n, t + 1), m = g(n, t), h = [];
|
|
771
795
|
for (let n = 0; n < this.entries.length; n++) {
|
|
772
796
|
let [a, o] = this.entries[n];
|
|
773
|
-
r &&
|
|
774
|
-
let u = n < this.entries.length - 1 ? s : c, d = r ?
|
|
797
|
+
r && h.push(...se(a, p, i));
|
|
798
|
+
let u = n < this.entries.length - 1 ? s : c, d = r ? Ve([
|
|
775
799
|
...a.comments?.trailing ?? [],
|
|
776
800
|
...o.comments?.leading ?? [],
|
|
777
801
|
...o.comments?.trailing ?? []
|
|
778
802
|
], i) : "";
|
|
779
|
-
|
|
803
|
+
h.push(`${p}${a._toCDN(e, t + 1)}${l}${o._toCDN(e, t + 1)}${u}${d}`);
|
|
780
804
|
}
|
|
781
|
-
return r &&
|
|
805
|
+
return r && h.push(...le(this, p, i)), `${f}\n${h.join("\n")}\n${m}}`;
|
|
782
806
|
}
|
|
783
807
|
_toHexDump(e, t) {
|
|
784
808
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -797,7 +821,7 @@ var E = class extends C {
|
|
|
797
821
|
}
|
|
798
822
|
let i = [{
|
|
799
823
|
depth: e,
|
|
800
|
-
hex: r(
|
|
824
|
+
hex: r(Pe(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
801
825
|
comment: `Map of length ${this.entries.length}`
|
|
802
826
|
}];
|
|
803
827
|
for (let [n, r] of this.entries) i.push(...n._toHexDump(e + 1, t)), i.push(...r._toHexDump(e + 1, t));
|
|
@@ -814,13 +838,13 @@ var E = class extends C {
|
|
|
814
838
|
}
|
|
815
839
|
return n;
|
|
816
840
|
};
|
|
817
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
841
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof R) ? (() => {
|
|
818
842
|
let n = e ? {
|
|
819
843
|
...e,
|
|
820
844
|
reviver: void 0
|
|
821
845
|
} : void 0, r = {};
|
|
822
846
|
for (let [e, t] of this.entries) {
|
|
823
|
-
let i = e instanceof
|
|
847
|
+
let i = e instanceof R ? e.value : e.toCDN(), a = t._toJS(n);
|
|
824
848
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
825
849
|
value: a,
|
|
826
850
|
writable: !0,
|
|
@@ -832,10 +856,10 @@ var E = class extends C {
|
|
|
832
856
|
let i = /* @__PURE__ */ new Map();
|
|
833
857
|
for (let e = 0; e < this.entries.length; e++) {
|
|
834
858
|
let [t] = this.entries[e];
|
|
835
|
-
i.set(t instanceof
|
|
859
|
+
i.set(t instanceof R ? t.value : t.toCDN(), e);
|
|
836
860
|
}
|
|
837
861
|
for (let n = 0; n < this.entries.length; n++) {
|
|
838
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
862
|
+
let [a, o] = this.entries[n], s = a instanceof R ? a.value : a.toCDN();
|
|
839
863
|
if (i.get(s) !== n) continue;
|
|
840
864
|
let c = o._toJS(e), l = t.call(r, s, c);
|
|
841
865
|
l === d || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
@@ -849,12 +873,12 @@ var E = class extends C {
|
|
|
849
873
|
})() : n();
|
|
850
874
|
}
|
|
851
875
|
};
|
|
852
|
-
function
|
|
876
|
+
function Ve(e, t) {
|
|
853
877
|
return e.length === 0 ? "" : " " + e.map((e) => _(e, t).trimEnd()).join(" ");
|
|
854
878
|
}
|
|
855
879
|
//#endregion
|
|
856
880
|
//#region src/ast/CborSimple.ts
|
|
857
|
-
var
|
|
881
|
+
var I = class e extends E {
|
|
858
882
|
value;
|
|
859
883
|
constructor(e) {
|
|
860
884
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
@@ -889,31 +913,33 @@ var N = class e extends C {
|
|
|
889
913
|
default: return new f(this.value);
|
|
890
914
|
}
|
|
891
915
|
}
|
|
892
|
-
},
|
|
916
|
+
}, He = class extends E {
|
|
893
917
|
items;
|
|
894
|
-
|
|
895
|
-
|
|
918
|
+
encodingWidth;
|
|
919
|
+
constructor(e, t) {
|
|
920
|
+
super(), this.items = e, this.encodingWidth = t?.encodingWidth;
|
|
896
921
|
}
|
|
897
922
|
_content(e) {
|
|
898
|
-
let t = new
|
|
923
|
+
let t = new je();
|
|
899
924
|
for (let n of this.items) n._encode(t, e);
|
|
900
925
|
return t.finish();
|
|
901
926
|
}
|
|
902
927
|
_encodeTo(e, t) {
|
|
903
928
|
let n = this._content(t);
|
|
904
|
-
|
|
929
|
+
w(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
905
930
|
}
|
|
906
931
|
_toCDN(e, t) {
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
932
|
+
let n = y(e, this.encodingWidth, () => v(BigInt(this._content(e).length)));
|
|
933
|
+
if (this.items.length === 0) return `<<>>${n}`;
|
|
934
|
+
let r = ie(e), { inlineSep: i, multilineSep: a, trailSep: o } = ue(e, r === null);
|
|
935
|
+
if (r === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(i)}>>${n}`;
|
|
936
|
+
let s = g(r, t + 1), c = g(r, t), l = this.items.map((n) => `${s}${n._toCDN(e, t + 1)}`), u = l.length - 1;
|
|
937
|
+
return `<<\n${l.map((e, t) => t < u ? `${e}${a}` : `${e}${o}`).join("\n")}\n${c}>>${n}`;
|
|
912
938
|
}
|
|
913
939
|
_toHexDump(e, t) {
|
|
914
940
|
let n = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "), r = this._content().length, i = [{
|
|
915
941
|
depth: e,
|
|
916
|
-
hex: n(
|
|
942
|
+
hex: n(Pe(2, BigInt(r), this.encodingWidth)),
|
|
917
943
|
comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
|
|
918
944
|
}];
|
|
919
945
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -922,17 +948,17 @@ var N = class e extends C {
|
|
|
922
948
|
_toJS(e) {
|
|
923
949
|
return this._content();
|
|
924
950
|
}
|
|
925
|
-
}, Ue = 999n,
|
|
951
|
+
}, Ue = 999n, We = class extends A {
|
|
926
952
|
constructor(e, t) {
|
|
927
|
-
let n = t.length === 1 && t[0] instanceof
|
|
928
|
-
super(Ue, new
|
|
953
|
+
let n = t.length === 1 && t[0] instanceof R ? t[0] : new P(t);
|
|
954
|
+
super(Ue, new P([new R(e), n]));
|
|
929
955
|
}
|
|
930
956
|
_toCDN(e, t) {
|
|
931
957
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
932
958
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
933
|
-
return i instanceof
|
|
959
|
+
return i instanceof R ? `${r}${we(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
934
960
|
}
|
|
935
|
-
},
|
|
961
|
+
}, Ge = class extends E {
|
|
936
962
|
inner;
|
|
937
963
|
ednSource;
|
|
938
964
|
constructor(e, t) {
|
|
@@ -942,20 +968,21 @@ var N = class e extends C {
|
|
|
942
968
|
this.inner._encode(e, t);
|
|
943
969
|
}
|
|
944
970
|
_toCDN(e, t) {
|
|
945
|
-
|
|
971
|
+
let n = e?.encodingIndicators ?? "auto";
|
|
972
|
+
return e?.appStrings !== !1 && n === "auto" ? this.ednSource : this.inner._toCDN(e, t);
|
|
946
973
|
}
|
|
947
974
|
_toJS(e) {
|
|
948
975
|
return this.inner._toJS(e);
|
|
949
976
|
}
|
|
950
|
-
},
|
|
977
|
+
}, Ke = 888n, L = class extends A {
|
|
951
978
|
constructor(e) {
|
|
952
|
-
e === void 0 ? super(
|
|
979
|
+
e === void 0 ? super(Ke, I.NULL) : super(Ke, new P(e));
|
|
953
980
|
}
|
|
954
981
|
_toCDN(e, t) {
|
|
955
|
-
return this.content instanceof
|
|
982
|
+
return this.content instanceof I ? "..." : this.content instanceof P ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
956
983
|
}
|
|
957
|
-
},
|
|
958
|
-
function
|
|
984
|
+
}, qe = 2n, Je = 3n, Ye = 18446744073709551615n, Xe = -18446744073709551616n;
|
|
985
|
+
function Ze(e) {
|
|
959
986
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
960
987
|
if (e === 0n) return new Uint8Array();
|
|
961
988
|
let t = e.toString(16);
|
|
@@ -964,16 +991,16 @@ function Xe(e) {
|
|
|
964
991
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
965
992
|
return n;
|
|
966
993
|
}
|
|
967
|
-
function
|
|
994
|
+
function Qe(e) {
|
|
968
995
|
let t = 0n;
|
|
969
996
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
970
997
|
return t;
|
|
971
998
|
}
|
|
972
|
-
var
|
|
999
|
+
var $e = class extends A {
|
|
973
1000
|
bigValue;
|
|
974
1001
|
constructor(e) {
|
|
975
|
-
if (e <=
|
|
976
|
-
super(
|
|
1002
|
+
if (e <= Ye) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1003
|
+
super(qe, new j(Ze(e))), this.bigValue = e;
|
|
977
1004
|
}
|
|
978
1005
|
_toCDN(e, t) {
|
|
979
1006
|
return this.bigValue.toString();
|
|
@@ -981,11 +1008,11 @@ var Qe = class extends D {
|
|
|
981
1008
|
_toJS(e) {
|
|
982
1009
|
return this.bigValue;
|
|
983
1010
|
}
|
|
984
|
-
},
|
|
1011
|
+
}, et = class extends A {
|
|
985
1012
|
bigValue;
|
|
986
1013
|
constructor(e) {
|
|
987
|
-
if (e >=
|
|
988
|
-
super(
|
|
1014
|
+
if (e >= Xe) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1015
|
+
super(Je, new j(Ze(-1n - e))), this.bigValue = e;
|
|
989
1016
|
}
|
|
990
1017
|
_toCDN(e, t) {
|
|
991
1018
|
return this.bigValue.toString();
|
|
@@ -993,22 +1020,22 @@ var Qe = class extends D {
|
|
|
993
1020
|
_toJS(e) {
|
|
994
1021
|
return this.bigValue;
|
|
995
1022
|
}
|
|
996
|
-
},
|
|
997
|
-
function
|
|
998
|
-
let r = new t(e, { offset: n?.offset }), i = new
|
|
999
|
-
return n?.preserveComments &&
|
|
1023
|
+
}, tt = new TextEncoder(), nt = new TextDecoder("utf-8", { fatal: !0 }), rt = new TextDecoder("utf-8", { fatal: !1 });
|
|
1024
|
+
function it(e, n) {
|
|
1025
|
+
let r = new t(e, { offset: n?.offset }), i = new gt(r, n ?? {}).parse();
|
|
1026
|
+
return n?.preserveComments && lt(i, r.comments, e), i;
|
|
1000
1027
|
}
|
|
1001
|
-
function
|
|
1028
|
+
function at(e) {
|
|
1002
1029
|
let t = e, n;
|
|
1003
1030
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1004
1031
|
numStr: t,
|
|
1005
1032
|
rawSuffix: n
|
|
1006
1033
|
};
|
|
1007
1034
|
}
|
|
1008
|
-
function
|
|
1035
|
+
function ot(e) {
|
|
1009
1036
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1010
1037
|
}
|
|
1011
|
-
function
|
|
1038
|
+
function st(e, t) {
|
|
1012
1039
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1013
1040
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1014
1041
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1032,14 +1059,14 @@ function at(e, t) {
|
|
|
1032
1059
|
};
|
|
1033
1060
|
let n = e, r;
|
|
1034
1061
|
return e.endsWith("_1") ? (r = "half", n = e.slice(0, -2)) : e.endsWith("_2") ? (r = "single", n = e.slice(0, -2)) : e.endsWith("_3") && (r = "double", n = e.slice(0, -2)), /^-?0[xX]/.test(n) ? {
|
|
1035
|
-
value:
|
|
1062
|
+
value: ze(n),
|
|
1036
1063
|
precision: r
|
|
1037
1064
|
} : {
|
|
1038
1065
|
value: parseFloat(n),
|
|
1039
1066
|
precision: r
|
|
1040
1067
|
};
|
|
1041
1068
|
}
|
|
1042
|
-
function
|
|
1069
|
+
function ct(e, t) {
|
|
1043
1070
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1044
1071
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1045
1072
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -1076,49 +1103,49 @@ function ot(e, t) {
|
|
|
1076
1103
|
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1077
1104
|
return l;
|
|
1078
1105
|
}
|
|
1079
|
-
function
|
|
1106
|
+
function lt(e, t, n) {
|
|
1080
1107
|
if (t.length === 0) return;
|
|
1081
|
-
let r =
|
|
1108
|
+
let r = ut(e), i = ft(n);
|
|
1082
1109
|
for (let a of t) {
|
|
1083
1110
|
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) : "";
|
|
1084
1111
|
if (o && i(o.end) === a.line && !s.includes(":")) {
|
|
1085
|
-
|
|
1112
|
+
dt(o.node, "trailing", t);
|
|
1086
1113
|
continue;
|
|
1087
1114
|
}
|
|
1088
1115
|
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];
|
|
1089
1116
|
if ((!c || l && l.end <= c.end) && l) {
|
|
1090
|
-
|
|
1117
|
+
dt(l.node, "leading", t);
|
|
1091
1118
|
continue;
|
|
1092
1119
|
}
|
|
1093
|
-
|
|
1120
|
+
dt(c?.node ?? e, "dangling", t);
|
|
1094
1121
|
}
|
|
1095
1122
|
}
|
|
1096
|
-
function
|
|
1123
|
+
function ut(e) {
|
|
1097
1124
|
let t = [], n = (e) => {
|
|
1098
1125
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1099
1126
|
node: e,
|
|
1100
1127
|
start: e.start,
|
|
1101
1128
|
end: e.end
|
|
1102
|
-
}), e instanceof
|
|
1129
|
+
}), e instanceof P || e instanceof He) {
|
|
1103
1130
|
for (let t of e.items) n(t);
|
|
1104
1131
|
return;
|
|
1105
1132
|
}
|
|
1106
|
-
if (e instanceof
|
|
1133
|
+
if (e instanceof F) {
|
|
1107
1134
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1108
1135
|
return;
|
|
1109
1136
|
}
|
|
1110
|
-
if (e instanceof
|
|
1137
|
+
if (e instanceof M || e instanceof N) {
|
|
1111
1138
|
for (let t of e.chunks) n(t);
|
|
1112
1139
|
return;
|
|
1113
1140
|
}
|
|
1114
|
-
e instanceof
|
|
1141
|
+
e instanceof A && n(e.content);
|
|
1115
1142
|
};
|
|
1116
1143
|
return n(e), t;
|
|
1117
1144
|
}
|
|
1118
|
-
function
|
|
1145
|
+
function dt(e, t, n) {
|
|
1119
1146
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1120
1147
|
}
|
|
1121
|
-
function
|
|
1148
|
+
function ft(e) {
|
|
1122
1149
|
let t = [0];
|
|
1123
1150
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1124
1151
|
return (n) => {
|
|
@@ -1132,15 +1159,15 @@ function ut(e) {
|
|
|
1132
1159
|
return a + 1;
|
|
1133
1160
|
};
|
|
1134
1161
|
}
|
|
1135
|
-
var
|
|
1136
|
-
["b32",
|
|
1137
|
-
["h32",
|
|
1138
|
-
["float",
|
|
1139
|
-
["same",
|
|
1140
|
-
["hash",
|
|
1141
|
-
["uuid",
|
|
1142
|
-
["UUID",
|
|
1143
|
-
]),
|
|
1162
|
+
var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, mt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, ht = new Map([
|
|
1163
|
+
["b32", pt("b32")],
|
|
1164
|
+
["h32", pt("h32")],
|
|
1165
|
+
["float", pt("float")],
|
|
1166
|
+
["same", pt("same")],
|
|
1167
|
+
["hash", mt("hash", "@cbortech/hash-extension")],
|
|
1168
|
+
["uuid", mt("uuid", "@cbortech/uuid-extension")],
|
|
1169
|
+
["UUID", mt("uuid", "@cbortech/uuid-extension")]
|
|
1170
|
+
]), gt = class {
|
|
1144
1171
|
t;
|
|
1145
1172
|
_options;
|
|
1146
1173
|
extByPrefix;
|
|
@@ -1193,12 +1220,12 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1193
1220
|
case "BYTES_HEX":
|
|
1194
1221
|
case "SQSTR":
|
|
1195
1222
|
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1196
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1197
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1198
|
-
case "TRUE": return this.t.consume(), new
|
|
1199
|
-
case "FALSE": return this.t.consume(), new
|
|
1200
|
-
case "NULL": return this.t.consume(), new
|
|
1201
|
-
case "UNDEFINED": return this.t.consume(), new
|
|
1223
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new M([]);
|
|
1224
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new N([]);
|
|
1225
|
+
case "TRUE": return this.t.consume(), new I(21);
|
|
1226
|
+
case "FALSE": return this.t.consume(), new I(20);
|
|
1227
|
+
case "NULL": return this.t.consume(), new I(22);
|
|
1228
|
+
case "UNDEFINED": return this.t.consume(), new I(23);
|
|
1202
1229
|
case "SIMPLE": return this.parseSimple();
|
|
1203
1230
|
case "LBRACKET": return this.parseArray();
|
|
1204
1231
|
case "LBRACE": return this.parseMap();
|
|
@@ -1206,23 +1233,28 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1206
1233
|
case "LT_LT": return this.parseEmbeddedCBOR();
|
|
1207
1234
|
case "APP_STRING": {
|
|
1208
1235
|
this.t.consume();
|
|
1209
|
-
let t =
|
|
1210
|
-
if (
|
|
1211
|
-
|
|
1236
|
+
let t, n = "";
|
|
1237
|
+
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
1238
|
+
let e = this.t.consume();
|
|
1239
|
+
t = this._resolveEncodingWidth(e.value, e), n = e.raw;
|
|
1240
|
+
}
|
|
1241
|
+
let r = this.extByPrefix.get(e.appPrefix);
|
|
1242
|
+
if (!r?.parseAppString) {
|
|
1243
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, [new R(e.value)]);
|
|
1212
1244
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1213
1245
|
}
|
|
1214
1246
|
{
|
|
1215
|
-
let
|
|
1247
|
+
let i = this._pendingWarnings.length;
|
|
1216
1248
|
try {
|
|
1217
|
-
let
|
|
1218
|
-
return
|
|
1219
|
-
ednEncoding:
|
|
1220
|
-
encodingWidth:
|
|
1221
|
-
ednSource: e.raw
|
|
1222
|
-
}) : (
|
|
1249
|
+
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1250
|
+
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof j && Object.getPrototypeOf(i) === j.prototype && i.ednSource === void 0 ? new j(i.value, {
|
|
1251
|
+
ednEncoding: i.ednEncoding,
|
|
1252
|
+
encodingWidth: i.encodingWidth,
|
|
1253
|
+
ednSource: e.raw + n
|
|
1254
|
+
}) : (i instanceof k && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1223
1255
|
} catch (t) {
|
|
1224
1256
|
if (this._options.strict !== !1) throw t;
|
|
1225
|
-
return this._pendingWarnings.length ===
|
|
1257
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new We(e.appPrefix, [new R(e.value)]);
|
|
1226
1258
|
}
|
|
1227
1259
|
}
|
|
1228
1260
|
}
|
|
@@ -1231,71 +1263,75 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1231
1263
|
let t = [];
|
|
1232
1264
|
for (; this.t.peek().type !== "GT_GT" && (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), !(t.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "GT_GT")));) t.push(this.parseValue());
|
|
1233
1265
|
this.expect("GT_GT");
|
|
1234
|
-
let n
|
|
1235
|
-
|
|
1236
|
-
|
|
1266
|
+
let n, r;
|
|
1267
|
+
this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
|
|
1268
|
+
let i = this.extByPrefix.get(e.appPrefix);
|
|
1269
|
+
if (!i) {
|
|
1270
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, t);
|
|
1237
1271
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1238
1272
|
}
|
|
1239
|
-
|
|
1273
|
+
i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
1240
1274
|
{
|
|
1241
|
-
let
|
|
1275
|
+
let a = this._pendingWarnings.length;
|
|
1242
1276
|
try {
|
|
1243
|
-
let
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1277
|
+
let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
|
|
1278
|
+
n !== void 0 && this._applyEiToResult(a, n, r ?? e);
|
|
1279
|
+
let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1280
|
+
if (a instanceof k) a.ednSource === void 0 && (a.ednSource = o);
|
|
1281
|
+
else if (i.preserveAppSeqSource) return new Ge(a, o);
|
|
1282
|
+
return a;
|
|
1247
1283
|
} catch (n) {
|
|
1248
1284
|
if (this._options.strict !== !1) throw n;
|
|
1249
|
-
return this._pendingWarnings.length ===
|
|
1285
|
+
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new We(e.appPrefix, t);
|
|
1250
1286
|
}
|
|
1251
1287
|
}
|
|
1252
1288
|
}
|
|
1253
1289
|
case "ELLIPSIS": {
|
|
1254
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1255
|
-
let e = [new
|
|
1290
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new L();
|
|
1291
|
+
let e = [new L()];
|
|
1256
1292
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1257
|
-
return new
|
|
1293
|
+
return new L(e);
|
|
1258
1294
|
}
|
|
1259
1295
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1260
1296
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1261
1297
|
}
|
|
1262
1298
|
}
|
|
1263
1299
|
parseIntegerOrTag() {
|
|
1264
|
-
let e = this.t.consume(), { numStr: t, rawSuffix: n } =
|
|
1265
|
-
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new
|
|
1266
|
-
if (i < -18446744073709551616n) return new
|
|
1300
|
+
let e = this.t.consume(), { numStr: t, rawSuffix: n } = at(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = ot(t);
|
|
1301
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new $e(i);
|
|
1302
|
+
if (i < -18446744073709551616n) return new et(i);
|
|
1267
1303
|
if (r !== void 0) {
|
|
1268
1304
|
let t = i >= 0n ? i : -(i + 1n);
|
|
1269
1305
|
r = this._validateEncodingFit(t, r, e);
|
|
1270
1306
|
}
|
|
1271
|
-
let a = i >= 0n ? new
|
|
1307
|
+
let a = i >= 0n ? new D(i, r === void 0 ? void 0 : { encodingWidth: r }) : new O(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1272
1308
|
if (this.t.peek().type === "LPAREN") {
|
|
1273
|
-
a instanceof
|
|
1309
|
+
a instanceof D || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1274
1310
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
1275
1311
|
this.expect("RPAREN");
|
|
1276
1312
|
let i = a.value, o = this.extByTag.get(i);
|
|
1277
1313
|
if (o?.parseTag) {
|
|
1278
1314
|
let e = o.parseTag(i, n);
|
|
1279
|
-
if (e !== void 0) return t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
|
|
1315
|
+
if (e !== void 0) return e instanceof A && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
|
|
1280
1316
|
}
|
|
1281
|
-
let s = new
|
|
1317
|
+
let s = new A(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1282
1318
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
1283
1319
|
}
|
|
1284
1320
|
return a;
|
|
1285
1321
|
}
|
|
1286
1322
|
parseFloat() {
|
|
1287
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1323
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = st(e.value, t);
|
|
1288
1324
|
if (r === "half" || r === "single") {
|
|
1289
|
-
let e = r === "half" ?
|
|
1325
|
+
let e = r === "half" ? x(b(n)) : Math.fround(n);
|
|
1290
1326
|
Object.is(n, e) || isNaN(n) && isNaN(e) || t(`${n} cannot be exactly represented as ${r === "half" ? "f16 (_1)" : "f32 (_2)"}; use _3 or remove the indicator`);
|
|
1291
1327
|
}
|
|
1292
|
-
return new
|
|
1328
|
+
return new k(n, r === void 0 ? void 0 : { precision: r });
|
|
1293
1329
|
}
|
|
1294
1330
|
parseString() {
|
|
1295
1331
|
let e = this.t.consume();
|
|
1296
1332
|
if (this.t.peek().type !== "PLUS") {
|
|
1297
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1298
|
-
return new
|
|
1333
|
+
let t = this.consumeEncodingIndicator(() => BigInt(tt.encode(e.value).length));
|
|
1334
|
+
return new R(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1299
1335
|
}
|
|
1300
1336
|
let t = !1, n = [{ text: e.value }];
|
|
1301
1337
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -1304,12 +1340,12 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1304
1340
|
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push({ text: e.value })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({ text: this._decodeUtf8(this._decodeBytesToken(e), e) })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1305
1341
|
}
|
|
1306
1342
|
if (!t) {
|
|
1307
|
-
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(
|
|
1308
|
-
return new
|
|
1343
|
+
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(tt.encode(e).length));
|
|
1344
|
+
return new R(e, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1309
1345
|
}
|
|
1310
1346
|
let r = [], i = "";
|
|
1311
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
1312
|
-
return i !== "" && r.push(new
|
|
1347
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new R(i)), i = ""), r.push(new L())) : i += e.text;
|
|
1348
|
+
return i !== "" && r.push(new R(i)), new L(r);
|
|
1313
1349
|
}
|
|
1314
1350
|
_isBytesToken(e) {
|
|
1315
1351
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
@@ -1318,9 +1354,9 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1318
1354
|
let n = (e) => this._warnOrFail(e, t);
|
|
1319
1355
|
switch (t.type) {
|
|
1320
1356
|
case "BYTES_HEX":
|
|
1321
|
-
case "SQSTR": return
|
|
1357
|
+
case "SQSTR": return re(t.value);
|
|
1322
1358
|
case "BYTES_B64": try {
|
|
1323
|
-
return
|
|
1359
|
+
return ct(t.value, n);
|
|
1324
1360
|
} catch (n) {
|
|
1325
1361
|
if (n instanceof e || !(n instanceof SyntaxError)) throw n;
|
|
1326
1362
|
this._fail(n.message, t);
|
|
@@ -1329,11 +1365,11 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1329
1365
|
}
|
|
1330
1366
|
}
|
|
1331
1367
|
_decodeUtf8(e, t) {
|
|
1332
|
-
if (this._options.allowInvalidUtf8) return
|
|
1368
|
+
if (this._options.allowInvalidUtf8) return rt.decode(e);
|
|
1333
1369
|
try {
|
|
1334
|
-
return
|
|
1370
|
+
return nt.decode(e);
|
|
1335
1371
|
} catch {
|
|
1336
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1372
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), rt.decode(e);
|
|
1337
1373
|
}
|
|
1338
1374
|
}
|
|
1339
1375
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -1342,7 +1378,7 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1342
1378
|
_parseBytesConcat(e, t, n) {
|
|
1343
1379
|
if (this.t.peek().type !== "PLUS") {
|
|
1344
1380
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1345
|
-
return new
|
|
1381
|
+
return new j(e, {
|
|
1346
1382
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1347
1383
|
ednSource: n,
|
|
1348
1384
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
@@ -1356,25 +1392,25 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1356
1392
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1357
1393
|
this.t.consume();
|
|
1358
1394
|
let t = this._buildBytesElidedItems(e.value);
|
|
1359
|
-
for (let e of t) e instanceof
|
|
1360
|
-
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes:
|
|
1395
|
+
for (let e of t) e instanceof L ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof j && i.push({ bytes: e.value });
|
|
1396
|
+
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: tt.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1361
1397
|
}
|
|
1362
1398
|
if (!r) {
|
|
1363
1399
|
let e = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
|
|
1364
|
-
return new
|
|
1400
|
+
return new j(t, n === void 0 ? void 0 : { encodingWidth: n });
|
|
1365
1401
|
}
|
|
1366
1402
|
let a = [], o = [], s = () => {
|
|
1367
|
-
o.length > 0 && (a.push(new
|
|
1403
|
+
o.length > 0 && (a.push(new j(this._concatBytes([...o]))), o.length = 0);
|
|
1368
1404
|
};
|
|
1369
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
1370
|
-
return s(), new
|
|
1405
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new L())) : o.push(e.bytes);
|
|
1406
|
+
return s(), new L(a);
|
|
1371
1407
|
}
|
|
1372
1408
|
_parseHexElidedConcat(e) {
|
|
1373
1409
|
let t = this._buildBytesElidedItems(e.value);
|
|
1374
1410
|
for (; this.t.peek().type === "PLUS";) {
|
|
1375
1411
|
this.t.consume();
|
|
1376
1412
|
let e = this.t.peek();
|
|
1377
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
1413
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new L());
|
|
1378
1414
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1379
1415
|
this.t.consume();
|
|
1380
1416
|
let n = this._buildBytesElidedItems(e.value);
|
|
@@ -1382,20 +1418,20 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1382
1418
|
} else if (this._isBytesToken(e.type)) {
|
|
1383
1419
|
this.t.consume();
|
|
1384
1420
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
1385
|
-
r instanceof
|
|
1421
|
+
r instanceof j ? t[t.length - 1] = new j(this._concatBytes([r.value, n])) : t.push(new j(n));
|
|
1386
1422
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1387
1423
|
}
|
|
1388
|
-
return new
|
|
1424
|
+
return new L(t);
|
|
1389
1425
|
}
|
|
1390
1426
|
_buildBytesElidedItems(e) {
|
|
1391
1427
|
let t = e.split("..."), n = [];
|
|
1392
|
-
for (let e = 0; e < t.length; e++) e > 0 && n.push(new
|
|
1428
|
+
for (let e = 0; e < t.length; e++) e > 0 && n.push(new L()), t[e].length > 0 && n.push(new j(re(t[e])));
|
|
1393
1429
|
return n;
|
|
1394
1430
|
}
|
|
1395
1431
|
_mergeFirstBytesItem(e, t) {
|
|
1396
1432
|
if (t.length === 0) return;
|
|
1397
1433
|
let n = e[e.length - 1], r = t[0];
|
|
1398
|
-
n instanceof
|
|
1434
|
+
n instanceof j && r instanceof j ? (e[e.length - 1] = new j(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
1399
1435
|
}
|
|
1400
1436
|
_concatBytes(e) {
|
|
1401
1437
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1406,14 +1442,20 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1406
1442
|
this.t.consume(), this.expect("LPAREN");
|
|
1407
1443
|
let e = this.t.peek();
|
|
1408
1444
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1409
|
-
let { numStr: t } =
|
|
1410
|
-
return this.expect("RPAREN"), new
|
|
1445
|
+
let { numStr: t } = at(e.value), n = Number(ot(t));
|
|
1446
|
+
return this.expect("RPAREN"), new I(n);
|
|
1411
1447
|
}
|
|
1412
1448
|
parseEmbeddedCBOR() {
|
|
1413
1449
|
this.t.consume();
|
|
1414
1450
|
let e = [];
|
|
1415
1451
|
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());
|
|
1416
|
-
|
|
1452
|
+
this.expect("GT_GT");
|
|
1453
|
+
let t;
|
|
1454
|
+
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
1455
|
+
let e = this.t.consume();
|
|
1456
|
+
t = this._resolveEncodingWidth(e.value, e);
|
|
1457
|
+
}
|
|
1458
|
+
return new He(e, { encodingWidth: t });
|
|
1417
1459
|
}
|
|
1418
1460
|
parseArray() {
|
|
1419
1461
|
this.t.consume();
|
|
@@ -1422,7 +1464,7 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1422
1464
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
1423
1465
|
for (; this.t.peek().type !== "RBRACKET" && !(i.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACKET"));) i.push(this.parseValue());
|
|
1424
1466
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1425
|
-
let a = new
|
|
1467
|
+
let a = new P(i, {
|
|
1426
1468
|
indefiniteLength: e,
|
|
1427
1469
|
encodingWidth: t
|
|
1428
1470
|
});
|
|
@@ -1440,7 +1482,7 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1440
1482
|
i.push([e, t]);
|
|
1441
1483
|
}
|
|
1442
1484
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1443
|
-
let a = new
|
|
1485
|
+
let a = new F(i, {
|
|
1444
1486
|
indefiniteLength: e,
|
|
1445
1487
|
encodingWidth: t
|
|
1446
1488
|
});
|
|
@@ -1459,16 +1501,16 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1459
1501
|
for (; this.t.peek().type !== "RPAREN" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RPAREN"));) n.push(this.parseValue());
|
|
1460
1502
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1461
1503
|
let r = n[0];
|
|
1462
|
-
if (r instanceof
|
|
1463
|
-
let e = new
|
|
1464
|
-
if (e instanceof
|
|
1504
|
+
if (r instanceof j) {
|
|
1505
|
+
let e = new M(n.map((e, t) => {
|
|
1506
|
+
if (e instanceof j) return e;
|
|
1465
1507
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1466
1508
|
}));
|
|
1467
1509
|
return t.length > 0 && (e.warnings = t), e;
|
|
1468
1510
|
}
|
|
1469
|
-
if (r instanceof
|
|
1470
|
-
let e = new
|
|
1471
|
-
if (e instanceof
|
|
1511
|
+
if (r instanceof R) {
|
|
1512
|
+
let e = new N(n.map((e, t) => {
|
|
1513
|
+
if (e instanceof R) return e;
|
|
1472
1514
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1473
1515
|
}));
|
|
1474
1516
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -1485,8 +1527,56 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1485
1527
|
let t = this.t.consume();
|
|
1486
1528
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1487
1529
|
}
|
|
1530
|
+
_applyEiToResult(e, t, n) {
|
|
1531
|
+
if (e instanceof k) {
|
|
1532
|
+
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1533
|
+
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1534
|
+
else if (e.precision !== r) {
|
|
1535
|
+
if (r !== "double") {
|
|
1536
|
+
let t = r === "half" ? x(b(e.value)) : Math.fround(e.value);
|
|
1537
|
+
!Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
|
|
1538
|
+
}
|
|
1539
|
+
e.precision = r;
|
|
1540
|
+
}
|
|
1541
|
+
} else if (e instanceof D) {
|
|
1542
|
+
if (e.encodingWidth === void 0) {
|
|
1543
|
+
let r = this._validateEncodingFit(e.value, t, n);
|
|
1544
|
+
r !== void 0 && (e.encodingWidth = r);
|
|
1545
|
+
}
|
|
1546
|
+
} else if (e instanceof O) {
|
|
1547
|
+
if (e.encodingWidth === void 0) {
|
|
1548
|
+
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1549
|
+
r !== void 0 && (e.encodingWidth = r);
|
|
1550
|
+
}
|
|
1551
|
+
} else if (e instanceof j) {
|
|
1552
|
+
if (e.encodingWidth === void 0) {
|
|
1553
|
+
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1554
|
+
r !== void 0 && (e.encodingWidth = r);
|
|
1555
|
+
}
|
|
1556
|
+
} else if (e instanceof R) {
|
|
1557
|
+
if (e.encodingWidth === void 0) {
|
|
1558
|
+
let r = this._validateEncodingFit(BigInt(tt.encode(e.value).length), t, n);
|
|
1559
|
+
r !== void 0 && (e.encodingWidth = r);
|
|
1560
|
+
}
|
|
1561
|
+
} else if (e instanceof P) {
|
|
1562
|
+
if (e.encodingWidth === void 0) {
|
|
1563
|
+
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1564
|
+
r !== void 0 && (e.encodingWidth = r);
|
|
1565
|
+
}
|
|
1566
|
+
} else if (e instanceof F) {
|
|
1567
|
+
if (e.encodingWidth === void 0) {
|
|
1568
|
+
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1569
|
+
r !== void 0 && (e.encodingWidth = r);
|
|
1570
|
+
}
|
|
1571
|
+
} else if (e instanceof A) {
|
|
1572
|
+
if (e.encodingWidth === void 0) {
|
|
1573
|
+
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1574
|
+
r !== void 0 && (e.encodingWidth = r);
|
|
1575
|
+
}
|
|
1576
|
+
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
1577
|
+
}
|
|
1488
1578
|
_validateEncodingFit(e, t, n) {
|
|
1489
|
-
let r =
|
|
1579
|
+
let r = Ne(t);
|
|
1490
1580
|
if (e <= r) return t;
|
|
1491
1581
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
1492
1582
|
this._warnOrFail(i, n);
|
|
@@ -1510,7 +1600,7 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1510
1600
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1511
1601
|
}
|
|
1512
1602
|
_hintMissingExtension(e, t) {
|
|
1513
|
-
let n =
|
|
1603
|
+
let n = ht.get(e);
|
|
1514
1604
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1515
1605
|
this._hintedPrefixes.add(e);
|
|
1516
1606
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
@@ -1537,7 +1627,7 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1537
1627
|
endOffset: n.endOffset
|
|
1538
1628
|
} : void 0);
|
|
1539
1629
|
}
|
|
1540
|
-
},
|
|
1630
|
+
}, _t = new TextEncoder(), vt = !1, R = class extends E {
|
|
1541
1631
|
indefiniteLength = !1;
|
|
1542
1632
|
value;
|
|
1543
1633
|
encodingWidth;
|
|
@@ -1545,27 +1635,27 @@ var R = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
1545
1635
|
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
1546
1636
|
}
|
|
1547
1637
|
_encodeTo(e, t) {
|
|
1548
|
-
let n =
|
|
1549
|
-
|
|
1638
|
+
let n = _t.encode(this.value);
|
|
1639
|
+
w(e, 3, n.length, this.encodingWidth), e.writeBytes(n);
|
|
1550
1640
|
}
|
|
1551
1641
|
_toCDN(e, t) {
|
|
1552
|
-
let n = this.encodingWidth
|
|
1553
|
-
return
|
|
1642
|
+
let n = y(e, this.encodingWidth, () => v(BigInt(_t.encode(this.value).length)));
|
|
1643
|
+
return yt(this.value, n, e, t);
|
|
1554
1644
|
}
|
|
1555
1645
|
_toJS(e) {
|
|
1556
1646
|
return this.value;
|
|
1557
1647
|
}
|
|
1558
1648
|
};
|
|
1559
|
-
function
|
|
1560
|
-
let i =
|
|
1649
|
+
function yt(e, t, n, r) {
|
|
1650
|
+
let i = bt(n?.textStringFormat ?? []), a = ie(n);
|
|
1561
1651
|
if (i.length === 0 || a === null) return Te(e) + t;
|
|
1562
1652
|
let o = /* @__PURE__ */ new Map(), s = null;
|
|
1563
|
-
if (i.includes("cdn") && (s =
|
|
1653
|
+
if (i.includes("cdn") && (s = St(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
|
|
1564
1654
|
if (i.includes("newline")) {
|
|
1565
|
-
let t = s === null ?
|
|
1655
|
+
let t = s === null ? xt(e, 0) : Ct(e);
|
|
1566
1656
|
for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
|
|
1567
1657
|
}
|
|
1568
|
-
let c =
|
|
1658
|
+
let c = At(e, o);
|
|
1569
1659
|
if (c.length <= 1) return Te(e) + t;
|
|
1570
1660
|
let l = c.map(({ text: e }, n) => {
|
|
1571
1661
|
let r = Te(e);
|
|
@@ -1577,10 +1667,10 @@ function gt(e, t, n, r) {
|
|
|
1577
1667
|
}
|
|
1578
1668
|
return u;
|
|
1579
1669
|
}
|
|
1580
|
-
function
|
|
1581
|
-
return e.map((e) => e === "cboredn" ? (
|
|
1670
|
+
function bt(e) {
|
|
1671
|
+
return e.map((e) => e === "cboredn" ? (vt || (vt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1582
1672
|
}
|
|
1583
|
-
function
|
|
1673
|
+
function xt(e, t) {
|
|
1584
1674
|
let n = [];
|
|
1585
1675
|
for (let r = 0; r < e.length; r++) {
|
|
1586
1676
|
let i = e[r];
|
|
@@ -1597,9 +1687,9 @@ function vt(e, t) {
|
|
|
1597
1687
|
}
|
|
1598
1688
|
return n;
|
|
1599
1689
|
}
|
|
1600
|
-
function
|
|
1690
|
+
function St(e) {
|
|
1601
1691
|
try {
|
|
1602
|
-
|
|
1692
|
+
it(e);
|
|
1603
1693
|
} catch {
|
|
1604
1694
|
return null;
|
|
1605
1695
|
}
|
|
@@ -1608,24 +1698,24 @@ function yt(e) {
|
|
|
1608
1698
|
let t = r.consume();
|
|
1609
1699
|
if (t.type === "EOF") break;
|
|
1610
1700
|
let c = !1;
|
|
1611
|
-
if (o || (o = !0, t.offset > 0 &&
|
|
1701
|
+
if (o || (o = !0, t.offset > 0 && Ot(r.comments, 0, t.offset) && n.push({
|
|
1612
1702
|
point: t.offset,
|
|
1613
1703
|
contentDepth: i
|
|
1614
1704
|
})), a !== null) {
|
|
1615
|
-
if (a.kind === "opener" &&
|
|
1705
|
+
if (a.kind === "opener" && Tt.has(t.type)) {
|
|
1616
1706
|
a.point = t.endOffset, s = t.endOffset;
|
|
1617
1707
|
continue;
|
|
1618
|
-
} else a.kind === "opener" &&
|
|
1708
|
+
} else a.kind === "opener" && Dt.has(t.type) && kt(e, a.point, t.offset) ? c = !0 : n.push({
|
|
1619
1709
|
point: t.offset,
|
|
1620
1710
|
contentDepth: a.contentDepth
|
|
1621
1711
|
});
|
|
1622
1712
|
a = null;
|
|
1623
1713
|
}
|
|
1624
|
-
|
|
1714
|
+
Et.has(t.type) ? (i++, a = {
|
|
1625
1715
|
point: t.endOffset,
|
|
1626
1716
|
contentDepth: i,
|
|
1627
1717
|
kind: "opener"
|
|
1628
|
-
}) :
|
|
1718
|
+
}) : Dt.has(t.type) ? (i = Math.max(0, i - 1), c || n.push({
|
|
1629
1719
|
point: t.offset,
|
|
1630
1720
|
contentDepth: i
|
|
1631
1721
|
})) : t.type === "COMMA" && (a = {
|
|
@@ -1640,23 +1730,23 @@ function yt(e) {
|
|
|
1640
1730
|
contentDepth: i
|
|
1641
1731
|
}), n;
|
|
1642
1732
|
}
|
|
1643
|
-
function
|
|
1733
|
+
function Ct(e) {
|
|
1644
1734
|
let n = [], r = new t(e), i = 0;
|
|
1645
1735
|
for (;;) {
|
|
1646
1736
|
let t = r.consume();
|
|
1647
1737
|
if (t.type === "EOF") break;
|
|
1648
|
-
if (
|
|
1649
|
-
else if (
|
|
1738
|
+
if (Et.has(t.type)) i++;
|
|
1739
|
+
else if (Dt.has(t.type)) i = Math.max(0, i - 1);
|
|
1650
1740
|
else if (t.type !== "COMMA") {
|
|
1651
1741
|
if (t.type === "TSTR") {
|
|
1652
1742
|
let r = e.slice(t.offset, t.endOffset);
|
|
1653
|
-
for (let e of
|
|
1743
|
+
for (let e of wt(r)) n.push({
|
|
1654
1744
|
point: t.offset + e,
|
|
1655
1745
|
contentDepth: i + 1
|
|
1656
1746
|
});
|
|
1657
1747
|
} else if (t.type === "RAWSTRING") {
|
|
1658
1748
|
let r = e.slice(t.offset, t.endOffset);
|
|
1659
|
-
for (let { point: e } of
|
|
1749
|
+
for (let { point: e } of xt(r, 0)) n.push({
|
|
1660
1750
|
point: t.offset + e,
|
|
1661
1751
|
contentDepth: i + 1
|
|
1662
1752
|
});
|
|
@@ -1665,7 +1755,7 @@ function bt(e) {
|
|
|
1665
1755
|
}
|
|
1666
1756
|
return n;
|
|
1667
1757
|
}
|
|
1668
|
-
function
|
|
1758
|
+
function wt(e) {
|
|
1669
1759
|
let t = [], n = 1, r = e.length - 1;
|
|
1670
1760
|
for (; n < r;) {
|
|
1671
1761
|
let r = e[n];
|
|
@@ -1681,24 +1771,24 @@ function xt(e) {
|
|
|
1681
1771
|
}
|
|
1682
1772
|
return t;
|
|
1683
1773
|
}
|
|
1684
|
-
var
|
|
1774
|
+
var Tt = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Et = new Set([
|
|
1685
1775
|
"LBRACKET",
|
|
1686
1776
|
"LBRACE",
|
|
1687
1777
|
"LPAREN",
|
|
1688
1778
|
"LT_LT"
|
|
1689
|
-
]),
|
|
1779
|
+
]), Dt = new Set([
|
|
1690
1780
|
"RBRACKET",
|
|
1691
1781
|
"RBRACE",
|
|
1692
1782
|
"RPAREN",
|
|
1693
1783
|
"GT_GT"
|
|
1694
1784
|
]);
|
|
1695
|
-
function
|
|
1785
|
+
function Ot(e, t, n) {
|
|
1696
1786
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
1697
1787
|
}
|
|
1698
|
-
function
|
|
1788
|
+
function kt(e, t, n) {
|
|
1699
1789
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
1700
1790
|
}
|
|
1701
|
-
function
|
|
1791
|
+
function At(e, t) {
|
|
1702
1792
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
1703
1793
|
if (n.length === 0) return [{
|
|
1704
1794
|
text: e,
|
|
@@ -1716,7 +1806,7 @@ function Dt(e, t) {
|
|
|
1716
1806
|
}
|
|
1717
1807
|
//#endregion
|
|
1718
1808
|
//#region src/extensions/dt.ts
|
|
1719
|
-
function
|
|
1809
|
+
function z(e) {
|
|
1720
1810
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
1721
1811
|
let t = Math.round(e * 1e3);
|
|
1722
1812
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -1724,17 +1814,17 @@ function B(e) {
|
|
|
1724
1814
|
for (; s.length < 3;) s += "0";
|
|
1725
1815
|
return `${i}.${s}Z`;
|
|
1726
1816
|
}
|
|
1727
|
-
var
|
|
1728
|
-
function
|
|
1817
|
+
var jt = new TextDecoder("utf-8", { fatal: !0 });
|
|
1818
|
+
function Mt(e) {
|
|
1729
1819
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
1730
1820
|
let t = e[0];
|
|
1731
|
-
if (t instanceof
|
|
1732
|
-
if (t instanceof
|
|
1821
|
+
if (t instanceof R) return t.value;
|
|
1822
|
+
if (t instanceof j) return jt.decode(t.value);
|
|
1733
1823
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
1734
1824
|
}
|
|
1735
|
-
var
|
|
1736
|
-
function
|
|
1737
|
-
if (!
|
|
1825
|
+
var Nt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
1826
|
+
function Pt(e, t) {
|
|
1827
|
+
if (!Nt.test(e)) {
|
|
1738
1828
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
1739
1829
|
if (t) t(n);
|
|
1740
1830
|
else throw SyntaxError(n);
|
|
@@ -1745,82 +1835,93 @@ function jt(e, t) {
|
|
|
1745
1835
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
1746
1836
|
if (i === void 0) {
|
|
1747
1837
|
let e = a / 1e3;
|
|
1748
|
-
return e >= 0 ? new
|
|
1838
|
+
return e >= 0 ? new It(BigInt(e)) : new Lt(BigInt(e));
|
|
1749
1839
|
}
|
|
1750
|
-
return new
|
|
1840
|
+
return new Rt(a / 1e3 + i);
|
|
1751
1841
|
}
|
|
1752
|
-
var
|
|
1842
|
+
var Ft = 1n, It = class extends D {
|
|
1753
1843
|
constructor(e, t) {
|
|
1754
1844
|
super(e, t);
|
|
1755
1845
|
}
|
|
1756
1846
|
_toCDN(e, t) {
|
|
1757
|
-
|
|
1847
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1848
|
+
let n = y(e, this.encodingWidth, () => v(this.value));
|
|
1849
|
+
return `dt'${z(Number(this.value))}'${n}`;
|
|
1758
1850
|
}
|
|
1759
|
-
},
|
|
1851
|
+
}, Lt = class extends O {
|
|
1760
1852
|
constructor(e, t) {
|
|
1761
1853
|
super(e, t);
|
|
1762
1854
|
}
|
|
1763
1855
|
_toCDN(e, t) {
|
|
1764
|
-
|
|
1856
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1857
|
+
let n = y(e, this.encodingWidth, () => v(this.argument));
|
|
1858
|
+
return `dt'${z(Number(this.value))}'${n}`;
|
|
1765
1859
|
}
|
|
1766
|
-
},
|
|
1860
|
+
}, Rt = class extends k {
|
|
1767
1861
|
constructor(e, t) {
|
|
1768
1862
|
super(e, t);
|
|
1769
1863
|
}
|
|
1770
1864
|
_toCDN(e, t) {
|
|
1771
|
-
|
|
1865
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1866
|
+
let n = T(this.value), r = De(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
1867
|
+
return `dt'${z(this.value)}'${r}`;
|
|
1772
1868
|
}
|
|
1773
|
-
},
|
|
1869
|
+
}, zt = class extends A {
|
|
1774
1870
|
constructor(e, t) {
|
|
1775
|
-
super(
|
|
1871
|
+
super(Ft, typeof e == "string" ? Pt(e) : e, t);
|
|
1776
1872
|
}
|
|
1777
1873
|
_toCDN(e, t) {
|
|
1778
1874
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1779
1875
|
let n = this.content;
|
|
1780
|
-
|
|
1876
|
+
if (n instanceof k ? n.precision !== void 0 && n.precision !== T(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
1877
|
+
...e,
|
|
1878
|
+
appStrings: !1
|
|
1879
|
+
}, t);
|
|
1880
|
+
let r = n instanceof k ? n.value : Number(n.value), i = y(e, this.encodingWidth, () => v(Ft));
|
|
1881
|
+
return `DT'${z(r)}'${i}`;
|
|
1781
1882
|
}
|
|
1782
|
-
},
|
|
1883
|
+
}, Bt = class extends zt {
|
|
1783
1884
|
constructor(e, t) {
|
|
1784
1885
|
super(e, t);
|
|
1785
1886
|
}
|
|
1786
1887
|
_toJS(e) {
|
|
1787
|
-
let t = this.content, n = t instanceof
|
|
1888
|
+
let t = this.content, n = t instanceof k ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
1788
1889
|
return new Date(n);
|
|
1789
1890
|
}
|
|
1790
1891
|
};
|
|
1791
|
-
function
|
|
1892
|
+
function Vt(e) {
|
|
1792
1893
|
let t = e?.jsDate ?? !1;
|
|
1793
1894
|
function n(e) {
|
|
1794
|
-
return t ? new
|
|
1895
|
+
return t ? new Bt(e) : new zt(e);
|
|
1795
1896
|
}
|
|
1796
1897
|
let r = {
|
|
1797
1898
|
appStringPrefixes: ["dt", "DT"],
|
|
1798
|
-
tagNumbers: [
|
|
1899
|
+
tagNumbers: [Ft],
|
|
1799
1900
|
parseAppString(e, t, r) {
|
|
1800
|
-
return e === "DT" ? n(t) :
|
|
1901
|
+
return e === "DT" ? n(t) : Pt(t, r);
|
|
1801
1902
|
},
|
|
1802
1903
|
parseAppSequence(e, t, r) {
|
|
1803
|
-
let i =
|
|
1804
|
-
return e === "DT" ? n(i) :
|
|
1904
|
+
let i = Mt(t);
|
|
1905
|
+
return e === "DT" ? n(i) : Pt(i, r);
|
|
1805
1906
|
},
|
|
1806
|
-
parseTag(e,
|
|
1907
|
+
parseTag(e, n) {
|
|
1807
1908
|
if (e !== 1n) return;
|
|
1808
1909
|
let r;
|
|
1809
|
-
if (
|
|
1810
|
-
else if (
|
|
1811
|
-
else if (
|
|
1910
|
+
if (n instanceof D) r = new It(n.value, { encodingWidth: n.encodingWidth });
|
|
1911
|
+
else if (n instanceof O) r = new Lt(n.value, { encodingWidth: n.encodingWidth });
|
|
1912
|
+
else if (n instanceof k) r = new Rt(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
1812
1913
|
else return;
|
|
1813
|
-
return n(
|
|
1914
|
+
return r.start = n.start, r.end = n.end, t ? new Bt(r) : new zt(r);
|
|
1814
1915
|
}
|
|
1815
1916
|
};
|
|
1816
1917
|
return t && (r.fromJS = (e, t) => {
|
|
1817
|
-
if (e instanceof Date) return new
|
|
1918
|
+
if (e instanceof Date) return new Bt(z(e.getTime() / 1e3));
|
|
1818
1919
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
1819
1920
|
}
|
|
1820
|
-
var
|
|
1921
|
+
var Ht = Vt(), Ut = Vt({ jsDate: !0 });
|
|
1821
1922
|
//#endregion
|
|
1822
1923
|
//#region src/utils/ip.ts
|
|
1823
|
-
function
|
|
1924
|
+
function Wt(e) {
|
|
1824
1925
|
let t = e.split(".");
|
|
1825
1926
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
1826
1927
|
let n = new Uint8Array(4);
|
|
@@ -1833,11 +1934,11 @@ function Vt(e) {
|
|
|
1833
1934
|
}
|
|
1834
1935
|
return n;
|
|
1835
1936
|
}
|
|
1836
|
-
function
|
|
1937
|
+
function Gt(e) {
|
|
1837
1938
|
let t = new Uint8Array(16);
|
|
1838
1939
|
if (e === "::") return t;
|
|
1839
1940
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1840
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
1941
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Wt(i[2]));
|
|
1841
1942
|
let a = n.split("::");
|
|
1842
1943
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
1843
1944
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -1854,11 +1955,11 @@ function Ht(e) {
|
|
|
1854
1955
|
}
|
|
1855
1956
|
return r && t.set(r, 12), t;
|
|
1856
1957
|
}
|
|
1857
|
-
function
|
|
1958
|
+
function Kt(e) {
|
|
1858
1959
|
return Array.from(e).join(".");
|
|
1859
1960
|
}
|
|
1860
|
-
function
|
|
1861
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
1961
|
+
function qt(e) {
|
|
1962
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Kt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
1862
1963
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
1863
1964
|
let i = -1, a = 0, o = 0;
|
|
1864
1965
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -1872,29 +1973,29 @@ function Wt(e) {
|
|
|
1872
1973
|
}
|
|
1873
1974
|
//#endregion
|
|
1874
1975
|
//#region src/extensions/ip.ts
|
|
1875
|
-
var
|
|
1876
|
-
function
|
|
1976
|
+
var Jt = "ip", B = "IP", V = 52n, Yt = 54n, Xt = new TextDecoder("utf-8", { fatal: !0 });
|
|
1977
|
+
function Zt(e) {
|
|
1877
1978
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
1878
1979
|
let t = e[0];
|
|
1879
|
-
if (t instanceof
|
|
1880
|
-
if (t instanceof
|
|
1980
|
+
if (t instanceof R) return t.value;
|
|
1981
|
+
if (t instanceof j) return Xt.decode(t.value);
|
|
1881
1982
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
1882
1983
|
}
|
|
1883
|
-
function
|
|
1984
|
+
function Qt(e) {
|
|
1884
1985
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
1885
|
-
bytes:
|
|
1986
|
+
bytes: Wt(e),
|
|
1886
1987
|
isV4: !0
|
|
1887
1988
|
} : {
|
|
1888
|
-
bytes:
|
|
1989
|
+
bytes: Gt(e),
|
|
1889
1990
|
isV4: !1
|
|
1890
1991
|
};
|
|
1891
1992
|
}
|
|
1892
|
-
function
|
|
1893
|
-
if (e.length === 4) return
|
|
1894
|
-
if (e.length === 16) return
|
|
1993
|
+
function $t(e) {
|
|
1994
|
+
if (e.length === 4) return Kt(e);
|
|
1995
|
+
if (e.length === 16) return qt(e);
|
|
1895
1996
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
1896
1997
|
}
|
|
1897
|
-
function
|
|
1998
|
+
function en(e, t) {
|
|
1898
1999
|
let n = new Uint8Array(e.length);
|
|
1899
2000
|
n.set(e);
|
|
1900
2001
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -1904,79 +2005,86 @@ function Xt(e, t) {
|
|
|
1904
2005
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
1905
2006
|
return n.slice(0, a);
|
|
1906
2007
|
}
|
|
1907
|
-
function
|
|
2008
|
+
function tn(e, t) {
|
|
1908
2009
|
let n = new Uint8Array(t);
|
|
1909
2010
|
return n.set(e), n;
|
|
1910
2011
|
}
|
|
1911
|
-
var
|
|
2012
|
+
var nn = class extends j {
|
|
1912
2013
|
_toCDN(e, t) {
|
|
1913
|
-
|
|
2014
|
+
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2015
|
+
let n = y(e, this.encodingWidth, () => v(BigInt(this.value.length)));
|
|
2016
|
+
return `${Jt}'${$t(this.value)}'${n}`;
|
|
1914
2017
|
}
|
|
1915
|
-
},
|
|
2018
|
+
}, rn = class extends P {
|
|
1916
2019
|
_isV4;
|
|
1917
2020
|
constructor(e, t, n) {
|
|
1918
|
-
super([new
|
|
2021
|
+
super([new D(BigInt(e)), new j(t)]), this._isV4 = n;
|
|
1919
2022
|
}
|
|
1920
2023
|
_toCDN(e, t) {
|
|
1921
2024
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1922
2025
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
1923
|
-
return `${
|
|
2026
|
+
return `${Jt}'${$t(tn(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
1924
2027
|
}
|
|
1925
|
-
},
|
|
2028
|
+
}, an = class extends A {
|
|
1926
2029
|
constructor(e, t) {
|
|
1927
2030
|
super(e, t);
|
|
1928
2031
|
}
|
|
1929
2032
|
_toCDN(e, t) {
|
|
1930
2033
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1931
|
-
let n = this.tag ===
|
|
1932
|
-
if (r instanceof
|
|
1933
|
-
|
|
1934
|
-
let
|
|
1935
|
-
return `${
|
|
2034
|
+
let n = this.tag === V ? 4 : 16, r = this.content;
|
|
2035
|
+
if (r instanceof j) {
|
|
2036
|
+
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2037
|
+
let n = y(e, this.encodingWidth, () => v(this.tag));
|
|
2038
|
+
return `${B}'${$t(r.value)}'${n}`;
|
|
2039
|
+
}
|
|
2040
|
+
if (r instanceof P && r.items.length === 2 && r.items[0] instanceof D && r.items[1] instanceof j) {
|
|
2041
|
+
if (r.encodingWidth !== void 0 || r.items[0].encodingWidth !== void 0 || r.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2042
|
+
let i = Number(r.items[0].value), a = tn(r.items[1].value, n), o = y(e, this.encodingWidth, () => v(this.tag));
|
|
2043
|
+
return `${B}'${$t(a)}/${i}'${o}`;
|
|
1936
2044
|
}
|
|
1937
2045
|
return super._toCDN(e, t);
|
|
1938
2046
|
}
|
|
1939
2047
|
};
|
|
1940
|
-
function
|
|
2048
|
+
function on(e, t) {
|
|
1941
2049
|
let n = t.indexOf("/");
|
|
1942
2050
|
if (n === -1) {
|
|
1943
|
-
let { bytes: n, isV4: r } =
|
|
1944
|
-
return e ===
|
|
2051
|
+
let { bytes: n, isV4: r } = Qt(t);
|
|
2052
|
+
return e === B ? new an(r ? V : Yt, new j(n)) : new nn(n);
|
|
1945
2053
|
}
|
|
1946
2054
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
1947
2055
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
1948
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2056
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = Qt(r), c = s ? 32 : 128;
|
|
1949
2057
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
1950
|
-
let l =
|
|
1951
|
-
return e ===
|
|
2058
|
+
let l = en(o, a);
|
|
2059
|
+
return e === B ? new an(s ? V : Yt, new P([new D(BigInt(a)), new j(l)])) : new rn(a, l, s);
|
|
1952
2060
|
}
|
|
1953
|
-
var
|
|
1954
|
-
appStringPrefixes: [
|
|
1955
|
-
tagNumbers: [
|
|
2061
|
+
var sn = {
|
|
2062
|
+
appStringPrefixes: [Jt, B],
|
|
2063
|
+
tagNumbers: [V, Yt],
|
|
1956
2064
|
parseAppString(e, t) {
|
|
1957
|
-
return
|
|
2065
|
+
return on(e, t);
|
|
1958
2066
|
},
|
|
1959
2067
|
parseAppSequence(e, t) {
|
|
1960
|
-
return
|
|
2068
|
+
return on(e, Zt(t));
|
|
1961
2069
|
},
|
|
1962
2070
|
parseTag(e, t) {
|
|
1963
|
-
if (!(e !==
|
|
2071
|
+
if (!(e !== V && e !== Yt) && (t instanceof j || t instanceof P)) return new an(e, t);
|
|
1964
2072
|
}
|
|
1965
|
-
},
|
|
1966
|
-
tagNumbers: [
|
|
2073
|
+
}, cn = 18446744073709551615n, ln = -18446744073709551616n, un = {
|
|
2074
|
+
tagNumbers: [qe, Je],
|
|
1967
2075
|
parseTag(e, t) {
|
|
1968
|
-
if (t instanceof
|
|
2076
|
+
if (t instanceof j) {
|
|
1969
2077
|
if (e === 2n) {
|
|
1970
|
-
let e =
|
|
1971
|
-
return e >
|
|
2078
|
+
let e = Qe(t.value);
|
|
2079
|
+
return e > cn ? new $e(e) : void 0;
|
|
1972
2080
|
}
|
|
1973
2081
|
if (e === 3n) {
|
|
1974
|
-
let e = -1n -
|
|
1975
|
-
return e <
|
|
2082
|
+
let e = -1n - Qe(t.value);
|
|
2083
|
+
return e < ln ? new et(e) : void 0;
|
|
1976
2084
|
}
|
|
1977
2085
|
}
|
|
1978
2086
|
}
|
|
1979
|
-
},
|
|
2087
|
+
}, dn = "cri", fn = "CRI", pn = 99n, mn = new Map([
|
|
1980
2088
|
["coap", -1n],
|
|
1981
2089
|
["coaps", -2n],
|
|
1982
2090
|
["http", -3n],
|
|
@@ -1987,47 +2095,47 @@ var nn = {
|
|
|
1987
2095
|
["coaps+tcp", -8n],
|
|
1988
2096
|
["coap+ws", -25n],
|
|
1989
2097
|
["coaps+ws", -26n]
|
|
1990
|
-
]),
|
|
1991
|
-
function
|
|
2098
|
+
]), hn = new Map([...mn.entries()].map(([e, t]) => [t, e]));
|
|
2099
|
+
function H(e) {
|
|
1992
2100
|
try {
|
|
1993
2101
|
return decodeURIComponent(e);
|
|
1994
2102
|
} catch {
|
|
1995
2103
|
return e;
|
|
1996
2104
|
}
|
|
1997
2105
|
}
|
|
1998
|
-
var
|
|
1999
|
-
function
|
|
2000
|
-
return Array.from(
|
|
2106
|
+
var gn = new TextEncoder(), _n = new TextDecoder("utf-8", { fatal: !0 });
|
|
2107
|
+
function vn(e) {
|
|
2108
|
+
return Array.from(gn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2001
2109
|
}
|
|
2002
|
-
function
|
|
2110
|
+
function U(e, t) {
|
|
2003
2111
|
let n = "";
|
|
2004
|
-
for (let r of e) n += t(r) ? r :
|
|
2112
|
+
for (let r of e) n += t(r) ? r : vn(r);
|
|
2005
2113
|
return n;
|
|
2006
2114
|
}
|
|
2007
|
-
function
|
|
2115
|
+
function yn(e) {
|
|
2008
2116
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2009
2117
|
}
|
|
2010
|
-
function
|
|
2118
|
+
function bn(e) {
|
|
2011
2119
|
return /[!$&'()*+,;=]/.test(e);
|
|
2012
2120
|
}
|
|
2013
|
-
function
|
|
2014
|
-
return
|
|
2121
|
+
function xn(e) {
|
|
2122
|
+
return yn(e) || bn(e) || e === ":" || e === "@";
|
|
2015
2123
|
}
|
|
2016
|
-
function
|
|
2017
|
-
return (
|
|
2124
|
+
function Sn(e) {
|
|
2125
|
+
return (xn(e) || e === "/" || e === "?") && e !== "&";
|
|
2018
2126
|
}
|
|
2019
|
-
function
|
|
2020
|
-
return
|
|
2127
|
+
function Cn(e) {
|
|
2128
|
+
return xn(e) || e === "/" || e === "?";
|
|
2021
2129
|
}
|
|
2022
|
-
function
|
|
2023
|
-
return
|
|
2130
|
+
function wn(e) {
|
|
2131
|
+
return yn(e) || bn(e) || e === ":";
|
|
2024
2132
|
}
|
|
2025
|
-
function
|
|
2026
|
-
return
|
|
2133
|
+
function Tn(e) {
|
|
2134
|
+
return yn(e) || bn(e);
|
|
2027
2135
|
}
|
|
2028
|
-
function
|
|
2136
|
+
function En(e) {
|
|
2029
2137
|
let t = [], n = e, r = n.indexOf("@");
|
|
2030
|
-
r >= 0 && (t.push(
|
|
2138
|
+
r >= 0 && (t.push(I.FALSE), t.push(new R(H(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2031
2139
|
let i, a = null;
|
|
2032
2140
|
if (n.startsWith("[")) {
|
|
2033
2141
|
let e = n.indexOf("]");
|
|
@@ -2036,228 +2144,243 @@ function Sn(e) {
|
|
|
2036
2144
|
let r = n.slice(e + 1);
|
|
2037
2145
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2038
2146
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2039
|
-
t.push(new
|
|
2147
|
+
t.push(new j(Gt(i)));
|
|
2040
2148
|
} else {
|
|
2041
2149
|
let e = n.lastIndexOf(":");
|
|
2042
|
-
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
|
|
2043
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2150
|
+
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 j(Wt(i)));
|
|
2151
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new R(e));
|
|
2044
2152
|
}
|
|
2045
2153
|
if (a !== null && a !== "") {
|
|
2046
2154
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2047
2155
|
let e = parseInt(a, 10);
|
|
2048
2156
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2049
|
-
t.push(new
|
|
2157
|
+
t.push(new D(BigInt(e)));
|
|
2050
2158
|
}
|
|
2051
|
-
return new
|
|
2159
|
+
return new P(t);
|
|
2052
2160
|
}
|
|
2053
|
-
function
|
|
2161
|
+
function Dn(e) {
|
|
2054
2162
|
let t = e.items, n = 0, r = "";
|
|
2055
|
-
if (n < t.length && t[n] instanceof
|
|
2163
|
+
if (n < t.length && t[n] instanceof I && t[n].value === 20) {
|
|
2056
2164
|
n++;
|
|
2057
2165
|
let e = t[n++];
|
|
2058
|
-
r +=
|
|
2166
|
+
r += U(e.value, wn) + "@";
|
|
2059
2167
|
}
|
|
2060
2168
|
if (n >= t.length) return r;
|
|
2061
2169
|
let i = t[n];
|
|
2062
|
-
if (i instanceof
|
|
2170
|
+
if (i instanceof j) {
|
|
2063
2171
|
n++;
|
|
2064
2172
|
let { length: e } = i.value;
|
|
2065
|
-
if (e === 4) r +=
|
|
2066
|
-
else if (e === 16) r += "[" +
|
|
2173
|
+
if (e === 4) r += Kt(i.value);
|
|
2174
|
+
else if (e === 16) r += "[" + qt(i.value) + "]";
|
|
2067
2175
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2068
|
-
n < t.length && t[n] instanceof
|
|
2176
|
+
n < t.length && t[n] instanceof R && (r += `%25${U(t[n++].value, Tn)}`);
|
|
2069
2177
|
} else {
|
|
2070
2178
|
let e = [];
|
|
2071
|
-
for (; n < t.length && t[n] instanceof
|
|
2179
|
+
for (; n < t.length && t[n] instanceof R;) e.push(U(t[n++].value, Tn));
|
|
2072
2180
|
r += e.join(".");
|
|
2073
2181
|
}
|
|
2074
|
-
return n < t.length && t[n] instanceof
|
|
2182
|
+
return n < t.length && t[n] instanceof D && (r += ":" + t[n].value.toString()), r;
|
|
2075
2183
|
}
|
|
2076
|
-
function
|
|
2184
|
+
function On(e) {
|
|
2077
2185
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2078
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2079
|
-
authority:
|
|
2186
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new R(H(e)))) : (r = t, i = []), {
|
|
2187
|
+
authority: En(r),
|
|
2080
2188
|
pathSegments: i
|
|
2081
2189
|
};
|
|
2082
2190
|
}
|
|
2083
|
-
function
|
|
2191
|
+
function kn(e) {
|
|
2084
2192
|
let t = e, n = null, r = t.indexOf("#");
|
|
2085
|
-
r >= 0 && (n =
|
|
2193
|
+
r >= 0 && (n = H(t.slice(r + 1)), t = t.slice(0, r));
|
|
2086
2194
|
let i = null, a = t.indexOf("?");
|
|
2087
2195
|
if (a >= 0) {
|
|
2088
2196
|
let e = t.slice(a + 1);
|
|
2089
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2197
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new R(H(e)));
|
|
2090
2198
|
}
|
|
2091
2199
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2092
2200
|
if (s) {
|
|
2093
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2094
|
-
if (o.push(n === void 0 ? new
|
|
2095
|
-
let { authority: e, pathSegments: n } =
|
|
2096
|
-
o.push(e, new
|
|
2201
|
+
let e = s[1].toLowerCase(), t = s[2], n = mn.get(e);
|
|
2202
|
+
if (o.push(n === void 0 ? new R(e) : new O(n)), t.startsWith("//")) {
|
|
2203
|
+
let { authority: e, pathSegments: n } = On(t);
|
|
2204
|
+
o.push(e, new P(n));
|
|
2097
2205
|
} else if (t.startsWith("/")) {
|
|
2098
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2099
|
-
o.push(
|
|
2206
|
+
let e = t.slice(1).split("/").map((e) => new R(H(e)));
|
|
2207
|
+
o.push(I.NULL, new P(e));
|
|
2100
2208
|
} else {
|
|
2101
|
-
let e = t.split("/").map((e) => new
|
|
2102
|
-
o.push(
|
|
2209
|
+
let e = t.split("/").map((e) => new R(H(e)));
|
|
2210
|
+
o.push(I.TRUE, new P(e));
|
|
2103
2211
|
}
|
|
2104
2212
|
} else if (t.startsWith("//")) {
|
|
2105
|
-
let { authority: e, pathSegments: n } =
|
|
2106
|
-
o.push(
|
|
2213
|
+
let { authority: e, pathSegments: n } = On(t);
|
|
2214
|
+
o.push(I.FALSE, e, new P(n));
|
|
2107
2215
|
} else if (t.startsWith("/")) {
|
|
2108
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2109
|
-
o.push(
|
|
2110
|
-
} else if (t === "") o.push(new
|
|
2216
|
+
let e = t.slice(1).split("/").map((e) => new R(H(e)));
|
|
2217
|
+
o.push(I.TRUE, new P(e));
|
|
2218
|
+
} else if (t === "") o.push(new D(0n));
|
|
2111
2219
|
else {
|
|
2112
2220
|
let n = 1n, r = t, i = !1;
|
|
2113
2221
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2114
2222
|
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)}`);
|
|
2115
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2116
|
-
o.push(new
|
|
2223
|
+
let a = r === "" ? [] : r.split("/").map((e) => new R(H(e)));
|
|
2224
|
+
o.push(new D(n), new P(a));
|
|
2117
2225
|
}
|
|
2118
|
-
if (i !== null && o.push(new
|
|
2226
|
+
if (i !== null && o.push(new P(i)), n !== null && (i === null && o.push(I.NULL), o.push(new R(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2119
2227
|
let e = o[o.length - 1];
|
|
2120
|
-
e instanceof
|
|
2228
|
+
e instanceof P && e.items.length === 0 && o.pop();
|
|
2121
2229
|
}
|
|
2122
|
-
return o.length === 1 && o[0] instanceof
|
|
2230
|
+
return o.length === 1 && o[0] instanceof D && o[0].value === 0n ? [] : o;
|
|
2123
2231
|
}
|
|
2124
|
-
function
|
|
2232
|
+
function W(e, t) {
|
|
2125
2233
|
let n = t, r = "";
|
|
2126
2234
|
if (n < e.length) {
|
|
2127
2235
|
let t = e[n];
|
|
2128
|
-
if (t instanceof
|
|
2236
|
+
if (t instanceof P) {
|
|
2129
2237
|
if (n++, t.items.length > 0) {
|
|
2130
2238
|
let e = t.items.map((e) => {
|
|
2131
|
-
if (!(e instanceof
|
|
2132
|
-
return
|
|
2239
|
+
if (!(e instanceof R)) throw Error("cri: query item must be a text string");
|
|
2240
|
+
return U(e.value, Sn);
|
|
2133
2241
|
});
|
|
2134
2242
|
r += "?" + e.join("&");
|
|
2135
2243
|
}
|
|
2136
|
-
} else t instanceof
|
|
2244
|
+
} else t instanceof I && t.value === 22 && n++;
|
|
2137
2245
|
}
|
|
2138
|
-
return n < e.length && e[n] instanceof
|
|
2246
|
+
return n < e.length && e[n] instanceof R && (r += "#" + U(e[n].value, Cn)), r;
|
|
2139
2247
|
}
|
|
2140
|
-
function
|
|
2248
|
+
function G(e) {
|
|
2141
2249
|
return e.items.map((e) => {
|
|
2142
|
-
if (!(e instanceof
|
|
2143
|
-
return
|
|
2250
|
+
if (!(e instanceof R)) throw Error("cri: path segment must be a text string");
|
|
2251
|
+
return U(e.value, xn);
|
|
2144
2252
|
});
|
|
2145
2253
|
}
|
|
2146
|
-
function
|
|
2254
|
+
function An(e) {
|
|
2147
2255
|
if (e.length === 0) return "";
|
|
2148
2256
|
let t = 0, n = e[t++];
|
|
2149
|
-
if (n instanceof
|
|
2257
|
+
if (n instanceof O || n instanceof R) {
|
|
2150
2258
|
let r;
|
|
2151
|
-
if (n instanceof
|
|
2152
|
-
let e =
|
|
2259
|
+
if (n instanceof O) {
|
|
2260
|
+
let e = hn.get(n.value);
|
|
2153
2261
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2154
2262
|
r = e + ":";
|
|
2155
2263
|
} else r = n.value + ":";
|
|
2156
2264
|
if (t >= e.length) return r;
|
|
2157
2265
|
let i = e[t++], a = "", o = !1;
|
|
2158
|
-
if (i instanceof
|
|
2159
|
-
else if (i instanceof
|
|
2266
|
+
if (i instanceof P) a = "//" + Dn(i), o = !0;
|
|
2267
|
+
else if (i instanceof I) if (i.value === 22) o = !0;
|
|
2160
2268
|
else if (i.value === 21) o = !1;
|
|
2161
2269
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2162
2270
|
else throw Error("cri: unexpected type for authority element");
|
|
2163
2271
|
let s = "";
|
|
2164
|
-
if (t < e.length && e[t] instanceof
|
|
2272
|
+
if (t < e.length && e[t] instanceof P) {
|
|
2165
2273
|
let n = e[t++];
|
|
2166
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2274
|
+
n.items.length > 0 && (s = (o ? "/" : "") + G(n).join("/"));
|
|
2167
2275
|
}
|
|
2168
|
-
return r + a + s +
|
|
2276
|
+
return r + a + s + W(e, t);
|
|
2169
2277
|
}
|
|
2170
|
-
if (n instanceof
|
|
2171
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2172
|
-
let n =
|
|
2173
|
-
if (t < e.length && e[t] instanceof
|
|
2278
|
+
if (n instanceof I && n.value === 20) {
|
|
2279
|
+
if (t >= e.length || !(e[t] instanceof P)) throw Error("cri: network-path reference requires an authority array");
|
|
2280
|
+
let n = Dn(e[t++]), r = "";
|
|
2281
|
+
if (t < e.length && e[t] instanceof P) {
|
|
2174
2282
|
let n = e[t++];
|
|
2175
|
-
n.items.length > 0 && (r = "/" +
|
|
2283
|
+
n.items.length > 0 && (r = "/" + G(n).join("/"));
|
|
2176
2284
|
}
|
|
2177
|
-
return "//" + n + r +
|
|
2285
|
+
return "//" + n + r + W(e, t);
|
|
2178
2286
|
}
|
|
2179
|
-
if (n instanceof
|
|
2287
|
+
if (n instanceof I && n.value === 21) {
|
|
2180
2288
|
let n = "/";
|
|
2181
|
-
if (t < e.length && e[t] instanceof
|
|
2289
|
+
if (t < e.length && e[t] instanceof P) {
|
|
2182
2290
|
let r = e[t++];
|
|
2183
|
-
n = "/" +
|
|
2291
|
+
n = "/" + G(r).join("/");
|
|
2184
2292
|
}
|
|
2185
|
-
return n +
|
|
2293
|
+
return n + W(e, t);
|
|
2186
2294
|
}
|
|
2187
|
-
if (n instanceof
|
|
2295
|
+
if (n instanceof D) {
|
|
2188
2296
|
let r = n.value;
|
|
2189
|
-
if (r === 0n) return
|
|
2297
|
+
if (r === 0n) return W(e, t);
|
|
2190
2298
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2191
|
-
if (t < e.length && e[t] instanceof
|
|
2299
|
+
if (t < e.length && e[t] instanceof P) {
|
|
2192
2300
|
let n = e[t++];
|
|
2193
2301
|
if (n.items.length > 0) {
|
|
2194
|
-
let e =
|
|
2302
|
+
let e = G(n);
|
|
2195
2303
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2196
2304
|
} else a = i === "" ? "./" : i;
|
|
2197
2305
|
} else a = i === "" ? "./" : i;
|
|
2198
|
-
return a +
|
|
2306
|
+
return a + W(e, t);
|
|
2199
2307
|
}
|
|
2200
2308
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2201
2309
|
}
|
|
2202
|
-
var
|
|
2310
|
+
var jn = class extends P {
|
|
2203
2311
|
_toCDN(e, t) {
|
|
2204
2312
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2205
2313
|
try {
|
|
2206
|
-
|
|
2314
|
+
let t = y(e, this.encodingWidth, () => v(BigInt(this.items.length)));
|
|
2315
|
+
return `${dn}'${An(this.items)}'${t}`;
|
|
2207
2316
|
} catch {
|
|
2208
2317
|
return super._toCDN(e, t);
|
|
2209
2318
|
}
|
|
2210
2319
|
}
|
|
2211
|
-
},
|
|
2320
|
+
}, Mn = class extends A {
|
|
2212
2321
|
constructor(e) {
|
|
2213
|
-
super(
|
|
2322
|
+
super(pn, e);
|
|
2214
2323
|
}
|
|
2215
2324
|
_toCDN(e, t) {
|
|
2216
2325
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2217
2326
|
try {
|
|
2218
|
-
|
|
2327
|
+
let n = this.content;
|
|
2328
|
+
if (n.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2329
|
+
let r = y(e, this.encodingWidth, () => v(pn));
|
|
2330
|
+
return `${fn}'${An(n.items)}'${r}`;
|
|
2219
2331
|
} catch {
|
|
2220
2332
|
return super._toCDN(e, t);
|
|
2221
2333
|
}
|
|
2222
2334
|
}
|
|
2223
2335
|
};
|
|
2224
|
-
function
|
|
2336
|
+
function Nn(e) {
|
|
2225
2337
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2226
2338
|
let t = e[0];
|
|
2227
|
-
if (t instanceof
|
|
2228
|
-
if (t instanceof
|
|
2339
|
+
if (t instanceof R) return t.value;
|
|
2340
|
+
if (t instanceof j) return _n.decode(t.value);
|
|
2229
2341
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2230
2342
|
}
|
|
2231
|
-
function
|
|
2232
|
-
let n = new
|
|
2233
|
-
return e ===
|
|
2343
|
+
function Pn(e, t) {
|
|
2344
|
+
let n = new jn(kn(t));
|
|
2345
|
+
return e === fn ? new Mn(n) : n;
|
|
2234
2346
|
}
|
|
2235
|
-
var
|
|
2236
|
-
appStringPrefixes: [
|
|
2237
|
-
tagNumbers: [
|
|
2347
|
+
var Fn = {
|
|
2348
|
+
appStringPrefixes: [dn, fn],
|
|
2349
|
+
tagNumbers: [pn],
|
|
2238
2350
|
parseAppString(e, t) {
|
|
2239
|
-
return
|
|
2351
|
+
return Pn(e, t);
|
|
2240
2352
|
},
|
|
2241
2353
|
parseAppSequence(e, t) {
|
|
2242
|
-
return
|
|
2354
|
+
return Pn(e, Nn(t));
|
|
2243
2355
|
},
|
|
2244
2356
|
parseTag(e, t) {
|
|
2245
|
-
if (e
|
|
2357
|
+
if (e !== 99n || !(t instanceof P)) return;
|
|
2358
|
+
let n = new jn(t.items, {
|
|
2246
2359
|
indefiniteLength: t.indefiniteLength,
|
|
2247
2360
|
encodingWidth: t.encodingWidth
|
|
2248
|
-
})
|
|
2361
|
+
});
|
|
2362
|
+
return n.start = t.start, n.end = t.end, new Mn(n);
|
|
2249
2363
|
}
|
|
2250
|
-
}
|
|
2364
|
+
};
|
|
2365
|
+
//#endregion
|
|
2366
|
+
//#region src/cbor/decoder.ts
|
|
2367
|
+
function K(e, t) {
|
|
2368
|
+
if (e === 24 && t <= 23n) return 0;
|
|
2369
|
+
if (e === 25 && t <= 255n) return 1;
|
|
2370
|
+
if (e === 26 && t <= 65535n) return 2;
|
|
2371
|
+
if (e === 27 && t <= 4294967295n) return 3;
|
|
2372
|
+
}
|
|
2373
|
+
var In = new TextDecoder("utf-8", {
|
|
2251
2374
|
fatal: !0,
|
|
2252
2375
|
ignoreBOM: !0
|
|
2253
|
-
}),
|
|
2376
|
+
}), Ln = new TextDecoder("utf-8", {
|
|
2254
2377
|
fatal: !1,
|
|
2255
2378
|
ignoreBOM: !0
|
|
2256
2379
|
});
|
|
2257
2380
|
function q(e) {
|
|
2258
2381
|
throw Error(`CBOR decode error: ${e}`);
|
|
2259
2382
|
}
|
|
2260
|
-
function
|
|
2383
|
+
function Rn(e, t, n) {
|
|
2261
2384
|
let r = {
|
|
2262
2385
|
message: e,
|
|
2263
2386
|
offset: t
|
|
@@ -2265,35 +2388,35 @@ function Fn(e, t, n) {
|
|
|
2265
2388
|
if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
|
|
2266
2389
|
return r;
|
|
2267
2390
|
}
|
|
2268
|
-
function
|
|
2391
|
+
function zn(e, t) {
|
|
2269
2392
|
e.warnings ??= [], e.warnings.push(t);
|
|
2270
2393
|
}
|
|
2271
|
-
function
|
|
2394
|
+
function Bn(e) {
|
|
2272
2395
|
let t = "";
|
|
2273
2396
|
for (let n of e) t += n.toString(16).padStart(2, "0");
|
|
2274
2397
|
return t;
|
|
2275
2398
|
}
|
|
2276
2399
|
function J(e) {
|
|
2277
|
-
if (e instanceof
|
|
2278
|
-
if (e instanceof
|
|
2279
|
-
if (e instanceof
|
|
2280
|
-
if (e instanceof
|
|
2281
|
-
if (e instanceof
|
|
2282
|
-
if (e instanceof
|
|
2400
|
+
if (e instanceof D) return ["u", String(e.value)];
|
|
2401
|
+
if (e instanceof O) return ["n", String(e.value)];
|
|
2402
|
+
if (e instanceof R) return ["t", e.value];
|
|
2403
|
+
if (e instanceof N) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2404
|
+
if (e instanceof j) return ["b", Bn(e.value)];
|
|
2405
|
+
if (e instanceof M) {
|
|
2283
2406
|
let t = "";
|
|
2284
|
-
for (let n of e.chunks) t +=
|
|
2407
|
+
for (let n of e.chunks) t += Bn(n.value);
|
|
2285
2408
|
return ["b", t];
|
|
2286
2409
|
}
|
|
2287
|
-
if (e instanceof
|
|
2288
|
-
if (e instanceof
|
|
2289
|
-
if (e instanceof
|
|
2290
|
-
if (e instanceof
|
|
2410
|
+
if (e instanceof k) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2411
|
+
if (e instanceof I) return ["s", e.value];
|
|
2412
|
+
if (e instanceof P) return ["A", e.items.map(J)];
|
|
2413
|
+
if (e instanceof F) {
|
|
2291
2414
|
let t = e.entries.map(([e, t]) => [J(e), J(t)]);
|
|
2292
2415
|
if (t.length <= 1) return ["M", t];
|
|
2293
2416
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2294
2417
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2295
2418
|
}
|
|
2296
|
-
if (e instanceof
|
|
2419
|
+
if (e instanceof A) return [
|
|
2297
2420
|
"G",
|
|
2298
2421
|
String(e.tag),
|
|
2299
2422
|
J(e.content)
|
|
@@ -2302,22 +2425,22 @@ function J(e) {
|
|
|
2302
2425
|
for (let e of t) n += e.toString(16).padStart(2, "0");
|
|
2303
2426
|
return ["c", n];
|
|
2304
2427
|
}
|
|
2305
|
-
function
|
|
2306
|
-
if (e instanceof
|
|
2307
|
-
if (e instanceof
|
|
2308
|
-
if (e instanceof
|
|
2309
|
-
if (e instanceof
|
|
2428
|
+
function Vn(e) {
|
|
2429
|
+
if (e instanceof D) return "u" + e.value;
|
|
2430
|
+
if (e instanceof O) return "n" + e.value;
|
|
2431
|
+
if (e instanceof R) return "t" + e.value;
|
|
2432
|
+
if (e instanceof N) {
|
|
2310
2433
|
let t = "t";
|
|
2311
2434
|
for (let n of e.chunks) t += n.value;
|
|
2312
2435
|
return t;
|
|
2313
2436
|
}
|
|
2314
|
-
if (e instanceof
|
|
2315
|
-
if (e instanceof
|
|
2437
|
+
if (e instanceof j) return "b" + Bn(e.value);
|
|
2438
|
+
if (e instanceof M) {
|
|
2316
2439
|
let t = "b";
|
|
2317
|
-
for (let n of e.chunks) t +=
|
|
2440
|
+
for (let n of e.chunks) t += Bn(n.value);
|
|
2318
2441
|
return t;
|
|
2319
2442
|
}
|
|
2320
|
-
return e instanceof
|
|
2443
|
+
return e instanceof k ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof I ? "s" + e.value : JSON.stringify(J(e));
|
|
2321
2444
|
}
|
|
2322
2445
|
function Y(e, t, n) {
|
|
2323
2446
|
if (n <= 23) return {
|
|
@@ -2344,7 +2467,7 @@ function Y(e, t, n) {
|
|
|
2344
2467
|
default: q(`reserved additional info value: ${n}`);
|
|
2345
2468
|
}
|
|
2346
2469
|
}
|
|
2347
|
-
function
|
|
2470
|
+
function Hn(e, t, n, r, i, a) {
|
|
2348
2471
|
let o = [], s = t;
|
|
2349
2472
|
for (;;) {
|
|
2350
2473
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
@@ -2359,65 +2482,65 @@ function zn(e, t, n, r, i, a) {
|
|
|
2359
2482
|
nextOffset: s
|
|
2360
2483
|
};
|
|
2361
2484
|
}
|
|
2362
|
-
function
|
|
2363
|
-
let i =
|
|
2364
|
-
t.has(i) && n.push(
|
|
2485
|
+
function Un(e, t, n, r) {
|
|
2486
|
+
let i = Vn(e);
|
|
2487
|
+
t.has(i) && n.push(Rn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2365
2488
|
}
|
|
2366
2489
|
function X(e, t, n, r) {
|
|
2367
|
-
let i = t, a =
|
|
2490
|
+
let i = t, a = Wn(e, t, n, r);
|
|
2368
2491
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2369
2492
|
}
|
|
2370
|
-
function
|
|
2493
|
+
function Wn(e, t, n, r) {
|
|
2371
2494
|
t >= e.byteLength && q("unexpected end of input");
|
|
2372
2495
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2373
2496
|
switch (a) {
|
|
2374
2497
|
case 0: {
|
|
2375
2498
|
let { value: n, nextOffset: r } = Y(e, t, o);
|
|
2376
2499
|
return {
|
|
2377
|
-
value: new
|
|
2500
|
+
value: new D(n, { encodingWidth: K(o, n) }),
|
|
2378
2501
|
nextOffset: r
|
|
2379
2502
|
};
|
|
2380
2503
|
}
|
|
2381
2504
|
case 1: {
|
|
2382
|
-
let { value: n, nextOffset: r } = Y(e, t, o);
|
|
2505
|
+
let { value: n, nextOffset: r } = Y(e, t, o), i = K(o, n);
|
|
2383
2506
|
return {
|
|
2384
|
-
value: new
|
|
2507
|
+
value: new O(-1n - n, { encodingWidth: i }),
|
|
2385
2508
|
nextOffset: r
|
|
2386
2509
|
};
|
|
2387
2510
|
}
|
|
2388
2511
|
case 2: {
|
|
2389
2512
|
if (o === 31) {
|
|
2390
|
-
let { chunks: i, nextOffset: a } =
|
|
2513
|
+
let { chunks: i, nextOffset: a } = Hn(e, t, n, r, "byte string", (e) => e instanceof j);
|
|
2391
2514
|
return {
|
|
2392
|
-
value: new
|
|
2515
|
+
value: new M(i),
|
|
2393
2516
|
nextOffset: a
|
|
2394
2517
|
};
|
|
2395
2518
|
}
|
|
2396
|
-
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i);
|
|
2519
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i);
|
|
2397
2520
|
return a + s > e.byteLength && q("byte string extends beyond input"), {
|
|
2398
|
-
value: new
|
|
2521
|
+
value: new j(new Uint8Array(e.buffer, e.byteOffset + a, s).slice(), { encodingWidth: c }),
|
|
2399
2522
|
nextOffset: a + s
|
|
2400
2523
|
};
|
|
2401
2524
|
}
|
|
2402
2525
|
case 3: {
|
|
2403
2526
|
if (o === 31) {
|
|
2404
|
-
let { chunks: i, nextOffset: a } =
|
|
2527
|
+
let { chunks: i, nextOffset: a } = Hn(e, t, n, r, "text string", (e) => e instanceof R);
|
|
2405
2528
|
return {
|
|
2406
|
-
value: new
|
|
2529
|
+
value: new N(i),
|
|
2407
2530
|
nextOffset: a
|
|
2408
2531
|
};
|
|
2409
2532
|
}
|
|
2410
|
-
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i);
|
|
2533
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i);
|
|
2411
2534
|
a + s > e.byteLength && q("text string extends beyond input");
|
|
2412
|
-
let
|
|
2535
|
+
let l = new Uint8Array(e.buffer, e.byteOffset + a, s), u, d;
|
|
2413
2536
|
try {
|
|
2414
|
-
|
|
2537
|
+
u = In.decode(l);
|
|
2415
2538
|
} catch {
|
|
2416
|
-
|
|
2539
|
+
d = Rn("invalid UTF-8 sequence in text string", a, n), u = Ln.decode(l);
|
|
2417
2540
|
}
|
|
2418
|
-
let
|
|
2419
|
-
return
|
|
2420
|
-
value:
|
|
2541
|
+
let f = new R(u, { encodingWidth: c });
|
|
2542
|
+
return d && zn(f, d), {
|
|
2543
|
+
value: f,
|
|
2421
2544
|
nextOffset: a + s
|
|
2422
2545
|
};
|
|
2423
2546
|
}
|
|
@@ -2433,18 +2556,18 @@ function Vn(e, t, n, r) {
|
|
|
2433
2556
|
i.push(t.value), a = t.nextOffset;
|
|
2434
2557
|
}
|
|
2435
2558
|
return {
|
|
2436
|
-
value: new
|
|
2559
|
+
value: new P(i, { indefiniteLength: !0 }),
|
|
2437
2560
|
nextOffset: a
|
|
2438
2561
|
};
|
|
2439
2562
|
}
|
|
2440
|
-
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = [],
|
|
2563
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i), l = [], u = a;
|
|
2441
2564
|
for (let t = 0; t < s; t++) {
|
|
2442
|
-
let t = X(e,
|
|
2443
|
-
|
|
2565
|
+
let t = X(e, u, n, r);
|
|
2566
|
+
l.push(t.value), u = t.nextOffset;
|
|
2444
2567
|
}
|
|
2445
2568
|
return {
|
|
2446
|
-
value: new
|
|
2447
|
-
nextOffset:
|
|
2569
|
+
value: new P(l, { encodingWidth: c }),
|
|
2570
|
+
nextOffset: u
|
|
2448
2571
|
};
|
|
2449
2572
|
}
|
|
2450
2573
|
case 5: {
|
|
@@ -2456,117 +2579,117 @@ function Vn(e, t, n, r) {
|
|
|
2456
2579
|
break;
|
|
2457
2580
|
}
|
|
2458
2581
|
let t = X(e, s, n, r);
|
|
2459
|
-
|
|
2582
|
+
Un(t.value, a, o, n), s = t.nextOffset;
|
|
2460
2583
|
let c = X(e, s, n, r);
|
|
2461
2584
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2462
2585
|
}
|
|
2463
|
-
let c = new
|
|
2464
|
-
for (let e of o)
|
|
2586
|
+
let c = new F(i, { indefiniteLength: !0 });
|
|
2587
|
+
for (let e of o) zn(c, e);
|
|
2465
2588
|
return {
|
|
2466
2589
|
value: c,
|
|
2467
2590
|
nextOffset: s
|
|
2468
2591
|
};
|
|
2469
2592
|
}
|
|
2470
|
-
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = [],
|
|
2593
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = K(o, i), l = [], u = /* @__PURE__ */ new Set(), d = [], f = a;
|
|
2471
2594
|
for (let t = 0; t < s; t++) {
|
|
2472
|
-
let t = X(e,
|
|
2473
|
-
|
|
2474
|
-
let i = X(e,
|
|
2475
|
-
|
|
2595
|
+
let t = X(e, f, n, r);
|
|
2596
|
+
Un(t.value, u, d, n), f = t.nextOffset;
|
|
2597
|
+
let i = X(e, f, n, r);
|
|
2598
|
+
f = i.nextOffset, l.push([t.value, i.value]);
|
|
2476
2599
|
}
|
|
2477
|
-
let
|
|
2478
|
-
for (let e of
|
|
2600
|
+
let p = new F(l, { encodingWidth: c });
|
|
2601
|
+
for (let e of d) zn(p, e);
|
|
2479
2602
|
return {
|
|
2480
|
-
value:
|
|
2481
|
-
nextOffset:
|
|
2603
|
+
value: p,
|
|
2604
|
+
nextOffset: f
|
|
2482
2605
|
};
|
|
2483
2606
|
}
|
|
2484
2607
|
case 6: {
|
|
2485
2608
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2486
|
-
let { value: i, nextOffset: a } = Y(e, t, o), s = X(e, a, n, r);
|
|
2609
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = K(o, i), c = X(e, a, n, r);
|
|
2487
2610
|
for (let e of r) {
|
|
2488
|
-
let t = e.parseTag(i,
|
|
2489
|
-
if (t !== void 0) return {
|
|
2611
|
+
let t = e.parseTag(i, c.value, n);
|
|
2612
|
+
if (t !== void 0) return t instanceof A && s !== void 0 && (t.encodingWidth = s), {
|
|
2490
2613
|
value: t,
|
|
2491
|
-
nextOffset:
|
|
2614
|
+
nextOffset: c.nextOffset
|
|
2492
2615
|
};
|
|
2493
2616
|
}
|
|
2494
2617
|
return {
|
|
2495
|
-
value: new
|
|
2496
|
-
nextOffset:
|
|
2618
|
+
value: new A(i, c.value, { encodingWidth: s }),
|
|
2619
|
+
nextOffset: c.nextOffset
|
|
2497
2620
|
};
|
|
2498
2621
|
}
|
|
2499
2622
|
case 7:
|
|
2500
2623
|
if (o <= 19) return {
|
|
2501
|
-
value: new
|
|
2624
|
+
value: new I(o),
|
|
2502
2625
|
nextOffset: t
|
|
2503
2626
|
};
|
|
2504
2627
|
if (o === 20) return {
|
|
2505
|
-
value: new
|
|
2628
|
+
value: new I(20),
|
|
2506
2629
|
nextOffset: t
|
|
2507
2630
|
};
|
|
2508
2631
|
if (o === 21) return {
|
|
2509
|
-
value: new
|
|
2632
|
+
value: new I(21),
|
|
2510
2633
|
nextOffset: t
|
|
2511
2634
|
};
|
|
2512
2635
|
if (o === 22) return {
|
|
2513
|
-
value: new
|
|
2636
|
+
value: new I(22),
|
|
2514
2637
|
nextOffset: t
|
|
2515
2638
|
};
|
|
2516
2639
|
if (o === 23) return {
|
|
2517
|
-
value: new
|
|
2640
|
+
value: new I(23),
|
|
2518
2641
|
nextOffset: t
|
|
2519
2642
|
};
|
|
2520
2643
|
if (o === 24) {
|
|
2521
2644
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
2522
2645
|
let r = e.getUint8(t);
|
|
2523
2646
|
if (r < 32) {
|
|
2524
|
-
let e =
|
|
2525
|
-
return
|
|
2647
|
+
let e = Rn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new I(r);
|
|
2648
|
+
return zn(i, e), {
|
|
2526
2649
|
value: i,
|
|
2527
2650
|
nextOffset: t + 1
|
|
2528
2651
|
};
|
|
2529
2652
|
}
|
|
2530
2653
|
return {
|
|
2531
|
-
value: new
|
|
2654
|
+
value: new I(r),
|
|
2532
2655
|
nextOffset: t + 1
|
|
2533
2656
|
};
|
|
2534
2657
|
}
|
|
2535
2658
|
return o === 25 ? (t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
2536
|
-
value: new
|
|
2659
|
+
value: new k(x(e.getUint16(t, !1)), { precision: "half" }),
|
|
2537
2660
|
nextOffset: t + 2
|
|
2538
2661
|
}) : o === 26 ? (t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
2539
|
-
value: new
|
|
2662
|
+
value: new k(e.getFloat32(t, !1), { precision: "single" }),
|
|
2540
2663
|
nextOffset: t + 4
|
|
2541
2664
|
}) : o === 27 ? (t + 8 > e.byteLength && q("unexpected end of input"), {
|
|
2542
|
-
value: new
|
|
2665
|
+
value: new k(e.getFloat64(t, !1), { precision: "double" }),
|
|
2543
2666
|
nextOffset: t + 8
|
|
2544
2667
|
}) : (o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item"));
|
|
2545
2668
|
}
|
|
2546
2669
|
return q(`unknown major type: ${a}`);
|
|
2547
2670
|
}
|
|
2548
|
-
function
|
|
2671
|
+
function Gn(e) {
|
|
2549
2672
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2550
2673
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2551
2674
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2552
2675
|
}
|
|
2553
|
-
function
|
|
2554
|
-
let n =
|
|
2676
|
+
function Kn(e, t) {
|
|
2677
|
+
let n = Gn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2555
2678
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
2556
2679
|
let { value: a, nextOffset: o } = X(r, i, t, [...t?.extensions ?? [], ...Z].filter((e) => e.parseTag !== void 0));
|
|
2557
2680
|
return !t?.allowTrailing && o !== r.byteLength && q(`${r.byteLength - o} trailing byte(s) after end of CBOR item`), a;
|
|
2558
2681
|
}
|
|
2559
2682
|
//#endregion
|
|
2560
2683
|
//#region src/extensions/cbordata.ts
|
|
2561
|
-
var
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2684
|
+
var qn = 24n, Z = [
|
|
2685
|
+
Ht,
|
|
2686
|
+
sn,
|
|
2687
|
+
un,
|
|
2688
|
+
Fn,
|
|
2566
2689
|
{
|
|
2567
|
-
tagNumbers: [
|
|
2690
|
+
tagNumbers: [qn],
|
|
2568
2691
|
parseTag(e, t, n) {
|
|
2569
|
-
if (e !== 24n || !(t instanceof
|
|
2692
|
+
if (e !== 24n || !(t instanceof j)) return;
|
|
2570
2693
|
let r = n ? {
|
|
2571
2694
|
extensions: n.extensions,
|
|
2572
2695
|
strict: n.strict,
|
|
@@ -2574,7 +2697,7 @@ var Wn = 24n, Z = [
|
|
|
2574
2697
|
silent: n.silent
|
|
2575
2698
|
} : void 0;
|
|
2576
2699
|
try {
|
|
2577
|
-
return new
|
|
2700
|
+
return new A(qn, new He([Kn(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2578
2701
|
} catch (e) {
|
|
2579
2702
|
if (r?.strict !== !1) throw e;
|
|
2580
2703
|
return;
|
|
@@ -2586,50 +2709,50 @@ var Wn = 24n, Z = [
|
|
|
2586
2709
|
//#region src/js/fromJS.ts
|
|
2587
2710
|
function Q(e, t) {
|
|
2588
2711
|
if (t?.replacer) {
|
|
2589
|
-
let { replacer: n, ...r } = t, i =
|
|
2590
|
-
return i === d ?
|
|
2712
|
+
let { replacer: n, ...r } = t, i = Xn(e, n, r.extensions, r.undefinedOmits);
|
|
2713
|
+
return i === d ? I.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2591
2714
|
}
|
|
2592
|
-
return
|
|
2715
|
+
return Jn(e, t, !0);
|
|
2593
2716
|
}
|
|
2594
|
-
function
|
|
2717
|
+
function Jn(e, t, n) {
|
|
2595
2718
|
for (let n of [...t?.extensions ?? [], ...Z]) if (n.fromJS) {
|
|
2596
2719
|
let r = n.fromJS(e, t ?? {});
|
|
2597
2720
|
if (r !== void 0) return r;
|
|
2598
2721
|
}
|
|
2599
2722
|
if (n && typeof e == "object" && e && u.symbol in e) {
|
|
2600
|
-
let n = e[u.symbol], r =
|
|
2723
|
+
let n = e[u.symbol], r = Jn(e, t, !1);
|
|
2601
2724
|
for (let e of [...t?.extensions ?? [], ...Z]) if (e.parseTag) {
|
|
2602
2725
|
let t = e.parseTag(n, r);
|
|
2603
2726
|
if (t !== void 0) return t;
|
|
2604
2727
|
}
|
|
2605
|
-
return new
|
|
2606
|
-
}
|
|
2607
|
-
if (e instanceof u.Null) return
|
|
2608
|
-
if (e instanceof u.Undefined) return
|
|
2609
|
-
if (e instanceof f) return new
|
|
2610
|
-
if (e === null) return
|
|
2611
|
-
if (e === void 0) return
|
|
2612
|
-
if (e === !0) return
|
|
2613
|
-
if (e === !1) return
|
|
2614
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
2615
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
2616
|
-
if (typeof e == "string") return new
|
|
2617
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return
|
|
2618
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
2619
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
2620
|
-
if (e instanceof $) return new
|
|
2621
|
-
if (Array.isArray(e)) return new
|
|
2728
|
+
return new A(n, r);
|
|
2729
|
+
}
|
|
2730
|
+
if (e instanceof u.Null) return I.NULL;
|
|
2731
|
+
if (e instanceof u.Undefined) return I.UNDEFINED;
|
|
2732
|
+
if (e instanceof f) return new I(e.value);
|
|
2733
|
+
if (e === null) return I.NULL;
|
|
2734
|
+
if (e === void 0) return I.UNDEFINED;
|
|
2735
|
+
if (e === !0) return I.TRUE;
|
|
2736
|
+
if (e === !1) return I.FALSE;
|
|
2737
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new $e(e) : e < -18446744073709551616n ? new et(e) : e >= 0n ? new D(e) : new O(e);
|
|
2738
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new D(BigInt(e)) : new O(BigInt(e)) : new k(e);
|
|
2739
|
+
if (typeof e == "string") return new R(e);
|
|
2740
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Jn(e.valueOf(), t, !1);
|
|
2741
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new j(new Uint8Array(e));
|
|
2742
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new P(Array.from(e, (e) => new D(BigInt(e)))) : new j(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
2743
|
+
if (e instanceof $) return new F([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
2744
|
+
if (Array.isArray(e)) return new P(e.map((e) => Q(e, t)));
|
|
2622
2745
|
if (typeof e == "object") {
|
|
2623
2746
|
let n = [];
|
|
2624
|
-
for (let [r, i] of Object.entries(e)) n.push([new
|
|
2625
|
-
return new
|
|
2747
|
+
for (let [r, i] of Object.entries(e)) n.push([new R(r), Q(i, t)]);
|
|
2748
|
+
return new F(n);
|
|
2626
2749
|
}
|
|
2627
2750
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2628
2751
|
}
|
|
2629
|
-
function
|
|
2752
|
+
function Yn(e) {
|
|
2630
2753
|
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 u.Null || e instanceof u.Undefined || e instanceof f;
|
|
2631
2754
|
}
|
|
2632
|
-
function
|
|
2755
|
+
function Xn(e, t, n, r) {
|
|
2633
2756
|
let i = [...n ?? [], ...Z];
|
|
2634
2757
|
function a(e) {
|
|
2635
2758
|
return e === d || r === !0 && e === void 0;
|
|
@@ -2640,7 +2763,7 @@ function qn(e, t, n, r) {
|
|
|
2640
2763
|
if (typeof e != "object" || !e) return e;
|
|
2641
2764
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
2642
2765
|
if (Array.isArray(e)) return e.map(r);
|
|
2643
|
-
if (u.symbol in e ||
|
|
2766
|
+
if (u.symbol in e || Yn(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
2644
2767
|
let t = Object.getPrototypeOf(e);
|
|
2645
2768
|
if (t === Object.prototype || t === null) {
|
|
2646
2769
|
let t = e.toJSON;
|
|
@@ -2675,7 +2798,7 @@ function qn(e, t, n, r) {
|
|
|
2675
2798
|
let r = s(t, String(n), e);
|
|
2676
2799
|
return a(r) ? null : r;
|
|
2677
2800
|
});
|
|
2678
|
-
if (
|
|
2801
|
+
if (Yn(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
2679
2802
|
let t = {};
|
|
2680
2803
|
for (let n of Object.keys(e)) {
|
|
2681
2804
|
let r = s(e[n], n, e);
|
|
@@ -2705,6 +2828,6 @@ var $ = class extends Array {
|
|
|
2705
2828
|
}
|
|
2706
2829
|
};
|
|
2707
2830
|
//#endregion
|
|
2708
|
-
export {
|
|
2831
|
+
export { i as A, b as C, n as D, d as E, r as O, x as S, f as T, A as _, Ut as a, D as b, et as c, I as d, F as f, j as g, M as h, Kn as i, u as k, $e as l, N as m, Xn as n, R as o, P as p, Q as r, it as s, $ as t, He as u, k as v, re as w, E as x, O as y };
|
|
2709
2832
|
|
|
2710
|
-
//# sourceMappingURL=mapEntries-
|
|
2833
|
+
//# sourceMappingURL=mapEntries-DDh7IS2M.js.map
|