@moqtap/codec 0.6.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.
Files changed (66) hide show
  1. package/README.md +4 -2
  2. package/dist/{chunk-CXFAQKL3.js → chunk-23KRITJ6.js} +1 -1
  3. package/dist/{chunk-JL3NEW3O.cjs → chunk-4XLYCT5Q.cjs} +90 -1
  4. package/dist/{chunk-DLSGOZ6P.js → chunk-5XZKO2U5.js} +34 -34
  5. package/dist/{chunk-62LYLROG.js → chunk-APTV6F72.js} +35 -35
  6. package/dist/{chunk-JB5VDJ2V.cjs → chunk-B56AG5HU.cjs} +37 -37
  7. package/dist/{chunk-4HBKHNU2.cjs → chunk-CZNW3R5E.cjs} +37 -37
  8. package/dist/{chunk-Q5D6OW6Q.js → chunk-DORX55MO.js} +1 -1
  9. package/dist/{chunk-OGZTQA24.cjs → chunk-EQAYMCXO.cjs} +64 -64
  10. package/dist/{chunk-HYI6LFMD.js → chunk-HEO2JG6C.js} +1 -1
  11. package/dist/{chunk-UP4XPH4J.js → chunk-I55J3KXD.js} +31 -31
  12. package/dist/{chunk-HZHSO7EW.cjs → chunk-IDV2JYJ6.cjs} +39 -39
  13. package/dist/{chunk-BAG6YWCP.cjs → chunk-IEJULBKB.cjs} +63 -63
  14. package/dist/{chunk-Y6KCSM3V.js → chunk-IJAF6PAY.js} +1 -1
  15. package/dist/{chunk-WMJVSBBE.cjs → chunk-J3ASFPCX.cjs} +57 -57
  16. package/dist/{chunk-COWGGUL4.js → chunk-JKMYAUGY.js} +1 -1
  17. package/dist/{chunk-SIYYMFCC.cjs → chunk-KCH4BQXK.cjs} +37 -37
  18. package/dist/{chunk-VOU7PNHI.js → chunk-KLPWJU6W.js} +89 -0
  19. package/dist/{chunk-NZ7GYEMT.js → chunk-KNLPX3YA.js} +1 -1
  20. package/dist/{chunk-A33U4WVS.cjs → chunk-KTVN4P6J.cjs} +67 -67
  21. package/dist/{chunk-7KBAWOBA.js → chunk-KYVTM5VI.js} +1 -1
  22. package/dist/{chunk-RZ3UML47.js → chunk-MD2OA7SE.js} +1 -1
  23. package/dist/{chunk-MSG2FXJ2.cjs → chunk-MH7537FB.cjs} +68 -68
  24. package/dist/{chunk-SHMA4PBY.js → chunk-N2V7Z37J.js} +1 -1
  25. package/dist/{chunk-HO44OANK.cjs → chunk-QGIHC6BA.cjs} +36 -36
  26. package/dist/{chunk-PKEOQSSZ.cjs → chunk-RIIA4ALQ.cjs} +37 -37
  27. package/dist/{chunk-XZE5R57R.cjs → chunk-VZHL2U2N.cjs} +37 -37
  28. package/dist/{chunk-RW4UG7CN.js → chunk-XHAP2YST.js} +1 -1
  29. package/dist/{chunk-JTRU76JN.cjs → chunk-Y4FRXYX6.cjs} +59 -59
  30. package/dist/draft07.cjs +4 -4
  31. package/dist/draft07.js +2 -2
  32. package/dist/draft08.cjs +3 -3
  33. package/dist/draft08.js +2 -2
  34. package/dist/draft09.cjs +3 -3
  35. package/dist/draft09.js +2 -2
  36. package/dist/draft10.cjs +3 -3
  37. package/dist/draft10.js +2 -2
  38. package/dist/draft11.cjs +3 -3
  39. package/dist/draft11.js +2 -2
  40. package/dist/draft12.cjs +3 -3
  41. package/dist/draft12.js +2 -2
  42. package/dist/draft13.cjs +3 -3
  43. package/dist/draft13.js +2 -2
  44. package/dist/draft14.cjs +3 -3
  45. package/dist/draft14.js +2 -2
  46. package/dist/draft15.cjs +3 -3
  47. package/dist/draft15.js +2 -2
  48. package/dist/draft16.cjs +3 -3
  49. package/dist/draft16.js +2 -2
  50. package/dist/draft17.cjs +3 -3
  51. package/dist/draft17.js +2 -2
  52. package/dist/draft18.cjs +3 -3
  53. package/dist/draft18.js +2 -2
  54. package/dist/draft19.cjs +3 -3
  55. package/dist/draft19.js +2 -2
  56. package/dist/index.cjs +28 -28
  57. package/dist/index.js +14 -14
  58. package/package.json +2 -2
  59. package/src/core/buffer-reader.ts +74 -2
  60. package/src/core/buffer-writer.ts +56 -4
  61. package/src/drafts/draft17/codec.ts +2 -2
  62. package/src/drafts/draft17/data-streams.ts +2 -2
  63. package/src/drafts/draft18/codec.ts +2 -2
  64. package/src/drafts/draft18/data-streams.ts +2 -2
  65. package/src/drafts/draft19/codec.ts +2 -2
  66. package/src/drafts/draft19/data-streams.ts +2 -2
@@ -1,10 +1,10 @@
1
1
  import {
2
- BufferReader,
3
- BufferWriter,
4
2
  DecodeError,
3
+ Draft17BufferReader,
4
+ Draft17BufferWriter,
5
5
  bytesToHex,
6
6
  hexToBytes
7
- } from "./chunk-VOU7PNHI.js";
7
+ } from "./chunk-KLPWJU6W.js";
8
8
 
9
9
  // src/drafts/draft17/messages.ts
10
10
  var MSG_REQUEST_UPDATE = 0x02n;
@@ -102,7 +102,7 @@ function encodeObjectProperties(props, w) {
102
102
  }
103
103
  }
104
104
  function encodeSubgroupStream(stream) {
105
- const w = new BufferWriter();
105
+ const w = new Draft17BufferWriter();
106
106
  const streamType = stream.headerType;
107
107
  w.writeVarInt(BigInt(streamType));
108
108
  const propertiesPresent = (streamType & 1) !== 0;
@@ -122,7 +122,7 @@ function encodeSubgroupStream(stream) {
122
122
  w.writeVarInt(delta);
123
123
  if (propertiesPresent) {
124
124
  if (obj.objectProperties && Object.keys(obj.objectProperties).length > 0) {
125
- const tmpW = new BufferWriter(32);
125
+ const tmpW = new Draft17BufferWriter(32);
126
126
  encodeObjectProperties(obj.objectProperties, tmpW);
127
127
  const raw = tmpW.finish();
128
128
  w.writeVarInt(BigInt(raw.byteLength));
@@ -142,7 +142,7 @@ function encodeSubgroupStream(stream) {
142
142
  return w.finish();
143
143
  }
144
144
  function encodeDatagram(dg) {
145
- const w = new BufferWriter();
145
+ const w = new Draft17BufferWriter();
146
146
  const dgType = dg.datagramType;
147
147
  w.writeVarInt(BigInt(dgType));
148
148
  w.writeVarInt(dg.trackAlias);
@@ -159,7 +159,7 @@ function encodeDatagram(dg) {
159
159
  }
160
160
  if (propertiesPresent) {
161
161
  if (dg.objectProperties && Object.keys(dg.objectProperties).length > 0) {
162
- const tmpW = new BufferWriter(32);
162
+ const tmpW = new Draft17BufferWriter(32);
163
163
  encodeObjectProperties(dg.objectProperties, tmpW);
164
164
  const raw = tmpW.finish();
165
165
  w.writeVarInt(BigInt(raw.byteLength));
@@ -176,7 +176,7 @@ function encodeDatagram(dg) {
176
176
  return w.finish();
177
177
  }
178
178
  function encodeFetchStream(stream) {
179
- const w = new BufferWriter();
179
+ const w = new Draft17BufferWriter();
180
180
  w.writeVarInt(FETCH_STREAM_TYPE);
181
181
  w.writeVarInt(stream.requestId);
182
182
  for (const obj of stream.objects) {
@@ -192,7 +192,7 @@ function encodeFetchStream(stream) {
192
192
  if (flags & 16) w.writeUint8(obj.publisherPriority);
193
193
  if (flags & 32) {
194
194
  if (obj.objectProperties && Object.keys(obj.objectProperties).length > 0) {
195
- const tmpW = new BufferWriter(32);
195
+ const tmpW = new Draft17BufferWriter(32);
196
196
  encodeObjectProperties(obj.objectProperties, tmpW);
197
197
  const raw = tmpW.finish();
198
198
  w.writeVarInt(BigInt(raw.byteLength));
@@ -213,7 +213,7 @@ function encodeFetchStream(stream) {
213
213
  if (flags & 16) w.writeUint8(obj.publisherPriority);
214
214
  if (flags & 32) {
215
215
  if (obj.objectProperties && Object.keys(obj.objectProperties).length > 0) {
216
- const tmpW = new BufferWriter(32);
216
+ const tmpW = new Draft17BufferWriter(32);
217
217
  encodeObjectProperties(obj.objectProperties, tmpW);
218
218
  const raw = tmpW.finish();
219
219
  w.writeVarInt(BigInt(raw.byteLength));
@@ -232,7 +232,7 @@ function encodeFetchStream(stream) {
232
232
  }
233
233
  function decodeSubgroupStream(bytes) {
234
234
  try {
235
- const r = new BufferReader(bytes);
235
+ const r = new Draft17BufferReader(bytes);
236
236
  const streamType = Number(r.readVarInt());
237
237
  if (!(streamType >= 16 && streamType <= 29 || streamType >= 48 && streamType <= 61) || (streamType & 6) === 6) {
238
238
  return {
@@ -332,7 +332,7 @@ function decodeSubgroupStream(bytes) {
332
332
  }
333
333
  function decodeDatagram(bytes) {
334
334
  try {
335
- const r = new BufferReader(bytes);
335
+ const r = new Draft17BufferReader(bytes);
336
336
  const dgType = Number(r.readVarInt());
337
337
  const objectIdAbsent = (dgType & 4) !== 0;
338
338
  const endOfGroup = (dgType & 2) !== 0;
@@ -388,7 +388,7 @@ function decodeDatagram(bytes) {
388
388
  }
389
389
  function decodeFetchStream(bytes) {
390
390
  try {
391
- const r = new BufferReader(bytes);
391
+ const r = new Draft17BufferReader(bytes);
392
392
  const streamType = r.readVarInt();
393
393
  if (streamType !== FETCH_STREAM_TYPE) {
394
394
  return {
@@ -635,7 +635,7 @@ function createSubgroupStreamDecoder() {
635
635
  buffer = newBuffer;
636
636
  if (!headerEmitted) {
637
637
  try {
638
- const r = new BufferReader(buffer.subarray(offset));
638
+ const r = new Draft17BufferReader(buffer.subarray(offset));
639
639
  const streamType = Number(r.readVarInt());
640
640
  if (!(streamType >= 16 && streamType <= 29 || streamType >= 48 && streamType <= 61)) {
641
641
  controller.error(
@@ -680,7 +680,7 @@ function createSubgroupStreamDecoder() {
680
680
  }
681
681
  while (offset < buffer.length) {
682
682
  try {
683
- const r = new BufferReader(buffer.subarray(offset));
683
+ const r = new Draft17BufferReader(buffer.subarray(offset));
684
684
  const delta = r.readVarInt();
685
685
  let objectId;
686
686
  if (firstObject) {
@@ -740,7 +740,7 @@ function createFetchStreamDecoder() {
740
740
  buffer = newBuffer;
741
741
  if (!headerEmitted) {
742
742
  try {
743
- const r = new BufferReader(buffer.subarray(offset));
743
+ const r = new Draft17BufferReader(buffer.subarray(offset));
744
744
  const streamType = r.readVarInt();
745
745
  if (streamType !== FETCH_STREAM_TYPE) {
746
746
  controller.error(
@@ -766,7 +766,7 @@ function createFetchStreamDecoder() {
766
766
  }
767
767
  while (offset < buffer.length) {
768
768
  try {
769
- const r = new BufferReader(buffer.subarray(offset));
769
+ const r = new Draft17BufferReader(buffer.subarray(offset));
770
770
  const flags = Number(r.readVarInt());
771
771
  const objectIdPresent = (flags & 4) !== 0;
772
772
  const groupIdPresent = (flags & 8) !== 0;
@@ -914,7 +914,7 @@ function encodeSetupOptions(opts, writer) {
914
914
  entries.push({
915
915
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
916
916
  encode: (w) => {
917
- const tmpW = new BufferWriter(64);
917
+ const tmpW = new Draft17BufferWriter(64);
918
918
  encodeAuthorizationToken(opts.authorization_token, tmpW);
919
919
  const raw = tmpW.finish();
920
920
  w.writeVarInt(BigInt(raw.byteLength));
@@ -956,7 +956,7 @@ function encodeSetupOptions(opts, writer) {
956
956
  encode: (w) => {
957
957
  if (id % 2n === 0n) {
958
958
  const raw = hexToBytes(u.raw_hex);
959
- const tmpReader = new BufferReader(raw);
959
+ const tmpReader = new Draft17BufferReader(raw);
960
960
  w.writeVarInt(tmpReader.readVarInt());
961
961
  } else {
962
962
  const raw = hexToBytes(u.raw_hex);
@@ -988,7 +988,7 @@ function decodeSetupOptions(reader, payloadEnd) {
988
988
  if (optType === SETUP_OPT_MAX_AUTH_TOKEN_CACHE_SIZE) {
989
989
  result.max_auth_token_cache_size = value;
990
990
  } else {
991
- const tmpWriter = new BufferWriter(16);
991
+ const tmpWriter = new Draft17BufferWriter(16);
992
992
  tmpWriter.writeVarInt(value);
993
993
  const raw = tmpWriter.finish();
994
994
  unknown.push({
@@ -1003,7 +1003,7 @@ function decodeSetupOptions(reader, payloadEnd) {
1003
1003
  if (optType === SETUP_OPT_PATH) {
1004
1004
  result.path = textDecoder.decode(bytes);
1005
1005
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
1006
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes));
1006
+ result.authorization_token = decodeAuthorizationToken(new Draft17BufferReader(bytes));
1007
1007
  } else if (optType === SETUP_OPT_AUTHORITY) {
1008
1008
  result.authority = textDecoder.decode(bytes);
1009
1009
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -1072,7 +1072,7 @@ function encodeParams(params, writer) {
1072
1072
  entries.push({
1073
1073
  type: PARAM_AUTHORIZATION_TOKEN,
1074
1074
  encode: (w) => {
1075
- const tmpW = new BufferWriter(64);
1075
+ const tmpW = new Draft17BufferWriter(64);
1076
1076
  encodeAuthorizationToken(params.authorization_token, tmpW);
1077
1077
  const raw = tmpW.finish();
1078
1078
  w.writeVarInt(BigInt(raw.byteLength));
@@ -1118,7 +1118,7 @@ function encodeParams(params, writer) {
1118
1118
  type: PARAM_SUBSCRIPTION_FILTER,
1119
1119
  encode: (w) => {
1120
1120
  const f = params.subscription_filter;
1121
- const tmpW = new BufferWriter(32);
1121
+ const tmpW = new Draft17BufferWriter(32);
1122
1122
  tmpW.writeVarInt(f.filter_type);
1123
1123
  if (f.filter_type === 3n || f.filter_type === 4n) {
1124
1124
  tmpW.writeVarInt(f.start_group);
@@ -1180,7 +1180,7 @@ function decodeParams(reader) {
1180
1180
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
1181
1181
  const length = Number(reader.readVarInt());
1182
1182
  const bytes = reader.readBytes(length);
1183
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes));
1183
+ result.authorization_token = decodeAuthorizationToken(new Draft17BufferReader(bytes));
1184
1184
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
1185
1185
  result.rendezvous_timeout = reader.readVarInt();
1186
1186
  } else if (paramType === PARAM_EXPIRES) {
@@ -1215,7 +1215,7 @@ function decodeParams(reader) {
1215
1215
  } else {
1216
1216
  if (paramType % 2n === 0n) {
1217
1217
  const value = reader.readVarInt();
1218
- const tmpWriter = new BufferWriter(16);
1218
+ const tmpWriter = new Draft17BufferWriter(16);
1219
1219
  tmpWriter.writeVarInt(value);
1220
1220
  const raw = tmpWriter.finish();
1221
1221
  unknown.push({
@@ -1293,7 +1293,7 @@ function encodeTrackProperties(props, writer) {
1293
1293
  encode: (w) => {
1294
1294
  if (id % 2n === 0n) {
1295
1295
  const raw = hexToBytes(u.raw_hex);
1296
- const tmpReader = new BufferReader(raw);
1296
+ const tmpReader = new Draft17BufferReader(raw);
1297
1297
  w.writeVarInt(tmpReader.readVarInt());
1298
1298
  } else {
1299
1299
  const raw = hexToBytes(u.raw_hex);
@@ -1333,7 +1333,7 @@ function decodeTrackProperties(reader, payloadEnd) {
1333
1333
  } else if (propType === TPROP_DYNAMIC_GROUPS) {
1334
1334
  result.dynamic_groups = value;
1335
1335
  } else {
1336
- const tmpWriter = new BufferWriter(16);
1336
+ const tmpWriter = new Draft17BufferWriter(16);
1337
1337
  tmpWriter.writeVarInt(value);
1338
1338
  const raw = tmpWriter.finish();
1339
1339
  unknown.push({
@@ -1660,13 +1660,13 @@ function encodeMessage(message) {
1660
1660
  if (typeId === void 0) {
1661
1661
  throw new Error(`Unknown message type: ${message.type}`);
1662
1662
  }
1663
- const payloadWriter = new BufferWriter();
1663
+ const payloadWriter = new Draft17BufferWriter();
1664
1664
  encodePayload(message, payloadWriter);
1665
1665
  const payload = payloadWriter.finishView();
1666
1666
  if (payload.byteLength > 65535) {
1667
1667
  throw new Error(`Payload too large for 16-bit length: ${payload.byteLength}`);
1668
1668
  }
1669
- const writer = new BufferWriter(payload.byteLength + 16);
1669
+ const writer = new Draft17BufferWriter(payload.byteLength + 16);
1670
1670
  writer.writeVarInt(typeId);
1671
1671
  writer.writeUint8(payload.byteLength >> 8 & 255);
1672
1672
  writer.writeUint8(payload.byteLength & 255);
@@ -1719,7 +1719,7 @@ function encodePayload(msg, w) {
1719
1719
  }
1720
1720
  function decodeMessage(bytes) {
1721
1721
  try {
1722
- const reader = new BufferReader(bytes);
1722
+ const reader = new Draft17BufferReader(bytes);
1723
1723
  const typeId = reader.readVarInt();
1724
1724
  const lenHi = reader.readUint8();
1725
1725
  const lenLo = reader.readUint8();
@@ -1727,7 +1727,7 @@ function decodeMessage(bytes) {
1727
1727
  const payloadStart = reader.offset;
1728
1728
  const _payloadEnd = payloadStart + payloadLength;
1729
1729
  const payloadBytes = reader.readBytes(payloadLength);
1730
- const payloadReader = new BufferReader(payloadBytes);
1730
+ const payloadReader = new Draft17BufferReader(payloadBytes);
1731
1731
  let message;
1732
1732
  if (typeId === MSG_SETUP) {
1733
1733
  message = decodeSetupPayload(payloadReader, payloadLength);
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkJL3NEW3Ocjs = require('./chunk-JL3NEW3O.cjs');
7
+ var _chunk4XLYCT5Qcjs = require('./chunk-4XLYCT5Q.cjs');
8
8
 
9
9
  // src/drafts/draft07/messages.ts
10
10
  var MSG_SUBSCRIBE_UPDATE = 0x02n;
@@ -108,11 +108,11 @@ function encodeVarInt(value) {
108
108
  }
109
109
  function decodeVarInt(bytes, offset = 0) {
110
110
  try {
111
- const reader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes, offset);
111
+ const reader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes, offset);
112
112
  const value = reader.readVarInt();
113
113
  return { ok: true, value, bytesRead: reader.offset - offset };
114
114
  } catch (e) {
115
- if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) {
115
+ if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) {
116
116
  return { ok: false, error: e };
117
117
  }
118
118
  throw e;
@@ -124,7 +124,7 @@ var SUBGROUP_STREAM_TYPE = 0x04n;
124
124
  var FETCH_STREAM_TYPE = 0x05n;
125
125
  var DATAGRAM_TYPE = 0x01n;
126
126
  function encodeSubgroupStream(stream) {
127
- const w = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
127
+ const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
128
128
  w.writeVarInt(SUBGROUP_STREAM_TYPE);
129
129
  w.writeVarInt(stream.trackAlias);
130
130
  w.writeVarInt(stream.groupId);
@@ -142,7 +142,7 @@ function encodeSubgroupStream(stream) {
142
142
  return w.finish();
143
143
  }
144
144
  function encodeDatagram(dg) {
145
- const w = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
145
+ const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
146
146
  w.writeVarInt(DATAGRAM_TYPE);
147
147
  w.writeVarInt(dg.trackAlias);
148
148
  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, _chunkJL3NEW3Ocjs.BufferWriter)();
160
+ const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
161
161
  w.writeVarInt(FETCH_STREAM_TYPE);
162
162
  w.writeVarInt(stream.subscribeId);
163
163
  for (const obj of stream.objects) {
@@ -176,12 +176,12 @@ function encodeFetchStream(stream) {
176
176
  }
177
177
  function decodeSubgroupStream(bytes) {
178
178
  try {
179
- const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes);
179
+ const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
180
180
  const streamType = Number(r.readVarInt());
181
181
  if (streamType !== 4) {
182
182
  return {
183
183
  ok: false,
184
- error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
184
+ error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
185
185
  "CONSTRAINT_VIOLATION",
186
186
  `Expected subgroup type 0x04, got 0x${streamType.toString(16)}`,
187
187
  0
@@ -233,18 +233,18 @@ function decodeSubgroupStream(bytes) {
233
233
  bytesRead: r.offset
234
234
  };
235
235
  } catch (e) {
236
- if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) return { ok: false, error: e };
236
+ if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
237
237
  throw e;
238
238
  }
239
239
  }
240
240
  function decodeDatagram(bytes) {
241
241
  try {
242
- const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes);
242
+ const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
243
243
  const streamType = Number(r.readVarInt());
244
244
  if (streamType !== 1) {
245
245
  return {
246
246
  ok: false,
247
- error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
247
+ error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
248
248
  "CONSTRAINT_VIOLATION",
249
249
  `Expected datagram type 0x01, got 0x${streamType.toString(16)}`,
250
250
  0
@@ -277,18 +277,18 @@ function decodeDatagram(bytes) {
277
277
  if (status !== void 0) result.status = status;
278
278
  return { ok: true, value: result, bytesRead: r.offset };
279
279
  } catch (e) {
280
- if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) return { ok: false, error: e };
280
+ if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
281
281
  throw e;
282
282
  }
283
283
  }
284
284
  function decodeFetchStream(bytes) {
285
285
  try {
286
- const r = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes);
286
+ const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
287
287
  const streamType = Number(r.readVarInt());
288
288
  if (streamType !== 5) {
289
289
  return {
290
290
  ok: false,
291
- error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
291
+ error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
292
292
  "CONSTRAINT_VIOLATION",
293
293
  `Expected fetch type 0x05, got 0x${streamType.toString(16)}`,
294
294
  0
@@ -335,7 +335,7 @@ function decodeFetchStream(bytes) {
335
335
  bytesRead: r.offset
336
336
  };
337
337
  } catch (e) {
338
- if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) return { ok: false, error: e };
338
+ if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
339
339
  throw e;
340
340
  }
341
341
  }
@@ -353,7 +353,7 @@ function encodeSetupParams(params, w) {
353
353
  w.writeVarInt(count);
354
354
  if (params.role !== void 0) {
355
355
  w.writeVarInt(SETUP_PARAM_ROLE);
356
- const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
356
+ const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
357
357
  tmpW.writeVarInt(params.role);
358
358
  const raw = tmpW.finish();
359
359
  w.writeVarInt(raw.byteLength);
@@ -367,7 +367,7 @@ function encodeSetupParams(params, w) {
367
367
  }
368
368
  if (params.max_subscribe_id !== void 0) {
369
369
  w.writeVarInt(SETUP_PARAM_MAX_SUBSCRIBE_ID);
370
- const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
370
+ const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
371
371
  tmpW.writeVarInt(params.max_subscribe_id);
372
372
  const raw = tmpW.finish();
373
373
  w.writeVarInt(raw.byteLength);
@@ -376,7 +376,7 @@ function encodeSetupParams(params, w) {
376
376
  if (params.unknown) {
377
377
  for (const u of params.unknown) {
378
378
  w.writeVarInt(BigInt(u.id));
379
- const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
379
+ const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
380
380
  w.writeVarInt(raw.byteLength);
381
381
  w.writeBytes(raw);
382
382
  }
@@ -391,21 +391,21 @@ function decodeSetupParams(r) {
391
391
  const length = Number(r.readVarInt());
392
392
  if (paramType === SETUP_PARAM_ROLE) {
393
393
  const blob = r.readBytes(length);
394
- const tmpReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(blob);
394
+ const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(blob);
395
395
  result.role = tmpReader.readVarInt();
396
396
  } else if (paramType === SETUP_PARAM_PATH) {
397
397
  const bytes = r.readBytes(length);
398
398
  result.path = textDecoder.decode(bytes);
399
399
  } else if (paramType === SETUP_PARAM_MAX_SUBSCRIBE_ID) {
400
400
  const blob = r.readBytes(length);
401
- const tmpReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(blob);
401
+ const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(blob);
402
402
  result.max_subscribe_id = tmpReader.readVarInt();
403
403
  } else {
404
404
  const bytes = r.readBytes(length);
405
405
  unknown.push({
406
406
  id: `0x${paramType.toString(16)}`,
407
407
  length,
408
- raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, bytes)
408
+ raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
409
409
  });
410
410
  }
411
411
  }
@@ -426,7 +426,7 @@ function encodeParams(params, w) {
426
426
  }
427
427
  if (params.delivery_timeout !== void 0) {
428
428
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
429
- const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
429
+ const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
430
430
  tmpW.writeVarInt(params.delivery_timeout);
431
431
  const raw = tmpW.finish();
432
432
  w.writeVarInt(raw.byteLength);
@@ -434,7 +434,7 @@ function encodeParams(params, w) {
434
434
  }
435
435
  if (params.max_cache_duration !== void 0) {
436
436
  w.writeVarInt(PARAM_MAX_CACHE_DURATION);
437
- const tmpW = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(16);
437
+ const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
438
438
  tmpW.writeVarInt(params.max_cache_duration);
439
439
  const raw = tmpW.finish();
440
440
  w.writeVarInt(raw.byteLength);
@@ -443,7 +443,7 @@ function encodeParams(params, w) {
443
443
  if (params.unknown) {
444
444
  for (const u of params.unknown) {
445
445
  w.writeVarInt(BigInt(u.id));
446
- const raw = _chunkJL3NEW3Ocjs.hexToBytes.call(void 0, u.raw_hex);
446
+ const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
447
447
  w.writeVarInt(raw.byteLength);
448
448
  w.writeBytes(raw);
449
449
  }
@@ -461,18 +461,18 @@ function decodeParams(r) {
461
461
  result.authorization_info = textDecoder.decode(bytes);
462
462
  } else if (paramType === PARAM_DELIVERY_TIMEOUT) {
463
463
  const blob = r.readBytes(length);
464
- const tmpReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(blob);
464
+ const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(blob);
465
465
  result.delivery_timeout = tmpReader.readVarInt();
466
466
  } else if (paramType === PARAM_MAX_CACHE_DURATION) {
467
467
  const blob = r.readBytes(length);
468
- const tmpReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(blob);
468
+ const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(blob);
469
469
  result.max_cache_duration = tmpReader.readVarInt();
470
470
  } else {
471
471
  const bytes = r.readBytes(length);
472
472
  unknown.push({
473
473
  id: `0x${paramType.toString(16)}`,
474
474
  length,
475
- raw_hex: _chunkJL3NEW3Ocjs.bytesToHex.call(void 0, bytes)
475
+ raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
476
476
  });
477
477
  }
478
478
  }
@@ -703,7 +703,7 @@ function encodePayload(msg, w) {
703
703
  function decodeClientSetupPayload(reader) {
704
704
  const numVersions = reader.readVarInt();
705
705
  if (numVersions === 0n) {
706
- throw new (0, _chunkJL3NEW3Ocjs.DecodeError)(
706
+ throw new (0, _chunk4XLYCT5Qcjs.DecodeError)(
707
707
  "CONSTRAINT_VIOLATION",
708
708
  "supported_versions must not be empty",
709
709
  reader.offset
@@ -730,7 +730,7 @@ function decodeSubscribePayload(reader) {
730
730
  const group_order = reader.readUint8();
731
731
  const filter_type = reader.readVarInt();
732
732
  if (filter_type < 1n || filter_type > 4n) {
733
- throw new (0, _chunkJL3NEW3Ocjs.DecodeError)(
733
+ throw new (0, _chunk4XLYCT5Qcjs.DecodeError)(
734
734
  "CONSTRAINT_VIOLATION",
735
735
  `Invalid filter type: ${filter_type}`,
736
736
  reader.offset
@@ -1043,7 +1043,7 @@ var payloadDecoders = /* @__PURE__ */ new Map([
1043
1043
  var dataStreamDecoders = /* @__PURE__ */ new Map([[MSG_OBJECT_DATAGRAM, decodeObjectDatagram]]);
1044
1044
  function encodeMessage(message) {
1045
1045
  if (message.type === "object_datagram") {
1046
- const writer2 = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
1046
+ const writer2 = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
1047
1047
  encodeObjectDatagram(message, writer2);
1048
1048
  return writer2.finish();
1049
1049
  }
@@ -1051,10 +1051,10 @@ function encodeMessage(message) {
1051
1051
  if (typeId === void 0) {
1052
1052
  throw new Error(`Unknown message type: ${message.type}`);
1053
1053
  }
1054
- const payloadWriter = new (0, _chunkJL3NEW3Ocjs.BufferWriter)();
1054
+ const payloadWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
1055
1055
  encodePayload(message, payloadWriter);
1056
1056
  const payload = payloadWriter.finishView();
1057
- const writer = new (0, _chunkJL3NEW3Ocjs.BufferWriter)(payload.byteLength + 16);
1057
+ const writer = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(payload.byteLength + 16);
1058
1058
  writer.writeVarInt(typeId);
1059
1059
  writer.writeVarInt(payload.byteLength);
1060
1060
  writer.writeBytes(payload);
@@ -1062,14 +1062,14 @@ function encodeMessage(message) {
1062
1062
  }
1063
1063
  function decodeMessage(bytes) {
1064
1064
  try {
1065
- const reader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(bytes, 0);
1065
+ const reader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes, 0);
1066
1066
  const typeId = reader.readVarInt();
1067
1067
  if (DATA_STREAM_TYPE_IDS.has(typeId)) {
1068
1068
  const decoder2 = dataStreamDecoders.get(typeId);
1069
1069
  if (!decoder2) {
1070
1070
  return {
1071
1071
  ok: false,
1072
- error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
1072
+ error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
1073
1073
  "UNKNOWN_MESSAGE_TYPE",
1074
1074
  `Unknown data stream type ID: 0x${typeId.toString(16)}`,
1075
1075
  0
@@ -1083,7 +1083,7 @@ function decodeMessage(bytes) {
1083
1083
  if (reader.remaining < payloadLength) {
1084
1084
  return {
1085
1085
  ok: false,
1086
- error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
1086
+ error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
1087
1087
  "UNEXPECTED_END",
1088
1088
  `Not enough bytes for payload: need ${payloadLength}, have ${reader.remaining}`,
1089
1089
  reader.offset
@@ -1096,18 +1096,18 @@ function decodeMessage(bytes) {
1096
1096
  if (!decoder) {
1097
1097
  return {
1098
1098
  ok: false,
1099
- error: new (0, _chunkJL3NEW3Ocjs.DecodeError)(
1099
+ error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
1100
1100
  "UNKNOWN_MESSAGE_TYPE",
1101
1101
  `Unknown message type ID: 0x${typeId.toString(16)}`,
1102
1102
  0
1103
1103
  )
1104
1104
  };
1105
1105
  }
1106
- const payloadReader = new (0, _chunkJL3NEW3Ocjs.BufferReader)(payloadBytes, 0);
1106
+ const payloadReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(payloadBytes, 0);
1107
1107
  const message = decoder(payloadReader);
1108
1108
  return { ok: true, value: message, bytesRead: totalBytesRead };
1109
1109
  } catch (e) {
1110
- if (e instanceof _chunkJL3NEW3Ocjs.DecodeError) {
1110
+ if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) {
1111
1111
  return { ok: false, error: e };
1112
1112
  }
1113
1113
  throw e;
@@ -1140,7 +1140,7 @@ function createStreamDecoder() {
1140
1140
  flush(controller) {
1141
1141
  if (offset < buffer.length) {
1142
1142
  controller.error(
1143
- new (0, _chunkJL3NEW3Ocjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete message data", 0)
1143
+ new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete message data", 0)
1144
1144
  );
1145
1145
  }
1146
1146
  }