@moqtap/codec 0.7.0 → 0.8.1
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 +24 -0
- package/dist/{chunk-5XZKO2U5.js → chunk-2XH6PHXR.js} +62 -51
- package/dist/{chunk-APTV6F72.js → chunk-3YAR3I3S.js} +67 -51
- package/dist/{chunk-Y4FRXYX6.cjs → chunk-7ENEWAMZ.cjs} +52 -58
- package/dist/{chunk-MD2OA7SE.js → chunk-BV6MITLO.js} +15 -8
- package/dist/{chunk-B56AG5HU.cjs → chunk-EVCPBFSR.cjs} +6 -4
- package/dist/{chunk-KNLPX3YA.js → chunk-H6DTAIWM.js} +6 -4
- package/dist/{chunk-J3ASFPCX.cjs → chunk-IADVBKEJ.cjs} +15 -8
- package/dist/{chunk-I55J3KXD.js → chunk-NH4L6NIY.js} +48 -33
- package/dist/{chunk-EQAYMCXO.cjs → chunk-PU2KV7VP.cjs} +48 -33
- package/dist/{chunk-HEO2JG6C.js → chunk-TMXRYOBS.js} +100 -92
- package/dist/{chunk-IEJULBKB.cjs → chunk-UA5XFP4O.cjs} +100 -92
- package/dist/{chunk-KTVN4P6J.cjs → chunk-UZO5Z2XT.cjs} +62 -51
- package/dist/{chunk-MH7537FB.cjs → chunk-VWXUT5R2.cjs} +67 -51
- package/dist/{chunk-DORX55MO.js → chunk-XQGEOFGE.js} +52 -58
- package/dist/{codec-B1snaM9L.d.cts → codec-N3g1lxQQ.d.cts} +1 -1
- package/dist/{codec-D49OofBr.d.ts → codec-v6Vloc7H.d.ts} +1 -1
- package/dist/draft12.cjs +2 -2
- package/dist/draft12.js +1 -1
- package/dist/draft14-session.d.cts +1 -1
- package/dist/draft14-session.d.ts +1 -1
- package/dist/draft14.cjs +2 -2
- package/dist/draft14.d.cts +3 -3
- package/dist/draft14.d.ts +3 -3
- package/dist/draft14.js +1 -1
- package/dist/draft15.cjs +2 -2
- package/dist/draft15.js +1 -1
- package/dist/draft16.cjs +2 -2
- package/dist/draft16.js +1 -1
- package/dist/draft17.cjs +2 -2
- package/dist/draft17.js +1 -1
- package/dist/draft18.cjs +2 -2
- package/dist/draft18.js +1 -1
- package/dist/draft19.cjs +2 -2
- package/dist/draft19.js +1 -1
- package/dist/index.cjs +68 -16
- package/dist/index.d.cts +73 -3
- package/dist/index.d.ts +73 -3
- package/dist/index.js +60 -8
- package/dist/session.d.cts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/{types-DjmrHp_s.d.cts → types-HI_bbXka.d.cts} +29 -23
- package/dist/{types-DjmrHp_s.d.ts → types-HI_bbXka.d.ts} +29 -23
- package/package.json +2 -2
- package/src/core/accessors.ts +120 -0
- package/src/drafts/draft12/data-streams.ts +13 -4
- package/src/drafts/draft14/codec.ts +52 -58
- package/src/drafts/draft14/types.ts +31 -25
- package/src/drafts/draft15/data-streams.ts +30 -16
- package/src/drafts/draft16/codec.ts +116 -93
- package/src/drafts/draft17/codec.ts +72 -35
- package/src/drafts/draft18/codec.ts +89 -53
- package/src/drafts/draft19/codec.ts +94 -53
- package/src/index.ts +8 -0
|
@@ -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) {
|
|
@@ -1121,7 +1121,6 @@ function encodePublishNamespacePayload(msg, w) {
|
|
|
1121
1121
|
}
|
|
1122
1122
|
function encodePublishNamespaceOkPayload(msg, w) {
|
|
1123
1123
|
w.writeVarInt(msg.request_id);
|
|
1124
|
-
encodeMessageParams(msg.parameters, w);
|
|
1125
1124
|
}
|
|
1126
1125
|
function encodePublishNamespaceErrorPayload(msg, w) {
|
|
1127
1126
|
w.writeVarInt(msg.request_id);
|
|
@@ -1143,7 +1142,6 @@ function encodeSubscribeNamespacePayload(msg, w) {
|
|
|
1143
1142
|
}
|
|
1144
1143
|
function encodeSubscribeNamespaceOkPayload(msg, w) {
|
|
1145
1144
|
w.writeVarInt(msg.request_id);
|
|
1146
|
-
encodeMessageParams(msg.parameters, w);
|
|
1147
1145
|
}
|
|
1148
1146
|
function encodeSubscribeNamespaceErrorPayload(msg, w) {
|
|
1149
1147
|
w.writeVarInt(msg.request_id);
|
|
@@ -1155,26 +1153,26 @@ function encodeUnsubscribeNamespacePayload(msg, w) {
|
|
|
1155
1153
|
}
|
|
1156
1154
|
function encodeFetchPayload(msg, w) {
|
|
1157
1155
|
w.writeVarInt(msg.request_id);
|
|
1158
|
-
w.writeUint8(
|
|
1159
|
-
w.writeUint8(
|
|
1156
|
+
w.writeUint8(msg.subscriber_priority);
|
|
1157
|
+
w.writeUint8(msg.group_order);
|
|
1160
1158
|
w.writeVarInt(msg.fetch_type);
|
|
1161
1159
|
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);
|
|
1160
|
+
if (ft === FetchType.Standalone && msg.standalone) {
|
|
1161
|
+
w.writeTuple(msg.standalone.track_namespace);
|
|
1162
|
+
w.writeString(msg.standalone.track_name);
|
|
1163
|
+
w.writeVarInt(msg.standalone.start_group);
|
|
1164
|
+
w.writeVarInt(msg.standalone.start_object);
|
|
1165
|
+
w.writeVarInt(msg.standalone.end_group);
|
|
1166
|
+
w.writeVarInt(msg.standalone.end_object);
|
|
1167
|
+
} else if (msg.joining) {
|
|
1168
|
+
w.writeVarInt(msg.joining.joining_request_id);
|
|
1169
|
+
w.writeVarInt(msg.joining.joining_start);
|
|
1172
1170
|
}
|
|
1173
1171
|
encodeMessageParams(msg.parameters, w);
|
|
1174
1172
|
}
|
|
1175
1173
|
function encodeFetchOkPayload(msg, w) {
|
|
1176
1174
|
w.writeVarInt(msg.request_id);
|
|
1177
|
-
w.writeUint8(
|
|
1175
|
+
w.writeUint8(msg.group_order);
|
|
1178
1176
|
w.writeVarInt(msg.end_of_track);
|
|
1179
1177
|
w.writeVarInt(msg.end_location.group);
|
|
1180
1178
|
w.writeVarInt(msg.end_location.object);
|
|
@@ -1192,8 +1190,8 @@ function encodeTrackStatusPayload(msg, w) {
|
|
|
1192
1190
|
w.writeVarInt(msg.request_id);
|
|
1193
1191
|
w.writeTuple(msg.track_namespace);
|
|
1194
1192
|
w.writeString(msg.track_name);
|
|
1195
|
-
w.writeUint8(
|
|
1196
|
-
w.writeUint8(
|
|
1193
|
+
w.writeUint8(msg.subscriber_priority);
|
|
1194
|
+
w.writeUint8(msg.group_order);
|
|
1197
1195
|
w.writeVarInt(msg.forward);
|
|
1198
1196
|
w.writeVarInt(msg.filter_type);
|
|
1199
1197
|
const ft = msg.filter_type;
|
|
@@ -1207,7 +1205,7 @@ function encodeTrackStatusOkPayload(msg, w) {
|
|
|
1207
1205
|
w.writeVarInt(msg.request_id);
|
|
1208
1206
|
w.writeVarInt(msg.track_alias);
|
|
1209
1207
|
w.writeVarInt(msg.expires);
|
|
1210
|
-
w.writeUint8(
|
|
1208
|
+
w.writeUint8(msg.group_order);
|
|
1211
1209
|
w.writeVarInt(msg.content_exists);
|
|
1212
1210
|
if (msg.content_exists === 1n) {
|
|
1213
1211
|
w.writeVarInt(msg.largest_location.group);
|
|
@@ -1254,8 +1252,8 @@ function decodeSubscribePayload(r) {
|
|
|
1254
1252
|
const request_id = r.readVarInt();
|
|
1255
1253
|
const track_namespace = r.readTuple();
|
|
1256
1254
|
const track_name = r.readString();
|
|
1257
|
-
const subscriber_priority =
|
|
1258
|
-
const group_order =
|
|
1255
|
+
const subscriber_priority = r.readUint8();
|
|
1256
|
+
const group_order = r.readUint8();
|
|
1259
1257
|
const forward = r.readVarInt();
|
|
1260
1258
|
const filter_type = r.readVarInt();
|
|
1261
1259
|
if (filter_type < FilterType.NextGroupStart || filter_type > FilterType.AbsoluteRange) {
|
|
@@ -1292,7 +1290,7 @@ function decodeSubscribeOkPayload(r) {
|
|
|
1292
1290
|
const request_id = r.readVarInt();
|
|
1293
1291
|
const track_alias = r.readVarInt();
|
|
1294
1292
|
const expires = r.readVarInt();
|
|
1295
|
-
const group_order =
|
|
1293
|
+
const group_order = r.readUint8();
|
|
1296
1294
|
const content_exists = r.readVarInt();
|
|
1297
1295
|
let largest_location;
|
|
1298
1296
|
if (content_exists === 1n) {
|
|
@@ -1319,7 +1317,7 @@ function decodeSubscribeUpdatePayload(r) {
|
|
|
1319
1317
|
const start_group = r.readVarInt();
|
|
1320
1318
|
const start_object = r.readVarInt();
|
|
1321
1319
|
const end_group = r.readVarInt();
|
|
1322
|
-
const subscriber_priority =
|
|
1320
|
+
const subscriber_priority = r.readUint8();
|
|
1323
1321
|
const forward = r.readVarInt();
|
|
1324
1322
|
const parameters = decodeMessageParams(r);
|
|
1325
1323
|
return {
|
|
@@ -1349,7 +1347,7 @@ function decodePublishPayload(r) {
|
|
|
1349
1347
|
const track_namespace = r.readTuple();
|
|
1350
1348
|
const track_name = r.readString();
|
|
1351
1349
|
const track_alias = r.readVarInt();
|
|
1352
|
-
const group_order =
|
|
1350
|
+
const group_order = r.readUint8();
|
|
1353
1351
|
const content_exists = r.readVarInt();
|
|
1354
1352
|
let largest_location;
|
|
1355
1353
|
if (content_exists === 1n) {
|
|
@@ -1376,8 +1374,8 @@ function decodePublishPayload(r) {
|
|
|
1376
1374
|
function decodePublishOkPayload(r) {
|
|
1377
1375
|
const request_id = r.readVarInt();
|
|
1378
1376
|
const forward = r.readVarInt();
|
|
1379
|
-
const subscriber_priority =
|
|
1380
|
-
const group_order =
|
|
1377
|
+
const subscriber_priority = r.readUint8();
|
|
1378
|
+
const group_order = r.readUint8();
|
|
1381
1379
|
const filter_type = r.readVarInt();
|
|
1382
1380
|
let start_group;
|
|
1383
1381
|
let start_object;
|
|
@@ -1431,8 +1429,7 @@ function decodePublishNamespacePayload(r) {
|
|
|
1431
1429
|
}
|
|
1432
1430
|
function decodePublishNamespaceOkPayload(r) {
|
|
1433
1431
|
const request_id = r.readVarInt();
|
|
1434
|
-
|
|
1435
|
-
return { type: "publish_namespace_ok", request_id, parameters };
|
|
1432
|
+
return { type: "publish_namespace_ok", request_id };
|
|
1436
1433
|
}
|
|
1437
1434
|
function decodePublishNamespaceErrorPayload(r) {
|
|
1438
1435
|
const request_id = r.readVarInt();
|
|
@@ -1473,8 +1470,7 @@ function decodeSubscribeNamespacePayload(r) {
|
|
|
1473
1470
|
}
|
|
1474
1471
|
function decodeSubscribeNamespaceOkPayload(r) {
|
|
1475
1472
|
const request_id = r.readVarInt();
|
|
1476
|
-
|
|
1477
|
-
return { type: "subscribe_namespace_ok", request_id, parameters };
|
|
1473
|
+
return { type: "subscribe_namespace_ok", request_id };
|
|
1478
1474
|
}
|
|
1479
1475
|
function decodeSubscribeNamespaceErrorPayload(r) {
|
|
1480
1476
|
const request_id = r.readVarInt();
|
|
@@ -1493,19 +1489,21 @@ function decodeUnsubscribeNamespacePayload(r) {
|
|
|
1493
1489
|
}
|
|
1494
1490
|
function decodeFetchPayload(r) {
|
|
1495
1491
|
const request_id = r.readVarInt();
|
|
1496
|
-
const subscriber_priority =
|
|
1497
|
-
const group_order =
|
|
1492
|
+
const subscriber_priority = r.readUint8();
|
|
1493
|
+
const group_order = r.readUint8();
|
|
1498
1494
|
const fetch_type = r.readVarInt();
|
|
1499
1495
|
if (fetch_type < FetchType.Standalone || fetch_type > FetchType.AbsoluteJoining) {
|
|
1500
1496
|
throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${fetch_type}`, r.offset);
|
|
1501
1497
|
}
|
|
1502
1498
|
if (fetch_type === FetchType.Standalone) {
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1499
|
+
const standalone = {
|
|
1500
|
+
track_namespace: r.readTuple(),
|
|
1501
|
+
track_name: r.readString(),
|
|
1502
|
+
start_group: r.readVarInt(),
|
|
1503
|
+
start_object: r.readVarInt(),
|
|
1504
|
+
end_group: r.readVarInt(),
|
|
1505
|
+
end_object: r.readVarInt()
|
|
1506
|
+
};
|
|
1509
1507
|
const parameters = decodeMessageParams(r);
|
|
1510
1508
|
return {
|
|
1511
1509
|
type: "fetch",
|
|
@@ -1513,17 +1511,14 @@ function decodeFetchPayload(r) {
|
|
|
1513
1511
|
subscriber_priority,
|
|
1514
1512
|
group_order,
|
|
1515
1513
|
fetch_type,
|
|
1516
|
-
|
|
1517
|
-
track_name,
|
|
1518
|
-
start_group,
|
|
1519
|
-
start_object,
|
|
1520
|
-
end_group,
|
|
1521
|
-
end_object,
|
|
1514
|
+
standalone,
|
|
1522
1515
|
parameters
|
|
1523
1516
|
};
|
|
1524
1517
|
} else {
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1518
|
+
const joining = {
|
|
1519
|
+
joining_request_id: r.readVarInt(),
|
|
1520
|
+
joining_start: r.readVarInt()
|
|
1521
|
+
};
|
|
1527
1522
|
const parameters = decodeMessageParams(r);
|
|
1528
1523
|
return {
|
|
1529
1524
|
type: "fetch",
|
|
@@ -1531,15 +1526,14 @@ function decodeFetchPayload(r) {
|
|
|
1531
1526
|
subscriber_priority,
|
|
1532
1527
|
group_order,
|
|
1533
1528
|
fetch_type,
|
|
1534
|
-
|
|
1535
|
-
joining_start,
|
|
1529
|
+
joining,
|
|
1536
1530
|
parameters
|
|
1537
1531
|
};
|
|
1538
1532
|
}
|
|
1539
1533
|
}
|
|
1540
1534
|
function decodeFetchOkPayload(r) {
|
|
1541
1535
|
const request_id = r.readVarInt();
|
|
1542
|
-
const group_order =
|
|
1536
|
+
const group_order = r.readUint8();
|
|
1543
1537
|
const end_of_track = r.readVarInt();
|
|
1544
1538
|
const end_location = {
|
|
1545
1539
|
group: r.readVarInt(),
|
|
@@ -1569,8 +1563,8 @@ function decodeTrackStatusPayload(r) {
|
|
|
1569
1563
|
const request_id = r.readVarInt();
|
|
1570
1564
|
const track_namespace = r.readTuple();
|
|
1571
1565
|
const track_name = r.readString();
|
|
1572
|
-
const subscriber_priority =
|
|
1573
|
-
const group_order =
|
|
1566
|
+
const subscriber_priority = r.readUint8();
|
|
1567
|
+
const group_order = r.readUint8();
|
|
1574
1568
|
const forward = r.readVarInt();
|
|
1575
1569
|
const filter_type = r.readVarInt();
|
|
1576
1570
|
let start_group;
|
|
@@ -1599,7 +1593,7 @@ function decodeTrackStatusOkPayload(r) {
|
|
|
1599
1593
|
const request_id = r.readVarInt();
|
|
1600
1594
|
const track_alias = r.readVarInt();
|
|
1601
1595
|
const expires = r.readVarInt();
|
|
1602
|
-
const group_order =
|
|
1596
|
+
const group_order = r.readUint8();
|
|
1603
1597
|
const content_exists = r.readVarInt();
|
|
1604
1598
|
let largest_location;
|
|
1605
1599
|
if (content_exists === 1n) {
|
|
@@ -108,11 +108,14 @@ function encodeDatagram(dg) {
|
|
|
108
108
|
w.writeVarInt(dg.groupId);
|
|
109
109
|
const extensionsPresent = (dgType & 1) !== 0;
|
|
110
110
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
111
|
+
const defaultPriority = (dgType & 8) !== 0;
|
|
111
112
|
const isStatus = (dgType & 32) !== 0;
|
|
112
113
|
if (!objectIdAbsent) {
|
|
113
114
|
w.writeVarInt(dg.objectId);
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
if (!defaultPriority) {
|
|
117
|
+
w.writeUint8(dg.publisherPriority);
|
|
118
|
+
}
|
|
116
119
|
if (extensionsPresent) {
|
|
117
120
|
const extData = dg.extensionData ?? new Uint8Array(0);
|
|
118
121
|
w.writeVarInt(BigInt(extData.length));
|
|
@@ -154,18 +157,18 @@ function decodeSubgroupStream(bytes) {
|
|
|
154
157
|
try {
|
|
155
158
|
const r = new BufferReader(bytes);
|
|
156
159
|
const streamType = Number(r.readVarInt());
|
|
157
|
-
if (!(streamType >= 16 && streamType <=
|
|
160
|
+
if (!(streamType >= 16 && streamType <= 31 || streamType >= 48 && streamType <= 63) || (streamType & 6) === 6) {
|
|
158
161
|
return {
|
|
159
162
|
ok: false,
|
|
160
163
|
error: new DecodeError(
|
|
161
164
|
"CONSTRAINT_VIOLATION",
|
|
162
|
-
`Expected subgroup stream type 0x10-
|
|
165
|
+
`Expected subgroup stream type 0x10-0x1F/0x30-0x3F, got 0x${streamType.toString(16)}`,
|
|
163
166
|
0
|
|
164
167
|
)
|
|
165
168
|
};
|
|
166
169
|
}
|
|
167
170
|
const extensionsPresent = (streamType & 1) !== 0;
|
|
168
|
-
const endOfGroup = (streamType &
|
|
171
|
+
const endOfGroup = (streamType & 8) !== 0;
|
|
169
172
|
const hasSubgroupField = (streamType & 4) !== 0;
|
|
170
173
|
const hasPriority = streamType < 48;
|
|
171
174
|
const trackAlias = r.readVarInt();
|
|
@@ -248,6 +251,7 @@ function decodeDatagram(bytes) {
|
|
|
248
251
|
const extensionsPresent = (dgType & 1) !== 0;
|
|
249
252
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
250
253
|
const endOfGroup = (dgType & 2) !== 0;
|
|
254
|
+
const defaultPriority = (dgType & 8) !== 0;
|
|
251
255
|
const isStatus = (dgType & 32) !== 0;
|
|
252
256
|
const trackAlias = r.readVarInt();
|
|
253
257
|
const groupId = r.readVarInt();
|
|
@@ -255,7 +259,10 @@ function decodeDatagram(bytes) {
|
|
|
255
259
|
if (!objectIdAbsent) {
|
|
256
260
|
objectId = r.readVarInt();
|
|
257
261
|
}
|
|
258
|
-
|
|
262
|
+
let publisherPriority = 128;
|
|
263
|
+
if (!defaultPriority) {
|
|
264
|
+
publisherPriority = r.readUint8();
|
|
265
|
+
}
|
|
259
266
|
let extensionData;
|
|
260
267
|
if (extensionsPresent) {
|
|
261
268
|
const extLen = Number(r.readVarInt());
|
|
@@ -472,7 +479,7 @@ function createSubgroupStreamDecoder() {
|
|
|
472
479
|
try {
|
|
473
480
|
const r = new BufferReader(buffer.subarray(offset));
|
|
474
481
|
const streamType = Number(r.readVarInt());
|
|
475
|
-
if (!(streamType >= 16 && streamType <=
|
|
482
|
+
if (!(streamType >= 16 && streamType <= 31 || streamType >= 48 && streamType <= 63)) {
|
|
476
483
|
controller.error(
|
|
477
484
|
new DecodeError(
|
|
478
485
|
"CONSTRAINT_VIOLATION",
|
|
@@ -667,7 +674,7 @@ function createDataStreamDecoder() {
|
|
|
667
674
|
if (inner === null) {
|
|
668
675
|
if (offset >= buffer.length) return;
|
|
669
676
|
const firstByte = buffer[offset];
|
|
670
|
-
if (firstByte >= 16 && firstByte <=
|
|
677
|
+
if (firstByte >= 16 && firstByte <= 31 || firstByte >= 48 && firstByte <= 63) {
|
|
671
678
|
const decoder = createSubgroupStreamDecoder();
|
|
672
679
|
inner = decoder;
|
|
673
680
|
} else if (firstByte === 5) {
|
|
@@ -690,7 +697,7 @@ function createDataStreamDecoder() {
|
|
|
690
697
|
const view = buffer.subarray(offset);
|
|
691
698
|
const firstByte = view[0];
|
|
692
699
|
let result;
|
|
693
|
-
if (firstByte >= 16 && firstByte <=
|
|
700
|
+
if (firstByte >= 16 && firstByte <= 31 || firstByte >= 48 && firstByte <= 63) {
|
|
694
701
|
result = decodeSubgroupStream(view);
|
|
695
702
|
} else if (firstByte === 5) {
|
|
696
703
|
result = decodeFetchStream(view);
|
|
@@ -46,7 +46,7 @@ function encodeDatagram(dg) {
|
|
|
46
46
|
w.writeVarInt(extData.byteLength);
|
|
47
47
|
if (extData.byteLength > 0) w.writeBytes(extData);
|
|
48
48
|
}
|
|
49
|
-
const isStatus = dg.streamTypeId
|
|
49
|
+
const isStatus = dg.streamTypeId >= 4;
|
|
50
50
|
if (isStatus) {
|
|
51
51
|
w.writeVarInt(_nullishCoalesce(dg.objectStatus, () => ( 0n)));
|
|
52
52
|
} else {
|
|
@@ -162,18 +162,19 @@ function decodeDatagram(bytes) {
|
|
|
162
162
|
try {
|
|
163
163
|
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
164
164
|
const streamTypeId = Number(r.readVarInt());
|
|
165
|
-
if (streamTypeId < 0 || streamTypeId >
|
|
165
|
+
if (streamTypeId < 0 || streamTypeId > 5) {
|
|
166
166
|
return {
|
|
167
167
|
ok: false,
|
|
168
168
|
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
169
169
|
"CONSTRAINT_VIOLATION",
|
|
170
|
-
`Expected datagram type 0x00-
|
|
170
|
+
`Expected datagram type 0x00-0x05, got 0x${streamTypeId.toString(16)}`,
|
|
171
171
|
0
|
|
172
172
|
)
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
const extensionsPresent = (streamTypeId & 1) !== 0;
|
|
176
|
-
const
|
|
176
|
+
const endOfGroup = (streamTypeId & 2) !== 0 && streamTypeId < 4;
|
|
177
|
+
const isStatus = streamTypeId >= 4;
|
|
177
178
|
const trackAlias = r.readVarInt();
|
|
178
179
|
const groupId = r.readVarInt();
|
|
179
180
|
const objectId = r.readVarInt();
|
|
@@ -202,6 +203,7 @@ function decodeDatagram(bytes) {
|
|
|
202
203
|
payloadLength: payload.byteLength,
|
|
203
204
|
payload
|
|
204
205
|
};
|
|
206
|
+
if (endOfGroup) result.endOfGroup = true;
|
|
205
207
|
if (extensionHeadersLength !== void 0)
|
|
206
208
|
result.extensionHeadersLength = extensionHeadersLength;
|
|
207
209
|
if (extensionData !== void 0)
|
|
@@ -46,7 +46,7 @@ function encodeDatagram(dg) {
|
|
|
46
46
|
w.writeVarInt(extData.byteLength);
|
|
47
47
|
if (extData.byteLength > 0) w.writeBytes(extData);
|
|
48
48
|
}
|
|
49
|
-
const isStatus = dg.streamTypeId
|
|
49
|
+
const isStatus = dg.streamTypeId >= 4;
|
|
50
50
|
if (isStatus) {
|
|
51
51
|
w.writeVarInt(dg.objectStatus ?? 0n);
|
|
52
52
|
} else {
|
|
@@ -162,18 +162,19 @@ function decodeDatagram(bytes) {
|
|
|
162
162
|
try {
|
|
163
163
|
const r = new BufferReader(bytes);
|
|
164
164
|
const streamTypeId = Number(r.readVarInt());
|
|
165
|
-
if (streamTypeId < 0 || streamTypeId >
|
|
165
|
+
if (streamTypeId < 0 || streamTypeId > 5) {
|
|
166
166
|
return {
|
|
167
167
|
ok: false,
|
|
168
168
|
error: new DecodeError(
|
|
169
169
|
"CONSTRAINT_VIOLATION",
|
|
170
|
-
`Expected datagram type 0x00-
|
|
170
|
+
`Expected datagram type 0x00-0x05, got 0x${streamTypeId.toString(16)}`,
|
|
171
171
|
0
|
|
172
172
|
)
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
const extensionsPresent = (streamTypeId & 1) !== 0;
|
|
176
|
-
const
|
|
176
|
+
const endOfGroup = (streamTypeId & 2) !== 0 && streamTypeId < 4;
|
|
177
|
+
const isStatus = streamTypeId >= 4;
|
|
177
178
|
const trackAlias = r.readVarInt();
|
|
178
179
|
const groupId = r.readVarInt();
|
|
179
180
|
const objectId = r.readVarInt();
|
|
@@ -202,6 +203,7 @@ function decodeDatagram(bytes) {
|
|
|
202
203
|
payloadLength: payload.byteLength,
|
|
203
204
|
payload
|
|
204
205
|
};
|
|
206
|
+
if (endOfGroup) result.endOfGroup = true;
|
|
205
207
|
if (extensionHeadersLength !== void 0)
|
|
206
208
|
result.extensionHeadersLength = extensionHeadersLength;
|
|
207
209
|
if (extensionData !== void 0)
|
|
@@ -108,11 +108,14 @@ function encodeDatagram(dg) {
|
|
|
108
108
|
w.writeVarInt(dg.groupId);
|
|
109
109
|
const extensionsPresent = (dgType & 1) !== 0;
|
|
110
110
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
111
|
+
const defaultPriority = (dgType & 8) !== 0;
|
|
111
112
|
const isStatus = (dgType & 32) !== 0;
|
|
112
113
|
if (!objectIdAbsent) {
|
|
113
114
|
w.writeVarInt(dg.objectId);
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
if (!defaultPriority) {
|
|
117
|
+
w.writeUint8(dg.publisherPriority);
|
|
118
|
+
}
|
|
116
119
|
if (extensionsPresent) {
|
|
117
120
|
const extData = _nullishCoalesce(dg.extensionData, () => ( new Uint8Array(0)));
|
|
118
121
|
w.writeVarInt(BigInt(extData.length));
|
|
@@ -154,18 +157,18 @@ function decodeSubgroupStream(bytes) {
|
|
|
154
157
|
try {
|
|
155
158
|
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
|
|
156
159
|
const streamType = Number(r.readVarInt());
|
|
157
|
-
if (!(streamType >= 16 && streamType <=
|
|
160
|
+
if (!(streamType >= 16 && streamType <= 31 || streamType >= 48 && streamType <= 63) || (streamType & 6) === 6) {
|
|
158
161
|
return {
|
|
159
162
|
ok: false,
|
|
160
163
|
error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
161
164
|
"CONSTRAINT_VIOLATION",
|
|
162
|
-
`Expected subgroup stream type 0x10-
|
|
165
|
+
`Expected subgroup stream type 0x10-0x1F/0x30-0x3F, got 0x${streamType.toString(16)}`,
|
|
163
166
|
0
|
|
164
167
|
)
|
|
165
168
|
};
|
|
166
169
|
}
|
|
167
170
|
const extensionsPresent = (streamType & 1) !== 0;
|
|
168
|
-
const endOfGroup = (streamType &
|
|
171
|
+
const endOfGroup = (streamType & 8) !== 0;
|
|
169
172
|
const hasSubgroupField = (streamType & 4) !== 0;
|
|
170
173
|
const hasPriority = streamType < 48;
|
|
171
174
|
const trackAlias = r.readVarInt();
|
|
@@ -248,6 +251,7 @@ function decodeDatagram(bytes) {
|
|
|
248
251
|
const extensionsPresent = (dgType & 1) !== 0;
|
|
249
252
|
const objectIdAbsent = (dgType & 4) !== 0;
|
|
250
253
|
const endOfGroup = (dgType & 2) !== 0;
|
|
254
|
+
const defaultPriority = (dgType & 8) !== 0;
|
|
251
255
|
const isStatus = (dgType & 32) !== 0;
|
|
252
256
|
const trackAlias = r.readVarInt();
|
|
253
257
|
const groupId = r.readVarInt();
|
|
@@ -255,7 +259,10 @@ function decodeDatagram(bytes) {
|
|
|
255
259
|
if (!objectIdAbsent) {
|
|
256
260
|
objectId = r.readVarInt();
|
|
257
261
|
}
|
|
258
|
-
|
|
262
|
+
let publisherPriority = 128;
|
|
263
|
+
if (!defaultPriority) {
|
|
264
|
+
publisherPriority = r.readUint8();
|
|
265
|
+
}
|
|
259
266
|
let extensionData;
|
|
260
267
|
if (extensionsPresent) {
|
|
261
268
|
const extLen = Number(r.readVarInt());
|
|
@@ -472,7 +479,7 @@ function createSubgroupStreamDecoder() {
|
|
|
472
479
|
try {
|
|
473
480
|
const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(buffer.subarray(offset));
|
|
474
481
|
const streamType = Number(r.readVarInt());
|
|
475
|
-
if (!(streamType >= 16 && streamType <=
|
|
482
|
+
if (!(streamType >= 16 && streamType <= 31 || streamType >= 48 && streamType <= 63)) {
|
|
476
483
|
controller.error(
|
|
477
484
|
new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
478
485
|
"CONSTRAINT_VIOLATION",
|
|
@@ -667,7 +674,7 @@ function createDataStreamDecoder() {
|
|
|
667
674
|
if (inner === null) {
|
|
668
675
|
if (offset >= buffer.length) return;
|
|
669
676
|
const firstByte = buffer[offset];
|
|
670
|
-
if (firstByte >= 16 && firstByte <=
|
|
677
|
+
if (firstByte >= 16 && firstByte <= 31 || firstByte >= 48 && firstByte <= 63) {
|
|
671
678
|
const decoder = createSubgroupStreamDecoder();
|
|
672
679
|
inner = decoder;
|
|
673
680
|
} else if (firstByte === 5) {
|
|
@@ -690,7 +697,7 @@ function createDataStreamDecoder() {
|
|
|
690
697
|
const view = buffer.subarray(offset);
|
|
691
698
|
const firstByte = view[0];
|
|
692
699
|
let result;
|
|
693
|
-
if (firstByte >= 16 && firstByte <=
|
|
700
|
+
if (firstByte >= 16 && firstByte <= 31 || firstByte >= 48 && firstByte <= 63) {
|
|
694
701
|
result = decodeSubgroupStream(view);
|
|
695
702
|
} else if (firstByte === 5) {
|
|
696
703
|
result = decodeFetchStream(view);
|