@moqtap/codec 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/dist/{chunk-CXFAQKL3.js → chunk-23KRITJ6.js} +1 -1
- package/dist/{chunk-JL3NEW3O.cjs → chunk-4XLYCT5Q.cjs} +90 -1
- package/dist/{chunk-DLSGOZ6P.js → chunk-5XZKO2U5.js} +34 -34
- package/dist/{chunk-62LYLROG.js → chunk-APTV6F72.js} +35 -35
- package/dist/{chunk-JB5VDJ2V.cjs → chunk-B56AG5HU.cjs} +37 -37
- package/dist/{chunk-JTRU76JN.cjs → chunk-BQHLUT37.cjs} +109 -111
- package/dist/{chunk-4HBKHNU2.cjs → chunk-CZNW3R5E.cjs} +37 -37
- package/dist/{chunk-OGZTQA24.cjs → chunk-EQAYMCXO.cjs} +64 -64
- package/dist/{chunk-HYI6LFMD.js → chunk-HEO2JG6C.js} +1 -1
- package/dist/{chunk-UP4XPH4J.js → chunk-I55J3KXD.js} +31 -31
- package/dist/{chunk-HZHSO7EW.cjs → chunk-IDV2JYJ6.cjs} +39 -39
- package/dist/{chunk-BAG6YWCP.cjs → chunk-IEJULBKB.cjs} +63 -63
- package/dist/{chunk-Y6KCSM3V.js → chunk-IJAF6PAY.js} +1 -1
- package/dist/{chunk-WMJVSBBE.cjs → chunk-J3ASFPCX.cjs} +57 -57
- package/dist/{chunk-Q5D6OW6Q.js → chunk-JJEN2VG5.js} +51 -53
- package/dist/{chunk-COWGGUL4.js → chunk-JKMYAUGY.js} +1 -1
- package/dist/{chunk-SIYYMFCC.cjs → chunk-KCH4BQXK.cjs} +37 -37
- package/dist/{chunk-VOU7PNHI.js → chunk-KLPWJU6W.js} +89 -0
- package/dist/{chunk-NZ7GYEMT.js → chunk-KNLPX3YA.js} +1 -1
- package/dist/{chunk-A33U4WVS.cjs → chunk-KTVN4P6J.cjs} +67 -67
- package/dist/{chunk-7KBAWOBA.js → chunk-KYVTM5VI.js} +1 -1
- package/dist/{chunk-RZ3UML47.js → chunk-MD2OA7SE.js} +1 -1
- package/dist/{chunk-MSG2FXJ2.cjs → chunk-MH7537FB.cjs} +68 -68
- package/dist/{chunk-SHMA4PBY.js → chunk-N2V7Z37J.js} +1 -1
- package/dist/{chunk-HO44OANK.cjs → chunk-QGIHC6BA.cjs} +36 -36
- package/dist/{chunk-PKEOQSSZ.cjs → chunk-RIIA4ALQ.cjs} +37 -37
- package/dist/{chunk-XZE5R57R.cjs → chunk-VZHL2U2N.cjs} +37 -37
- package/dist/{chunk-RW4UG7CN.js → chunk-XHAP2YST.js} +1 -1
- package/dist/{codec-B1snaM9L.d.cts → codec-BnamSx7L.d.cts} +1 -1
- package/dist/{codec-D49OofBr.d.ts → codec-CFhUGTu2.d.ts} +1 -1
- package/dist/draft07.cjs +4 -4
- package/dist/draft07.js +2 -2
- package/dist/draft08.cjs +3 -3
- package/dist/draft08.js +2 -2
- package/dist/draft09.cjs +3 -3
- package/dist/draft09.js +2 -2
- package/dist/draft10.cjs +3 -3
- package/dist/draft10.js +2 -2
- package/dist/draft11.cjs +3 -3
- package/dist/draft11.js +2 -2
- package/dist/draft12.cjs +3 -3
- package/dist/draft12.js +2 -2
- package/dist/draft13.cjs +3 -3
- package/dist/draft13.js +2 -2
- package/dist/draft14-session.d.cts +1 -1
- package/dist/draft14-session.d.ts +1 -1
- package/dist/draft14.cjs +3 -3
- package/dist/draft14.d.cts +3 -3
- package/dist/draft14.d.ts +3 -3
- package/dist/draft14.js +2 -2
- package/dist/draft15.cjs +3 -3
- package/dist/draft15.js +2 -2
- package/dist/draft16.cjs +3 -3
- package/dist/draft16.js +2 -2
- package/dist/draft17.cjs +3 -3
- package/dist/draft17.js +2 -2
- package/dist/draft18.cjs +3 -3
- package/dist/draft18.js +2 -2
- package/dist/draft19.cjs +3 -3
- package/dist/draft19.js +2 -2
- package/dist/index.cjs +81 -29
- package/dist/index.d.cts +73 -3
- package/dist/index.d.ts +73 -3
- package/dist/index.js +67 -15
- package/dist/session.d.cts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/{types-DjmrHp_s.d.cts → types-CVeKIk7A.d.cts} +29 -21
- package/dist/{types-DjmrHp_s.d.ts → types-CVeKIk7A.d.ts} +29 -21
- package/package.json +2 -2
- package/src/core/accessors.ts +120 -0
- package/src/core/buffer-reader.ts +74 -2
- package/src/core/buffer-writer.ts +56 -4
- package/src/drafts/draft14/codec.ts +50 -52
- package/src/drafts/draft14/types.ts +31 -23
- package/src/drafts/draft17/codec.ts +2 -2
- package/src/drafts/draft17/data-streams.ts +2 -2
- package/src/drafts/draft18/codec.ts +2 -2
- package/src/drafts/draft18/data-streams.ts +2 -2
- package/src/drafts/draft19/codec.ts +2 -2
- package/src/drafts/draft19/data-streams.ts +2 -2
- package/src/index.ts +8 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk4XLYCT5Qcjs = require('./chunk-4XLYCT5Q.cjs');
|
|
8
8
|
|
|
9
9
|
// src/drafts/draft14/messages.ts
|
|
10
10
|
var MSG_SUBSCRIBE_UPDATE = 0x02n;
|
|
@@ -101,7 +101,7 @@ function isValidSubgroupType(t) {
|
|
|
101
101
|
return t >= 16 && t <= 21 || t >= 24 && t <= 29;
|
|
102
102
|
}
|
|
103
103
|
function encodeSubgroupStream(stream) {
|
|
104
|
-
const w = new (0,
|
|
104
|
+
const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
105
105
|
w.writeVarInt(BigInt(stream.headerType));
|
|
106
106
|
w.writeVarInt(stream.trackAlias);
|
|
107
107
|
w.writeVarInt(stream.groupId);
|
|
@@ -133,7 +133,7 @@ function encodeSubgroupStream(stream) {
|
|
|
133
133
|
return w.finish();
|
|
134
134
|
}
|
|
135
135
|
function encodeDatagram(dg) {
|
|
136
|
-
const w = new (0,
|
|
136
|
+
const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
137
137
|
w.writeVarInt(BigInt(dg.datagramType));
|
|
138
138
|
w.writeVarInt(dg.trackAlias);
|
|
139
139
|
w.writeVarInt(dg.groupId);
|
|
@@ -157,7 +157,7 @@ function encodeDatagram(dg) {
|
|
|
157
157
|
return w.finish();
|
|
158
158
|
}
|
|
159
159
|
function encodeFetchStream(stream) {
|
|
160
|
-
const w = new (0,
|
|
160
|
+
const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
161
161
|
w.writeVarInt(FETCH_STREAM_TYPE);
|
|
162
162
|
w.writeVarInt(stream.requestId);
|
|
163
163
|
for (const obj of stream.objects) {
|
|
@@ -179,12 +179,12 @@ function encodeFetchStream(stream) {
|
|
|
179
179
|
}
|
|
180
180
|
function decodeSubgroupStream(bytes) {
|
|
181
181
|
try {
|
|
182
|
-
const r = new (0,
|
|
182
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
183
183
|
const streamType = Number(r.readVarInt());
|
|
184
184
|
if (!isValidSubgroupType(streamType)) {
|
|
185
185
|
return {
|
|
186
186
|
ok: false,
|
|
187
|
-
error: new (0,
|
|
187
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
188
188
|
"CONSTRAINT_VIOLATION",
|
|
189
189
|
`Expected subgroup stream type 0x10-0x1D, got 0x${streamType.toString(16)}`,
|
|
190
190
|
0
|
|
@@ -261,19 +261,19 @@ function decodeSubgroupStream(bytes) {
|
|
|
261
261
|
bytesRead: r.offset
|
|
262
262
|
};
|
|
263
263
|
} catch (e) {
|
|
264
|
-
if (e instanceof
|
|
264
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
265
265
|
throw e;
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
function decodeDatagram(bytes) {
|
|
269
269
|
try {
|
|
270
|
-
const r = new (0,
|
|
270
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
271
271
|
const dgType = Number(r.readVarInt());
|
|
272
272
|
const validDatagram = dgType >= 0 && dgType <= 7 || dgType === 32 || dgType === 33;
|
|
273
273
|
if (!validDatagram) {
|
|
274
274
|
return {
|
|
275
275
|
ok: false,
|
|
276
|
-
error: new (0,
|
|
276
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
277
277
|
"CONSTRAINT_VIOLATION",
|
|
278
278
|
`Expected datagram type 0x00-0x07 or 0x20-0x21, got 0x${dgType.toString(16)}`,
|
|
279
279
|
0
|
|
@@ -322,18 +322,18 @@ function decodeDatagram(bytes) {
|
|
|
322
322
|
result.extensionData = extensionData;
|
|
323
323
|
return { ok: true, value: result, bytesRead: r.offset };
|
|
324
324
|
} catch (e) {
|
|
325
|
-
if (e instanceof
|
|
325
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
326
326
|
throw e;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
function decodeFetchStream(bytes) {
|
|
330
330
|
try {
|
|
331
|
-
const r = new (0,
|
|
331
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
332
332
|
const streamType = r.readVarInt();
|
|
333
333
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
334
334
|
return {
|
|
335
335
|
ok: false,
|
|
336
|
-
error: new (0,
|
|
336
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
337
337
|
"CONSTRAINT_VIOLATION",
|
|
338
338
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
339
339
|
0
|
|
@@ -383,7 +383,7 @@ function decodeFetchStream(bytes) {
|
|
|
383
383
|
bytesRead: r.offset
|
|
384
384
|
};
|
|
385
385
|
} catch (e) {
|
|
386
|
-
if (e instanceof
|
|
386
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
387
387
|
throw e;
|
|
388
388
|
}
|
|
389
389
|
}
|
|
@@ -420,11 +420,11 @@ function createSubgroupStreamDecoder() {
|
|
|
420
420
|
buffer = newBuffer;
|
|
421
421
|
if (!headerEmitted) {
|
|
422
422
|
try {
|
|
423
|
-
const r = new (0,
|
|
423
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
424
424
|
const streamType = Number(r.readVarInt());
|
|
425
425
|
if (!isValidSubgroupType(streamType)) {
|
|
426
426
|
controller.error(
|
|
427
|
-
new (0,
|
|
427
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
428
428
|
"CONSTRAINT_VIOLATION",
|
|
429
429
|
`Expected subgroup stream type 0x10-0x1D, got 0x${streamType.toString(16)}`,
|
|
430
430
|
0
|
|
@@ -452,7 +452,7 @@ function createSubgroupStreamDecoder() {
|
|
|
452
452
|
headerEmitted = true;
|
|
453
453
|
offset += r.offset;
|
|
454
454
|
} catch (e) {
|
|
455
|
-
if (e instanceof
|
|
455
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
456
456
|
return;
|
|
457
457
|
}
|
|
458
458
|
controller.error(e);
|
|
@@ -461,7 +461,7 @@ function createSubgroupStreamDecoder() {
|
|
|
461
461
|
}
|
|
462
462
|
while (offset < buffer.length) {
|
|
463
463
|
try {
|
|
464
|
-
const r = new (0,
|
|
464
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
465
465
|
const byteOffset = r.offset;
|
|
466
466
|
const delta = r.readVarInt();
|
|
467
467
|
const objectId = firstObject ? delta : prevObjectId + 1n + delta;
|
|
@@ -497,7 +497,7 @@ function createSubgroupStreamDecoder() {
|
|
|
497
497
|
prevObjectId = objectId;
|
|
498
498
|
offset += r.offset;
|
|
499
499
|
} catch (e) {
|
|
500
|
-
if (e instanceof
|
|
500
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
501
501
|
break;
|
|
502
502
|
}
|
|
503
503
|
controller.error(e);
|
|
@@ -507,7 +507,7 @@ function createSubgroupStreamDecoder() {
|
|
|
507
507
|
},
|
|
508
508
|
flush(controller) {
|
|
509
509
|
if (offset < buffer.length) {
|
|
510
|
-
controller.error(new (0,
|
|
510
|
+
controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
});
|
|
@@ -528,11 +528,11 @@ function createFetchStreamDecoder() {
|
|
|
528
528
|
buffer = newBuffer;
|
|
529
529
|
if (!headerEmitted) {
|
|
530
530
|
try {
|
|
531
|
-
const r = new (0,
|
|
531
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
532
532
|
const streamType = r.readVarInt();
|
|
533
533
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
534
534
|
controller.error(
|
|
535
|
-
new (0,
|
|
535
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
536
536
|
"CONSTRAINT_VIOLATION",
|
|
537
537
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
538
538
|
0
|
|
@@ -545,7 +545,7 @@ function createFetchStreamDecoder() {
|
|
|
545
545
|
headerEmitted = true;
|
|
546
546
|
offset += r.offset;
|
|
547
547
|
} catch (e) {
|
|
548
|
-
if (e instanceof
|
|
548
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
549
549
|
return;
|
|
550
550
|
}
|
|
551
551
|
controller.error(e);
|
|
@@ -554,7 +554,7 @@ function createFetchStreamDecoder() {
|
|
|
554
554
|
}
|
|
555
555
|
while (offset < buffer.length) {
|
|
556
556
|
try {
|
|
557
|
-
const r = new (0,
|
|
557
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
558
558
|
const byteOffset = r.offset;
|
|
559
559
|
const groupId = r.readVarInt();
|
|
560
560
|
const subgroupId = r.readVarInt();
|
|
@@ -590,7 +590,7 @@ function createFetchStreamDecoder() {
|
|
|
590
590
|
controller.enqueue(obj);
|
|
591
591
|
offset += r.offset;
|
|
592
592
|
} catch (e) {
|
|
593
|
-
if (e instanceof
|
|
593
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
594
594
|
break;
|
|
595
595
|
}
|
|
596
596
|
controller.error(e);
|
|
@@ -600,7 +600,7 @@ function createFetchStreamDecoder() {
|
|
|
600
600
|
},
|
|
601
601
|
flush(controller) {
|
|
602
602
|
if (offset < buffer.length) {
|
|
603
|
-
controller.error(new (0,
|
|
603
|
+
controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
});
|
|
@@ -625,7 +625,7 @@ function createDataStreamDecoder() {
|
|
|
625
625
|
buffer = newBuffer;
|
|
626
626
|
if (detectedType === null) {
|
|
627
627
|
try {
|
|
628
|
-
const r = new (0,
|
|
628
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
629
629
|
const streamType = Number(r.readVarInt());
|
|
630
630
|
if (isValidSubgroupType(streamType)) {
|
|
631
631
|
detectedType = "subgroup";
|
|
@@ -633,7 +633,7 @@ function createDataStreamDecoder() {
|
|
|
633
633
|
detectedType = "fetch";
|
|
634
634
|
} else {
|
|
635
635
|
controller.error(
|
|
636
|
-
new (0,
|
|
636
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
637
637
|
"CONSTRAINT_VIOLATION",
|
|
638
638
|
`Unknown data stream type: 0x${streamType.toString(16)}`,
|
|
639
639
|
0
|
|
@@ -642,7 +642,7 @@ function createDataStreamDecoder() {
|
|
|
642
642
|
return;
|
|
643
643
|
}
|
|
644
644
|
} catch (e) {
|
|
645
|
-
if (e instanceof
|
|
645
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
646
646
|
return;
|
|
647
647
|
}
|
|
648
648
|
controller.error(e);
|
|
@@ -652,7 +652,7 @@ function createDataStreamDecoder() {
|
|
|
652
652
|
if (detectedType === "subgroup") {
|
|
653
653
|
if (!headerEmitted) {
|
|
654
654
|
try {
|
|
655
|
-
const r = new (0,
|
|
655
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
656
656
|
const streamType = Number(r.readVarInt());
|
|
657
657
|
extensionsPresent = (streamType & 1) !== 0;
|
|
658
658
|
const hasSubgroupField = (streamType & 4) !== 0;
|
|
@@ -672,14 +672,14 @@ function createDataStreamDecoder() {
|
|
|
672
672
|
headerEmitted = true;
|
|
673
673
|
offset += r.offset;
|
|
674
674
|
} catch (e) {
|
|
675
|
-
if (e instanceof
|
|
675
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") return;
|
|
676
676
|
controller.error(e);
|
|
677
677
|
return;
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
while (offset < buffer.length) {
|
|
681
681
|
try {
|
|
682
|
-
const r = new (0,
|
|
682
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
683
683
|
const byteOffset = r.offset;
|
|
684
684
|
const delta = r.readVarInt();
|
|
685
685
|
const objectId = firstObject ? delta : prevObjectId + 1n + delta;
|
|
@@ -715,7 +715,7 @@ function createDataStreamDecoder() {
|
|
|
715
715
|
prevObjectId = objectId;
|
|
716
716
|
offset += r.offset;
|
|
717
717
|
} catch (e) {
|
|
718
|
-
if (e instanceof
|
|
718
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") break;
|
|
719
719
|
controller.error(e);
|
|
720
720
|
return;
|
|
721
721
|
}
|
|
@@ -723,21 +723,21 @@ function createDataStreamDecoder() {
|
|
|
723
723
|
} else {
|
|
724
724
|
if (!headerEmitted) {
|
|
725
725
|
try {
|
|
726
|
-
const r = new (0,
|
|
726
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
727
727
|
r.readVarInt();
|
|
728
728
|
const requestId = r.readVarInt();
|
|
729
729
|
controller.enqueue({ type: "fetch_header", requestId });
|
|
730
730
|
headerEmitted = true;
|
|
731
731
|
offset += r.offset;
|
|
732
732
|
} catch (e) {
|
|
733
|
-
if (e instanceof
|
|
733
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") return;
|
|
734
734
|
controller.error(e);
|
|
735
735
|
return;
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
738
|
while (offset < buffer.length) {
|
|
739
739
|
try {
|
|
740
|
-
const r = new (0,
|
|
740
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
741
741
|
const byteOffset = r.offset;
|
|
742
742
|
const groupId = r.readVarInt();
|
|
743
743
|
const subgroupId = r.readVarInt();
|
|
@@ -773,7 +773,7 @@ function createDataStreamDecoder() {
|
|
|
773
773
|
controller.enqueue(obj);
|
|
774
774
|
offset += r.offset;
|
|
775
775
|
} catch (e) {
|
|
776
|
-
if (e instanceof
|
|
776
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") break;
|
|
777
777
|
controller.error(e);
|
|
778
778
|
return;
|
|
779
779
|
}
|
|
@@ -782,7 +782,7 @@ function createDataStreamDecoder() {
|
|
|
782
782
|
},
|
|
783
783
|
flush(controller) {
|
|
784
784
|
if (offset < buffer.length) {
|
|
785
|
-
controller.error(new (0,
|
|
785
|
+
controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
788
|
});
|
|
@@ -824,7 +824,7 @@ function encodeSetupParams(params, writer) {
|
|
|
824
824
|
if (params.authorization_token !== void 0) {
|
|
825
825
|
writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
|
|
826
826
|
const tok = params.authorization_token;
|
|
827
|
-
const tmpWriter = new (0,
|
|
827
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
|
|
828
828
|
tmpWriter.writeVarInt(tok.alias_type);
|
|
829
829
|
if (tok.token_type !== void 0) {
|
|
830
830
|
tmpWriter.writeVarInt(tok.token_type);
|
|
@@ -859,7 +859,7 @@ function encodeSetupParams(params, writer) {
|
|
|
859
859
|
for (const u of params.unknown) {
|
|
860
860
|
const id = BigInt(u.id);
|
|
861
861
|
writer.writeVarInt(id);
|
|
862
|
-
const raw =
|
|
862
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
863
863
|
writer.writeVarInt(raw.byteLength);
|
|
864
864
|
writer.writeBytes(raw);
|
|
865
865
|
}
|
|
@@ -880,13 +880,13 @@ function decodeSetupParams(reader) {
|
|
|
880
880
|
} else if (paramType === PARAM_MAX_AUTH_TOKEN_CACHE_SIZE) {
|
|
881
881
|
result.max_auth_token_cache_size = value;
|
|
882
882
|
} else {
|
|
883
|
-
const tmpWriter = new (0,
|
|
883
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
|
|
884
884
|
tmpWriter.writeVarInt(value);
|
|
885
885
|
const raw = tmpWriter.finish();
|
|
886
886
|
unknown.push({
|
|
887
887
|
id: `0x${paramType.toString(16)}`,
|
|
888
888
|
length: raw.byteLength,
|
|
889
|
-
raw_hex:
|
|
889
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
890
890
|
});
|
|
891
891
|
}
|
|
892
892
|
} else {
|
|
@@ -895,7 +895,7 @@ function decodeSetupParams(reader) {
|
|
|
895
895
|
if (paramType === PARAM_PATH) {
|
|
896
896
|
result.path = textDecoder.decode(bytes);
|
|
897
897
|
} else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
898
|
-
const tokenReader = new (0,
|
|
898
|
+
const tokenReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
899
899
|
const alias_type = tokenReader.readVarInt();
|
|
900
900
|
const tok = { alias_type };
|
|
901
901
|
if (tokenReader.remaining > 0) {
|
|
@@ -914,7 +914,7 @@ function decodeSetupParams(reader) {
|
|
|
914
914
|
unknown.push({
|
|
915
915
|
id: `0x${paramType.toString(16)}`,
|
|
916
916
|
length,
|
|
917
|
-
raw_hex:
|
|
917
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
918
918
|
});
|
|
919
919
|
}
|
|
920
920
|
}
|
|
@@ -936,7 +936,7 @@ function encodeMessageParams(params, writer) {
|
|
|
936
936
|
if (params.authorization_token !== void 0) {
|
|
937
937
|
writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
|
|
938
938
|
const tok = params.authorization_token;
|
|
939
|
-
const tmpWriter = new (0,
|
|
939
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
|
|
940
940
|
tmpWriter.writeVarInt(tok.alias_type);
|
|
941
941
|
if (tok.token_type !== void 0) {
|
|
942
942
|
tmpWriter.writeVarInt(tok.token_type);
|
|
@@ -959,7 +959,7 @@ function encodeMessageParams(params, writer) {
|
|
|
959
959
|
for (const u of params.unknown) {
|
|
960
960
|
const id = BigInt(u.id);
|
|
961
961
|
writer.writeVarInt(id);
|
|
962
|
-
const raw =
|
|
962
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
963
963
|
writer.writeVarInt(raw.byteLength);
|
|
964
964
|
writer.writeBytes(raw);
|
|
965
965
|
}
|
|
@@ -978,20 +978,20 @@ function decodeMessageParams(reader) {
|
|
|
978
978
|
} else if (paramType === PARAM_MAX_CACHE_DURATION) {
|
|
979
979
|
result.max_cache_duration = value;
|
|
980
980
|
} else {
|
|
981
|
-
const tmpWriter = new (0,
|
|
981
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
|
|
982
982
|
tmpWriter.writeVarInt(value);
|
|
983
983
|
const raw = tmpWriter.finish();
|
|
984
984
|
unknown.push({
|
|
985
985
|
id: `0x${paramType.toString(16)}`,
|
|
986
986
|
length: raw.byteLength,
|
|
987
|
-
raw_hex:
|
|
987
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
988
988
|
});
|
|
989
989
|
}
|
|
990
990
|
} else {
|
|
991
991
|
const length = Number(reader.readVarInt());
|
|
992
992
|
const bytes = reader.readBytes(length);
|
|
993
993
|
if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
994
|
-
const tokenReader = new (0,
|
|
994
|
+
const tokenReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
995
995
|
const alias_type = tokenReader.readVarInt();
|
|
996
996
|
const tok = { alias_type };
|
|
997
997
|
if (tokenReader.remaining > 0) {
|
|
@@ -1006,7 +1006,7 @@ function decodeMessageParams(reader) {
|
|
|
1006
1006
|
unknown.push({
|
|
1007
1007
|
id: `0x${paramType.toString(16)}`,
|
|
1008
1008
|
length,
|
|
1009
|
-
raw_hex:
|
|
1009
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
1010
1010
|
});
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
@@ -1029,8 +1029,8 @@ function encodeSubscribePayload(msg, w) {
|
|
|
1029
1029
|
w.writeVarInt(msg.request_id);
|
|
1030
1030
|
w.writeTuple(msg.track_namespace);
|
|
1031
1031
|
w.writeString(msg.track_name);
|
|
1032
|
-
w.writeUint8(
|
|
1033
|
-
w.writeUint8(
|
|
1032
|
+
w.writeUint8(msg.subscriber_priority);
|
|
1033
|
+
w.writeUint8(msg.group_order);
|
|
1034
1034
|
w.writeVarInt(msg.forward);
|
|
1035
1035
|
w.writeVarInt(msg.filter_type);
|
|
1036
1036
|
const ft = msg.filter_type;
|
|
@@ -1047,7 +1047,7 @@ function encodeSubscribeOkPayload(msg, w) {
|
|
|
1047
1047
|
w.writeVarInt(msg.request_id);
|
|
1048
1048
|
w.writeVarInt(msg.track_alias);
|
|
1049
1049
|
w.writeVarInt(msg.expires);
|
|
1050
|
-
w.writeUint8(
|
|
1050
|
+
w.writeUint8(msg.group_order);
|
|
1051
1051
|
w.writeVarInt(msg.content_exists);
|
|
1052
1052
|
if (msg.content_exists === 1n) {
|
|
1053
1053
|
w.writeVarInt(msg.largest_location.group);
|
|
@@ -1061,7 +1061,7 @@ function encodeSubscribeUpdatePayload(msg, w) {
|
|
|
1061
1061
|
w.writeVarInt(msg.start_group);
|
|
1062
1062
|
w.writeVarInt(msg.start_object);
|
|
1063
1063
|
w.writeVarInt(msg.end_group);
|
|
1064
|
-
w.writeUint8(
|
|
1064
|
+
w.writeUint8(msg.subscriber_priority);
|
|
1065
1065
|
w.writeVarInt(msg.forward);
|
|
1066
1066
|
encodeMessageParams(msg.parameters, w);
|
|
1067
1067
|
}
|
|
@@ -1078,7 +1078,7 @@ function encodePublishPayload(msg, w) {
|
|
|
1078
1078
|
w.writeTuple(msg.track_namespace);
|
|
1079
1079
|
w.writeString(msg.track_name);
|
|
1080
1080
|
w.writeVarInt(msg.track_alias);
|
|
1081
|
-
w.writeUint8(
|
|
1081
|
+
w.writeUint8(msg.group_order);
|
|
1082
1082
|
w.writeVarInt(msg.content_exists);
|
|
1083
1083
|
if (msg.content_exists === 1n) {
|
|
1084
1084
|
w.writeVarInt(msg.largest_location.group);
|
|
@@ -1090,8 +1090,8 @@ function encodePublishPayload(msg, w) {
|
|
|
1090
1090
|
function encodePublishOkPayload(msg, w) {
|
|
1091
1091
|
w.writeVarInt(msg.request_id);
|
|
1092
1092
|
w.writeVarInt(msg.forward);
|
|
1093
|
-
w.writeUint8(
|
|
1094
|
-
w.writeUint8(
|
|
1093
|
+
w.writeUint8(msg.subscriber_priority);
|
|
1094
|
+
w.writeUint8(msg.group_order);
|
|
1095
1095
|
w.writeVarInt(msg.filter_type);
|
|
1096
1096
|
const ft = msg.filter_type;
|
|
1097
1097
|
if (ft >= FilterType.AbsoluteStart) {
|
|
@@ -1155,26 +1155,26 @@ function encodeUnsubscribeNamespacePayload(msg, w) {
|
|
|
1155
1155
|
}
|
|
1156
1156
|
function encodeFetchPayload(msg, w) {
|
|
1157
1157
|
w.writeVarInt(msg.request_id);
|
|
1158
|
-
w.writeUint8(
|
|
1159
|
-
w.writeUint8(
|
|
1158
|
+
w.writeUint8(msg.subscriber_priority);
|
|
1159
|
+
w.writeUint8(msg.group_order);
|
|
1160
1160
|
w.writeVarInt(msg.fetch_type);
|
|
1161
1161
|
const ft = msg.fetch_type;
|
|
1162
|
-
if (ft === FetchType.Standalone) {
|
|
1163
|
-
w.writeTuple(msg.track_namespace);
|
|
1164
|
-
w.writeString(msg.track_name);
|
|
1165
|
-
w.writeVarInt(msg.start_group);
|
|
1166
|
-
w.writeVarInt(msg.start_object);
|
|
1167
|
-
w.writeVarInt(msg.end_group);
|
|
1168
|
-
w.writeVarInt(msg.end_object);
|
|
1169
|
-
} else {
|
|
1170
|
-
w.writeVarInt(msg.joining_request_id);
|
|
1171
|
-
w.writeVarInt(msg.joining_start);
|
|
1162
|
+
if (ft === FetchType.Standalone && msg.standalone) {
|
|
1163
|
+
w.writeTuple(msg.standalone.track_namespace);
|
|
1164
|
+
w.writeString(msg.standalone.track_name);
|
|
1165
|
+
w.writeVarInt(msg.standalone.start_group);
|
|
1166
|
+
w.writeVarInt(msg.standalone.start_object);
|
|
1167
|
+
w.writeVarInt(msg.standalone.end_group);
|
|
1168
|
+
w.writeVarInt(msg.standalone.end_object);
|
|
1169
|
+
} else if (msg.joining) {
|
|
1170
|
+
w.writeVarInt(msg.joining.joining_request_id);
|
|
1171
|
+
w.writeVarInt(msg.joining.joining_start);
|
|
1172
1172
|
}
|
|
1173
1173
|
encodeMessageParams(msg.parameters, w);
|
|
1174
1174
|
}
|
|
1175
1175
|
function encodeFetchOkPayload(msg, w) {
|
|
1176
1176
|
w.writeVarInt(msg.request_id);
|
|
1177
|
-
w.writeUint8(
|
|
1177
|
+
w.writeUint8(msg.group_order);
|
|
1178
1178
|
w.writeVarInt(msg.end_of_track);
|
|
1179
1179
|
w.writeVarInt(msg.end_location.group);
|
|
1180
1180
|
w.writeVarInt(msg.end_location.object);
|
|
@@ -1192,8 +1192,8 @@ function encodeTrackStatusPayload(msg, w) {
|
|
|
1192
1192
|
w.writeVarInt(msg.request_id);
|
|
1193
1193
|
w.writeTuple(msg.track_namespace);
|
|
1194
1194
|
w.writeString(msg.track_name);
|
|
1195
|
-
w.writeUint8(
|
|
1196
|
-
w.writeUint8(
|
|
1195
|
+
w.writeUint8(msg.subscriber_priority);
|
|
1196
|
+
w.writeUint8(msg.group_order);
|
|
1197
1197
|
w.writeVarInt(msg.forward);
|
|
1198
1198
|
w.writeVarInt(msg.filter_type);
|
|
1199
1199
|
const ft = msg.filter_type;
|
|
@@ -1207,7 +1207,7 @@ function encodeTrackStatusOkPayload(msg, w) {
|
|
|
1207
1207
|
w.writeVarInt(msg.request_id);
|
|
1208
1208
|
w.writeVarInt(msg.track_alias);
|
|
1209
1209
|
w.writeVarInt(msg.expires);
|
|
1210
|
-
w.writeUint8(
|
|
1210
|
+
w.writeUint8(msg.group_order);
|
|
1211
1211
|
w.writeVarInt(msg.content_exists);
|
|
1212
1212
|
if (msg.content_exists === 1n) {
|
|
1213
1213
|
w.writeVarInt(msg.largest_location.group);
|
|
@@ -1232,7 +1232,7 @@ function encodeRequestsBlockedPayload(msg, w) {
|
|
|
1232
1232
|
function decodeClientSetupPayload(r) {
|
|
1233
1233
|
const numVersions = Number(r.readVarInt());
|
|
1234
1234
|
if (numVersions === 0) {
|
|
1235
|
-
throw new (0,
|
|
1235
|
+
throw new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
1236
1236
|
"CONSTRAINT_VIOLATION",
|
|
1237
1237
|
"CLIENT_SETUP must offer at least one version",
|
|
1238
1238
|
r.offset
|
|
@@ -1254,12 +1254,12 @@ function decodeSubscribePayload(r) {
|
|
|
1254
1254
|
const request_id = r.readVarInt();
|
|
1255
1255
|
const track_namespace = r.readTuple();
|
|
1256
1256
|
const track_name = r.readString();
|
|
1257
|
-
const subscriber_priority =
|
|
1258
|
-
const group_order =
|
|
1257
|
+
const subscriber_priority = r.readUint8();
|
|
1258
|
+
const group_order = r.readUint8();
|
|
1259
1259
|
const forward = r.readVarInt();
|
|
1260
1260
|
const filter_type = r.readVarInt();
|
|
1261
1261
|
if (filter_type < FilterType.NextGroupStart || filter_type > FilterType.AbsoluteRange) {
|
|
1262
|
-
throw new (0,
|
|
1262
|
+
throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${filter_type}`, r.offset);
|
|
1263
1263
|
}
|
|
1264
1264
|
let start_group;
|
|
1265
1265
|
let start_object;
|
|
@@ -1292,7 +1292,7 @@ function decodeSubscribeOkPayload(r) {
|
|
|
1292
1292
|
const request_id = r.readVarInt();
|
|
1293
1293
|
const track_alias = r.readVarInt();
|
|
1294
1294
|
const expires = r.readVarInt();
|
|
1295
|
-
const group_order =
|
|
1295
|
+
const group_order = r.readUint8();
|
|
1296
1296
|
const content_exists = r.readVarInt();
|
|
1297
1297
|
let largest_location;
|
|
1298
1298
|
if (content_exists === 1n) {
|
|
@@ -1319,7 +1319,7 @@ function decodeSubscribeUpdatePayload(r) {
|
|
|
1319
1319
|
const start_group = r.readVarInt();
|
|
1320
1320
|
const start_object = r.readVarInt();
|
|
1321
1321
|
const end_group = r.readVarInt();
|
|
1322
|
-
const subscriber_priority =
|
|
1322
|
+
const subscriber_priority = r.readUint8();
|
|
1323
1323
|
const forward = r.readVarInt();
|
|
1324
1324
|
const parameters = decodeMessageParams(r);
|
|
1325
1325
|
return {
|
|
@@ -1349,7 +1349,7 @@ function decodePublishPayload(r) {
|
|
|
1349
1349
|
const track_namespace = r.readTuple();
|
|
1350
1350
|
const track_name = r.readString();
|
|
1351
1351
|
const track_alias = r.readVarInt();
|
|
1352
|
-
const group_order =
|
|
1352
|
+
const group_order = r.readUint8();
|
|
1353
1353
|
const content_exists = r.readVarInt();
|
|
1354
1354
|
let largest_location;
|
|
1355
1355
|
if (content_exists === 1n) {
|
|
@@ -1376,8 +1376,8 @@ function decodePublishPayload(r) {
|
|
|
1376
1376
|
function decodePublishOkPayload(r) {
|
|
1377
1377
|
const request_id = r.readVarInt();
|
|
1378
1378
|
const forward = r.readVarInt();
|
|
1379
|
-
const subscriber_priority =
|
|
1380
|
-
const group_order =
|
|
1379
|
+
const subscriber_priority = r.readUint8();
|
|
1380
|
+
const group_order = r.readUint8();
|
|
1381
1381
|
const filter_type = r.readVarInt();
|
|
1382
1382
|
let start_group;
|
|
1383
1383
|
let start_object;
|
|
@@ -1493,19 +1493,21 @@ function decodeUnsubscribeNamespacePayload(r) {
|
|
|
1493
1493
|
}
|
|
1494
1494
|
function decodeFetchPayload(r) {
|
|
1495
1495
|
const request_id = r.readVarInt();
|
|
1496
|
-
const subscriber_priority =
|
|
1497
|
-
const group_order =
|
|
1496
|
+
const subscriber_priority = r.readUint8();
|
|
1497
|
+
const group_order = r.readUint8();
|
|
1498
1498
|
const fetch_type = r.readVarInt();
|
|
1499
1499
|
if (fetch_type < FetchType.Standalone || fetch_type > FetchType.AbsoluteJoining) {
|
|
1500
|
-
throw new (0,
|
|
1500
|
+
throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${fetch_type}`, r.offset);
|
|
1501
1501
|
}
|
|
1502
1502
|
if (fetch_type === FetchType.Standalone) {
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1503
|
+
const standalone = {
|
|
1504
|
+
track_namespace: r.readTuple(),
|
|
1505
|
+
track_name: r.readString(),
|
|
1506
|
+
start_group: r.readVarInt(),
|
|
1507
|
+
start_object: r.readVarInt(),
|
|
1508
|
+
end_group: r.readVarInt(),
|
|
1509
|
+
end_object: r.readVarInt()
|
|
1510
|
+
};
|
|
1509
1511
|
const parameters = decodeMessageParams(r);
|
|
1510
1512
|
return {
|
|
1511
1513
|
type: "fetch",
|
|
@@ -1513,17 +1515,14 @@ function decodeFetchPayload(r) {
|
|
|
1513
1515
|
subscriber_priority,
|
|
1514
1516
|
group_order,
|
|
1515
1517
|
fetch_type,
|
|
1516
|
-
|
|
1517
|
-
track_name,
|
|
1518
|
-
start_group,
|
|
1519
|
-
start_object,
|
|
1520
|
-
end_group,
|
|
1521
|
-
end_object,
|
|
1518
|
+
standalone,
|
|
1522
1519
|
parameters
|
|
1523
1520
|
};
|
|
1524
1521
|
} else {
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1522
|
+
const joining = {
|
|
1523
|
+
joining_request_id: r.readVarInt(),
|
|
1524
|
+
joining_start: r.readVarInt()
|
|
1525
|
+
};
|
|
1527
1526
|
const parameters = decodeMessageParams(r);
|
|
1528
1527
|
return {
|
|
1529
1528
|
type: "fetch",
|
|
@@ -1531,15 +1530,14 @@ function decodeFetchPayload(r) {
|
|
|
1531
1530
|
subscriber_priority,
|
|
1532
1531
|
group_order,
|
|
1533
1532
|
fetch_type,
|
|
1534
|
-
|
|
1535
|
-
joining_start,
|
|
1533
|
+
joining,
|
|
1536
1534
|
parameters
|
|
1537
1535
|
};
|
|
1538
1536
|
}
|
|
1539
1537
|
}
|
|
1540
1538
|
function decodeFetchOkPayload(r) {
|
|
1541
1539
|
const request_id = r.readVarInt();
|
|
1542
|
-
const group_order =
|
|
1540
|
+
const group_order = r.readUint8();
|
|
1543
1541
|
const end_of_track = r.readVarInt();
|
|
1544
1542
|
const end_location = {
|
|
1545
1543
|
group: r.readVarInt(),
|
|
@@ -1569,8 +1567,8 @@ function decodeTrackStatusPayload(r) {
|
|
|
1569
1567
|
const request_id = r.readVarInt();
|
|
1570
1568
|
const track_namespace = r.readTuple();
|
|
1571
1569
|
const track_name = r.readString();
|
|
1572
|
-
const subscriber_priority =
|
|
1573
|
-
const group_order =
|
|
1570
|
+
const subscriber_priority = r.readUint8();
|
|
1571
|
+
const group_order = r.readUint8();
|
|
1574
1572
|
const forward = r.readVarInt();
|
|
1575
1573
|
const filter_type = r.readVarInt();
|
|
1576
1574
|
let start_group;
|
|
@@ -1599,7 +1597,7 @@ function decodeTrackStatusOkPayload(r) {
|
|
|
1599
1597
|
const request_id = r.readVarInt();
|
|
1600
1598
|
const track_alias = r.readVarInt();
|
|
1601
1599
|
const expires = r.readVarInt();
|
|
1602
|
-
const group_order =
|
|
1600
|
+
const group_order = r.readUint8();
|
|
1603
1601
|
const content_exists = r.readVarInt();
|
|
1604
1602
|
let largest_location;
|
|
1605
1603
|
if (content_exists === 1n) {
|
|
@@ -1675,13 +1673,13 @@ function encodeMessage(message) {
|
|
|
1675
1673
|
if (typeId === void 0) {
|
|
1676
1674
|
throw new Error(`Unknown message type: ${message.type}`);
|
|
1677
1675
|
}
|
|
1678
|
-
const payloadWriter = new (0,
|
|
1676
|
+
const payloadWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
1679
1677
|
encodePayload(message, payloadWriter);
|
|
1680
1678
|
const payload = payloadWriter.finishView();
|
|
1681
1679
|
if (payload.byteLength > 65535) {
|
|
1682
1680
|
throw new Error(`Payload too large for 16-bit length: ${payload.byteLength}`);
|
|
1683
1681
|
}
|
|
1684
|
-
const writer = new (0,
|
|
1682
|
+
const writer = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(payload.byteLength + 16);
|
|
1685
1683
|
writer.writeVarInt(typeId);
|
|
1686
1684
|
writer.writeUint8(payload.byteLength >> 8 & 255);
|
|
1687
1685
|
writer.writeUint8(payload.byteLength & 255);
|
|
@@ -1758,18 +1756,18 @@ function encodePayload(msg, w) {
|
|
|
1758
1756
|
}
|
|
1759
1757
|
function decodeMessage(bytes) {
|
|
1760
1758
|
try {
|
|
1761
|
-
const reader = new (0,
|
|
1759
|
+
const reader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
1762
1760
|
const typeId = reader.readVarInt();
|
|
1763
1761
|
const lenHi = reader.readUint8();
|
|
1764
1762
|
const lenLo = reader.readUint8();
|
|
1765
1763
|
const payloadLength = lenHi << 8 | lenLo;
|
|
1766
1764
|
const payloadBytes = reader.readBytes(payloadLength);
|
|
1767
|
-
const payloadReader = new (0,
|
|
1765
|
+
const payloadReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(payloadBytes);
|
|
1768
1766
|
const decoder = payloadDecoders.get(typeId);
|
|
1769
1767
|
if (!decoder) {
|
|
1770
1768
|
return {
|
|
1771
1769
|
ok: false,
|
|
1772
|
-
error: new (0,
|
|
1770
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
1773
1771
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1774
1772
|
`Unknown message type ID: 0x${typeId.toString(16)}`,
|
|
1775
1773
|
0
|
|
@@ -1779,7 +1777,7 @@ function decodeMessage(bytes) {
|
|
|
1779
1777
|
const message = decoder(payloadReader);
|
|
1780
1778
|
return { ok: true, value: message, bytesRead: reader.offset };
|
|
1781
1779
|
} catch (e) {
|
|
1782
|
-
if (e instanceof
|
|
1780
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) {
|
|
1783
1781
|
return { ok: false, error: e };
|
|
1784
1782
|
}
|
|
1785
1783
|
throw e;
|
|
@@ -1814,7 +1812,7 @@ function createStreamDecoder() {
|
|
|
1814
1812
|
flush(controller) {
|
|
1815
1813
|
if (offset < buffer.length) {
|
|
1816
1814
|
controller.error(
|
|
1817
|
-
new (0,
|
|
1815
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete message data", 0)
|
|
1818
1816
|
);
|
|
1819
1817
|
}
|
|
1820
1818
|
}
|