@moqtap/codec 0.4.3 → 0.6.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 (133) hide show
  1. package/dist/chunk-62LYLROG.js +2095 -0
  2. package/dist/chunk-A33U4WVS.cjs +1993 -0
  3. package/dist/chunk-A655PHFX.cjs +446 -0
  4. package/dist/chunk-CQ65LKPQ.cjs +446 -0
  5. package/dist/chunk-DLSGOZ6P.js +1993 -0
  6. package/dist/chunk-IWYKDCXP.js +446 -0
  7. package/dist/chunk-MSG2FXJ2.cjs +2095 -0
  8. package/dist/chunk-O5DQ44TM.js +446 -0
  9. package/dist/{codec-C7UzTYSS.d.cts → codec-B1snaM9L.d.cts} +1 -1
  10. package/dist/{codec-ZwV-Njt6.d.ts → codec-BLYAy2OP.d.ts} +1 -1
  11. package/dist/{codec-B2lYE0YA.d.ts → codec-BNS3gS77.d.ts} +1 -1
  12. package/dist/{codec-BbbLDSKA.d.cts → codec-BOtv3R5j.d.cts} +1 -1
  13. package/dist/{codec-DDUBJGn0.d.cts → codec-BOyrk_C9.d.cts} +1 -1
  14. package/dist/{codec-BWQ5Jlap.d.cts → codec-BqqoYdh_.d.cts} +1 -1
  15. package/dist/{codec-3Ppy_5Gd.d.ts → codec-CI0BjmHc.d.ts} +1 -1
  16. package/dist/{codec-DftaRuVz.d.ts → codec-CWj5iTxA.d.ts} +1 -1
  17. package/dist/{codec-B_QST4y1.d.cts → codec-CyApDKwf.d.cts} +1 -1
  18. package/dist/{codec-BFg5xnrJ.d.ts → codec-D2JbI2tp.d.ts} +1 -1
  19. package/dist/{codec-DFU-6Rax.d.ts → codec-D47r_-Rl.d.ts} +1 -1
  20. package/dist/{codec-Db-0pk38.d.ts → codec-D49OofBr.d.ts} +1 -1
  21. package/dist/codec-D89DWXbv.d.cts +30 -0
  22. package/dist/{codec-R9TJCq-E.d.cts → codec-D95gT98n.d.cts} +1 -1
  23. package/dist/codec-DAePx2NL.d.ts +30 -0
  24. package/dist/{codec-CpZrZ3ok.d.ts → codec-DJmV04i0.d.ts} +1 -1
  25. package/dist/{codec-Va_wZCF_.d.ts → codec-DL0njGkL.d.ts} +1 -1
  26. package/dist/{codec-CFWQY9Lj.d.cts → codec-DQWQSam3.d.cts} +1 -1
  27. package/dist/{codec-wtt6WF1K.d.ts → codec-DplRgIKq.d.ts} +1 -1
  28. package/dist/{codec-CewFCsEy.d.ts → codec-DujHf55Z.d.ts} +1 -1
  29. package/dist/{codec-j819z_hL.d.cts → codec-DvcJgYKq.d.cts} +1 -1
  30. package/dist/{codec-C8aSvE41.d.cts → codec-NMsTK0GX.d.cts} +1 -1
  31. package/dist/codec-WwwUipaU.d.ts +30 -0
  32. package/dist/{codec-CAbm9d_n.d.cts → codec-cou9XBMF.d.cts} +1 -1
  33. package/dist/{codec-lqDowbyT.d.cts → codec-hvkJfCF5.d.cts} +1 -1
  34. package/dist/codec-xeuGZY77.d.cts +30 -0
  35. package/dist/draft07-session.d.cts +3 -3
  36. package/dist/draft07-session.d.ts +3 -3
  37. package/dist/draft07.d.cts +3 -3
  38. package/dist/draft07.d.ts +3 -3
  39. package/dist/draft08-session.d.cts +3 -3
  40. package/dist/draft08-session.d.ts +3 -3
  41. package/dist/draft08.d.cts +4 -4
  42. package/dist/draft08.d.ts +4 -4
  43. package/dist/draft09-session.d.cts +3 -3
  44. package/dist/draft09-session.d.ts +3 -3
  45. package/dist/draft09.d.cts +4 -4
  46. package/dist/draft09.d.ts +4 -4
  47. package/dist/draft10-session.d.cts +3 -3
  48. package/dist/draft10-session.d.ts +3 -3
  49. package/dist/draft10.d.cts +4 -4
  50. package/dist/draft10.d.ts +4 -4
  51. package/dist/draft11-session.d.cts +3 -3
  52. package/dist/draft11-session.d.ts +3 -3
  53. package/dist/draft11.d.cts +4 -4
  54. package/dist/draft11.d.ts +4 -4
  55. package/dist/draft12-session.d.cts +3 -3
  56. package/dist/draft12-session.d.ts +3 -3
  57. package/dist/draft12.d.cts +4 -4
  58. package/dist/draft12.d.ts +4 -4
  59. package/dist/draft13-session.d.cts +3 -3
  60. package/dist/draft13-session.d.ts +3 -3
  61. package/dist/draft13.d.cts +4 -4
  62. package/dist/draft13.d.ts +4 -4
  63. package/dist/draft14-session.d.cts +3 -3
  64. package/dist/draft14-session.d.ts +3 -3
  65. package/dist/draft14.d.cts +4 -4
  66. package/dist/draft14.d.ts +4 -4
  67. package/dist/draft15-session.d.cts +3 -3
  68. package/dist/draft15-session.d.ts +3 -3
  69. package/dist/draft15.d.cts +4 -4
  70. package/dist/draft15.d.ts +4 -4
  71. package/dist/draft16-session.d.cts +3 -3
  72. package/dist/draft16-session.d.ts +3 -3
  73. package/dist/draft16.d.cts +4 -4
  74. package/dist/draft16.d.ts +4 -4
  75. package/dist/draft17-session.d.cts +3 -3
  76. package/dist/draft17-session.d.ts +3 -3
  77. package/dist/draft17.d.cts +3 -3
  78. package/dist/draft17.d.ts +3 -3
  79. package/dist/draft18-session.cjs +8 -0
  80. package/dist/draft18-session.d.cts +50 -0
  81. package/dist/draft18-session.d.ts +50 -0
  82. package/dist/draft18-session.js +8 -0
  83. package/dist/draft18.cjs +179 -0
  84. package/dist/draft18.d.cts +126 -0
  85. package/dist/draft18.d.ts +126 -0
  86. package/dist/draft18.js +179 -0
  87. package/dist/draft19-session.cjs +8 -0
  88. package/dist/draft19-session.d.cts +50 -0
  89. package/dist/draft19-session.d.ts +50 -0
  90. package/dist/draft19-session.js +8 -0
  91. package/dist/draft19.cjs +189 -0
  92. package/dist/draft19.d.cts +130 -0
  93. package/dist/draft19.d.ts +130 -0
  94. package/dist/draft19.js +189 -0
  95. package/dist/index.cjs +13 -1
  96. package/dist/index.d.cts +24 -14
  97. package/dist/index.d.ts +24 -14
  98. package/dist/index.js +13 -1
  99. package/dist/{session-types-X-IYEGoG.d.ts → session-types-C0l_-Ups.d.ts} +1 -1
  100. package/dist/{session-types-C7UONex5.d.cts → session-types-KsqyVp6y.d.cts} +1 -1
  101. package/dist/session.cjs +9 -1
  102. package/dist/session.d.cts +7 -3
  103. package/dist/session.d.ts +7 -3
  104. package/dist/session.js +9 -1
  105. package/dist/{types-DuIO7cWK.d.cts → types-CdCSIfvI.d.cts} +1 -1
  106. package/dist/{types-DuIO7cWK.d.ts → types-CdCSIfvI.d.ts} +1 -1
  107. package/dist/types-Cqp10JtB.d.cts +249 -0
  108. package/dist/types-Cqp10JtB.d.ts +249 -0
  109. package/dist/types-zHgCS6o5.d.cts +265 -0
  110. package/dist/types-zHgCS6o5.d.ts +265 -0
  111. package/package.json +26 -2
  112. package/src/core/types.ts +14 -1
  113. package/src/drafts/draft17/error-codes.ts +72 -0
  114. package/src/drafts/draft18/codec.ts +1310 -0
  115. package/src/drafts/draft18/data-streams.ts +996 -0
  116. package/src/drafts/draft18/error-codes.ts +75 -0
  117. package/src/drafts/draft18/index.ts +122 -0
  118. package/src/drafts/draft18/messages.ts +56 -0
  119. package/src/drafts/draft18/rules.ts +85 -0
  120. package/src/drafts/draft18/session-fsm.ts +451 -0
  121. package/src/drafts/draft18/session.ts +15 -0
  122. package/src/drafts/draft18/types.ts +347 -0
  123. package/src/drafts/draft19/codec.ts +1425 -0
  124. package/src/drafts/draft19/data-streams.ts +996 -0
  125. package/src/drafts/draft19/error-codes.ts +78 -0
  126. package/src/drafts/draft19/index.ts +126 -0
  127. package/src/drafts/draft19/messages.ts +58 -0
  128. package/src/drafts/draft19/rules.ts +85 -0
  129. package/src/drafts/draft19/session-fsm.ts +451 -0
  130. package/src/drafts/draft19/session.ts +15 -0
  131. package/src/drafts/draft19/types.ts +368 -0
  132. package/src/index.ts +17 -1
  133. package/src/session.ts +8 -0
@@ -0,0 +1,347 @@
1
+ // Draft-18 specific message types
2
+
3
+ // Unknown parameter for passthrough
4
+ export interface UnknownParam {
5
+ readonly id: string // e.g. "0x21"
6
+ readonly length: number
7
+ readonly raw_hex: string
8
+ }
9
+
10
+ // Authorization token parameter (nested structure within length-prefixed param)
11
+ export interface AuthorizationToken {
12
+ readonly alias_type: bigint // 0=DELETE, 1=REGISTER, 2=USE_ALIAS, 3=USE_VALUE
13
+ readonly token_alias?: bigint // present for DELETE(0), REGISTER(1), USE_ALIAS(2)
14
+ readonly token_type?: bigint // present for REGISTER(1), USE_VALUE(3)
15
+ readonly token_value?: Uint8Array // present for REGISTER(1), USE_VALUE(3)
16
+ }
17
+
18
+ // Setup options (KVP encoding, no count prefix)
19
+ export interface Draft18SetupOptions {
20
+ path?: string // 0x01 odd
21
+ authorization_token?: AuthorizationToken // 0x03 odd
22
+ max_auth_token_cache_size?: bigint // 0x04 even
23
+ authority?: string // 0x05 odd
24
+ moqt_implementation?: string // 0x07 odd
25
+ unknown?: UnknownParam[]
26
+ }
27
+
28
+ // Subscription filter parameter
29
+ export interface SubscriptionFilter {
30
+ readonly filter_type: bigint
31
+ readonly start_group?: bigint
32
+ readonly start_object?: bigint
33
+ readonly end_group?: bigint
34
+ }
35
+
36
+ // Largest object location parameter
37
+ export interface LargestObject {
38
+ readonly group: bigint
39
+ readonly object: bigint
40
+ }
41
+
42
+ // Version-specific parameters (delta-encoded types, count-prefixed)
43
+ export interface Draft18Params {
44
+ object_delivery_timeout?: bigint // 0x02 varint (renamed from delivery_timeout in draft-17)
45
+ authorization_token?: AuthorizationToken // 0x03 length-prefixed nested
46
+ rendezvous_timeout?: bigint // 0x04 varint
47
+ subgroup_delivery_timeout?: bigint // 0x06 varint (NEW in draft-18)
48
+ expires?: bigint // 0x08 varint
49
+ largest_object?: LargestObject // 0x09 Location (2 bare varints)
50
+ fill_timeout?: bigint // 0x0a varint (NEW in draft-18)
51
+ forward?: bigint // 0x10 uint8 (was varint in draft-17)
52
+ subscriber_priority?: bigint // 0x20 uint8
53
+ subscription_filter?: SubscriptionFilter // 0x21 length-prefixed
54
+ group_order?: bigint // 0x22 uint8
55
+ new_group_request?: bigint // 0x32 varint
56
+ track_namespace_prefix?: string[] // 0x34 Track Namespace encoding (NEW in draft-18)
57
+ unknown?: UnknownParam[]
58
+ }
59
+
60
+ // Track properties (KVP encoding, no count prefix, read until end of payload)
61
+ export interface Draft18TrackProperties {
62
+ object_delivery_timeout?: bigint // 0x02 even varint (renamed from delivery_timeout)
63
+ max_cache_duration?: bigint // 0x04 even varint
64
+ subgroup_delivery_timeout?: bigint // 0x06 even varint (NEW in draft-18)
65
+ immutable_properties?: Uint8Array // 0x0b odd length-prefixed
66
+ default_publisher_priority?: bigint // 0x0e even varint
67
+ default_publisher_group_order?: bigint // 0x22 even varint
68
+ dynamic_groups?: bigint // 0x30 even varint
69
+ unknown?: UnknownParam[]
70
+ }
71
+
72
+ // Draft-18 message type tag union
73
+ export type Draft18MessageType =
74
+ | 'setup'
75
+ | 'subscribe'
76
+ | 'subscribe_ok'
77
+ | 'request_update'
78
+ | 'publish'
79
+ | 'publish_done'
80
+ | 'publish_namespace'
81
+ | 'namespace'
82
+ | 'namespace_done'
83
+ | 'subscribe_namespace'
84
+ | 'subscribe_tracks'
85
+ | 'publish_blocked'
86
+ | 'fetch'
87
+ | 'fetch_ok'
88
+ | 'track_status'
89
+ | 'request_ok'
90
+ | 'request_error'
91
+ | 'goaway'
92
+
93
+ // Base
94
+ export interface Draft18BaseMessage {
95
+ readonly type: Draft18MessageType
96
+ }
97
+
98
+ // Setup — single unified message (0x2F00)
99
+ export interface Draft18Setup extends Draft18BaseMessage {
100
+ readonly type: 'setup'
101
+ readonly options: Draft18SetupOptions
102
+ }
103
+
104
+ // Subscribe — Required Request ID Delta REMOVED in draft-18
105
+ export interface Draft18Subscribe extends Draft18BaseMessage {
106
+ readonly type: 'subscribe'
107
+ readonly request_id: bigint
108
+ readonly track_namespace: string[]
109
+ readonly track_name: string
110
+ readonly parameters: Draft18Params
111
+ }
112
+
113
+ export interface Draft18SubscribeOk extends Draft18BaseMessage {
114
+ readonly type: 'subscribe_ok'
115
+ readonly track_alias: bigint
116
+ readonly parameters: Draft18Params
117
+ readonly track_properties: Draft18TrackProperties
118
+ }
119
+
120
+ export interface Draft18RequestUpdate extends Draft18BaseMessage {
121
+ readonly type: 'request_update'
122
+ readonly request_id: bigint
123
+ readonly parameters: Draft18Params
124
+ }
125
+
126
+ // Publish
127
+ export interface Draft18Publish extends Draft18BaseMessage {
128
+ readonly type: 'publish'
129
+ readonly request_id: bigint
130
+ readonly track_namespace: string[]
131
+ readonly track_name: string
132
+ readonly track_alias: bigint
133
+ readonly parameters: Draft18Params
134
+ readonly track_properties: Draft18TrackProperties
135
+ }
136
+
137
+ export interface Draft18PublishDone extends Draft18BaseMessage {
138
+ readonly type: 'publish_done'
139
+ readonly status_code: bigint
140
+ readonly stream_count: bigint
141
+ readonly reason_phrase: string
142
+ }
143
+
144
+ // Namespace
145
+ export interface Draft18PublishNamespace extends Draft18BaseMessage {
146
+ readonly type: 'publish_namespace'
147
+ readonly request_id: bigint
148
+ readonly track_namespace: string[]
149
+ readonly parameters: Draft18Params
150
+ }
151
+
152
+ export interface Draft18Namespace extends Draft18BaseMessage {
153
+ readonly type: 'namespace'
154
+ readonly namespace_suffix: string[]
155
+ }
156
+
157
+ export interface Draft18NamespaceDone extends Draft18BaseMessage {
158
+ readonly type: 'namespace_done'
159
+ readonly namespace_suffix: string[]
160
+ }
161
+
162
+ // SUBSCRIBE_NAMESPACE — type 0x50, subscribe_options field removed in draft-18
163
+ export interface Draft18SubscribeNamespace extends Draft18BaseMessage {
164
+ readonly type: 'subscribe_namespace'
165
+ readonly request_id: bigint
166
+ readonly namespace_prefix: string[]
167
+ readonly parameters: Draft18Params
168
+ }
169
+
170
+ // SUBSCRIBE_TRACKS — NEW in draft-18, type 0x51
171
+ export interface Draft18SubscribeTracks extends Draft18BaseMessage {
172
+ readonly type: 'subscribe_tracks'
173
+ readonly request_id: bigint
174
+ readonly namespace_prefix: string[]
175
+ readonly parameters: Draft18Params
176
+ }
177
+
178
+ export interface Draft18PublishBlocked extends Draft18BaseMessage {
179
+ readonly type: 'publish_blocked'
180
+ readonly namespace_suffix: string[]
181
+ readonly track_name: string
182
+ }
183
+
184
+ // Fetch
185
+ export interface StandaloneFetch {
186
+ readonly track_namespace: string[]
187
+ readonly track_name: string
188
+ readonly start_group: bigint
189
+ readonly start_object: bigint
190
+ readonly end_group: bigint
191
+ readonly end_object: bigint
192
+ }
193
+
194
+ export interface JoiningFetch {
195
+ readonly joining_request_id: bigint
196
+ readonly joining_start: bigint
197
+ }
198
+
199
+ export interface Draft18Fetch extends Draft18BaseMessage {
200
+ readonly type: 'fetch'
201
+ readonly request_id: bigint
202
+ readonly fetch_type: bigint
203
+ readonly standalone?: StandaloneFetch
204
+ readonly joining?: JoiningFetch
205
+ readonly parameters: Draft18Params
206
+ }
207
+
208
+ export interface Draft18FetchOk extends Draft18BaseMessage {
209
+ readonly type: 'fetch_ok'
210
+ readonly end_of_track: number // uint8
211
+ readonly end_group: bigint
212
+ readonly end_object: bigint
213
+ readonly parameters: Draft18Params
214
+ readonly track_properties: Draft18TrackProperties
215
+ }
216
+
217
+ // Track Status — same format as subscribe in draft-18 (without required_request_id_delta)
218
+ export interface Draft18TrackStatus extends Draft18BaseMessage {
219
+ readonly type: 'track_status'
220
+ readonly request_id: bigint
221
+ readonly track_namespace: string[]
222
+ readonly track_name: string
223
+ readonly parameters: Draft18Params
224
+ }
225
+
226
+ // REQUEST_OK — gained trailing Track Properties in draft-18
227
+ export interface Draft18RequestOk extends Draft18BaseMessage {
228
+ readonly type: 'request_ok'
229
+ readonly parameters: Draft18Params
230
+ readonly track_properties: Draft18TrackProperties
231
+ }
232
+
233
+ // Redirect structure (used inside REQUEST_ERROR when error_code = REDIRECT 0x34)
234
+ export interface Redirect {
235
+ readonly connect_uri: string
236
+ readonly track_namespace: string[]
237
+ readonly track_name: string
238
+ }
239
+
240
+ export interface Draft18RequestError extends Draft18BaseMessage {
241
+ readonly type: 'request_error'
242
+ readonly error_code: bigint
243
+ readonly retry_interval: bigint
244
+ readonly reason_phrase: string
245
+ readonly redirect?: Redirect
246
+ }
247
+
248
+ // Session Control
249
+ export interface Draft18GoAway extends Draft18BaseMessage {
250
+ readonly type: 'goaway'
251
+ readonly new_session_uri: string
252
+ readonly timeout: bigint
253
+ readonly request_id?: bigint // Present only on control stream in draft-18
254
+ }
255
+
256
+ // Union of all draft-18 control messages
257
+ export type Draft18Message =
258
+ | Draft18Setup
259
+ | Draft18Subscribe
260
+ | Draft18SubscribeOk
261
+ | Draft18RequestUpdate
262
+ | Draft18Publish
263
+ | Draft18PublishDone
264
+ | Draft18PublishNamespace
265
+ | Draft18Namespace
266
+ | Draft18NamespaceDone
267
+ | Draft18SubscribeNamespace
268
+ | Draft18SubscribeTracks
269
+ | Draft18PublishBlocked
270
+ | Draft18Fetch
271
+ | Draft18FetchOk
272
+ | Draft18TrackStatus
273
+ | Draft18RequestOk
274
+ | Draft18RequestError
275
+ | Draft18GoAway
276
+
277
+ // Data stream types
278
+ export interface ObjectPayload {
279
+ readonly type: 'object'
280
+ readonly byteOffset: number
281
+ readonly payloadByteOffset: number
282
+ readonly objectId: bigint
283
+ readonly payloadLength: number
284
+ readonly status?: bigint
285
+ readonly extensionData: Uint8Array
286
+ readonly objectProperties?: Record<string, bigint>
287
+ readonly payload: Uint8Array
288
+ }
289
+
290
+ export interface SubgroupStream {
291
+ readonly type: 'subgroup'
292
+ readonly headerType: number
293
+ readonly trackAlias: bigint
294
+ readonly groupId: bigint
295
+ readonly subgroupId: bigint
296
+ readonly publisherPriority: number
297
+ readonly endOfGroup?: boolean
298
+ readonly firstObject?: boolean
299
+ readonly objects: ObjectPayload[]
300
+ }
301
+
302
+ export interface DatagramObject {
303
+ readonly type: 'datagram'
304
+ readonly datagramType: number
305
+ readonly trackAlias: bigint
306
+ readonly groupId: bigint
307
+ readonly objectId: bigint
308
+ readonly publisherPriority: number
309
+ readonly endOfGroup?: boolean
310
+ readonly objectStatus?: bigint
311
+ readonly objectProperties?: Record<string, bigint>
312
+ readonly payloadLength: number
313
+ readonly payload: Uint8Array
314
+ }
315
+
316
+ export interface FetchObjectPayload extends ObjectPayload {
317
+ readonly serializationFlags: number
318
+ readonly groupId: bigint
319
+ readonly subgroupId: bigint
320
+ readonly publisherPriority: number
321
+ readonly objectProperties?: Record<string, bigint>
322
+ }
323
+
324
+ export interface FetchStream {
325
+ readonly type: 'fetch'
326
+ readonly requestId: bigint
327
+ readonly objects: FetchObjectPayload[]
328
+ }
329
+
330
+ export type Draft18DataStream = SubgroupStream | DatagramObject | FetchStream
331
+
332
+ // Streaming data stream decoder types
333
+ export interface SubgroupStreamHeader {
334
+ readonly type: 'subgroup_header'
335
+ readonly trackAlias: bigint
336
+ readonly groupId: bigint
337
+ readonly subgroupId: bigint
338
+ readonly publisherPriority: number
339
+ }
340
+
341
+ export interface FetchStreamHeader {
342
+ readonly type: 'fetch_header'
343
+ readonly requestId: bigint
344
+ }
345
+
346
+ export type DataStreamHeader = SubgroupStreamHeader | FetchStreamHeader
347
+ export type DataStreamEvent = DataStreamHeader | ObjectPayload