@moqtap/codec 0.5.0 → 0.7.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 +4 -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-APTV6F72.js +2095 -0
- package/dist/{chunk-JB5VDJ2V.cjs → chunk-B56AG5HU.cjs} +37 -37
- package/dist/chunk-CQ65LKPQ.cjs +446 -0
- package/dist/{chunk-4HBKHNU2.cjs → chunk-CZNW3R5E.cjs} +37 -37
- package/dist/{chunk-Q5D6OW6Q.js → chunk-DORX55MO.js} +1 -1
- 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-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-MH7537FB.cjs +2095 -0
- package/dist/{chunk-SHMA4PBY.js → chunk-N2V7Z37J.js} +1 -1
- package/dist/chunk-O5DQ44TM.js +446 -0
- 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/{chunk-JTRU76JN.cjs → chunk-Y4FRXYX6.cjs} +59 -59
- package/dist/{codec-yJ_axwtp.d.cts → codec-B1snaM9L.d.cts} +1 -1
- package/dist/{codec-Tdey03Bo.d.ts → codec-BLYAy2OP.d.ts} +1 -1
- package/dist/{codec-DqHwYWM-.d.ts → codec-BNS3gS77.d.ts} +1 -1
- package/dist/{codec-CBLLytyP.d.cts → codec-BOtv3R5j.d.cts} +1 -1
- package/dist/{codec-C17JvsEU.d.cts → codec-BOyrk_C9.d.cts} +1 -1
- package/dist/{codec-BsSNjvB3.d.cts → codec-BqqoYdh_.d.cts} +1 -1
- package/dist/{codec-BhW5CGZq.d.ts → codec-CI0BjmHc.d.ts} +1 -1
- package/dist/{codec-BvzKRqiP.d.ts → codec-CWj5iTxA.d.ts} +1 -1
- package/dist/{codec-DbpLHKXN.d.cts → codec-CyApDKwf.d.cts} +1 -1
- package/dist/{codec-6s9d5yZm.d.ts → codec-D2JbI2tp.d.ts} +1 -1
- package/dist/{codec-BzRIVIzS.d.ts → codec-D47r_-Rl.d.ts} +1 -1
- package/dist/{codec-GayA_uN0.d.ts → codec-D49OofBr.d.ts} +1 -1
- package/dist/{codec-MxIhLDR5.d.cts → codec-D89DWXbv.d.cts} +1 -1
- package/dist/{codec-CzBmYisK.d.cts → codec-D95gT98n.d.cts} +1 -1
- package/dist/codec-DAePx2NL.d.ts +30 -0
- package/dist/{codec-D_9X0i31.d.ts → codec-DJmV04i0.d.ts} +1 -1
- package/dist/{codec-Cbv3sG2y.d.ts → codec-DL0njGkL.d.ts} +1 -1
- package/dist/{codec-D2YMCU11.d.cts → codec-DQWQSam3.d.cts} +1 -1
- package/dist/{codec-Bp4HPezr.d.ts → codec-DplRgIKq.d.ts} +1 -1
- package/dist/{codec-3ZgEK-Yj.d.ts → codec-DujHf55Z.d.ts} +1 -1
- package/dist/{codec-DS-As0Pp.d.cts → codec-DvcJgYKq.d.cts} +1 -1
- package/dist/{codec-D5Ss123f.d.cts → codec-NMsTK0GX.d.cts} +1 -1
- package/dist/{codec-BvSmr-Jp.d.ts → codec-WwwUipaU.d.ts} +1 -1
- package/dist/{codec-B6ouUJrm.d.cts → codec-cou9XBMF.d.cts} +1 -1
- package/dist/{codec-R28KwiGM.d.cts → codec-hvkJfCF5.d.cts} +1 -1
- package/dist/codec-xeuGZY77.d.cts +30 -0
- package/dist/draft07-session.d.cts +3 -3
- package/dist/draft07-session.d.ts +3 -3
- package/dist/draft07.cjs +4 -4
- package/dist/draft07.d.cts +3 -3
- package/dist/draft07.d.ts +3 -3
- package/dist/draft07.js +2 -2
- package/dist/draft08-session.d.cts +3 -3
- package/dist/draft08-session.d.ts +3 -3
- package/dist/draft08.cjs +3 -3
- package/dist/draft08.d.cts +4 -4
- package/dist/draft08.d.ts +4 -4
- package/dist/draft08.js +2 -2
- package/dist/draft09-session.d.cts +3 -3
- package/dist/draft09-session.d.ts +3 -3
- package/dist/draft09.cjs +3 -3
- package/dist/draft09.d.cts +4 -4
- package/dist/draft09.d.ts +4 -4
- package/dist/draft09.js +2 -2
- package/dist/draft10-session.d.cts +3 -3
- package/dist/draft10-session.d.ts +3 -3
- package/dist/draft10.cjs +3 -3
- package/dist/draft10.d.cts +4 -4
- package/dist/draft10.d.ts +4 -4
- package/dist/draft10.js +2 -2
- package/dist/draft11-session.d.cts +3 -3
- package/dist/draft11-session.d.ts +3 -3
- package/dist/draft11.cjs +3 -3
- package/dist/draft11.d.cts +4 -4
- package/dist/draft11.d.ts +4 -4
- package/dist/draft11.js +2 -2
- package/dist/draft12-session.d.cts +3 -3
- package/dist/draft12-session.d.ts +3 -3
- package/dist/draft12.cjs +3 -3
- package/dist/draft12.d.cts +4 -4
- package/dist/draft12.d.ts +4 -4
- package/dist/draft12.js +2 -2
- package/dist/draft13-session.d.cts +3 -3
- package/dist/draft13-session.d.ts +3 -3
- package/dist/draft13.cjs +3 -3
- package/dist/draft13.d.cts +4 -4
- package/dist/draft13.d.ts +4 -4
- package/dist/draft13.js +2 -2
- package/dist/draft14-session.d.cts +3 -3
- package/dist/draft14-session.d.ts +3 -3
- package/dist/draft14.cjs +3 -3
- package/dist/draft14.d.cts +4 -4
- package/dist/draft14.d.ts +4 -4
- package/dist/draft14.js +2 -2
- package/dist/draft15-session.d.cts +3 -3
- package/dist/draft15-session.d.ts +3 -3
- package/dist/draft15.cjs +3 -3
- package/dist/draft15.d.cts +4 -4
- package/dist/draft15.d.ts +4 -4
- package/dist/draft15.js +2 -2
- package/dist/draft16-session.d.cts +3 -3
- package/dist/draft16-session.d.ts +3 -3
- package/dist/draft16.cjs +3 -3
- package/dist/draft16.d.cts +4 -4
- package/dist/draft16.d.ts +4 -4
- package/dist/draft16.js +2 -2
- package/dist/draft17-session.d.cts +3 -3
- package/dist/draft17-session.d.ts +3 -3
- package/dist/draft17.cjs +3 -3
- package/dist/draft17.d.cts +3 -3
- package/dist/draft17.d.ts +3 -3
- package/dist/draft17.js +2 -2
- package/dist/draft18-session.d.cts +3 -3
- package/dist/draft18-session.d.ts +3 -3
- package/dist/draft18.cjs +3 -3
- package/dist/draft18.d.cts +3 -3
- package/dist/draft18.d.ts +3 -3
- package/dist/draft18.js +2 -2
- package/dist/draft19-session.cjs +8 -0
- package/dist/draft19-session.d.cts +50 -0
- package/dist/draft19-session.d.ts +50 -0
- package/dist/draft19-session.js +8 -0
- package/dist/draft19.cjs +189 -0
- package/dist/draft19.d.cts +130 -0
- package/dist/draft19.d.ts +130 -0
- package/dist/draft19.js +189 -0
- package/dist/index.cjs +33 -27
- package/dist/index.d.cts +20 -15
- package/dist/index.d.ts +20 -15
- package/dist/index.js +20 -14
- package/dist/{session-types-DBpCRtrL.d.ts → session-types-C0l_-Ups.d.ts} +1 -1
- package/dist/{session-types-sBaTRwDh.d.cts → session-types-KsqyVp6y.d.cts} +1 -1
- package/dist/session.cjs +5 -1
- package/dist/session.d.cts +5 -3
- package/dist/session.d.ts +5 -3
- package/dist/session.js +5 -1
- package/dist/{types-CnBuq68e.d.cts → types-CdCSIfvI.d.cts} +1 -1
- package/dist/{types-CnBuq68e.d.ts → types-CdCSIfvI.d.ts} +1 -1
- package/dist/types-zHgCS6o5.d.cts +265 -0
- package/dist/types-zHgCS6o5.d.ts +265 -0
- package/package.json +14 -2
- package/src/core/buffer-reader.ts +74 -2
- package/src/core/buffer-writer.ts +56 -4
- package/src/core/types.ts +1 -0
- 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 +1425 -0
- package/src/drafts/draft19/data-streams.ts +996 -0
- package/src/drafts/draft19/error-codes.ts +78 -0
- package/src/drafts/draft19/index.ts +126 -0
- package/src/drafts/draft19/messages.ts +58 -0
- package/src/drafts/draft19/rules.ts +85 -0
- package/src/drafts/draft19/session-fsm.ts +451 -0
- package/src/drafts/draft19/session.ts +15 -0
- package/src/drafts/draft19/types.ts +368 -0
- package/src/index.ts +9 -1
- package/src/session.ts +4 -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/draft15/messages.ts
|
|
10
10
|
var MSG_SUBSCRIBE_UPDATE = 0x02n;
|
|
@@ -68,7 +68,7 @@ var MESSAGE_ID_MAP = new Map(
|
|
|
68
68
|
// src/drafts/draft15/data-streams.ts
|
|
69
69
|
var FETCH_STREAM_TYPE = 0x05n;
|
|
70
70
|
function encodeSubgroupStream(stream) {
|
|
71
|
-
const w = new (0,
|
|
71
|
+
const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
72
72
|
const streamType = stream.headerType;
|
|
73
73
|
w.writeVarInt(BigInt(streamType));
|
|
74
74
|
const extensionsPresent = (streamType & 1) !== 0;
|
|
@@ -101,7 +101,7 @@ function encodeSubgroupStream(stream) {
|
|
|
101
101
|
return w.finish();
|
|
102
102
|
}
|
|
103
103
|
function encodeDatagram(dg) {
|
|
104
|
-
const w = new (0,
|
|
104
|
+
const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
105
105
|
const dgType = dg.datagramType;
|
|
106
106
|
w.writeVarInt(BigInt(dgType));
|
|
107
107
|
w.writeVarInt(dg.trackAlias);
|
|
@@ -126,7 +126,7 @@ function encodeDatagram(dg) {
|
|
|
126
126
|
return w.finish();
|
|
127
127
|
}
|
|
128
128
|
function encodeFetchStream(stream) {
|
|
129
|
-
const w = new (0,
|
|
129
|
+
const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
130
130
|
w.writeVarInt(FETCH_STREAM_TYPE);
|
|
131
131
|
w.writeVarInt(stream.requestId);
|
|
132
132
|
for (const obj of stream.objects) {
|
|
@@ -152,12 +152,12 @@ function encodeFetchStream(stream) {
|
|
|
152
152
|
}
|
|
153
153
|
function decodeSubgroupStream(bytes) {
|
|
154
154
|
try {
|
|
155
|
-
const r = new (0,
|
|
155
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
156
156
|
const streamType = Number(r.readVarInt());
|
|
157
157
|
if (!(streamType >= 16 && streamType <= 23 || streamType >= 48 && streamType <= 55)) {
|
|
158
158
|
return {
|
|
159
159
|
ok: false,
|
|
160
|
-
error: new (0,
|
|
160
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
161
161
|
"CONSTRAINT_VIOLATION",
|
|
162
162
|
`Expected subgroup stream type 0x10-0x17/0x30-0x37, got 0x${streamType.toString(16)}`,
|
|
163
163
|
0
|
|
@@ -237,13 +237,13 @@ function decodeSubgroupStream(bytes) {
|
|
|
237
237
|
bytesRead: r.offset
|
|
238
238
|
};
|
|
239
239
|
} catch (e) {
|
|
240
|
-
if (e instanceof
|
|
240
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
241
241
|
throw e;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
function decodeDatagram(bytes) {
|
|
245
245
|
try {
|
|
246
|
-
const r = new (0,
|
|
246
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
247
247
|
const dgType = Number(r.readVarInt());
|
|
248
248
|
const extensionsPresent = (dgType & 1) !== 0;
|
|
249
249
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
@@ -287,18 +287,18 @@ function decodeDatagram(bytes) {
|
|
|
287
287
|
result.extensionData = extensionData;
|
|
288
288
|
return { ok: true, value: result, bytesRead: r.offset };
|
|
289
289
|
} catch (e) {
|
|
290
|
-
if (e instanceof
|
|
290
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
291
291
|
throw e;
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
function decodeFetchStream(bytes) {
|
|
295
295
|
try {
|
|
296
|
-
const r = new (0,
|
|
296
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
297
297
|
const streamType = r.readVarInt();
|
|
298
298
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
299
299
|
return {
|
|
300
300
|
ok: false,
|
|
301
|
-
error: new (0,
|
|
301
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
302
302
|
"CONSTRAINT_VIOLATION",
|
|
303
303
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
304
304
|
0
|
|
@@ -323,7 +323,7 @@ function decodeFetchStream(bytes) {
|
|
|
323
323
|
if (flags & 192) {
|
|
324
324
|
return {
|
|
325
325
|
ok: false,
|
|
326
|
-
error: new (0,
|
|
326
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
327
327
|
"CONSTRAINT_VIOLATION",
|
|
328
328
|
"Reserved bits set in fetch object flags",
|
|
329
329
|
r.offset
|
|
@@ -336,7 +336,7 @@ function decodeFetchStream(bytes) {
|
|
|
336
336
|
} else if (first) {
|
|
337
337
|
return {
|
|
338
338
|
ok: false,
|
|
339
|
-
error: new (0,
|
|
339
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
340
340
|
"CONSTRAINT_VIOLATION",
|
|
341
341
|
"First fetch object must include groupId",
|
|
342
342
|
r.offset
|
|
@@ -350,7 +350,7 @@ function decodeFetchStream(bytes) {
|
|
|
350
350
|
if (first) {
|
|
351
351
|
return {
|
|
352
352
|
ok: false,
|
|
353
|
-
error: new (0,
|
|
353
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
354
354
|
"CONSTRAINT_VIOLATION",
|
|
355
355
|
"First fetch object cannot reference prior subgroupId",
|
|
356
356
|
r.offset
|
|
@@ -362,7 +362,7 @@ function decodeFetchStream(bytes) {
|
|
|
362
362
|
if (first) {
|
|
363
363
|
return {
|
|
364
364
|
ok: false,
|
|
365
|
-
error: new (0,
|
|
365
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
366
366
|
"CONSTRAINT_VIOLATION",
|
|
367
367
|
"First fetch object cannot reference prior subgroupId",
|
|
368
368
|
r.offset
|
|
@@ -379,7 +379,7 @@ function decodeFetchStream(bytes) {
|
|
|
379
379
|
} else if (first) {
|
|
380
380
|
return {
|
|
381
381
|
ok: false,
|
|
382
|
-
error: new (0,
|
|
382
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
383
383
|
"CONSTRAINT_VIOLATION",
|
|
384
384
|
"First fetch object must include objectId",
|
|
385
385
|
r.offset
|
|
@@ -432,7 +432,7 @@ function decodeFetchStream(bytes) {
|
|
|
432
432
|
bytesRead: r.offset
|
|
433
433
|
};
|
|
434
434
|
} catch (e) {
|
|
435
|
-
if (e instanceof
|
|
435
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
|
|
436
436
|
throw e;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
@@ -470,11 +470,11 @@ function createSubgroupStreamDecoder() {
|
|
|
470
470
|
buffer = newBuffer;
|
|
471
471
|
if (!headerEmitted) {
|
|
472
472
|
try {
|
|
473
|
-
const r = new (0,
|
|
473
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
474
474
|
const streamType = Number(r.readVarInt());
|
|
475
475
|
if (!(streamType >= 16 && streamType <= 23 || streamType >= 48 && streamType <= 55)) {
|
|
476
476
|
controller.error(
|
|
477
|
-
new (0,
|
|
477
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
478
478
|
"CONSTRAINT_VIOLATION",
|
|
479
479
|
`Expected subgroup stream type, got 0x${streamType.toString(16)}`,
|
|
480
480
|
0
|
|
@@ -506,7 +506,7 @@ function createSubgroupStreamDecoder() {
|
|
|
506
506
|
headerEmitted = true;
|
|
507
507
|
offset += r.offset;
|
|
508
508
|
} catch (e) {
|
|
509
|
-
if (e instanceof
|
|
509
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
510
510
|
return;
|
|
511
511
|
}
|
|
512
512
|
controller.error(e);
|
|
@@ -515,7 +515,7 @@ function createSubgroupStreamDecoder() {
|
|
|
515
515
|
}
|
|
516
516
|
while (offset < buffer.length) {
|
|
517
517
|
try {
|
|
518
|
-
const r = new (0,
|
|
518
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
519
519
|
const byteOffset = r.offset;
|
|
520
520
|
const delta = r.readVarInt();
|
|
521
521
|
let objectId;
|
|
@@ -545,7 +545,7 @@ function createSubgroupStreamDecoder() {
|
|
|
545
545
|
offset += r.offset;
|
|
546
546
|
prevObjectId = objectId;
|
|
547
547
|
} catch (e) {
|
|
548
|
-
if (e instanceof
|
|
548
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
551
|
controller.error(e);
|
|
@@ -555,7 +555,7 @@ function createSubgroupStreamDecoder() {
|
|
|
555
555
|
},
|
|
556
556
|
flush(controller) {
|
|
557
557
|
if (offset < buffer.length) {
|
|
558
|
-
controller.error(new (0,
|
|
558
|
+
controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
});
|
|
@@ -576,11 +576,11 @@ function createFetchStreamDecoder() {
|
|
|
576
576
|
buffer = newBuffer;
|
|
577
577
|
if (!headerEmitted) {
|
|
578
578
|
try {
|
|
579
|
-
const r = new (0,
|
|
579
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
580
580
|
const streamType = r.readVarInt();
|
|
581
581
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
582
582
|
controller.error(
|
|
583
|
-
new (0,
|
|
583
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
584
584
|
"CONSTRAINT_VIOLATION",
|
|
585
585
|
`Expected fetch stream type 0x05, got 0x${streamType.toString(16)}`,
|
|
586
586
|
0
|
|
@@ -593,7 +593,7 @@ function createFetchStreamDecoder() {
|
|
|
593
593
|
headerEmitted = true;
|
|
594
594
|
offset += r.offset;
|
|
595
595
|
} catch (e) {
|
|
596
|
-
if (e instanceof
|
|
596
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
597
597
|
return;
|
|
598
598
|
}
|
|
599
599
|
controller.error(e);
|
|
@@ -602,7 +602,7 @@ function createFetchStreamDecoder() {
|
|
|
602
602
|
}
|
|
603
603
|
while (offset < buffer.length) {
|
|
604
604
|
try {
|
|
605
|
-
const r = new (0,
|
|
605
|
+
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
606
606
|
const flags = r.readUint8();
|
|
607
607
|
const objectIdPresent = (flags & 4) !== 0;
|
|
608
608
|
const groupIdPresent = (flags & 8) !== 0;
|
|
@@ -633,7 +633,7 @@ function createFetchStreamDecoder() {
|
|
|
633
633
|
});
|
|
634
634
|
offset += r.offset;
|
|
635
635
|
} catch (e) {
|
|
636
|
-
if (e instanceof
|
|
636
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError && e.code === "UNEXPECTED_END") {
|
|
637
637
|
break;
|
|
638
638
|
}
|
|
639
639
|
controller.error(e);
|
|
@@ -643,7 +643,7 @@ function createFetchStreamDecoder() {
|
|
|
643
643
|
},
|
|
644
644
|
flush(controller) {
|
|
645
645
|
if (offset < buffer.length) {
|
|
646
|
-
controller.error(new (0,
|
|
646
|
+
controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
});
|
|
@@ -675,7 +675,7 @@ function createDataStreamDecoder() {
|
|
|
675
675
|
inner = decoder;
|
|
676
676
|
} else {
|
|
677
677
|
controller.error(
|
|
678
|
-
new (0,
|
|
678
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
679
679
|
"CONSTRAINT_VIOLATION",
|
|
680
680
|
`Unknown data stream type: 0x${firstByte.toString(16)}`,
|
|
681
681
|
0
|
|
@@ -696,7 +696,7 @@ function createDataStreamDecoder() {
|
|
|
696
696
|
result = decodeFetchStream(view);
|
|
697
697
|
} else {
|
|
698
698
|
controller.error(
|
|
699
|
-
new (0,
|
|
699
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
700
700
|
"CONSTRAINT_VIOLATION",
|
|
701
701
|
`Unknown data stream type: 0x${firstByte.toString(16)}`,
|
|
702
702
|
0
|
|
@@ -758,7 +758,7 @@ function encodeSetupParams(params, writer) {
|
|
|
758
758
|
}
|
|
759
759
|
if (params.authorization_token !== void 0) {
|
|
760
760
|
writer.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN);
|
|
761
|
-
const tmpW = new (0,
|
|
761
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
|
|
762
762
|
encodeAuthorizationToken(params.authorization_token, tmpW);
|
|
763
763
|
const raw = tmpW.finish();
|
|
764
764
|
writer.writeVarInt(raw.byteLength);
|
|
@@ -785,12 +785,12 @@ function encodeSetupParams(params, writer) {
|
|
|
785
785
|
const id = BigInt(u.id);
|
|
786
786
|
writer.writeVarInt(id);
|
|
787
787
|
if (id % 2n === 0n) {
|
|
788
|
-
const raw =
|
|
789
|
-
const tmpReader = new (0,
|
|
788
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
789
|
+
const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(raw);
|
|
790
790
|
const value = tmpReader.readVarInt();
|
|
791
791
|
writer.writeVarInt(value);
|
|
792
792
|
} else {
|
|
793
|
-
const raw =
|
|
793
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
794
794
|
writer.writeVarInt(raw.byteLength);
|
|
795
795
|
writer.writeBytes(raw);
|
|
796
796
|
}
|
|
@@ -810,13 +810,13 @@ function decodeSetupParams(reader) {
|
|
|
810
810
|
} else if (paramType === SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE) {
|
|
811
811
|
result.max_auth_token_cache_size = value;
|
|
812
812
|
} else {
|
|
813
|
-
const tmpWriter = new (0,
|
|
813
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
|
|
814
814
|
tmpWriter.writeVarInt(value);
|
|
815
815
|
const raw = tmpWriter.finish();
|
|
816
816
|
unknown.push({
|
|
817
817
|
id: `0x${paramType.toString(16)}`,
|
|
818
818
|
length: raw.byteLength,
|
|
819
|
-
raw_hex:
|
|
819
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
820
820
|
});
|
|
821
821
|
}
|
|
822
822
|
} else {
|
|
@@ -825,7 +825,7 @@ function decodeSetupParams(reader) {
|
|
|
825
825
|
if (paramType === SETUP_PARAM_PATH) {
|
|
826
826
|
result.path = textDecoder.decode(bytes);
|
|
827
827
|
} else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
|
|
828
|
-
result.authorization_token = decodeAuthorizationToken(new (0,
|
|
828
|
+
result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes));
|
|
829
829
|
} else if (paramType === SETUP_PARAM_AUTHORITY) {
|
|
830
830
|
result.authority = textDecoder.decode(bytes);
|
|
831
831
|
} else if (paramType === SETUP_PARAM_MOQT_IMPLEMENTATION) {
|
|
@@ -834,7 +834,7 @@ function decodeSetupParams(reader) {
|
|
|
834
834
|
unknown.push({
|
|
835
835
|
id: `0x${paramType.toString(16)}`,
|
|
836
836
|
length,
|
|
837
|
-
raw_hex:
|
|
837
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
838
838
|
});
|
|
839
839
|
}
|
|
840
840
|
}
|
|
@@ -901,7 +901,7 @@ function encodeParams(params, writer) {
|
|
|
901
901
|
}
|
|
902
902
|
if (params.authorization_token !== void 0) {
|
|
903
903
|
writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
|
|
904
|
-
const tmpW = new (0,
|
|
904
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
|
|
905
905
|
encodeAuthorizationToken(params.authorization_token, tmpW);
|
|
906
906
|
const raw = tmpW.finish();
|
|
907
907
|
writer.writeVarInt(raw.byteLength);
|
|
@@ -917,7 +917,7 @@ function encodeParams(params, writer) {
|
|
|
917
917
|
}
|
|
918
918
|
if (params.largest_object !== void 0) {
|
|
919
919
|
writer.writeVarInt(PARAM_LARGEST_OBJECT);
|
|
920
|
-
const tmpW = new (0,
|
|
920
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
|
|
921
921
|
tmpW.writeVarInt(params.largest_object.group);
|
|
922
922
|
tmpW.writeVarInt(params.largest_object.object);
|
|
923
923
|
const raw = tmpW.finish();
|
|
@@ -938,7 +938,7 @@ function encodeParams(params, writer) {
|
|
|
938
938
|
}
|
|
939
939
|
if (params.subscription_filter !== void 0) {
|
|
940
940
|
writer.writeVarInt(PARAM_SUBSCRIPTION_FILTER);
|
|
941
|
-
const tmpW = new (0,
|
|
941
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(32);
|
|
942
942
|
const f = params.subscription_filter;
|
|
943
943
|
tmpW.writeVarInt(f.filter_type);
|
|
944
944
|
if (f.filter_type === 3n || f.filter_type === 4n) {
|
|
@@ -969,12 +969,12 @@ function encodeParams(params, writer) {
|
|
|
969
969
|
const id = BigInt(u.id);
|
|
970
970
|
writer.writeVarInt(id);
|
|
971
971
|
if (id % 2n === 0n) {
|
|
972
|
-
const raw =
|
|
973
|
-
const tmpReader = new (0,
|
|
972
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
973
|
+
const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(raw);
|
|
974
974
|
const value = tmpReader.readVarInt();
|
|
975
975
|
writer.writeVarInt(value);
|
|
976
976
|
} else {
|
|
977
|
-
const raw =
|
|
977
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
978
978
|
writer.writeVarInt(raw.byteLength);
|
|
979
979
|
writer.writeBytes(raw);
|
|
980
980
|
}
|
|
@@ -992,7 +992,7 @@ function decodeParams(reader) {
|
|
|
992
992
|
} else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
993
993
|
const length = Number(reader.readVarInt());
|
|
994
994
|
const tokenBytes = reader.readBytes(length);
|
|
995
|
-
result.authorization_token = decodeAuthorizationToken(new (0,
|
|
995
|
+
result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.BufferReader)(tokenBytes));
|
|
996
996
|
} else if (paramType === PARAM_MAX_CACHE_DURATION) {
|
|
997
997
|
result.max_cache_duration = reader.readVarInt();
|
|
998
998
|
} else if (paramType === PARAM_EXPIRES) {
|
|
@@ -1034,13 +1034,13 @@ function decodeParams(reader) {
|
|
|
1034
1034
|
result.subscription_filter = filter;
|
|
1035
1035
|
} else if (paramType % 2n === 0n) {
|
|
1036
1036
|
const value = reader.readVarInt();
|
|
1037
|
-
const tmpWriter = new (0,
|
|
1037
|
+
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
|
|
1038
1038
|
tmpWriter.writeVarInt(value);
|
|
1039
1039
|
const raw = tmpWriter.finish();
|
|
1040
1040
|
unknown.push({
|
|
1041
1041
|
id: `0x${paramType.toString(16)}`,
|
|
1042
1042
|
length: raw.byteLength,
|
|
1043
|
-
raw_hex:
|
|
1043
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
1044
1044
|
});
|
|
1045
1045
|
} else {
|
|
1046
1046
|
const length = Number(reader.readVarInt());
|
|
@@ -1048,7 +1048,7 @@ function decodeParams(reader) {
|
|
|
1048
1048
|
unknown.push({
|
|
1049
1049
|
id: `0x${paramType.toString(16)}`,
|
|
1050
1050
|
length,
|
|
1051
|
-
raw_hex:
|
|
1051
|
+
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
1052
1052
|
});
|
|
1053
1053
|
}
|
|
1054
1054
|
}
|
|
@@ -1287,7 +1287,7 @@ function decodeFetchPayload(r) {
|
|
|
1287
1287
|
const fetch_type = r.readVarInt();
|
|
1288
1288
|
const ft = Number(fetch_type);
|
|
1289
1289
|
if (ft < 1 || ft > 3) {
|
|
1290
|
-
throw new (0,
|
|
1290
|
+
throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${ft}`, r.offset);
|
|
1291
1291
|
}
|
|
1292
1292
|
let standalone;
|
|
1293
1293
|
let joining;
|
|
@@ -1406,13 +1406,13 @@ function encodeMessage(message) {
|
|
|
1406
1406
|
if (typeId === void 0) {
|
|
1407
1407
|
throw new Error(`Unknown message type: ${message.type}`);
|
|
1408
1408
|
}
|
|
1409
|
-
const payloadWriter = new (0,
|
|
1409
|
+
const payloadWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
|
|
1410
1410
|
encodePayload(message, payloadWriter);
|
|
1411
1411
|
const payload = payloadWriter.finishView();
|
|
1412
1412
|
if (payload.byteLength > 65535) {
|
|
1413
1413
|
throw new Error(`Payload too large for 16-bit length: ${payload.byteLength}`);
|
|
1414
1414
|
}
|
|
1415
|
-
const writer = new (0,
|
|
1415
|
+
const writer = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(payload.byteLength + 16);
|
|
1416
1416
|
writer.writeVarInt(typeId);
|
|
1417
1417
|
writer.writeUint8(payload.byteLength >> 8 & 255);
|
|
1418
1418
|
writer.writeUint8(payload.byteLength & 255);
|
|
@@ -1475,18 +1475,18 @@ function encodePayload(msg, w) {
|
|
|
1475
1475
|
}
|
|
1476
1476
|
function decodeMessage(bytes) {
|
|
1477
1477
|
try {
|
|
1478
|
-
const reader = new (0,
|
|
1478
|
+
const reader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
1479
1479
|
const typeId = reader.readVarInt();
|
|
1480
1480
|
const lenHi = reader.readUint8();
|
|
1481
1481
|
const lenLo = reader.readUint8();
|
|
1482
1482
|
const payloadLength = lenHi << 8 | lenLo;
|
|
1483
1483
|
const payloadBytes = reader.readBytes(payloadLength);
|
|
1484
|
-
const payloadReader = new (0,
|
|
1484
|
+
const payloadReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(payloadBytes);
|
|
1485
1485
|
const decoder = payloadDecoders.get(typeId);
|
|
1486
1486
|
if (!decoder) {
|
|
1487
1487
|
return {
|
|
1488
1488
|
ok: false,
|
|
1489
|
-
error: new (0,
|
|
1489
|
+
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
1490
1490
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1491
1491
|
`Unknown message type ID: 0x${typeId.toString(16)}`,
|
|
1492
1492
|
0
|
|
@@ -1496,7 +1496,7 @@ function decodeMessage(bytes) {
|
|
|
1496
1496
|
const message = decoder(payloadReader);
|
|
1497
1497
|
return { ok: true, value: message, bytesRead: reader.offset };
|
|
1498
1498
|
} catch (e) {
|
|
1499
|
-
if (e instanceof
|
|
1499
|
+
if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) {
|
|
1500
1500
|
return { ok: false, error: e };
|
|
1501
1501
|
}
|
|
1502
1502
|
throw e;
|
|
@@ -1531,7 +1531,7 @@ function createStreamDecoder() {
|
|
|
1531
1531
|
flush(controller) {
|
|
1532
1532
|
if (offset < buffer.length) {
|
|
1533
1533
|
controller.error(
|
|
1534
|
-
new (0,
|
|
1534
|
+
new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete message data", 0)
|
|
1535
1535
|
);
|
|
1536
1536
|
}
|
|
1537
1537
|
}
|