@moqtap/codec 0.1.0 → 0.2.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 (277) hide show
  1. package/README.md +99 -95
  2. package/dist/chunk-4RIXXEII.js +1275 -0
  3. package/dist/chunk-4XYGE53S.cjs +698 -0
  4. package/dist/chunk-4YJANAXU.cjs +1109 -0
  5. package/dist/chunk-6AEHWULA.cjs +641 -0
  6. package/dist/chunk-7DUBLRXC.js +680 -0
  7. package/dist/{chunk-WNTXF3DE.cjs → chunk-7IVGHMKJ.cjs} +164 -62
  8. package/dist/{chunk-YBSEOSSP.js → chunk-A27S7HW7.js} +5 -1
  9. package/dist/chunk-BISI45MN.cjs +680 -0
  10. package/dist/{chunk-3BSZ55L3.cjs → chunk-BPNL5YFQ.cjs} +158 -24
  11. package/dist/chunk-CXDHOMHG.js +1097 -0
  12. package/dist/chunk-DUBCL3WF.cjs +749 -0
  13. package/dist/chunk-DWK5ZQZ4.js +642 -0
  14. package/dist/chunk-E6E3NQYU.js +680 -0
  15. package/dist/chunk-EFM5T7OM.js +698 -0
  16. package/dist/chunk-ENURAVHI.cjs +680 -0
  17. package/dist/{chunk-5WFXFLL4.cjs → chunk-FUFTMAQD.cjs} +96 -63
  18. package/dist/{chunk-2NARXGVA.cjs → chunk-FWISIR26.cjs} +5 -1
  19. package/dist/{chunk-YPXLV5YK.js → chunk-FXZ2MYKJ.js} +376 -38
  20. package/dist/chunk-G26SJ6XS.cjs +1341 -0
  21. package/dist/chunk-G7GI7LJA.js +737 -0
  22. package/dist/chunk-GXEW4COZ.cjs +737 -0
  23. package/dist/chunk-HSVYF6XX.cjs +1361 -0
  24. package/dist/chunk-IBVM4DMJ.cjs +1097 -0
  25. package/dist/chunk-IV2H5CFI.cjs +1275 -0
  26. package/dist/chunk-IV2HRJVT.js +1198 -0
  27. package/dist/chunk-JSQM2MG3.js +680 -0
  28. package/dist/chunk-K4OLITS2.cjs +1055 -0
  29. package/dist/{chunk-UOBWHJA5.js → chunk-KFTCU2P6.js} +2 -3
  30. package/dist/chunk-LH4NTURO.js +1361 -0
  31. package/dist/{chunk-DC4L6ZIT.js → chunk-MFAP7R6L.js} +154 -20
  32. package/dist/chunk-NGVE2RZT.js +1097 -0
  33. package/dist/chunk-NUX5BHWO.js +1341 -0
  34. package/dist/chunk-PJRA2TQ5.js +1055 -0
  35. package/dist/chunk-RVJAGE4S.cjs +1198 -0
  36. package/dist/{chunk-QYG6KGOV.cjs → chunk-RWQ43Z4F.cjs} +2 -3
  37. package/dist/chunk-RZHAPEXO.js +749 -0
  38. package/dist/chunk-ST24APEO.js +1109 -0
  39. package/dist/chunk-SYHW3FLI.cjs +642 -0
  40. package/dist/chunk-TLYNOOQP.cjs +432 -0
  41. package/dist/{chunk-23YG7F46.js → chunk-TMNGRIPL.js} +153 -51
  42. package/dist/{chunk-IQPDRQVC.js → chunk-U2B3B42P.js} +62 -29
  43. package/dist/chunk-UNS34PTA.cjs +680 -0
  44. package/dist/chunk-UR6JKS56.js +432 -0
  45. package/dist/{chunk-GDRGWFEK.cjs → chunk-UYXTY6ZQ.cjs} +376 -38
  46. package/dist/chunk-XUUCOLWU.cjs +1097 -0
  47. package/dist/chunk-YG5KJESI.js +641 -0
  48. package/dist/chunk-ZBKE2QRQ.js +1401 -0
  49. package/dist/chunk-ZSPO2GF2.cjs +1401 -0
  50. package/dist/codec-95k8CAu5.d.cts +35 -0
  51. package/dist/codec-AFuOxfsO.d.ts +60 -0
  52. package/dist/codec-B-UJ5Iow.d.cts +75 -0
  53. package/dist/codec-BC5jfvMb.d.ts +35 -0
  54. package/dist/codec-BECYPfY8.d.ts +35 -0
  55. package/dist/codec-BsPU1vNC.d.ts +39 -0
  56. package/dist/codec-BvpuF-6u.d.cts +39 -0
  57. package/dist/codec-C8jZI5Cx.d.cts +39 -0
  58. package/dist/codec-CAevkgf5.d.cts +33 -0
  59. package/dist/codec-CSUqCrRs.d.ts +39 -0
  60. package/dist/codec-C_HMXNK_.d.ts +33 -0
  61. package/dist/{codec-CTvFtQQI.d.cts → codec-CpuvYTSV.d.cts} +5 -5
  62. package/dist/codec-D0x8-SCw.d.cts +35 -0
  63. package/dist/codec-D7ARhpG1.d.ts +75 -0
  64. package/dist/codec-DNAUGshO.d.cts +60 -0
  65. package/dist/codec-DPx_QNn0.d.ts +31 -0
  66. package/dist/{codec-qPzfmLNu.d.ts → codec-DRhCx_hw.d.ts} +5 -5
  67. package/dist/codec-Db7YPe3l.d.ts +31 -0
  68. package/dist/codec-axkJpb7D.d.cts +31 -0
  69. package/dist/codec-ujAbFaep.d.cts +31 -0
  70. package/dist/draft10-session.cjs +6 -0
  71. package/dist/draft10-session.d.cts +8 -0
  72. package/dist/draft10-session.d.ts +8 -0
  73. package/dist/draft10-session.js +6 -0
  74. package/dist/draft10.cjs +115 -0
  75. package/dist/draft10.d.cts +95 -0
  76. package/dist/draft10.d.ts +95 -0
  77. package/dist/draft10.js +115 -0
  78. package/dist/draft11-session.cjs +6 -0
  79. package/dist/draft11-session.d.cts +8 -0
  80. package/dist/draft11-session.d.ts +8 -0
  81. package/dist/draft11-session.js +6 -0
  82. package/dist/draft11.cjs +109 -0
  83. package/dist/draft11.d.cts +99 -0
  84. package/dist/draft11.d.ts +99 -0
  85. package/dist/draft11.js +109 -0
  86. package/dist/draft12-session.cjs +6 -0
  87. package/dist/draft12-session.d.cts +8 -0
  88. package/dist/draft12-session.d.ts +8 -0
  89. package/dist/draft12-session.js +6 -0
  90. package/dist/draft12.cjs +117 -0
  91. package/dist/draft12.d.cts +106 -0
  92. package/dist/draft12.d.ts +106 -0
  93. package/dist/draft12.js +117 -0
  94. package/dist/draft13-session.cjs +6 -0
  95. package/dist/draft13-session.d.cts +8 -0
  96. package/dist/draft13-session.d.ts +8 -0
  97. package/dist/draft13-session.js +6 -0
  98. package/dist/draft13.cjs +119 -0
  99. package/dist/draft13.d.cts +108 -0
  100. package/dist/draft13.d.ts +108 -0
  101. package/dist/draft13.js +119 -0
  102. package/dist/draft14-session.cjs +2 -2
  103. package/dist/draft14-session.d.cts +4 -4
  104. package/dist/draft14-session.d.ts +4 -4
  105. package/dist/draft14-session.js +1 -1
  106. package/dist/draft14.cjs +4 -4
  107. package/dist/draft14.d.cts +27 -15
  108. package/dist/draft14.d.ts +27 -15
  109. package/dist/draft14.js +3 -3
  110. package/dist/draft15-session.cjs +6 -0
  111. package/dist/draft15-session.d.cts +8 -0
  112. package/dist/draft15-session.d.ts +8 -0
  113. package/dist/draft15-session.js +6 -0
  114. package/dist/draft15.cjs +111 -0
  115. package/dist/draft15.d.cts +93 -0
  116. package/dist/draft15.d.ts +93 -0
  117. package/dist/draft15.js +111 -0
  118. package/dist/draft16-session.cjs +6 -0
  119. package/dist/draft16-session.d.cts +8 -0
  120. package/dist/draft16-session.d.ts +8 -0
  121. package/dist/draft16-session.js +6 -0
  122. package/dist/draft16.cjs +113 -0
  123. package/dist/draft16.d.cts +94 -0
  124. package/dist/draft16.d.ts +94 -0
  125. package/dist/draft16.js +113 -0
  126. package/dist/draft17-session.cjs +8 -0
  127. package/dist/draft17-session.d.cts +51 -0
  128. package/dist/draft17-session.d.ts +51 -0
  129. package/dist/draft17-session.js +8 -0
  130. package/dist/draft17.cjs +99 -0
  131. package/dist/draft17.d.cts +40 -0
  132. package/dist/draft17.d.ts +40 -0
  133. package/dist/draft17.js +99 -0
  134. package/dist/draft7-session.cjs +3 -3
  135. package/dist/draft7-session.d.cts +3 -3
  136. package/dist/draft7-session.d.ts +3 -3
  137. package/dist/draft7-session.js +2 -2
  138. package/dist/draft7.cjs +6 -6
  139. package/dist/draft7.d.cts +10 -10
  140. package/dist/draft7.d.ts +10 -10
  141. package/dist/draft7.js +3 -3
  142. package/dist/draft8-session.cjs +6 -0
  143. package/dist/draft8-session.d.cts +8 -0
  144. package/dist/draft8-session.d.ts +8 -0
  145. package/dist/draft8-session.js +6 -0
  146. package/dist/draft8.cjs +115 -0
  147. package/dist/draft8.d.cts +95 -0
  148. package/dist/draft8.d.ts +95 -0
  149. package/dist/draft8.js +115 -0
  150. package/dist/draft9-session.cjs +6 -0
  151. package/dist/draft9-session.d.cts +8 -0
  152. package/dist/draft9-session.d.ts +8 -0
  153. package/dist/draft9-session.js +6 -0
  154. package/dist/draft9.cjs +115 -0
  155. package/dist/draft9.d.cts +95 -0
  156. package/dist/draft9.d.ts +95 -0
  157. package/dist/draft9.js +115 -0
  158. package/dist/index.cjs +79 -7
  159. package/dist/index.d.cts +71 -8
  160. package/dist/index.d.ts +71 -8
  161. package/dist/index.js +77 -5
  162. package/dist/{session-types-B9NIf7_F.d.ts → session-types-CJIFbTPd.d.ts} +20 -20
  163. package/dist/{session-types-CCo-oA-d.d.cts → session-types-Cbq8IGCP.d.cts} +20 -20
  164. package/dist/session.cjs +5 -5
  165. package/dist/session.d.cts +3 -3
  166. package/dist/session.d.ts +3 -3
  167. package/dist/session.js +5 -5
  168. package/dist/types-4VxSL2Ho.d.cts +261 -0
  169. package/dist/types-4VxSL2Ho.d.ts +261 -0
  170. package/dist/types-B2afJZM-.d.cts +236 -0
  171. package/dist/types-B2afJZM-.d.ts +236 -0
  172. package/dist/{types-CIk5W10V.d.ts → types-BTFeKYCb.d.cts} +37 -37
  173. package/dist/{types-CIk5W10V.d.cts → types-BTFeKYCb.d.ts} +37 -37
  174. package/dist/types-Bg6QYNVt.d.cts +290 -0
  175. package/dist/types-Bg6QYNVt.d.ts +290 -0
  176. package/dist/types-C_1HrqBl.d.cts +306 -0
  177. package/dist/types-C_1HrqBl.d.ts +306 -0
  178. package/dist/types-Cw4WE9dh.d.cts +261 -0
  179. package/dist/types-Cw4WE9dh.d.ts +261 -0
  180. package/dist/types-D5gNQiDj.d.cts +261 -0
  181. package/dist/types-D5gNQiDj.d.ts +261 -0
  182. package/dist/types-DqCDFqgB.d.cts +230 -0
  183. package/dist/types-DqCDFqgB.d.ts +230 -0
  184. package/dist/types-ERexTpT8.d.cts +217 -0
  185. package/dist/types-ERexTpT8.d.ts +217 -0
  186. package/dist/{types-ClXELFGN.d.cts → types-QNXoxC9Y.d.cts} +36 -41
  187. package/dist/{types-ClXELFGN.d.ts → types-QNXoxC9Y.d.ts} +36 -41
  188. package/dist/types-r-CasCf1.d.cts +262 -0
  189. package/dist/types-r-CasCf1.d.ts +262 -0
  190. package/package.json +116 -8
  191. package/src/core/buffer-reader.ts +16 -9
  192. package/src/core/buffer-writer.ts +2 -2
  193. package/src/core/errors.ts +1 -1
  194. package/src/core/session-types.ts +28 -41
  195. package/src/core/types.ts +92 -75
  196. package/src/drafts/draft07/announce-fsm.ts +1 -1
  197. package/src/drafts/draft07/codec.ts +235 -118
  198. package/src/drafts/draft07/index.ts +43 -44
  199. package/src/drafts/draft07/messages.ts +1 -1
  200. package/src/drafts/draft07/parameters.ts +2 -2
  201. package/src/drafts/draft07/rules.ts +67 -38
  202. package/src/drafts/draft07/session-fsm.ts +330 -117
  203. package/src/drafts/draft07/session.ts +10 -10
  204. package/src/drafts/draft07/subscription-fsm.ts +1 -1
  205. package/src/drafts/draft07/varint.ts +4 -4
  206. package/src/drafts/draft08/codec.ts +1254 -0
  207. package/src/drafts/draft08/index.ts +125 -0
  208. package/src/drafts/draft08/messages.ts +72 -0
  209. package/src/drafts/draft08/rules.ts +91 -0
  210. package/src/drafts/draft08/session-fsm.ts +718 -0
  211. package/src/drafts/draft08/session.ts +26 -0
  212. package/src/drafts/draft08/types.ts +377 -0
  213. package/src/drafts/draft09/codec.ts +1235 -0
  214. package/src/drafts/draft09/index.ts +125 -0
  215. package/src/drafts/draft09/messages.ts +72 -0
  216. package/src/drafts/draft09/rules.ts +91 -0
  217. package/src/drafts/draft09/session-fsm.ts +718 -0
  218. package/src/drafts/draft09/session.ts +26 -0
  219. package/src/drafts/draft09/types.ts +376 -0
  220. package/src/drafts/draft10/codec.ts +1235 -0
  221. package/src/drafts/draft10/index.ts +125 -0
  222. package/src/drafts/draft10/messages.ts +72 -0
  223. package/src/drafts/draft10/rules.ts +91 -0
  224. package/src/drafts/draft10/session-fsm.ts +718 -0
  225. package/src/drafts/draft10/session.ts +26 -0
  226. package/src/drafts/draft10/types.ts +376 -0
  227. package/src/drafts/draft11/codec.ts +1198 -0
  228. package/src/drafts/draft11/index.ts +123 -0
  229. package/src/drafts/draft11/messages.ts +71 -0
  230. package/src/drafts/draft11/rules.ts +100 -0
  231. package/src/drafts/draft11/session-fsm.ts +758 -0
  232. package/src/drafts/draft11/session.ts +26 -0
  233. package/src/drafts/draft11/types.ts +375 -0
  234. package/src/drafts/draft12/codec.ts +1354 -0
  235. package/src/drafts/draft12/index.ts +130 -0
  236. package/src/drafts/draft12/messages.ts +84 -0
  237. package/src/drafts/draft12/rules.ts +106 -0
  238. package/src/drafts/draft12/session-fsm.ts +805 -0
  239. package/src/drafts/draft12/session.ts +26 -0
  240. package/src/drafts/draft12/types.ts +414 -0
  241. package/src/drafts/draft13/codec.ts +1438 -0
  242. package/src/drafts/draft13/index.ts +132 -0
  243. package/src/drafts/draft13/messages.ts +86 -0
  244. package/src/drafts/draft13/rules.ts +108 -0
  245. package/src/drafts/draft13/session-fsm.ts +819 -0
  246. package/src/drafts/draft13/session.ts +26 -0
  247. package/src/drafts/draft13/types.ts +433 -0
  248. package/src/drafts/draft14/codec.ts +339 -189
  249. package/src/drafts/draft14/index.ts +103 -108
  250. package/src/drafts/draft14/messages.ts +61 -61
  251. package/src/drafts/draft14/rules.ts +77 -34
  252. package/src/drafts/draft14/session-fsm.ts +640 -147
  253. package/src/drafts/draft14/session.ts +13 -13
  254. package/src/drafts/draft14/types.ts +68 -68
  255. package/src/drafts/draft15/codec.ts +1661 -0
  256. package/src/drafts/draft15/index.ts +121 -0
  257. package/src/drafts/draft15/messages.ts +64 -0
  258. package/src/drafts/draft15/rules.ts +95 -0
  259. package/src/drafts/draft15/session-fsm.ts +687 -0
  260. package/src/drafts/draft15/session.ts +26 -0
  261. package/src/drafts/draft15/types.ts +336 -0
  262. package/src/drafts/draft16/codec.ts +1623 -0
  263. package/src/drafts/draft16/index.ts +123 -0
  264. package/src/drafts/draft16/messages.ts +67 -0
  265. package/src/drafts/draft16/rules.ts +96 -0
  266. package/src/drafts/draft16/session-fsm.ts +682 -0
  267. package/src/drafts/draft16/session.ts +26 -0
  268. package/src/drafts/draft16/types.ts +354 -0
  269. package/src/drafts/draft17/codec.ts +1621 -0
  270. package/src/drafts/draft17/index.ts +105 -0
  271. package/src/drafts/draft17/messages.ts +53 -0
  272. package/src/drafts/draft17/rules.ts +85 -0
  273. package/src/drafts/draft17/session-fsm.ts +437 -0
  274. package/src/drafts/draft17/session.ts +15 -0
  275. package/src/drafts/draft17/types.ts +310 -0
  276. package/src/index.ts +283 -33
  277. package/src/session.ts +20 -20
@@ -1,132 +1,127 @@
1
- export { createDraft14Codec } from './codec.js';
2
- export type { Draft14Codec } from './codec.js';
3
-
1
+ export type { Draft14Codec } from "./codec.js";
4
2
  export {
5
- encodeMessage,
3
+ createDataStreamDecoder,
4
+ createDraft14Codec,
5
+ createFetchStreamDecoder,
6
+ createStreamDecoder,
7
+ createSubgroupStreamDecoder,
8
+ decodeDatagram,
9
+ decodeDataStream,
10
+ decodeFetchStream,
6
11
  decodeMessage,
7
- encodeSubgroupStream,
12
+ decodeSubgroupStream,
8
13
  encodeDatagram,
9
14
  encodeFetchStream,
10
- decodeSubgroupStream,
11
- decodeDatagram,
12
- decodeFetchStream,
13
- decodeDataStream,
14
- createStreamDecoder,
15
- createSubgroupStreamDecoder,
16
- createFetchStreamDecoder,
17
- createDataStreamDecoder,
18
- } from './codec.js';
19
-
20
- export type {
21
- Draft14Message,
22
- Draft14MessageType,
23
- Draft14BaseMessage,
24
- Draft14Params,
25
- UnknownParam,
26
- Draft14ClientSetup,
27
- Draft14ServerSetup,
28
- Draft14Subscribe,
29
- Draft14SubscribeOk,
30
- Draft14SubscribeUpdate,
31
- Draft14SubscribeError,
32
- Draft14Unsubscribe,
33
- Draft14Publish,
34
- Draft14PublishOk,
35
- Draft14PublishError,
36
- Draft14PublishDone,
37
- Draft14PublishNamespace,
38
- Draft14PublishNamespaceOk,
39
- Draft14PublishNamespaceError,
40
- Draft14PublishNamespaceDone,
41
- Draft14PublishNamespaceCancel,
42
- Draft14SubscribeNamespace,
43
- Draft14SubscribeNamespaceOk,
44
- Draft14SubscribeNamespaceError,
45
- Draft14UnsubscribeNamespace,
46
- Draft14Fetch,
47
- Draft14FetchOk,
48
- Draft14FetchError,
49
- Draft14FetchCancel,
50
- Draft14TrackStatus,
51
- Draft14TrackStatusOk,
52
- Draft14TrackStatusError,
53
- Draft14GoAway,
54
- Draft14MaxRequestId,
55
- Draft14RequestsBlocked,
56
- Draft14DataStream,
57
- SubgroupStream,
58
- DatagramObject,
59
- FetchStream,
60
- ObjectPayload,
61
- SubgroupStreamHeader,
62
- FetchStreamHeader,
63
- DataStreamHeader,
64
- DataStreamEvent,
65
- } from './types.js';
66
-
15
+ encodeMessage,
16
+ encodeSubgroupStream,
17
+ } from "./codec.js";
67
18
  export {
19
+ MESSAGE_ID_MAP,
20
+ MESSAGE_TYPE_MAP,
68
21
  MSG_CLIENT_SETUP,
69
- MSG_SERVER_SETUP,
70
- MSG_SUBSCRIBE,
71
- MSG_SUBSCRIBE_OK,
72
- MSG_SUBSCRIBE_UPDATE,
73
- MSG_SUBSCRIBE_ERROR,
74
- MSG_UNSUBSCRIBE,
22
+ MSG_FETCH,
23
+ MSG_FETCH_CANCEL,
24
+ MSG_FETCH_ERROR,
25
+ MSG_FETCH_OK,
26
+ MSG_GOAWAY,
27
+ MSG_MAX_REQUEST_ID,
75
28
  MSG_PUBLISH,
76
- MSG_PUBLISH_OK,
77
- MSG_PUBLISH_ERROR,
78
29
  MSG_PUBLISH_DONE,
30
+ MSG_PUBLISH_ERROR,
79
31
  MSG_PUBLISH_NAMESPACE,
80
- MSG_PUBLISH_NAMESPACE_OK,
81
- MSG_PUBLISH_NAMESPACE_ERROR,
82
- MSG_PUBLISH_NAMESPACE_DONE,
83
32
  MSG_PUBLISH_NAMESPACE_CANCEL,
33
+ MSG_PUBLISH_NAMESPACE_DONE,
34
+ MSG_PUBLISH_NAMESPACE_ERROR,
35
+ MSG_PUBLISH_NAMESPACE_OK,
36
+ MSG_PUBLISH_OK,
37
+ MSG_REQUESTS_BLOCKED,
38
+ MSG_SERVER_SETUP,
39
+ MSG_SUBSCRIBE,
40
+ MSG_SUBSCRIBE_ERROR,
84
41
  MSG_SUBSCRIBE_NAMESPACE,
85
- MSG_SUBSCRIBE_NAMESPACE_OK,
86
42
  MSG_SUBSCRIBE_NAMESPACE_ERROR,
87
- MSG_UNSUBSCRIBE_NAMESPACE,
88
- MSG_FETCH,
89
- MSG_FETCH_OK,
90
- MSG_FETCH_ERROR,
91
- MSG_FETCH_CANCEL,
43
+ MSG_SUBSCRIBE_NAMESPACE_OK,
44
+ MSG_SUBSCRIBE_OK,
45
+ MSG_SUBSCRIBE_UPDATE,
92
46
  MSG_TRACK_STATUS,
93
- MSG_TRACK_STATUS_OK,
94
47
  MSG_TRACK_STATUS_ERROR,
95
- MSG_GOAWAY,
96
- MSG_MAX_REQUEST_ID,
97
- MSG_REQUESTS_BLOCKED,
98
- MESSAGE_TYPE_MAP,
99
- MESSAGE_ID_MAP,
100
- PARAM_ROLE,
101
- PARAM_PATH,
48
+ MSG_TRACK_STATUS_OK,
49
+ MSG_UNSUBSCRIBE,
50
+ MSG_UNSUBSCRIBE_NAMESPACE,
102
51
  PARAM_MAX_REQUEST_ID,
103
- } from './messages.js';
104
-
105
- // Session state machine
106
- export { createDraft14SessionState } from './session.js';
107
- export { Draft14SessionFSM } from './session-fsm.js';
52
+ PARAM_PATH,
53
+ PARAM_ROLE,
54
+ } from "./messages.js";
108
55
  export {
109
- CONTROL_MESSAGES,
110
- CLIENT_ONLY_MESSAGES,
111
- SERVER_ONLY_MESSAGES,
112
56
  BIDIRECTIONAL_MESSAGES,
113
- getLegalOutgoing,
57
+ CLIENT_ONLY_MESSAGES,
58
+ CONTROL_MESSAGES,
114
59
  getLegalIncoming,
115
- } from './rules.js';
116
-
60
+ getLegalOutgoing,
61
+ SERVER_ONLY_MESSAGES,
62
+ } from "./rules.js";
117
63
  export type {
64
+ FetchPhase,
65
+ FetchState,
66
+ ProtocolViolation,
67
+ ProtocolViolationCode,
68
+ PublishPhase,
69
+ PublishState,
70
+ SessionPhase,
118
71
  SessionState,
119
72
  SessionStateOptions,
120
- SessionPhase,
121
- SubscriptionState,
73
+ SideEffect,
122
74
  SubscriptionPhase,
123
- PublishState,
124
- PublishPhase,
125
- FetchState,
126
- FetchPhase,
75
+ SubscriptionState,
127
76
  TransitionResult,
128
77
  ValidationResult,
129
- ProtocolViolation,
130
- ProtocolViolationCode,
131
- SideEffect,
132
- } from './session.js';
78
+ } from "./session.js";
79
+ // Session state machine
80
+ export { createDraft14SessionState } from "./session.js";
81
+ export { Draft14SessionFSM } from "./session-fsm.js";
82
+ export type {
83
+ DatagramObject,
84
+ DataStreamEvent,
85
+ DataStreamHeader,
86
+ Draft14BaseMessage,
87
+ Draft14ClientSetup,
88
+ Draft14DataStream,
89
+ Draft14Fetch,
90
+ Draft14FetchCancel,
91
+ Draft14FetchError,
92
+ Draft14FetchOk,
93
+ Draft14GoAway,
94
+ Draft14MaxRequestId,
95
+ Draft14Message,
96
+ Draft14MessageType,
97
+ Draft14Params,
98
+ Draft14Publish,
99
+ Draft14PublishDone,
100
+ Draft14PublishError,
101
+ Draft14PublishNamespace,
102
+ Draft14PublishNamespaceCancel,
103
+ Draft14PublishNamespaceDone,
104
+ Draft14PublishNamespaceError,
105
+ Draft14PublishNamespaceOk,
106
+ Draft14PublishOk,
107
+ Draft14RequestsBlocked,
108
+ Draft14ServerSetup,
109
+ Draft14Subscribe,
110
+ Draft14SubscribeError,
111
+ Draft14SubscribeNamespace,
112
+ Draft14SubscribeNamespaceError,
113
+ Draft14SubscribeNamespaceOk,
114
+ Draft14SubscribeOk,
115
+ Draft14SubscribeUpdate,
116
+ Draft14TrackStatus,
117
+ Draft14TrackStatusError,
118
+ Draft14TrackStatusOk,
119
+ Draft14Unsubscribe,
120
+ Draft14UnsubscribeNamespace,
121
+ FetchStream,
122
+ FetchStreamHeader,
123
+ ObjectPayload,
124
+ SubgroupStream,
125
+ SubgroupStreamHeader,
126
+ UnknownParam,
127
+ } from "./types.js";
@@ -1,76 +1,76 @@
1
1
  // Draft-14 message type wire IDs
2
2
 
3
- export const MSG_SUBSCRIBE_UPDATE = 0x02n;
4
- export const MSG_SUBSCRIBE = 0x03n;
5
- export const MSG_SUBSCRIBE_OK = 0x04n;
6
- export const MSG_SUBSCRIBE_ERROR = 0x05n;
7
- export const MSG_PUBLISH_NAMESPACE = 0x06n;
8
- export const MSG_PUBLISH_NAMESPACE_OK = 0x07n;
3
+ export const MSG_SUBSCRIBE_UPDATE = 0x02n;
4
+ export const MSG_SUBSCRIBE = 0x03n;
5
+ export const MSG_SUBSCRIBE_OK = 0x04n;
6
+ export const MSG_SUBSCRIBE_ERROR = 0x05n;
7
+ export const MSG_PUBLISH_NAMESPACE = 0x06n;
8
+ export const MSG_PUBLISH_NAMESPACE_OK = 0x07n;
9
9
  export const MSG_PUBLISH_NAMESPACE_ERROR = 0x08n;
10
- export const MSG_PUBLISH_NAMESPACE_DONE = 0x09n;
11
- export const MSG_UNSUBSCRIBE = 0x0An;
12
- export const MSG_PUBLISH_DONE = 0x0Bn;
13
- export const MSG_PUBLISH_NAMESPACE_CANCEL = 0x0Cn;
14
- export const MSG_TRACK_STATUS = 0x0Dn;
15
- export const MSG_TRACK_STATUS_OK = 0x0En;
16
- export const MSG_TRACK_STATUS_ERROR = 0x0Fn;
17
- export const MSG_GOAWAY = 0x10n;
10
+ export const MSG_PUBLISH_NAMESPACE_DONE = 0x09n;
11
+ export const MSG_UNSUBSCRIBE = 0x0an;
12
+ export const MSG_PUBLISH_DONE = 0x0bn;
13
+ export const MSG_PUBLISH_NAMESPACE_CANCEL = 0x0cn;
14
+ export const MSG_TRACK_STATUS = 0x0dn;
15
+ export const MSG_TRACK_STATUS_OK = 0x0en;
16
+ export const MSG_TRACK_STATUS_ERROR = 0x0fn;
17
+ export const MSG_GOAWAY = 0x10n;
18
18
  export const MSG_SUBSCRIBE_NAMESPACE = 0x11n;
19
- export const MSG_SUBSCRIBE_NAMESPACE_OK = 0x12n;
19
+ export const MSG_SUBSCRIBE_NAMESPACE_OK = 0x12n;
20
20
  export const MSG_SUBSCRIBE_NAMESPACE_ERROR = 0x13n;
21
- export const MSG_UNSUBSCRIBE_NAMESPACE = 0x14n;
22
- export const MSG_MAX_REQUEST_ID = 0x15n;
23
- export const MSG_FETCH = 0x16n;
24
- export const MSG_FETCH_CANCEL = 0x17n;
25
- export const MSG_FETCH_OK = 0x18n;
26
- export const MSG_FETCH_ERROR = 0x19n;
27
- export const MSG_REQUESTS_BLOCKED = 0x1An;
28
- export const MSG_PUBLISH = 0x1Dn;
29
- export const MSG_PUBLISH_OK = 0x1En;
30
- export const MSG_PUBLISH_ERROR = 0x1Fn;
31
- export const MSG_CLIENT_SETUP = 0x20n;
32
- export const MSG_SERVER_SETUP = 0x21n;
21
+ export const MSG_UNSUBSCRIBE_NAMESPACE = 0x14n;
22
+ export const MSG_MAX_REQUEST_ID = 0x15n;
23
+ export const MSG_FETCH = 0x16n;
24
+ export const MSG_FETCH_CANCEL = 0x17n;
25
+ export const MSG_FETCH_OK = 0x18n;
26
+ export const MSG_FETCH_ERROR = 0x19n;
27
+ export const MSG_REQUESTS_BLOCKED = 0x1an;
28
+ export const MSG_PUBLISH = 0x1dn;
29
+ export const MSG_PUBLISH_OK = 0x1en;
30
+ export const MSG_PUBLISH_ERROR = 0x1fn;
31
+ export const MSG_CLIENT_SETUP = 0x20n;
32
+ export const MSG_SERVER_SETUP = 0x21n;
33
33
 
34
34
  // Parameter type IDs
35
- export const PARAM_ROLE = 0x00n;
36
- export const PARAM_PATH = 0x01n;
37
- export const PARAM_MAX_REQUEST_ID = 0x02n;
35
+ export const PARAM_ROLE = 0x00n;
36
+ export const PARAM_PATH = 0x01n;
37
+ export const PARAM_MAX_REQUEST_ID = 0x02n;
38
38
 
39
39
  // Map from wire ID to message type name
40
40
  export const MESSAGE_TYPE_MAP: ReadonlyMap<bigint, string> = new Map([
41
- [MSG_CLIENT_SETUP, 'client_setup'],
42
- [MSG_SERVER_SETUP, 'server_setup'],
43
- [MSG_SUBSCRIBE, 'subscribe'],
44
- [MSG_SUBSCRIBE_OK, 'subscribe_ok'],
45
- [MSG_SUBSCRIBE_UPDATE, 'subscribe_update'],
46
- [MSG_SUBSCRIBE_ERROR, 'subscribe_error'],
47
- [MSG_UNSUBSCRIBE, 'unsubscribe'],
48
- [MSG_PUBLISH, 'publish'],
49
- [MSG_PUBLISH_OK, 'publish_ok'],
50
- [MSG_PUBLISH_ERROR, 'publish_error'],
51
- [MSG_PUBLISH_DONE, 'publish_done'],
52
- [MSG_PUBLISH_NAMESPACE, 'publish_namespace'],
53
- [MSG_PUBLISH_NAMESPACE_OK, 'publish_namespace_ok'],
54
- [MSG_PUBLISH_NAMESPACE_ERROR, 'publish_namespace_error'],
55
- [MSG_PUBLISH_NAMESPACE_DONE, 'publish_namespace_done'],
56
- [MSG_PUBLISH_NAMESPACE_CANCEL, 'publish_namespace_cancel'],
57
- [MSG_SUBSCRIBE_NAMESPACE, 'subscribe_namespace'],
58
- [MSG_SUBSCRIBE_NAMESPACE_OK, 'subscribe_namespace_ok'],
59
- [MSG_SUBSCRIBE_NAMESPACE_ERROR, 'subscribe_namespace_error'],
60
- [MSG_UNSUBSCRIBE_NAMESPACE, 'unsubscribe_namespace'],
61
- [MSG_FETCH, 'fetch'],
62
- [MSG_FETCH_OK, 'fetch_ok'],
63
- [MSG_FETCH_ERROR, 'fetch_error'],
64
- [MSG_FETCH_CANCEL, 'fetch_cancel'],
65
- [MSG_TRACK_STATUS, 'track_status'],
66
- [MSG_TRACK_STATUS_OK, 'track_status_ok'],
67
- [MSG_TRACK_STATUS_ERROR, 'track_status_error'],
68
- [MSG_GOAWAY, 'goaway'],
69
- [MSG_MAX_REQUEST_ID, 'max_request_id'],
70
- [MSG_REQUESTS_BLOCKED, 'requests_blocked'],
41
+ [MSG_CLIENT_SETUP, "client_setup"],
42
+ [MSG_SERVER_SETUP, "server_setup"],
43
+ [MSG_SUBSCRIBE, "subscribe"],
44
+ [MSG_SUBSCRIBE_OK, "subscribe_ok"],
45
+ [MSG_SUBSCRIBE_UPDATE, "subscribe_update"],
46
+ [MSG_SUBSCRIBE_ERROR, "subscribe_error"],
47
+ [MSG_UNSUBSCRIBE, "unsubscribe"],
48
+ [MSG_PUBLISH, "publish"],
49
+ [MSG_PUBLISH_OK, "publish_ok"],
50
+ [MSG_PUBLISH_ERROR, "publish_error"],
51
+ [MSG_PUBLISH_DONE, "publish_done"],
52
+ [MSG_PUBLISH_NAMESPACE, "publish_namespace"],
53
+ [MSG_PUBLISH_NAMESPACE_OK, "publish_namespace_ok"],
54
+ [MSG_PUBLISH_NAMESPACE_ERROR, "publish_namespace_error"],
55
+ [MSG_PUBLISH_NAMESPACE_DONE, "publish_namespace_done"],
56
+ [MSG_PUBLISH_NAMESPACE_CANCEL, "publish_namespace_cancel"],
57
+ [MSG_SUBSCRIBE_NAMESPACE, "subscribe_namespace"],
58
+ [MSG_SUBSCRIBE_NAMESPACE_OK, "subscribe_namespace_ok"],
59
+ [MSG_SUBSCRIBE_NAMESPACE_ERROR, "subscribe_namespace_error"],
60
+ [MSG_UNSUBSCRIBE_NAMESPACE, "unsubscribe_namespace"],
61
+ [MSG_FETCH, "fetch"],
62
+ [MSG_FETCH_OK, "fetch_ok"],
63
+ [MSG_FETCH_ERROR, "fetch_error"],
64
+ [MSG_FETCH_CANCEL, "fetch_cancel"],
65
+ [MSG_TRACK_STATUS, "track_status"],
66
+ [MSG_TRACK_STATUS_OK, "track_status_ok"],
67
+ [MSG_TRACK_STATUS_ERROR, "track_status_error"],
68
+ [MSG_GOAWAY, "goaway"],
69
+ [MSG_MAX_REQUEST_ID, "max_request_id"],
70
+ [MSG_REQUESTS_BLOCKED, "requests_blocked"],
71
71
  ]);
72
72
 
73
73
  // Reverse map from message type name to wire ID
74
74
  export const MESSAGE_ID_MAP: ReadonlyMap<string, bigint> = new Map(
75
- [...MESSAGE_TYPE_MAP.entries()].map(([id, name]) => [name, id])
75
+ [...MESSAGE_TYPE_MAP.entries()].map(([id, name]) => [name, id]),
76
76
  );
@@ -1,61 +1,101 @@
1
- import type { Draft14MessageType } from './types.js';
1
+ import type { Draft14MessageType } from "./types.js";
2
2
 
3
3
  // All draft-14 control messages
4
4
  export const CONTROL_MESSAGES: ReadonlySet<Draft14MessageType> = new Set([
5
- 'client_setup', 'server_setup',
6
- 'subscribe', 'subscribe_ok', 'subscribe_update', 'subscribe_error', 'unsubscribe',
7
- 'publish', 'publish_ok', 'publish_error', 'publish_done',
8
- 'publish_namespace', 'publish_namespace_ok', 'publish_namespace_error', 'publish_namespace_done', 'publish_namespace_cancel',
9
- 'subscribe_namespace', 'subscribe_namespace_ok', 'subscribe_namespace_error', 'unsubscribe_namespace',
10
- 'fetch', 'fetch_ok', 'fetch_error', 'fetch_cancel',
11
- 'track_status', 'track_status_ok', 'track_status_error',
12
- 'goaway',
13
- 'max_request_id', 'requests_blocked',
5
+ "client_setup",
6
+ "server_setup",
7
+ "subscribe",
8
+ "subscribe_ok",
9
+ "subscribe_update",
10
+ "subscribe_error",
11
+ "unsubscribe",
12
+ "publish",
13
+ "publish_ok",
14
+ "publish_error",
15
+ "publish_done",
16
+ "publish_namespace",
17
+ "publish_namespace_ok",
18
+ "publish_namespace_error",
19
+ "publish_namespace_done",
20
+ "publish_namespace_cancel",
21
+ "subscribe_namespace",
22
+ "subscribe_namespace_ok",
23
+ "subscribe_namespace_error",
24
+ "unsubscribe_namespace",
25
+ "fetch",
26
+ "fetch_ok",
27
+ "fetch_error",
28
+ "fetch_cancel",
29
+ "track_status",
30
+ "track_status_ok",
31
+ "track_status_error",
32
+ "goaway",
33
+ "max_request_id",
34
+ "requests_blocked",
14
35
  ]);
15
36
 
16
37
  // Draft-14 is more symmetric: only setup messages are role-restricted.
17
38
  // All other messages can be sent by both client and server.
18
- export const CLIENT_ONLY_MESSAGES: ReadonlySet<Draft14MessageType> = new Set([
19
- 'client_setup',
20
- ]);
39
+ export const CLIENT_ONLY_MESSAGES: ReadonlySet<Draft14MessageType> = new Set(["client_setup"]);
21
40
 
22
- export const SERVER_ONLY_MESSAGES: ReadonlySet<Draft14MessageType> = new Set([
23
- 'server_setup',
24
- ]);
41
+ export const SERVER_ONLY_MESSAGES: ReadonlySet<Draft14MessageType> = new Set(["server_setup"]);
25
42
 
26
43
  // Messages that are bidirectional (both client and server can send)
27
44
  export const BIDIRECTIONAL_MESSAGES: ReadonlySet<Draft14MessageType> = new Set([
28
- 'subscribe', 'subscribe_ok', 'subscribe_update', 'subscribe_error', 'unsubscribe',
29
- 'publish', 'publish_ok', 'publish_error', 'publish_done',
30
- 'publish_namespace', 'publish_namespace_ok', 'publish_namespace_error', 'publish_namespace_done', 'publish_namespace_cancel',
31
- 'subscribe_namespace', 'subscribe_namespace_ok', 'subscribe_namespace_error', 'unsubscribe_namespace',
32
- 'fetch', 'fetch_ok', 'fetch_error', 'fetch_cancel',
33
- 'track_status', 'track_status_ok', 'track_status_error',
34
- 'goaway',
35
- 'max_request_id', 'requests_blocked',
45
+ "subscribe",
46
+ "subscribe_ok",
47
+ "subscribe_update",
48
+ "subscribe_error",
49
+ "unsubscribe",
50
+ "publish",
51
+ "publish_ok",
52
+ "publish_error",
53
+ "publish_done",
54
+ "publish_namespace",
55
+ "publish_namespace_ok",
56
+ "publish_namespace_error",
57
+ "publish_namespace_done",
58
+ "publish_namespace_cancel",
59
+ "subscribe_namespace",
60
+ "subscribe_namespace_ok",
61
+ "subscribe_namespace_error",
62
+ "unsubscribe_namespace",
63
+ "fetch",
64
+ "fetch_ok",
65
+ "fetch_error",
66
+ "fetch_cancel",
67
+ "track_status",
68
+ "track_status_ok",
69
+ "track_status_error",
70
+ "goaway",
71
+ "max_request_id",
72
+ "requests_blocked",
36
73
  ]);
37
74
 
38
75
  // Messages legal in each session phase -- for outbound validation
39
- export function getLegalOutgoing(phase: string, role: 'client' | 'server'): Set<Draft14MessageType> {
76
+ export function getLegalOutgoing(
77
+ phase: string,
78
+ role: "client" | "server",
79
+ ): Set<Draft14MessageType> {
40
80
  const legal = new Set<Draft14MessageType>();
41
81
 
42
82
  switch (phase) {
43
- case 'idle':
44
- if (role === 'client') legal.add('client_setup');
83
+ case "idle":
84
+ if (role === "client") legal.add("client_setup");
45
85
  break;
46
- case 'setup':
47
- if (role === 'server') legal.add('server_setup');
86
+ case "setup":
87
+ if (role === "server") legal.add("server_setup");
48
88
  break;
49
- case 'ready': {
89
+ case "ready": {
50
90
  // Both roles can send goaway
51
- legal.add('goaway');
91
+ legal.add("goaway");
52
92
  // All bidirectional messages are legal for both roles
53
93
  for (const msg of BIDIRECTIONAL_MESSAGES) {
54
94
  legal.add(msg);
55
95
  }
56
96
  break;
57
97
  }
58
- case 'draining':
98
+ case "draining":
59
99
  // Limited set during draining - can still finish active operations
60
100
  break;
61
101
  }
@@ -63,8 +103,11 @@ export function getLegalOutgoing(phase: string, role: 'client' | 'server'): Set<
63
103
  return legal;
64
104
  }
65
105
 
66
- export function getLegalIncoming(phase: string, role: 'client' | 'server'): Set<Draft14MessageType> {
106
+ export function getLegalIncoming(
107
+ phase: string,
108
+ role: "client" | "server",
109
+ ): Set<Draft14MessageType> {
67
110
  // Incoming from remote = the other role's outgoing
68
- const remoteRole = role === 'client' ? 'server' : 'client';
111
+ const remoteRole = role === "client" ? "server" : "client";
69
112
  return getLegalOutgoing(phase, remoteRole);
70
113
  }