moqtail 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -7
- package/dist/client-BW1agDFV.mjs +4941 -0
- package/dist/client-Z7egUKTO.cjs +5108 -0
- package/dist/client.cjs +30 -8242
- package/dist/client.d.cts +1642 -1527
- package/dist/client.d.mts +1958 -0
- package/dist/client.mjs +2 -0
- package/dist/index-DBbxKcc1.d.cts +3051 -0
- package/dist/index-DBbxKcc1.d.mts +3051 -0
- package/dist/index.cjs +298 -8963
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +5 -0
- package/dist/logger-ByDB8lYF.mjs +56 -0
- package/dist/logger-c2NoQqtx.cjs +85 -0
- package/dist/{logger-C6QS408Z.d.cts → logger-dEoueCj7.d.cts} +13 -12
- package/dist/{logger-C6QS408Z.d.ts → logger-dEoueCj7.d.mts} +13 -12
- package/dist/model.cjs +6822 -4870
- package/dist/model.d.cts +2 -442
- package/dist/model.d.mts +2 -0
- package/dist/model.mjs +6756 -0
- package/dist/util.cjs +123 -142
- package/dist/util.d.cts +29 -24
- package/dist/{util.d.ts → util.d.mts} +29 -24
- package/dist/util.mjs +121 -0
- package/package.json +19 -18
- package/dist/client.d.ts +0 -1843
- package/dist/client.js +0 -8221
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -8813
- package/dist/model.d.ts +0 -442
- package/dist/model.js +0 -4939
- package/dist/setup_parameter-BgNrJRDS.d.cts +0 -2758
- package/dist/setup_parameter-BgNrJRDS.d.ts +0 -2758
- package/dist/util.js +0 -139
package/dist/model.js
DELETED
|
@@ -1,4939 +0,0 @@
|
|
|
1
|
-
// src/model/catalog/cmsf.ts
|
|
2
|
-
function isString(v) {
|
|
3
|
-
return typeof v === "string";
|
|
4
|
-
}
|
|
5
|
-
function isNumber(v) {
|
|
6
|
-
return typeof v === "number";
|
|
7
|
-
}
|
|
8
|
-
function isStringArray(v) {
|
|
9
|
-
return Array.isArray(v) && v.every((item) => isString(item));
|
|
10
|
-
}
|
|
11
|
-
function isValidPackaging(v) {
|
|
12
|
-
return v === "cmaf" || v === "chunk-per-object" || v === "timeline";
|
|
13
|
-
}
|
|
14
|
-
function isValidRole(v) {
|
|
15
|
-
return v === "video" || v === "audio" || v === "timeline";
|
|
16
|
-
}
|
|
17
|
-
function isValidBase64(str) {
|
|
18
|
-
try {
|
|
19
|
-
return btoa(atob(str)) === str;
|
|
20
|
-
} catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function validateTrack(track) {
|
|
25
|
-
if (typeof track !== "object" || track === null) {
|
|
26
|
-
throw new Error("Track must be an object");
|
|
27
|
-
}
|
|
28
|
-
const t = track;
|
|
29
|
-
if (!isString(t["name"])) {
|
|
30
|
-
throw new Error("Track.name must be a string");
|
|
31
|
-
}
|
|
32
|
-
if (!isValidPackaging(t["packaging"])) {
|
|
33
|
-
throw new Error("Track.packaging must be 'cmaf', 'chunk-per-object', or 'timeline'");
|
|
34
|
-
}
|
|
35
|
-
if (!isValidRole(t["role"])) {
|
|
36
|
-
throw new Error("Track.role must be 'video', 'audio', or 'timeline'");
|
|
37
|
-
}
|
|
38
|
-
const name = t["name"];
|
|
39
|
-
const packaging = t["packaging"];
|
|
40
|
-
const role = t["role"];
|
|
41
|
-
let codec;
|
|
42
|
-
if (t["codec"] !== void 0) {
|
|
43
|
-
if (!isString(t["codec"])) {
|
|
44
|
-
throw new Error("Track.codec must be a string");
|
|
45
|
-
}
|
|
46
|
-
codec = t["codec"];
|
|
47
|
-
}
|
|
48
|
-
let depends;
|
|
49
|
-
if (t["depends"] !== void 0) {
|
|
50
|
-
if (!isStringArray(t["depends"])) {
|
|
51
|
-
throw new Error("Track.depends must be an array of strings");
|
|
52
|
-
}
|
|
53
|
-
depends = t["depends"];
|
|
54
|
-
}
|
|
55
|
-
let mimeType;
|
|
56
|
-
if (t["mimeType"] !== void 0) {
|
|
57
|
-
if (!isString(t["mimeType"])) {
|
|
58
|
-
throw new Error("Track.mimeType must be a string");
|
|
59
|
-
}
|
|
60
|
-
mimeType = t["mimeType"];
|
|
61
|
-
}
|
|
62
|
-
let width;
|
|
63
|
-
if (t["width"] !== void 0) {
|
|
64
|
-
if (!isNumber(t["width"])) {
|
|
65
|
-
throw new Error("Track.width must be a number");
|
|
66
|
-
}
|
|
67
|
-
width = t["width"];
|
|
68
|
-
}
|
|
69
|
-
let height;
|
|
70
|
-
if (t["height"] !== void 0) {
|
|
71
|
-
if (!isNumber(t["height"])) {
|
|
72
|
-
throw new Error("Track.height must be a number");
|
|
73
|
-
}
|
|
74
|
-
height = t["height"];
|
|
75
|
-
}
|
|
76
|
-
let timescale;
|
|
77
|
-
if (t["timescale"] !== void 0) {
|
|
78
|
-
if (!isNumber(t["timescale"])) {
|
|
79
|
-
throw new Error("Track.timescale must be a number");
|
|
80
|
-
}
|
|
81
|
-
timescale = t["timescale"];
|
|
82
|
-
}
|
|
83
|
-
let bitrate;
|
|
84
|
-
if (t["bitrate"] !== void 0) {
|
|
85
|
-
if (!isNumber(t["bitrate"])) {
|
|
86
|
-
throw new Error("Track.bitrate must be a number");
|
|
87
|
-
}
|
|
88
|
-
bitrate = t["bitrate"];
|
|
89
|
-
}
|
|
90
|
-
let initData;
|
|
91
|
-
if (t["initData"] !== void 0) {
|
|
92
|
-
if (!isString(t["initData"])) {
|
|
93
|
-
throw new Error("Track.initData must be a string");
|
|
94
|
-
}
|
|
95
|
-
if (!isValidBase64(t["initData"])) {
|
|
96
|
-
throw new Error("Track.initData must be a valid base64 string");
|
|
97
|
-
}
|
|
98
|
-
initData = t["initData"];
|
|
99
|
-
}
|
|
100
|
-
if (packaging === "cmaf" && (!codec || codec.length === 0)) {
|
|
101
|
-
throw new Error("codec is required when packaging is 'cmaf'");
|
|
102
|
-
}
|
|
103
|
-
if (packaging === "timeline" && mimeType !== "text/csv") {
|
|
104
|
-
throw new Error("mimeType must be 'text/csv' when packaging is 'timeline'");
|
|
105
|
-
}
|
|
106
|
-
if (packaging === "timeline" && (!depends || depends.length === 0)) {
|
|
107
|
-
throw new Error("At least one dependee must be present when packaging is 'timeline'");
|
|
108
|
-
}
|
|
109
|
-
const result = {
|
|
110
|
-
name,
|
|
111
|
-
packaging,
|
|
112
|
-
role
|
|
113
|
-
};
|
|
114
|
-
if (codec !== void 0) result.codec = codec;
|
|
115
|
-
if (depends !== void 0) result.depends = depends;
|
|
116
|
-
if (mimeType !== void 0) result.mimeType = mimeType;
|
|
117
|
-
if (width !== void 0) result.width = width;
|
|
118
|
-
if (height !== void 0) result.height = height;
|
|
119
|
-
if (timescale !== void 0) result.timescale = timescale;
|
|
120
|
-
if (bitrate !== void 0) result.bitrate = bitrate;
|
|
121
|
-
if (initData !== void 0) result.initData = initData;
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
function validateCMSF(obj) {
|
|
125
|
-
if (typeof obj !== "object" || obj === null) {
|
|
126
|
-
throw new Error("CMSF must be an object");
|
|
127
|
-
}
|
|
128
|
-
const o = obj;
|
|
129
|
-
if (!isNumber(o["version"])) {
|
|
130
|
-
throw new Error("CMSF.version must be a number");
|
|
131
|
-
}
|
|
132
|
-
if (!Array.isArray(o["tracks"])) {
|
|
133
|
-
throw new Error("CMSF.tracks must be an array");
|
|
134
|
-
}
|
|
135
|
-
const version = o["version"];
|
|
136
|
-
const tracksArray = o["tracks"];
|
|
137
|
-
const tracks = tracksArray.map(validateTrack);
|
|
138
|
-
return {
|
|
139
|
-
version,
|
|
140
|
-
tracks
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
var CMSFCatalog = class _CMSFCatalog {
|
|
144
|
-
#catalog;
|
|
145
|
-
constructor(catalog) {
|
|
146
|
-
this.#catalog = catalog;
|
|
147
|
-
}
|
|
148
|
-
static from(payload) {
|
|
149
|
-
const decoder = new TextDecoder();
|
|
150
|
-
const json = decoder.decode(payload);
|
|
151
|
-
const catalog = validateCMSF(JSON.parse(json));
|
|
152
|
-
return new _CMSFCatalog(catalog);
|
|
153
|
-
}
|
|
154
|
-
getByTrackName(trackName) {
|
|
155
|
-
return this.#catalog.tracks.find((track) => track.name === this.extractTrackName(trackName));
|
|
156
|
-
}
|
|
157
|
-
getTracks(role) {
|
|
158
|
-
if (role) return this.#catalog.tracks.filter((track) => track.role === role);
|
|
159
|
-
return this.#catalog.tracks;
|
|
160
|
-
}
|
|
161
|
-
getVideo(index = 0) {
|
|
162
|
-
const videos = this.#catalog.tracks.filter((track) => track.role === "video");
|
|
163
|
-
if (index < 0 || index >= videos.length) return void 0;
|
|
164
|
-
return videos[index];
|
|
165
|
-
}
|
|
166
|
-
getAudio(index = 0) {
|
|
167
|
-
const audios = this.#catalog.tracks.filter((track) => track.role === "audio");
|
|
168
|
-
if (index < 0 || index >= audios.length) return void 0;
|
|
169
|
-
return audios[index];
|
|
170
|
-
}
|
|
171
|
-
getTimeline(index = 0) {
|
|
172
|
-
const timelines = this.#catalog.tracks.filter((track) => track.role === "timeline");
|
|
173
|
-
if (index < 0 || index >= timelines.length) return void 0;
|
|
174
|
-
return timelines[index];
|
|
175
|
-
}
|
|
176
|
-
getCodecString(trackName) {
|
|
177
|
-
const track = this.#catalog.tracks.find((track2) => track2.name === this.extractTrackName(trackName));
|
|
178
|
-
if (!track) return void 0;
|
|
179
|
-
if (!track.codec) throw new Error(`Track ${trackName} does not have a codec`);
|
|
180
|
-
return track.codec;
|
|
181
|
-
}
|
|
182
|
-
getRole(trackName) {
|
|
183
|
-
const track = this.#catalog.tracks.find((track2) => track2.name === this.extractTrackName(trackName));
|
|
184
|
-
if (!track) return void 0;
|
|
185
|
-
return track.role;
|
|
186
|
-
}
|
|
187
|
-
getPackaging(trackName) {
|
|
188
|
-
const track = this.#catalog.tracks.find((track2) => track2.name === this.extractTrackName(trackName));
|
|
189
|
-
if (!track) return void 0;
|
|
190
|
-
return track.packaging;
|
|
191
|
-
}
|
|
192
|
-
isCMAF(trackName) {
|
|
193
|
-
const packaging = this.getPackaging(trackName);
|
|
194
|
-
return packaging === "cmaf" || packaging === "chunk-per-object";
|
|
195
|
-
}
|
|
196
|
-
getTimescale(trackName) {
|
|
197
|
-
const track = this.#catalog.tracks.find((track2) => track2.name === this.extractTrackName(trackName));
|
|
198
|
-
return track?.timescale;
|
|
199
|
-
}
|
|
200
|
-
getInitData(trackName) {
|
|
201
|
-
const track = this.#catalog.tracks.find((track2) => track2.name === this.extractTrackName(trackName));
|
|
202
|
-
if (!track) return void 0;
|
|
203
|
-
if (!track.initData) throw new Error(`Track ${trackName} does not have initData`);
|
|
204
|
-
return new Uint8Array(
|
|
205
|
-
atob(track.initData).split("").map((c) => c.charCodeAt(0))
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
extractTrackName(input) {
|
|
209
|
-
const parts = input.split("/");
|
|
210
|
-
return parts[parts.length - 1];
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// src/model/error/error.ts
|
|
215
|
-
var MOQtailError = class extends Error {
|
|
216
|
-
constructor(cause) {
|
|
217
|
-
super(cause);
|
|
218
|
-
this.name = this.constructor.name;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
var NotEnoughBytesError = class extends MOQtailError {
|
|
222
|
-
constructor(context, needed, available) {
|
|
223
|
-
super(`[${context}] not enough bytes: needed ${needed}, available ${available}`);
|
|
224
|
-
this.context = context;
|
|
225
|
-
this.needed = needed;
|
|
226
|
-
this.available = available;
|
|
227
|
-
}
|
|
228
|
-
context;
|
|
229
|
-
needed;
|
|
230
|
-
available;
|
|
231
|
-
};
|
|
232
|
-
var CastingError = class extends MOQtailError {
|
|
233
|
-
constructor(context, fromType, toType, details) {
|
|
234
|
-
super(`[${context}] cannot cast from ${fromType} to ${toType}, [${details}]`);
|
|
235
|
-
this.context = context;
|
|
236
|
-
this.fromType = fromType;
|
|
237
|
-
this.toType = toType;
|
|
238
|
-
this.details = details;
|
|
239
|
-
}
|
|
240
|
-
context;
|
|
241
|
-
fromType;
|
|
242
|
-
toType;
|
|
243
|
-
details;
|
|
244
|
-
};
|
|
245
|
-
var VarIntOverflowError = class extends MOQtailError {
|
|
246
|
-
constructor(context, value) {
|
|
247
|
-
super(`[${context}] value ${value} too large to encode as varint`);
|
|
248
|
-
this.context = context;
|
|
249
|
-
this.value = value;
|
|
250
|
-
}
|
|
251
|
-
context;
|
|
252
|
-
value;
|
|
253
|
-
};
|
|
254
|
-
var LengthExceedsMaxError = class extends MOQtailError {
|
|
255
|
-
constructor(context, max, len) {
|
|
256
|
-
super(`[${context}] length ${len} exceeds maximum of ${max}, protocol violation`);
|
|
257
|
-
this.context = context;
|
|
258
|
-
this.max = max;
|
|
259
|
-
this.len = len;
|
|
260
|
-
}
|
|
261
|
-
context;
|
|
262
|
-
max;
|
|
263
|
-
len;
|
|
264
|
-
};
|
|
265
|
-
var KeyValueFormattingError = class extends MOQtailError {
|
|
266
|
-
constructor(context) {
|
|
267
|
-
super(`[${context}] key value formatting error`);
|
|
268
|
-
this.context = context;
|
|
269
|
-
}
|
|
270
|
-
context;
|
|
271
|
-
};
|
|
272
|
-
var InvalidTypeError = class extends MOQtailError {
|
|
273
|
-
constructor(context, details) {
|
|
274
|
-
super(`Invalid type: [${context}], [${details}]`);
|
|
275
|
-
this.context = context;
|
|
276
|
-
this.details = details;
|
|
277
|
-
}
|
|
278
|
-
context;
|
|
279
|
-
details;
|
|
280
|
-
};
|
|
281
|
-
var InvalidUTF8Error = class extends MOQtailError {
|
|
282
|
-
constructor(context, details) {
|
|
283
|
-
super(`Invalid UTF8: [${context}], [${details}]`);
|
|
284
|
-
this.context = context;
|
|
285
|
-
this.details = details;
|
|
286
|
-
}
|
|
287
|
-
context;
|
|
288
|
-
details;
|
|
289
|
-
};
|
|
290
|
-
var ProtocolViolationError = class extends MOQtailError {
|
|
291
|
-
constructor(context, details) {
|
|
292
|
-
super(`Protocol violation: [${context}], [${details}]`);
|
|
293
|
-
this.context = context;
|
|
294
|
-
this.details = details;
|
|
295
|
-
}
|
|
296
|
-
context;
|
|
297
|
-
details;
|
|
298
|
-
};
|
|
299
|
-
var TrackNameError = class extends MOQtailError {
|
|
300
|
-
constructor(context, details) {
|
|
301
|
-
super(`Track naming error: [${context}], [${details}]`);
|
|
302
|
-
this.context = context;
|
|
303
|
-
this.details = details;
|
|
304
|
-
}
|
|
305
|
-
context;
|
|
306
|
-
details;
|
|
307
|
-
};
|
|
308
|
-
var RequestIdError = class extends MOQtailError {
|
|
309
|
-
constructor(context, details) {
|
|
310
|
-
super(`Request ID error: [${context}], [${details}]`);
|
|
311
|
-
this.context = context;
|
|
312
|
-
this.details = details;
|
|
313
|
-
}
|
|
314
|
-
context;
|
|
315
|
-
details;
|
|
316
|
-
};
|
|
317
|
-
var TimeoutError = class extends MOQtailError {
|
|
318
|
-
constructor(context) {
|
|
319
|
-
super(`Timeout: [${context}]`);
|
|
320
|
-
this.context = context;
|
|
321
|
-
}
|
|
322
|
-
context;
|
|
323
|
-
};
|
|
324
|
-
var InternalError = class extends MOQtailError {
|
|
325
|
-
constructor(context, details) {
|
|
326
|
-
super(`Internal error: [${context}], [${details}]`);
|
|
327
|
-
this.context = context;
|
|
328
|
-
this.details = details;
|
|
329
|
-
}
|
|
330
|
-
context;
|
|
331
|
-
details;
|
|
332
|
-
};
|
|
333
|
-
var TerminationError = class extends MOQtailError {
|
|
334
|
-
constructor(context, terminationCode) {
|
|
335
|
-
super(`Connection terminated with code ${terminationCode}: ${context}`);
|
|
336
|
-
this.context = context;
|
|
337
|
-
this.terminationCode = terminationCode;
|
|
338
|
-
}
|
|
339
|
-
context;
|
|
340
|
-
terminationCode;
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
// src/model/common/pair.ts
|
|
344
|
-
var MAX_VALUE_LENGTH = 2 ** 16 - 1;
|
|
345
|
-
var MAX_U64 = 2n ** 64n - 1n;
|
|
346
|
-
var KeyValuePair = class _KeyValuePair {
|
|
347
|
-
/**
|
|
348
|
-
* The key/type identifier for this pair.
|
|
349
|
-
* - Even: value is a varint.
|
|
350
|
-
* - Odd: value is a blob.
|
|
351
|
-
*/
|
|
352
|
-
typeValue;
|
|
353
|
-
/**
|
|
354
|
-
* The value for this pair.
|
|
355
|
-
* - If `typeValue` is even: a varint (`bigint`).
|
|
356
|
-
* - If `typeValue` is odd: a binary blob (`Uint8Array`).
|
|
357
|
-
*/
|
|
358
|
-
value;
|
|
359
|
-
/**
|
|
360
|
-
* Constructs a new KeyValuePair.
|
|
361
|
-
* @param typeValue - The key/type identifier.
|
|
362
|
-
* @param value - The value (varint or blob).
|
|
363
|
-
* @internal Use static factory methods instead.
|
|
364
|
-
*/
|
|
365
|
-
constructor(typeValue, value) {
|
|
366
|
-
this.typeValue = typeValue;
|
|
367
|
-
this.value = value;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Creates a new varint KeyValuePair.
|
|
371
|
-
* @param typeValue - Must be even.
|
|
372
|
-
* @param value - The varint value.
|
|
373
|
-
* @returns A KeyValuePair with varint value.
|
|
374
|
-
* @throws KeyValueFormattingError if typeValue is not even.
|
|
375
|
-
*/
|
|
376
|
-
static tryNewVarInt(typeValue, value) {
|
|
377
|
-
const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
|
|
378
|
-
if (tv % 2n !== 0n) {
|
|
379
|
-
throw new KeyValueFormattingError("KeyValuePair.tryNewVarInt");
|
|
380
|
-
}
|
|
381
|
-
const v = typeof value === "number" ? BigInt(value) : value;
|
|
382
|
-
return new _KeyValuePair(tv, v);
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Creates a new blob KeyValuePair.
|
|
386
|
-
* @param typeValue - Must be odd.
|
|
387
|
-
* @param value - The binary blob value.
|
|
388
|
-
* @returns A KeyValuePair with blob value.
|
|
389
|
-
* @throws KeyValueFormattingError if typeValue is not odd.
|
|
390
|
-
* @throws LengthExceedsMaxError if value length exceeds 65535 bytes.
|
|
391
|
-
*/
|
|
392
|
-
static tryNewBytes(typeValue, value) {
|
|
393
|
-
const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
|
|
394
|
-
if (tv % 2n === 0n) {
|
|
395
|
-
throw new KeyValueFormattingError("KeyValuePair.tryNewBytes");
|
|
396
|
-
}
|
|
397
|
-
const len = value.length;
|
|
398
|
-
if (len > MAX_VALUE_LENGTH) {
|
|
399
|
-
throw new LengthExceedsMaxError("KeyValuePair.tryNewBytes", MAX_VALUE_LENGTH, len);
|
|
400
|
-
}
|
|
401
|
-
return new _KeyValuePair(tv, value);
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Serializes this key-value pair to a frozen byte buffer.
|
|
405
|
-
* Equivalent to {@link KeyValuePair.serializeDelta} with `prevType = 0n`.
|
|
406
|
-
* @returns The serialized buffer.
|
|
407
|
-
*/
|
|
408
|
-
serialize() {
|
|
409
|
-
return this.serializeDelta(0n);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Serializes this pair's wire form, encoding the Type as a delta from
|
|
413
|
-
* `prevType` (the type of the previous KVP in the same list, or 0n if this
|
|
414
|
-
* is the first entry).
|
|
415
|
-
* @param prevType - The type of the previous KVP in the same list.
|
|
416
|
-
* @throws ProtocolViolationError if this pair's type is less than prevType
|
|
417
|
-
* (Delta Type is an unsigned varint, so the list must be sorted ascending).
|
|
418
|
-
*/
|
|
419
|
-
serializeDelta(prevType) {
|
|
420
|
-
if (this.typeValue < prevType) {
|
|
421
|
-
throw new ProtocolViolationError(
|
|
422
|
-
"KeyValuePair.serializeDelta",
|
|
423
|
-
`type ${this.typeValue} is less than previous type ${prevType}; a KVP list must be sorted by ascending type to be delta-encoded`
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
const buf = new ByteBuffer();
|
|
427
|
-
buf.putVI(this.typeValue - prevType);
|
|
428
|
-
if (isVarInt(this)) {
|
|
429
|
-
buf.putVI(this.value);
|
|
430
|
-
} else if (isBytes(this)) {
|
|
431
|
-
buf.putLengthPrefixedBytes(this.value);
|
|
432
|
-
}
|
|
433
|
-
return buf.freeze();
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* Deserializes a KeyValuePair from a buffer.
|
|
437
|
-
* Equivalent to {@link KeyValuePair.deserializeDelta} with `prevType = 0n`.
|
|
438
|
-
* @param buf - The buffer to read from.
|
|
439
|
-
* @returns The deserialized KeyValuePair.
|
|
440
|
-
* @throws LengthExceedsMaxError if blob length exceeds 65535 bytes.
|
|
441
|
-
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
442
|
-
*/
|
|
443
|
-
static deserialize(buf) {
|
|
444
|
-
return _KeyValuePair.deserializeDelta(buf, 0n);
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Deserializes a wire-form KVP whose Type field is a delta from `prevType`
|
|
448
|
-
* (the type of the previous KVP in the same list, or 0n if this is the
|
|
449
|
-
* first entry).
|
|
450
|
-
* @param buf - The buffer to read from.
|
|
451
|
-
* @param prevType - The type of the previous KVP in the same list.
|
|
452
|
-
* @throws ProtocolViolationError if prevType + delta exceeds 2^64 - 1.
|
|
453
|
-
*/
|
|
454
|
-
static deserializeDelta(buf, prevType) {
|
|
455
|
-
const deltaType = buf.getVI();
|
|
456
|
-
const typeValue = prevType + deltaType;
|
|
457
|
-
if (typeValue > MAX_U64) {
|
|
458
|
-
throw new ProtocolViolationError(
|
|
459
|
-
"KeyValuePair.deserializeDelta",
|
|
460
|
-
`previous type ${prevType} plus delta type ${deltaType} exceeds 2^64 - 1`
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
if (typeValue % 2n === 0n) {
|
|
464
|
-
const value = buf.getVI();
|
|
465
|
-
return new _KeyValuePair(typeValue, value);
|
|
466
|
-
} else {
|
|
467
|
-
const len = buf.getNumberVI();
|
|
468
|
-
if (len > MAX_VALUE_LENGTH) {
|
|
469
|
-
throw new LengthExceedsMaxError("KeyValuePair.deserialize", MAX_VALUE_LENGTH, len);
|
|
470
|
-
}
|
|
471
|
-
const value = buf.getBytes(len);
|
|
472
|
-
return new _KeyValuePair(typeValue, value);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Checks if this pair is equal to another.
|
|
477
|
-
* @param other - The other KeyValuePair.
|
|
478
|
-
* @returns True if both type and value are equal.
|
|
479
|
-
*/
|
|
480
|
-
equals(other) {
|
|
481
|
-
if (this.typeValue !== other.typeValue) return false;
|
|
482
|
-
if (isVarInt(this) && isVarInt(other)) {
|
|
483
|
-
return this.value === other.value;
|
|
484
|
-
}
|
|
485
|
-
if (isBytes(this) && isBytes(other)) {
|
|
486
|
-
const a = this.value;
|
|
487
|
-
const b = other.value;
|
|
488
|
-
if (a.length !== b.length) return false;
|
|
489
|
-
for (let i = 0; i < a.length; i++) {
|
|
490
|
-
if (a[i] !== b[i]) return false;
|
|
491
|
-
}
|
|
492
|
-
return true;
|
|
493
|
-
}
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
function serializeKvpList(items) {
|
|
498
|
-
const sorted = [...items].sort((a, b) => a.typeValue < b.typeValue ? -1 : a.typeValue > b.typeValue ? 1 : 0);
|
|
499
|
-
const buf = new ByteBuffer();
|
|
500
|
-
let prevType = 0n;
|
|
501
|
-
for (const kvp of sorted) {
|
|
502
|
-
buf.putBytes(kvp.serializeDelta(prevType).toUint8Array());
|
|
503
|
-
prevType = kvp.typeValue;
|
|
504
|
-
}
|
|
505
|
-
return buf.freeze();
|
|
506
|
-
}
|
|
507
|
-
function deserializeKvpList(buf, count) {
|
|
508
|
-
const n = typeof count === "bigint" ? Number(count) : count;
|
|
509
|
-
const items = new Array(n);
|
|
510
|
-
let prevType = 0n;
|
|
511
|
-
for (let i = 0; i < n; i++) {
|
|
512
|
-
const kvp = KeyValuePair.deserializeDelta(buf, prevType);
|
|
513
|
-
prevType = kvp.typeValue;
|
|
514
|
-
items[i] = kvp;
|
|
515
|
-
}
|
|
516
|
-
return items;
|
|
517
|
-
}
|
|
518
|
-
function deserializeKvpListUntilEmpty(buf) {
|
|
519
|
-
const items = [];
|
|
520
|
-
let prevType = 0n;
|
|
521
|
-
while (buf.remaining > 0) {
|
|
522
|
-
const kvp = KeyValuePair.deserializeDelta(buf, prevType);
|
|
523
|
-
prevType = kvp.typeValue;
|
|
524
|
-
items.push(kvp);
|
|
525
|
-
}
|
|
526
|
-
return items;
|
|
527
|
-
}
|
|
528
|
-
function isVarInt(pair) {
|
|
529
|
-
return pair.typeValue % 2n === 0n;
|
|
530
|
-
}
|
|
531
|
-
function isBytes(pair) {
|
|
532
|
-
return pair.typeValue % 2n !== 0n;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// src/model/common/location.ts
|
|
536
|
-
var Location = class _Location {
|
|
537
|
-
/**
|
|
538
|
-
* The group index for this location.
|
|
539
|
-
*/
|
|
540
|
-
group;
|
|
541
|
-
/**
|
|
542
|
-
* The object index within the group for this location.
|
|
543
|
-
*/
|
|
544
|
-
object;
|
|
545
|
-
/**
|
|
546
|
-
* Constructs a new Location.
|
|
547
|
-
* @param group - The group index (number or bigint).
|
|
548
|
-
* @param object - The object index (number or bigint).
|
|
549
|
-
*/
|
|
550
|
-
constructor(group, object) {
|
|
551
|
-
this.group = BigInt(group);
|
|
552
|
-
this.object = BigInt(object);
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* Serializes this Location to a FrozenByteBuffer.
|
|
556
|
-
* @returns The serialized buffer.
|
|
557
|
-
* @throws CastingError if group or object is negative.
|
|
558
|
-
* @throws VarIntOverflowError if group or object exceeds varint encoding limits.
|
|
559
|
-
*/
|
|
560
|
-
serialize() {
|
|
561
|
-
const buf = new ByteBuffer();
|
|
562
|
-
buf.putVI(this.group);
|
|
563
|
-
buf.putVI(this.object);
|
|
564
|
-
return buf.freeze();
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Deserializes a Location from a buffer.
|
|
568
|
-
* @param buf - The buffer to read from.
|
|
569
|
-
* @returns The deserialized Location.
|
|
570
|
-
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
571
|
-
*/
|
|
572
|
-
static deserialize(buf) {
|
|
573
|
-
const group = buf.getVI();
|
|
574
|
-
const object = buf.getVI();
|
|
575
|
-
return new _Location(group, object);
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Checks if this Location is equal to another.
|
|
579
|
-
* @param other - The other Location to compare.
|
|
580
|
-
* @returns True if both group and object are equal.
|
|
581
|
-
*/
|
|
582
|
-
equals(other) {
|
|
583
|
-
return this.group === other.group && this.object === other.object;
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Compares this Location to another for ordering.
|
|
587
|
-
* @param other - The other Location to compare.
|
|
588
|
-
* @returns -1 if this \< other, 1 if this \> other, 0 if equal.
|
|
589
|
-
*/
|
|
590
|
-
compare(other) {
|
|
591
|
-
if (this.group < other.group) return -1;
|
|
592
|
-
if (this.group > other.group) return 1;
|
|
593
|
-
if (this.object < other.object) return -1;
|
|
594
|
-
if (this.object > other.object) return 1;
|
|
595
|
-
return 0;
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
// src/model/common/tuple.ts
|
|
600
|
-
var PATH_SEPARATOR = "/";
|
|
601
|
-
var TupleField = class _TupleField {
|
|
602
|
-
/**
|
|
603
|
-
* The raw value of the field as a byte array.
|
|
604
|
-
*/
|
|
605
|
-
constructor(value) {
|
|
606
|
-
this.value = value;
|
|
607
|
-
}
|
|
608
|
-
value;
|
|
609
|
-
/**
|
|
610
|
-
* Creates a TupleField from a UTF-8 string.
|
|
611
|
-
* @param str - The string to encode.
|
|
612
|
-
* @returns A new TupleField containing the encoded value.
|
|
613
|
-
*/
|
|
614
|
-
static fromUtf8(str) {
|
|
615
|
-
return new _TupleField(new TextEncoder().encode(str));
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Decodes the field value to a UTF-8 string.
|
|
619
|
-
* @returns The decoded string.
|
|
620
|
-
*/
|
|
621
|
-
toUtf8() {
|
|
622
|
-
return new TextDecoder().decode(this.value);
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Serializes this field to a length-prefixed byte array.
|
|
626
|
-
* @returns The serialized bytes.
|
|
627
|
-
*/
|
|
628
|
-
serialize() {
|
|
629
|
-
const buf = new ByteBuffer();
|
|
630
|
-
buf.putVI(this.value.length);
|
|
631
|
-
buf.putBytes(this.value);
|
|
632
|
-
return buf.toUint8Array();
|
|
633
|
-
}
|
|
634
|
-
/**
|
|
635
|
-
* Deserializes a TupleField from a buffer.
|
|
636
|
-
* @param buf - The buffer to read from.
|
|
637
|
-
* @returns The deserialized TupleField.
|
|
638
|
-
* @throws CastingError if the length cannot be safely cast to number.
|
|
639
|
-
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
640
|
-
*/
|
|
641
|
-
static deserialize(buf) {
|
|
642
|
-
const lenBig = buf.getVI();
|
|
643
|
-
const len = Number(lenBig);
|
|
644
|
-
if (BigInt(len) !== lenBig) {
|
|
645
|
-
throw new CastingError("TupleField.deserialize", "bigint", "number", `${lenBig}`);
|
|
646
|
-
}
|
|
647
|
-
const bytes = buf.getBytes(len);
|
|
648
|
-
return new _TupleField(bytes);
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
var Tuple = class _Tuple {
|
|
652
|
-
/**
|
|
653
|
-
* The ordered list of fields in this tuple.
|
|
654
|
-
*/
|
|
655
|
-
constructor(fields = []) {
|
|
656
|
-
this.fields = fields;
|
|
657
|
-
}
|
|
658
|
-
fields;
|
|
659
|
-
/**
|
|
660
|
-
* Creates a Tuple from a path string, splitting on '/'.
|
|
661
|
-
* @param path - The path string (e.g. '/foo/bar').
|
|
662
|
-
* @returns A Tuple with each segment as a field.
|
|
663
|
-
*/
|
|
664
|
-
static fromUtf8Path(path) {
|
|
665
|
-
const parts = path.split(PATH_SEPARATOR).filter(Boolean);
|
|
666
|
-
const fields = parts.map(TupleField.fromUtf8);
|
|
667
|
-
return new _Tuple(fields);
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Converts the tuple to a path string, joining fields with '/'.
|
|
671
|
-
* @returns The path string (e.g. '/foo/bar').
|
|
672
|
-
*/
|
|
673
|
-
toUtf8Path() {
|
|
674
|
-
return this.fields.map((f) => PATH_SEPARATOR + f.toUtf8()).join("");
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Adds a field to the tuple.
|
|
678
|
-
* @param field - The TupleField to add.
|
|
679
|
-
*/
|
|
680
|
-
add(field) {
|
|
681
|
-
this.fields.push(field);
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Gets the field at the specified index.
|
|
685
|
-
* @param index - The field index.
|
|
686
|
-
* @returns The TupleField at the index.
|
|
687
|
-
* @throws Error if no field exists at the index.
|
|
688
|
-
*/
|
|
689
|
-
get(index) {
|
|
690
|
-
const field = this.fields[index];
|
|
691
|
-
if (!field) throw new Error("Field not found at index");
|
|
692
|
-
return field;
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Sets the field at the specified index.
|
|
696
|
-
* @param index - The field index.
|
|
697
|
-
* @param field - The TupleField to set.
|
|
698
|
-
*/
|
|
699
|
-
set(index, field) {
|
|
700
|
-
this.fields[index] = field;
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* Clears all fields from the tuple.
|
|
704
|
-
*/
|
|
705
|
-
clear() {
|
|
706
|
-
this.fields.length = 0;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Serializes the tuple to a FrozenByteBuffer.
|
|
710
|
-
* @returns The serialized buffer.
|
|
711
|
-
*/
|
|
712
|
-
serialize() {
|
|
713
|
-
const buf = new ByteBuffer();
|
|
714
|
-
buf.putVI(this.fields.length);
|
|
715
|
-
for (const field of this.fields) {
|
|
716
|
-
buf.putBytes(field.serialize());
|
|
717
|
-
}
|
|
718
|
-
return buf.freeze();
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Deserializes a Tuple from a buffer.
|
|
722
|
-
* @param buf - The buffer to read from.
|
|
723
|
-
* @returns The deserialized Tuple.
|
|
724
|
-
* @throws CastingError if the count cannot be safely cast to number.
|
|
725
|
-
* @throws NotEnoughBytesError if buffer does not contain enough bytes.
|
|
726
|
-
*/
|
|
727
|
-
static deserialize(buf) {
|
|
728
|
-
const countBig = buf.getVI();
|
|
729
|
-
const count = Number(countBig);
|
|
730
|
-
if (BigInt(count) !== countBig) {
|
|
731
|
-
throw new CastingError("Tuple.deserialize", "bigint", "number", `${countBig}`);
|
|
732
|
-
}
|
|
733
|
-
const fields = [];
|
|
734
|
-
for (let i = 0; i < count; i++) {
|
|
735
|
-
const field = TupleField.deserialize(buf);
|
|
736
|
-
fields.push(field);
|
|
737
|
-
}
|
|
738
|
-
return new _Tuple(fields);
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Checks if this tuple is equal to another.
|
|
742
|
-
* @param other - The other Tuple to compare.
|
|
743
|
-
* @returns True if all fields are equal.
|
|
744
|
-
*/
|
|
745
|
-
equals(other) {
|
|
746
|
-
if (this.fields.length !== other.fields.length) return false;
|
|
747
|
-
return this.fields.every((f, i) => f.value.toString() === other.fields[i].value.toString());
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
// src/model/common/reason_phrase.ts
|
|
752
|
-
var MAX_REASON_PHRASE_LEN = 1024;
|
|
753
|
-
var ReasonPhrase = class _ReasonPhrase {
|
|
754
|
-
/**
|
|
755
|
-
* The underlying phrase string.
|
|
756
|
-
* @public
|
|
757
|
-
*/
|
|
758
|
-
#phrase;
|
|
759
|
-
/**
|
|
760
|
-
* Constructs a ReasonPhrase, validating UTF-8 encoding and length.
|
|
761
|
-
*
|
|
762
|
-
* @param phrase - The string to use as the reason phrase.
|
|
763
|
-
* @throws {@link InvalidUTF8Error} if encoding fails.
|
|
764
|
-
* @throws {@link LengthExceedsMaxError} if the encoded phrase exceeds {@link MAX_REASON_PHRASE_LEN} bytes.
|
|
765
|
-
* @public
|
|
766
|
-
*/
|
|
767
|
-
constructor(phrase) {
|
|
768
|
-
let encodedPhrase;
|
|
769
|
-
try {
|
|
770
|
-
encodedPhrase = new TextEncoder().encode(phrase);
|
|
771
|
-
} catch (e) {
|
|
772
|
-
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
773
|
-
throw new InvalidUTF8Error("ReasonPhrase.constructor (TextEncoder failed)", errorMessage);
|
|
774
|
-
}
|
|
775
|
-
if (encodedPhrase.length > MAX_REASON_PHRASE_LEN) {
|
|
776
|
-
throw new LengthExceedsMaxError("ReasonPhrase.constructor", MAX_REASON_PHRASE_LEN, encodedPhrase.length);
|
|
777
|
-
}
|
|
778
|
-
this.#phrase = phrase;
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* Returns the phrase string.
|
|
782
|
-
* @public
|
|
783
|
-
*/
|
|
784
|
-
get phrase() {
|
|
785
|
-
return this.#phrase;
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Serializes the ReasonPhrase into a {@link FrozenByteBuffer} containing:
|
|
789
|
-
* varint(length_of_phrase_bytes) || phrase_bytes
|
|
790
|
-
*
|
|
791
|
-
* @returns The serialized buffer.
|
|
792
|
-
* @public
|
|
793
|
-
*/
|
|
794
|
-
serialize() {
|
|
795
|
-
const buf = new ByteBuffer();
|
|
796
|
-
const phraseBytes = new TextEncoder().encode(this.#phrase);
|
|
797
|
-
buf.putVI(phraseBytes.length);
|
|
798
|
-
buf.putBytes(phraseBytes);
|
|
799
|
-
return buf.freeze();
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* Deserializes a ReasonPhrase from the given buffer.
|
|
803
|
-
* Reads varint(length) || utf8‑bytes.
|
|
804
|
-
*
|
|
805
|
-
* @param buf - The buffer to read from.
|
|
806
|
-
* @returns The deserialized ReasonPhrase.
|
|
807
|
-
* @throws :{@link CastingError} if the length cannot be safely cast to a number.
|
|
808
|
-
* @throws :{@link LengthExceedsMaxError} if the length exceeds {@link MAX_REASON_PHRASE_LEN}.
|
|
809
|
-
* @throws :{@link NotEnoughBytesError} if the buffer does not contain enough bytes.
|
|
810
|
-
* @throws :{@link InvalidUTF8Error} if decoding fails.
|
|
811
|
-
* @public
|
|
812
|
-
*/
|
|
813
|
-
static deserialize(buf) {
|
|
814
|
-
const lenBig = buf.getVI();
|
|
815
|
-
let len;
|
|
816
|
-
try {
|
|
817
|
-
len = Number(lenBig);
|
|
818
|
-
if (BigInt(len) !== lenBig) {
|
|
819
|
-
throw new Error(`Value ${lenBig.toString()} cannot be accurately represented as a number.`);
|
|
820
|
-
}
|
|
821
|
-
} catch (e) {
|
|
822
|
-
const errorDetails = e instanceof Error ? e.message : String(e);
|
|
823
|
-
throw new CastingError("ReasonPhrase.deserialize length", "bigint", "number", errorDetails);
|
|
824
|
-
}
|
|
825
|
-
if (len > MAX_REASON_PHRASE_LEN) {
|
|
826
|
-
throw new LengthExceedsMaxError("ReasonPhrase.deserialize", MAX_REASON_PHRASE_LEN, len);
|
|
827
|
-
}
|
|
828
|
-
if (buf.remaining < len) {
|
|
829
|
-
throw new NotEnoughBytesError("ReasonPhrase.deserialize value", len, buf.remaining);
|
|
830
|
-
}
|
|
831
|
-
const phraseBytes = buf.getBytes(len);
|
|
832
|
-
try {
|
|
833
|
-
const phraseStr = new TextDecoder("utf-8", { fatal: true }).decode(phraseBytes);
|
|
834
|
-
return new _ReasonPhrase(phraseStr);
|
|
835
|
-
} catch (e) {
|
|
836
|
-
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
837
|
-
throw new InvalidUTF8Error("ReasonPhrase.deserialize (decode)", errorMessage);
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// src/model/data/constant.ts
|
|
843
|
-
var ObjectDatagramType = /* @__PURE__ */ ((ObjectDatagramType2) => {
|
|
844
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x00"] = 0] = "Type0x00";
|
|
845
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x01"] = 1] = "Type0x01";
|
|
846
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x02"] = 2] = "Type0x02";
|
|
847
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x03"] = 3] = "Type0x03";
|
|
848
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x04"] = 4] = "Type0x04";
|
|
849
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x05"] = 5] = "Type0x05";
|
|
850
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x06"] = 6] = "Type0x06";
|
|
851
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x07"] = 7] = "Type0x07";
|
|
852
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x08"] = 8] = "Type0x08";
|
|
853
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x09"] = 9] = "Type0x09";
|
|
854
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x0A"] = 10] = "Type0x0A";
|
|
855
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x0B"] = 11] = "Type0x0B";
|
|
856
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x0C"] = 12] = "Type0x0C";
|
|
857
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x0D"] = 13] = "Type0x0D";
|
|
858
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x0E"] = 14] = "Type0x0E";
|
|
859
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x0F"] = 15] = "Type0x0F";
|
|
860
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x20"] = 32] = "Type0x20";
|
|
861
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x21"] = 33] = "Type0x21";
|
|
862
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x24"] = 36] = "Type0x24";
|
|
863
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x25"] = 37] = "Type0x25";
|
|
864
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x28"] = 40] = "Type0x28";
|
|
865
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x29"] = 41] = "Type0x29";
|
|
866
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x2C"] = 44] = "Type0x2C";
|
|
867
|
-
ObjectDatagramType2[ObjectDatagramType2["Type0x2D"] = 45] = "Type0x2D";
|
|
868
|
-
return ObjectDatagramType2;
|
|
869
|
-
})(ObjectDatagramType || {});
|
|
870
|
-
((ObjectDatagramType2) => {
|
|
871
|
-
const INVALID_BITS_MASK = 208;
|
|
872
|
-
function tryFrom(value) {
|
|
873
|
-
const v = typeof value === "bigint" ? Number(value) : value;
|
|
874
|
-
if ((v & INVALID_BITS_MASK) !== 0) {
|
|
875
|
-
throw new Error(`Invalid ObjectDatagramType: ${value}, must match form 0b00X0XXXX`);
|
|
876
|
-
}
|
|
877
|
-
if ((v & 34) === 34) {
|
|
878
|
-
throw new Error(`Invalid ObjectDatagramType: ${value}, STATUS and END_OF_GROUP cannot both be set`);
|
|
879
|
-
}
|
|
880
|
-
return v;
|
|
881
|
-
}
|
|
882
|
-
ObjectDatagramType2.tryFrom = tryFrom;
|
|
883
|
-
function hasExtensions(t) {
|
|
884
|
-
return (t & 1) !== 0;
|
|
885
|
-
}
|
|
886
|
-
ObjectDatagramType2.hasExtensions = hasExtensions;
|
|
887
|
-
function isEndOfGroup(t) {
|
|
888
|
-
return (t & 2) !== 0;
|
|
889
|
-
}
|
|
890
|
-
ObjectDatagramType2.isEndOfGroup = isEndOfGroup;
|
|
891
|
-
function isZeroObjectId(t) {
|
|
892
|
-
return (t & 4) !== 0;
|
|
893
|
-
}
|
|
894
|
-
ObjectDatagramType2.isZeroObjectId = isZeroObjectId;
|
|
895
|
-
function hasDefaultPriority(t) {
|
|
896
|
-
return (t & 8) !== 0;
|
|
897
|
-
}
|
|
898
|
-
ObjectDatagramType2.hasDefaultPriority = hasDefaultPriority;
|
|
899
|
-
function isStatus(t) {
|
|
900
|
-
return (t & 32) !== 0;
|
|
901
|
-
}
|
|
902
|
-
ObjectDatagramType2.isStatus = isStatus;
|
|
903
|
-
function fromProperties(hasExtensions2, endOfGroup, objectIdIsZero, defaultPriority, isStatus2) {
|
|
904
|
-
if (isStatus2 && endOfGroup) {
|
|
905
|
-
throw new Error("PROTOCOL_VIOLATION: STATUS and END_OF_GROUP cannot both be set");
|
|
906
|
-
}
|
|
907
|
-
let type = 0;
|
|
908
|
-
if (hasExtensions2) type |= 1;
|
|
909
|
-
if (endOfGroup) type |= 2;
|
|
910
|
-
if (objectIdIsZero) type |= 4;
|
|
911
|
-
if (defaultPriority) type |= 8;
|
|
912
|
-
if (isStatus2) type |= 32;
|
|
913
|
-
return type;
|
|
914
|
-
}
|
|
915
|
-
ObjectDatagramType2.fromProperties = fromProperties;
|
|
916
|
-
})(ObjectDatagramType || (ObjectDatagramType = {}));
|
|
917
|
-
var FetchHeaderType = /* @__PURE__ */ ((FetchHeaderType2) => {
|
|
918
|
-
FetchHeaderType2[FetchHeaderType2["Type0x05"] = 5] = "Type0x05";
|
|
919
|
-
return FetchHeaderType2;
|
|
920
|
-
})(FetchHeaderType || {});
|
|
921
|
-
((FetchHeaderType2) => {
|
|
922
|
-
function tryFrom(value) {
|
|
923
|
-
const v = typeof value === "bigint" ? Number(value) : value;
|
|
924
|
-
switch (v) {
|
|
925
|
-
case 5:
|
|
926
|
-
return 5 /* Type0x05 */;
|
|
927
|
-
default:
|
|
928
|
-
throw new Error(`Invalid FetchHeaderType: ${value}`);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
FetchHeaderType2.tryFrom = tryFrom;
|
|
932
|
-
})(FetchHeaderType || (FetchHeaderType = {}));
|
|
933
|
-
var SubgroupHeaderType = /* @__PURE__ */ ((SubgroupHeaderType2) => {
|
|
934
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x10"] = 16] = "Type0x10";
|
|
935
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x11"] = 17] = "Type0x11";
|
|
936
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x12"] = 18] = "Type0x12";
|
|
937
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x13"] = 19] = "Type0x13";
|
|
938
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x14"] = 20] = "Type0x14";
|
|
939
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x15"] = 21] = "Type0x15";
|
|
940
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x18"] = 24] = "Type0x18";
|
|
941
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x19"] = 25] = "Type0x19";
|
|
942
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1A"] = 26] = "Type0x1A";
|
|
943
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1B"] = 27] = "Type0x1B";
|
|
944
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1C"] = 28] = "Type0x1C";
|
|
945
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x1D"] = 29] = "Type0x1D";
|
|
946
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x30"] = 48] = "Type0x30";
|
|
947
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x31"] = 49] = "Type0x31";
|
|
948
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x32"] = 50] = "Type0x32";
|
|
949
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x33"] = 51] = "Type0x33";
|
|
950
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x34"] = 52] = "Type0x34";
|
|
951
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x35"] = 53] = "Type0x35";
|
|
952
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x38"] = 56] = "Type0x38";
|
|
953
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x39"] = 57] = "Type0x39";
|
|
954
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x3A"] = 58] = "Type0x3A";
|
|
955
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x3B"] = 59] = "Type0x3B";
|
|
956
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x3C"] = 60] = "Type0x3C";
|
|
957
|
-
SubgroupHeaderType2[SubgroupHeaderType2["Type0x3D"] = 61] = "Type0x3D";
|
|
958
|
-
return SubgroupHeaderType2;
|
|
959
|
-
})(SubgroupHeaderType || {});
|
|
960
|
-
((SubgroupHeaderType2) => {
|
|
961
|
-
SubgroupHeaderType2.EXTENSIONS = 1;
|
|
962
|
-
SubgroupHeaderType2.SUBGROUP_ID_MODE_MASK = 6;
|
|
963
|
-
SubgroupHeaderType2.END_OF_GROUP = 8;
|
|
964
|
-
SubgroupHeaderType2.REQUIRED_BIT = 16;
|
|
965
|
-
SubgroupHeaderType2.DEFAULT_PRIORITY = 32;
|
|
966
|
-
const INVALID_BITS_MASK = 192;
|
|
967
|
-
const RESERVED_SUBGROUP_MODE = 6;
|
|
968
|
-
function hasExtensions(t) {
|
|
969
|
-
return (t & SubgroupHeaderType2.EXTENSIONS) !== 0;
|
|
970
|
-
}
|
|
971
|
-
SubgroupHeaderType2.hasExtensions = hasExtensions;
|
|
972
|
-
function hasExplicitSubgroupId(t) {
|
|
973
|
-
return (t & SubgroupHeaderType2.SUBGROUP_ID_MODE_MASK) === 4;
|
|
974
|
-
}
|
|
975
|
-
SubgroupHeaderType2.hasExplicitSubgroupId = hasExplicitSubgroupId;
|
|
976
|
-
function isSubgroupIdZero(t) {
|
|
977
|
-
return (t & SubgroupHeaderType2.SUBGROUP_ID_MODE_MASK) === 0;
|
|
978
|
-
}
|
|
979
|
-
SubgroupHeaderType2.isSubgroupIdZero = isSubgroupIdZero;
|
|
980
|
-
function isSubgroupIdFirstObjectId(t) {
|
|
981
|
-
return (t & SubgroupHeaderType2.SUBGROUP_ID_MODE_MASK) === 2;
|
|
982
|
-
}
|
|
983
|
-
SubgroupHeaderType2.isSubgroupIdFirstObjectId = isSubgroupIdFirstObjectId;
|
|
984
|
-
function containsEndOfGroup(t) {
|
|
985
|
-
return (t & SubgroupHeaderType2.END_OF_GROUP) !== 0;
|
|
986
|
-
}
|
|
987
|
-
SubgroupHeaderType2.containsEndOfGroup = containsEndOfGroup;
|
|
988
|
-
function hasDefaultPriority(t) {
|
|
989
|
-
return (t & SubgroupHeaderType2.DEFAULT_PRIORITY) !== 0;
|
|
990
|
-
}
|
|
991
|
-
SubgroupHeaderType2.hasDefaultPriority = hasDefaultPriority;
|
|
992
|
-
function tryFrom(value) {
|
|
993
|
-
const v = typeof value === "bigint" ? Number(value) : value;
|
|
994
|
-
if ((v & INVALID_BITS_MASK) !== 0) {
|
|
995
|
-
throw new Error(`Invalid SubgroupHeaderType: 0x${v.toString(16)} (invalid bits set)`);
|
|
996
|
-
}
|
|
997
|
-
if ((v & SubgroupHeaderType2.REQUIRED_BIT) === 0) {
|
|
998
|
-
throw new Error(`Invalid SubgroupHeaderType: 0x${v.toString(16)} (bit 4 not set)`);
|
|
999
|
-
}
|
|
1000
|
-
if ((v & SubgroupHeaderType2.SUBGROUP_ID_MODE_MASK) === RESERVED_SUBGROUP_MODE) {
|
|
1001
|
-
throw new Error(`Invalid SubgroupHeaderType: 0x${v.toString(16)} (reserved SUBGROUP_ID_MODE)`);
|
|
1002
|
-
}
|
|
1003
|
-
return v;
|
|
1004
|
-
}
|
|
1005
|
-
SubgroupHeaderType2.tryFrom = tryFrom;
|
|
1006
|
-
function fromProperties(hasExtensions2, subgroupIdMode, containsEndOfGroup2, hasDefaultPriority2 = false) {
|
|
1007
|
-
let t = SubgroupHeaderType2.REQUIRED_BIT;
|
|
1008
|
-
if (hasExtensions2) t |= SubgroupHeaderType2.EXTENSIONS;
|
|
1009
|
-
t |= (subgroupIdMode & 3) << 1;
|
|
1010
|
-
if (containsEndOfGroup2) t |= SubgroupHeaderType2.END_OF_GROUP;
|
|
1011
|
-
if (hasDefaultPriority2) t |= SubgroupHeaderType2.DEFAULT_PRIORITY;
|
|
1012
|
-
return t;
|
|
1013
|
-
}
|
|
1014
|
-
SubgroupHeaderType2.fromProperties = fromProperties;
|
|
1015
|
-
})(SubgroupHeaderType || (SubgroupHeaderType = {}));
|
|
1016
|
-
var ObjectForwardingPreference = /* @__PURE__ */ ((ObjectForwardingPreference2) => {
|
|
1017
|
-
ObjectForwardingPreference2["Subgroup"] = "Subgroup";
|
|
1018
|
-
ObjectForwardingPreference2["Datagram"] = "Datagram";
|
|
1019
|
-
return ObjectForwardingPreference2;
|
|
1020
|
-
})(ObjectForwardingPreference || {});
|
|
1021
|
-
((ObjectForwardingPreference2) => {
|
|
1022
|
-
function tryFrom(value) {
|
|
1023
|
-
if (value === "Subgroup") return "Subgroup" /* Subgroup */;
|
|
1024
|
-
if (value === "Datagram") return "Datagram" /* Datagram */;
|
|
1025
|
-
throw new Error(`Invalid ObjectForwardingPreference: ${value}`);
|
|
1026
|
-
}
|
|
1027
|
-
ObjectForwardingPreference2.tryFrom = tryFrom;
|
|
1028
|
-
})(ObjectForwardingPreference || (ObjectForwardingPreference = {}));
|
|
1029
|
-
var ObjectStatus = /* @__PURE__ */ ((ObjectStatus2) => {
|
|
1030
|
-
ObjectStatus2[ObjectStatus2["Normal"] = 0] = "Normal";
|
|
1031
|
-
ObjectStatus2[ObjectStatus2["EndOfGroup"] = 3] = "EndOfGroup";
|
|
1032
|
-
ObjectStatus2[ObjectStatus2["EndOfTrack"] = 4] = "EndOfTrack";
|
|
1033
|
-
return ObjectStatus2;
|
|
1034
|
-
})(ObjectStatus || {});
|
|
1035
|
-
((ObjectStatus2) => {
|
|
1036
|
-
function tryFrom(value) {
|
|
1037
|
-
const v = typeof value === "bigint" ? Number(value) : value;
|
|
1038
|
-
switch (v) {
|
|
1039
|
-
case 0:
|
|
1040
|
-
return 0 /* Normal */;
|
|
1041
|
-
case 3:
|
|
1042
|
-
return 3 /* EndOfGroup */;
|
|
1043
|
-
case 4:
|
|
1044
|
-
return 4 /* EndOfTrack */;
|
|
1045
|
-
default:
|
|
1046
|
-
throw new Error(`Invalid ObjectStatus: ${value}`);
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
ObjectStatus2.tryFrom = tryFrom;
|
|
1050
|
-
})(ObjectStatus || (ObjectStatus = {}));
|
|
1051
|
-
|
|
1052
|
-
// src/model/data/datagram.ts
|
|
1053
|
-
var Datagram = class _Datagram {
|
|
1054
|
-
constructor(type, trackAlias, location, publisherPriority, extensionHeaders, payload, objectStatus, endOfGroup) {
|
|
1055
|
-
this.type = type;
|
|
1056
|
-
this.publisherPriority = publisherPriority;
|
|
1057
|
-
this.extensionHeaders = extensionHeaders;
|
|
1058
|
-
this.payload = payload;
|
|
1059
|
-
this.objectStatus = objectStatus;
|
|
1060
|
-
this.endOfGroup = endOfGroup;
|
|
1061
|
-
this.trackAlias = BigInt(trackAlias);
|
|
1062
|
-
this.location = location;
|
|
1063
|
-
}
|
|
1064
|
-
type;
|
|
1065
|
-
publisherPriority;
|
|
1066
|
-
extensionHeaders;
|
|
1067
|
-
payload;
|
|
1068
|
-
objectStatus;
|
|
1069
|
-
endOfGroup;
|
|
1070
|
-
trackAlias;
|
|
1071
|
-
location;
|
|
1072
|
-
get groupId() {
|
|
1073
|
-
return this.location.group;
|
|
1074
|
-
}
|
|
1075
|
-
get objectId() {
|
|
1076
|
-
return this.location.object;
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* Create a new Datagram with payload content.
|
|
1080
|
-
* The type is automatically determined based on the properties.
|
|
1081
|
-
*/
|
|
1082
|
-
static newPayload(trackAlias, groupId, objectId, publisherPriority, extensionHeaders, payload, endOfGroup = false) {
|
|
1083
|
-
const hasExtensions = extensionHeaders !== null && extensionHeaders.length > 0;
|
|
1084
|
-
const objectIdIsZero = objectId === 0n;
|
|
1085
|
-
const defaultPriority = publisherPriority === null;
|
|
1086
|
-
const type = ObjectDatagramType.fromProperties(hasExtensions, endOfGroup, objectIdIsZero, defaultPriority, false);
|
|
1087
|
-
return new _Datagram(
|
|
1088
|
-
type,
|
|
1089
|
-
trackAlias,
|
|
1090
|
-
new Location(groupId, objectId),
|
|
1091
|
-
publisherPriority,
|
|
1092
|
-
hasExtensions ? extensionHeaders : null,
|
|
1093
|
-
payload,
|
|
1094
|
-
null,
|
|
1095
|
-
endOfGroup
|
|
1096
|
-
);
|
|
1097
|
-
}
|
|
1098
|
-
/**
|
|
1099
|
-
* Create a new Datagram with Object Status (no payload).
|
|
1100
|
-
* endOfGroup is always false since STATUS + END_OF_GROUP is invalid.
|
|
1101
|
-
*/
|
|
1102
|
-
static newStatus(trackAlias, groupId, objectId, publisherPriority, extensionHeaders, objectStatus) {
|
|
1103
|
-
const hasExtensions = extensionHeaders !== null && extensionHeaders.length > 0;
|
|
1104
|
-
const objectIdIsZero = objectId === 0n;
|
|
1105
|
-
const defaultPriority = publisherPriority === null;
|
|
1106
|
-
const type = ObjectDatagramType.fromProperties(hasExtensions, false, objectIdIsZero, defaultPriority, true);
|
|
1107
|
-
return new _Datagram(
|
|
1108
|
-
type,
|
|
1109
|
-
trackAlias,
|
|
1110
|
-
new Location(groupId, objectId),
|
|
1111
|
-
publisherPriority,
|
|
1112
|
-
hasExtensions ? extensionHeaders : null,
|
|
1113
|
-
null,
|
|
1114
|
-
objectStatus,
|
|
1115
|
-
false
|
|
1116
|
-
);
|
|
1117
|
-
}
|
|
1118
|
-
serialize() {
|
|
1119
|
-
const buf = new ByteBuffer();
|
|
1120
|
-
buf.putVI(this.type);
|
|
1121
|
-
buf.putVI(this.trackAlias);
|
|
1122
|
-
buf.putVI(this.location.group);
|
|
1123
|
-
if (!ObjectDatagramType.isZeroObjectId(this.type)) {
|
|
1124
|
-
buf.putVI(this.location.object);
|
|
1125
|
-
}
|
|
1126
|
-
if (!ObjectDatagramType.hasDefaultPriority(this.type)) {
|
|
1127
|
-
buf.putU8(this.publisherPriority);
|
|
1128
|
-
}
|
|
1129
|
-
if (ObjectDatagramType.hasExtensions(this.type)) {
|
|
1130
|
-
const extBytes = this.extensionHeaders ? serializeKvpList(this.extensionHeaders).toUint8Array() : new Uint8Array(0);
|
|
1131
|
-
buf.putLengthPrefixedBytes(extBytes);
|
|
1132
|
-
}
|
|
1133
|
-
if (ObjectDatagramType.isStatus(this.type)) {
|
|
1134
|
-
buf.putVI(this.objectStatus);
|
|
1135
|
-
} else {
|
|
1136
|
-
buf.putBytes(this.payload);
|
|
1137
|
-
}
|
|
1138
|
-
return buf.freeze();
|
|
1139
|
-
}
|
|
1140
|
-
static deserialize(buf) {
|
|
1141
|
-
const msgTypeRaw = buf.getNumberVI();
|
|
1142
|
-
const msgType = ObjectDatagramType.tryFrom(msgTypeRaw);
|
|
1143
|
-
const trackAlias = buf.getVI();
|
|
1144
|
-
const groupId = buf.getVI();
|
|
1145
|
-
let objectId;
|
|
1146
|
-
if (ObjectDatagramType.isZeroObjectId(msgType)) {
|
|
1147
|
-
objectId = 0n;
|
|
1148
|
-
} else {
|
|
1149
|
-
objectId = buf.getVI();
|
|
1150
|
-
}
|
|
1151
|
-
let publisherPriority;
|
|
1152
|
-
if (ObjectDatagramType.hasDefaultPriority(msgType)) {
|
|
1153
|
-
publisherPriority = null;
|
|
1154
|
-
} else {
|
|
1155
|
-
publisherPriority = buf.getU8();
|
|
1156
|
-
}
|
|
1157
|
-
let extensionHeaders = null;
|
|
1158
|
-
if (ObjectDatagramType.hasExtensions(msgType)) {
|
|
1159
|
-
const extBytes = buf.getLengthPrefixedBytes();
|
|
1160
|
-
const headerBytes = new FrozenByteBuffer5(extBytes);
|
|
1161
|
-
extensionHeaders = deserializeKvpListUntilEmpty(headerBytes);
|
|
1162
|
-
}
|
|
1163
|
-
let payload = null;
|
|
1164
|
-
let objectStatus = null;
|
|
1165
|
-
if (ObjectDatagramType.isStatus(msgType)) {
|
|
1166
|
-
objectStatus = ObjectStatus.tryFrom(buf.getVI());
|
|
1167
|
-
} else {
|
|
1168
|
-
payload = buf.getBytes(buf.remaining);
|
|
1169
|
-
}
|
|
1170
|
-
const endOfGroup = ObjectDatagramType.isEndOfGroup(msgType);
|
|
1171
|
-
return new _Datagram(
|
|
1172
|
-
msgType,
|
|
1173
|
-
trackAlias,
|
|
1174
|
-
new Location(groupId, objectId),
|
|
1175
|
-
publisherPriority,
|
|
1176
|
-
extensionHeaders,
|
|
1177
|
-
payload,
|
|
1178
|
-
objectStatus,
|
|
1179
|
-
endOfGroup
|
|
1180
|
-
);
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
|
|
1184
|
-
// src/model/data/fetch_header.ts
|
|
1185
|
-
var FetchHeader = class _FetchHeader {
|
|
1186
|
-
constructor(type, requestId) {
|
|
1187
|
-
this.type = type;
|
|
1188
|
-
this.requestId = BigInt(requestId);
|
|
1189
|
-
}
|
|
1190
|
-
type;
|
|
1191
|
-
requestId;
|
|
1192
|
-
serialize() {
|
|
1193
|
-
const buf = new ByteBuffer();
|
|
1194
|
-
buf.putVI(this.type);
|
|
1195
|
-
buf.putVI(this.requestId);
|
|
1196
|
-
return buf.freeze();
|
|
1197
|
-
}
|
|
1198
|
-
static deserialize(buf) {
|
|
1199
|
-
const typeRaw = buf.getVI();
|
|
1200
|
-
const type = FetchHeaderType.tryFrom(typeRaw);
|
|
1201
|
-
const requestId = buf.getVI();
|
|
1202
|
-
return new _FetchHeader(type, requestId);
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
|
|
1206
|
-
// src/model/data/fetch_object.ts
|
|
1207
|
-
var FLAG_SUBGROUP_MODE_MASK = 3;
|
|
1208
|
-
var FLAG_OBJECT_ID_PRESENT = 4;
|
|
1209
|
-
var FLAG_GROUP_ID_PRESENT = 8;
|
|
1210
|
-
var FLAG_PRIORITY_PRESENT = 16;
|
|
1211
|
-
var FLAG_EXTENSIONS_PRESENT = 32;
|
|
1212
|
-
var FLAG_DATAGRAM = 64;
|
|
1213
|
-
var SUBGROUP_MODE_ZERO = 0;
|
|
1214
|
-
var SUBGROUP_MODE_PRIOR = 1;
|
|
1215
|
-
var SUBGROUP_MODE_PRIOR_PLUS_ONE = 2;
|
|
1216
|
-
var SUBGROUP_MODE_PRESENT = 3;
|
|
1217
|
-
var END_OF_NON_EXISTENT_RANGE = 0x8cn;
|
|
1218
|
-
var END_OF_UNKNOWN_RANGE = 0x10cn;
|
|
1219
|
-
var EndOfRangeKind = /* @__PURE__ */ ((EndOfRangeKind2) => {
|
|
1220
|
-
EndOfRangeKind2[EndOfRangeKind2["NonExistent"] = 140] = "NonExistent";
|
|
1221
|
-
EndOfRangeKind2[EndOfRangeKind2["Unknown"] = 268] = "Unknown";
|
|
1222
|
-
return EndOfRangeKind2;
|
|
1223
|
-
})(EndOfRangeKind || {});
|
|
1224
|
-
var FetchObject = class _FetchObject {
|
|
1225
|
-
constructor(kind, location, subgroupId, publisherPriority, forwardingPreference, extensionHeaders, payload, endOfRange) {
|
|
1226
|
-
this.kind = kind;
|
|
1227
|
-
this.publisherPriority = publisherPriority;
|
|
1228
|
-
this.forwardingPreference = forwardingPreference;
|
|
1229
|
-
this.extensionHeaders = extensionHeaders;
|
|
1230
|
-
this.payload = payload;
|
|
1231
|
-
this.endOfRange = endOfRange;
|
|
1232
|
-
this.location = location;
|
|
1233
|
-
this.subgroupId = BigInt(subgroupId);
|
|
1234
|
-
}
|
|
1235
|
-
kind;
|
|
1236
|
-
publisherPriority;
|
|
1237
|
-
forwardingPreference;
|
|
1238
|
-
extensionHeaders;
|
|
1239
|
-
payload;
|
|
1240
|
-
endOfRange;
|
|
1241
|
-
location;
|
|
1242
|
-
subgroupId;
|
|
1243
|
-
get groupId() {
|
|
1244
|
-
return this.location.group;
|
|
1245
|
-
}
|
|
1246
|
-
get objectId() {
|
|
1247
|
-
return this.location.object;
|
|
1248
|
-
}
|
|
1249
|
-
/**
|
|
1250
|
-
* Context to thread into the next call on this stream.
|
|
1251
|
-
* Returns null for EndOfRange markers — they MUST NOT update prior state.
|
|
1252
|
-
*/
|
|
1253
|
-
toContext() {
|
|
1254
|
-
if (this.kind === "end_of_range") return null;
|
|
1255
|
-
return {
|
|
1256
|
-
groupId: this.groupId,
|
|
1257
|
-
subgroupId: this.subgroupId,
|
|
1258
|
-
objectId: this.objectId,
|
|
1259
|
-
publisherPriority: this.publisherPriority
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
static newObject(groupId, subgroupId, objectId, publisherPriority, forwardingPreference, extensionHeaders, payload) {
|
|
1263
|
-
return new _FetchObject(
|
|
1264
|
-
"object",
|
|
1265
|
-
new Location(groupId, objectId),
|
|
1266
|
-
subgroupId,
|
|
1267
|
-
publisherPriority,
|
|
1268
|
-
forwardingPreference,
|
|
1269
|
-
extensionHeaders,
|
|
1270
|
-
payload,
|
|
1271
|
-
null
|
|
1272
|
-
);
|
|
1273
|
-
}
|
|
1274
|
-
static newEndOfRange(kind, groupId, objectId) {
|
|
1275
|
-
return new _FetchObject(
|
|
1276
|
-
"end_of_range",
|
|
1277
|
-
new Location(groupId, objectId),
|
|
1278
|
-
0,
|
|
1279
|
-
0,
|
|
1280
|
-
"Subgroup" /* Subgroup */,
|
|
1281
|
-
null,
|
|
1282
|
-
null,
|
|
1283
|
-
kind
|
|
1284
|
-
);
|
|
1285
|
-
}
|
|
1286
|
-
serialize(prev) {
|
|
1287
|
-
const buf = new ByteBuffer();
|
|
1288
|
-
if (this.kind === "end_of_range") {
|
|
1289
|
-
buf.putVI(this.endOfRange === 140 /* NonExistent */ ? END_OF_NON_EXISTENT_RANGE : END_OF_UNKNOWN_RANGE);
|
|
1290
|
-
buf.putVI(this.groupId);
|
|
1291
|
-
buf.putVI(this.objectId);
|
|
1292
|
-
return buf.freeze();
|
|
1293
|
-
}
|
|
1294
|
-
const isDatagram = this.forwardingPreference === "Datagram" /* Datagram */;
|
|
1295
|
-
const hasExtensions = !!(this.extensionHeaders && this.extensionHeaders.length > 0);
|
|
1296
|
-
let hasGroupId;
|
|
1297
|
-
let hasObjectId;
|
|
1298
|
-
let hasPriority;
|
|
1299
|
-
let subgroupMode;
|
|
1300
|
-
if (!prev) {
|
|
1301
|
-
hasGroupId = true;
|
|
1302
|
-
hasObjectId = true;
|
|
1303
|
-
hasPriority = true;
|
|
1304
|
-
subgroupMode = isDatagram || this.subgroupId === 0n ? SUBGROUP_MODE_ZERO : SUBGROUP_MODE_PRESENT;
|
|
1305
|
-
} else {
|
|
1306
|
-
hasGroupId = prev.groupId !== this.groupId;
|
|
1307
|
-
hasObjectId = prev.objectId + 1n !== this.objectId;
|
|
1308
|
-
hasPriority = prev.publisherPriority !== this.publisherPriority;
|
|
1309
|
-
if (isDatagram) {
|
|
1310
|
-
subgroupMode = SUBGROUP_MODE_ZERO;
|
|
1311
|
-
} else if (this.subgroupId === 0n) {
|
|
1312
|
-
subgroupMode = SUBGROUP_MODE_ZERO;
|
|
1313
|
-
} else if (prev.subgroupId === this.subgroupId) {
|
|
1314
|
-
subgroupMode = SUBGROUP_MODE_PRIOR;
|
|
1315
|
-
} else if (prev.subgroupId + 1n === this.subgroupId) {
|
|
1316
|
-
subgroupMode = SUBGROUP_MODE_PRIOR_PLUS_ONE;
|
|
1317
|
-
} else {
|
|
1318
|
-
subgroupMode = SUBGROUP_MODE_PRESENT;
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
let flags = subgroupMode & FLAG_SUBGROUP_MODE_MASK;
|
|
1322
|
-
if (hasObjectId) flags |= FLAG_OBJECT_ID_PRESENT;
|
|
1323
|
-
if (hasGroupId) flags |= FLAG_GROUP_ID_PRESENT;
|
|
1324
|
-
if (hasPriority) flags |= FLAG_PRIORITY_PRESENT;
|
|
1325
|
-
if (hasExtensions) flags |= FLAG_EXTENSIONS_PRESENT;
|
|
1326
|
-
if (isDatagram) flags |= FLAG_DATAGRAM;
|
|
1327
|
-
buf.putVI(flags);
|
|
1328
|
-
if (hasGroupId) buf.putVI(this.groupId);
|
|
1329
|
-
if (!isDatagram && subgroupMode === SUBGROUP_MODE_PRESENT) buf.putVI(this.subgroupId);
|
|
1330
|
-
if (hasObjectId) buf.putVI(this.objectId);
|
|
1331
|
-
if (hasPriority) buf.putU8(this.publisherPriority);
|
|
1332
|
-
if (hasExtensions) {
|
|
1333
|
-
buf.putLengthPrefixedBytes(serializeKvpList(this.extensionHeaders).toUint8Array());
|
|
1334
|
-
}
|
|
1335
|
-
const payloadBytes = this.payload ?? new Uint8Array(0);
|
|
1336
|
-
buf.putLengthPrefixedBytes(payloadBytes);
|
|
1337
|
-
return buf.freeze();
|
|
1338
|
-
}
|
|
1339
|
-
static deserialize(buf, prev) {
|
|
1340
|
-
const flagsRaw = buf.getVI();
|
|
1341
|
-
if (flagsRaw >= 128n) {
|
|
1342
|
-
let kind;
|
|
1343
|
-
if (flagsRaw === END_OF_NON_EXISTENT_RANGE) {
|
|
1344
|
-
kind = 140 /* NonExistent */;
|
|
1345
|
-
} else if (flagsRaw === END_OF_UNKNOWN_RANGE) {
|
|
1346
|
-
kind = 268 /* Unknown */;
|
|
1347
|
-
} else {
|
|
1348
|
-
throw new ProtocolViolationError(
|
|
1349
|
-
"FetchObject.deserialize",
|
|
1350
|
-
`invalid Serialization Flags value 0x${flagsRaw.toString(16)}`
|
|
1351
|
-
);
|
|
1352
|
-
}
|
|
1353
|
-
const groupId2 = buf.getVI();
|
|
1354
|
-
const objectId2 = buf.getVI();
|
|
1355
|
-
return _FetchObject.newEndOfRange(kind, groupId2, objectId2);
|
|
1356
|
-
}
|
|
1357
|
-
const flags = Number(flagsRaw);
|
|
1358
|
-
const subgroupMode = flags & FLAG_SUBGROUP_MODE_MASK;
|
|
1359
|
-
const hasObjectId = (flags & FLAG_OBJECT_ID_PRESENT) !== 0;
|
|
1360
|
-
const hasGroupId = (flags & FLAG_GROUP_ID_PRESENT) !== 0;
|
|
1361
|
-
const hasPriority = (flags & FLAG_PRIORITY_PRESENT) !== 0;
|
|
1362
|
-
const hasExtensions = (flags & FLAG_EXTENSIONS_PRESENT) !== 0;
|
|
1363
|
-
const isDatagram = (flags & FLAG_DATAGRAM) !== 0;
|
|
1364
|
-
if (!prev) {
|
|
1365
|
-
if (!hasObjectId || !hasGroupId || !hasPriority) {
|
|
1366
|
-
throw new ProtocolViolationError(
|
|
1367
|
-
"FetchObject.deserialize",
|
|
1368
|
-
"first object must carry explicit group/object/priority"
|
|
1369
|
-
);
|
|
1370
|
-
}
|
|
1371
|
-
if (!isDatagram && (subgroupMode === SUBGROUP_MODE_PRIOR || subgroupMode === SUBGROUP_MODE_PRIOR_PLUS_ONE)) {
|
|
1372
|
-
throw new ProtocolViolationError("FetchObject.deserialize", "first object cannot reference prior subgroup");
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
const groupId = hasGroupId ? buf.getVI() : (() => {
|
|
1376
|
-
if (!prev)
|
|
1377
|
-
throw new ProtocolViolationError("FetchObject.deserialize", "group_id inherited but no prior object");
|
|
1378
|
-
return prev.groupId;
|
|
1379
|
-
})();
|
|
1380
|
-
let subgroupId;
|
|
1381
|
-
if (isDatagram) {
|
|
1382
|
-
subgroupId = 0n;
|
|
1383
|
-
} else {
|
|
1384
|
-
switch (subgroupMode) {
|
|
1385
|
-
case SUBGROUP_MODE_ZERO:
|
|
1386
|
-
subgroupId = 0n;
|
|
1387
|
-
break;
|
|
1388
|
-
case SUBGROUP_MODE_PRIOR:
|
|
1389
|
-
if (!prev)
|
|
1390
|
-
throw new ProtocolViolationError("FetchObject.deserialize", "subgroup_id inherited but no prior object");
|
|
1391
|
-
subgroupId = prev.subgroupId;
|
|
1392
|
-
break;
|
|
1393
|
-
case SUBGROUP_MODE_PRIOR_PLUS_ONE:
|
|
1394
|
-
if (!prev)
|
|
1395
|
-
throw new ProtocolViolationError("FetchObject.deserialize", "subgroup_id inherited but no prior object");
|
|
1396
|
-
subgroupId = prev.subgroupId + 1n;
|
|
1397
|
-
break;
|
|
1398
|
-
case SUBGROUP_MODE_PRESENT:
|
|
1399
|
-
subgroupId = buf.getVI();
|
|
1400
|
-
break;
|
|
1401
|
-
default:
|
|
1402
|
-
throw new ProtocolViolationError("FetchObject.deserialize", `invalid subgroup mode ${subgroupMode}`);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
const objectId = hasObjectId ? buf.getVI() : (() => {
|
|
1406
|
-
if (!prev)
|
|
1407
|
-
throw new ProtocolViolationError("FetchObject.deserialize", "object_id inherited but no prior object");
|
|
1408
|
-
return prev.objectId + 1n;
|
|
1409
|
-
})();
|
|
1410
|
-
const publisherPriority = hasPriority ? buf.getU8() : (() => {
|
|
1411
|
-
if (!prev)
|
|
1412
|
-
throw new ProtocolViolationError("FetchObject.deserialize", "priority inherited but no prior object");
|
|
1413
|
-
return prev.publisherPriority;
|
|
1414
|
-
})();
|
|
1415
|
-
let extensionHeaders = null;
|
|
1416
|
-
if (hasExtensions) {
|
|
1417
|
-
const extLen = buf.getNumberVI();
|
|
1418
|
-
const headerBytes = new FrozenByteBuffer5(buf.getBytes(extLen));
|
|
1419
|
-
extensionHeaders = deserializeKvpListUntilEmpty(headerBytes);
|
|
1420
|
-
}
|
|
1421
|
-
const payloadLen = buf.getNumberVI();
|
|
1422
|
-
const payload = buf.getBytes(payloadLen);
|
|
1423
|
-
const forwardingPreference = isDatagram ? "Datagram" /* Datagram */ : "Subgroup" /* Subgroup */;
|
|
1424
|
-
const resolvedSubgroupId = isDatagram ? objectId : subgroupId;
|
|
1425
|
-
return _FetchObject.newObject(
|
|
1426
|
-
groupId,
|
|
1427
|
-
resolvedSubgroupId,
|
|
1428
|
-
objectId,
|
|
1429
|
-
publisherPriority,
|
|
1430
|
-
forwardingPreference,
|
|
1431
|
-
extensionHeaders,
|
|
1432
|
-
payload
|
|
1433
|
-
);
|
|
1434
|
-
}
|
|
1435
|
-
};
|
|
1436
|
-
|
|
1437
|
-
// src/model/data/full_track_name.ts
|
|
1438
|
-
var MAX_NAMESPACE_TUPLE_COUNT = 32;
|
|
1439
|
-
var MAX_FULL_TRACK_NAME_LENGTH = 4096;
|
|
1440
|
-
var FullTrackName = class _FullTrackName {
|
|
1441
|
-
constructor(namespace, name) {
|
|
1442
|
-
this.namespace = namespace;
|
|
1443
|
-
this.name = name;
|
|
1444
|
-
}
|
|
1445
|
-
namespace;
|
|
1446
|
-
name;
|
|
1447
|
-
/**
|
|
1448
|
-
* Human-readable representation: `\<namespace path joined by '/'\>:\<name as lowercase hex\>`.
|
|
1449
|
-
* If the underlying {@link Tuple} exposes `toUtf8Path`, it's used; otherwise the raw fields are joined.
|
|
1450
|
-
* This is lossy only in the sense that name bytes are hex encoded; round-tripping requires serialization.
|
|
1451
|
-
*/
|
|
1452
|
-
toString() {
|
|
1453
|
-
const nsStr = this.namespace.toUtf8Path ? this.namespace.toUtf8Path() : Array.from(this.namespace.fields).join("/");
|
|
1454
|
-
const nameStr = Array.from(this.name).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1455
|
-
return `${nsStr}:${nameStr}`;
|
|
1456
|
-
}
|
|
1457
|
-
/**
|
|
1458
|
-
* Construct a validated full track name.
|
|
1459
|
-
*
|
|
1460
|
-
* Validation steps:
|
|
1461
|
-
* 1. Convert namespace string -\> {@link Tuple} (split on '/') if needed.
|
|
1462
|
-
* 2. Reject if namespace tuple field count is 0 or \> {@link MAX_NAMESPACE_TUPLE_COUNT}.
|
|
1463
|
-
* 3. Encode name string to UTF-8 if needed.
|
|
1464
|
-
* 4. Reject if total serialized length (namespace tuple + name bytes) \> {@link MAX_FULL_TRACK_NAME_LENGTH}.
|
|
1465
|
-
*
|
|
1466
|
-
* @throws :{@link TrackNameError} on any constraint violation.
|
|
1467
|
-
* @example
|
|
1468
|
-
* ```ts
|
|
1469
|
-
* const full = FullTrackName.tryNew('media/video', 'keyframe')
|
|
1470
|
-
* console.log(full.toString()) // media/video:6b65796672616d65
|
|
1471
|
-
* ```
|
|
1472
|
-
*/
|
|
1473
|
-
static tryNew(namespace, name) {
|
|
1474
|
-
const nsTuple = typeof namespace === "string" ? Tuple.fromUtf8Path(namespace) : namespace;
|
|
1475
|
-
const nsCount = nsTuple.fields.length;
|
|
1476
|
-
if (nsCount === 0 || nsCount > MAX_NAMESPACE_TUPLE_COUNT) {
|
|
1477
|
-
throw new TrackNameError(
|
|
1478
|
-
"FullTrackName::tryNew(nsCount)",
|
|
1479
|
-
`Namespace cannot be empty or cannot exceed ${MAX_NAMESPACE_TUPLE_COUNT} fields`
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
const nameBytes = typeof name === "string" ? new TextEncoder().encode(name) : name;
|
|
1483
|
-
const totalLen = nsTuple.serialize().toUint8Array().length + nameBytes.length;
|
|
1484
|
-
if (totalLen > MAX_FULL_TRACK_NAME_LENGTH) {
|
|
1485
|
-
throw new TrackNameError(
|
|
1486
|
-
"FullTrackName::tryNew(totalLen)",
|
|
1487
|
-
`Total length cannot exceed ${MAX_FULL_TRACK_NAME_LENGTH}`
|
|
1488
|
-
);
|
|
1489
|
-
}
|
|
1490
|
-
return new _FullTrackName(nsTuple, nameBytes);
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* Serialize to a frozen buffer: tuple (namespace) followed by length‑prefixed name bytes.
|
|
1494
|
-
* Consumers needing raw bytes should call `.toUint8Array()` on the returned {@link FrozenByteBuffer}.
|
|
1495
|
-
*/
|
|
1496
|
-
serialize() {
|
|
1497
|
-
const buf = new ByteBuffer();
|
|
1498
|
-
buf.putTuple(this.namespace);
|
|
1499
|
-
buf.putLengthPrefixedBytes(this.name);
|
|
1500
|
-
return buf.freeze();
|
|
1501
|
-
}
|
|
1502
|
-
/**
|
|
1503
|
-
* Parse a serialized full track name. Performs the same validations as {@link FullTrackName.tryNew}.
|
|
1504
|
-
* The provided buffer's read cursor advances accordingly.
|
|
1505
|
-
* @throws :{@link TrackNameError} if constraints are violated.
|
|
1506
|
-
*/
|
|
1507
|
-
static deserialize(buf) {
|
|
1508
|
-
const namespace = buf.getTuple();
|
|
1509
|
-
const nsCount = namespace.fields.length;
|
|
1510
|
-
if (nsCount === 0 || nsCount > MAX_NAMESPACE_TUPLE_COUNT) {
|
|
1511
|
-
throw new TrackNameError(
|
|
1512
|
-
"FullTrackName::deserialize(nsCount)",
|
|
1513
|
-
`Namespace cannot be empty or cannot exceed ${MAX_NAMESPACE_TUPLE_COUNT} fields`
|
|
1514
|
-
);
|
|
1515
|
-
}
|
|
1516
|
-
const name = buf.getLengthPrefixedBytes();
|
|
1517
|
-
const totalLen = namespace.serialize().toUint8Array().length + name.length;
|
|
1518
|
-
if (totalLen > MAX_FULL_TRACK_NAME_LENGTH) {
|
|
1519
|
-
throw new TrackNameError(
|
|
1520
|
-
"FullTrackName::deserialize(totalLen)",
|
|
1521
|
-
`Total length cannot exceed ${MAX_FULL_TRACK_NAME_LENGTH}`
|
|
1522
|
-
);
|
|
1523
|
-
}
|
|
1524
|
-
return new _FullTrackName(namespace, name);
|
|
1525
|
-
}
|
|
1526
|
-
};
|
|
1527
|
-
|
|
1528
|
-
// src/model/error/constant.ts
|
|
1529
|
-
var TerminationCode = /* @__PURE__ */ ((TerminationCode2) => {
|
|
1530
|
-
TerminationCode2[TerminationCode2["NO_ERROR"] = 0] = "NO_ERROR";
|
|
1531
|
-
TerminationCode2[TerminationCode2["INTERNAL_ERROR"] = 1] = "INTERNAL_ERROR";
|
|
1532
|
-
TerminationCode2[TerminationCode2["UNAUTHORIZED"] = 2] = "UNAUTHORIZED";
|
|
1533
|
-
TerminationCode2[TerminationCode2["PROTOCOL_VIOLATION"] = 3] = "PROTOCOL_VIOLATION";
|
|
1534
|
-
TerminationCode2[TerminationCode2["INVALID_REQUEST_ID"] = 4] = "INVALID_REQUEST_ID";
|
|
1535
|
-
TerminationCode2[TerminationCode2["DUPLICATE_TRACK_ALIAS"] = 5] = "DUPLICATE_TRACK_ALIAS";
|
|
1536
|
-
TerminationCode2[TerminationCode2["KEY_VALUE_FORMATTING_ERROR"] = 6] = "KEY_VALUE_FORMATTING_ERROR";
|
|
1537
|
-
TerminationCode2[TerminationCode2["TOO_MANY_REQUESTS"] = 7] = "TOO_MANY_REQUESTS";
|
|
1538
|
-
TerminationCode2[TerminationCode2["INVALID_PATH"] = 8] = "INVALID_PATH";
|
|
1539
|
-
TerminationCode2[TerminationCode2["MALFORMED_PATH"] = 9] = "MALFORMED_PATH";
|
|
1540
|
-
TerminationCode2[TerminationCode2["GOAWAY_TIMEOUT"] = 16] = "GOAWAY_TIMEOUT";
|
|
1541
|
-
TerminationCode2[TerminationCode2["CONTROL_MESSAGE_TIMEOUT"] = 17] = "CONTROL_MESSAGE_TIMEOUT";
|
|
1542
|
-
TerminationCode2[TerminationCode2["DATA_STREAM_TIMEOUT"] = 18] = "DATA_STREAM_TIMEOUT";
|
|
1543
|
-
TerminationCode2[TerminationCode2["AUTH_TOKEN_CACHE_OVERFLOW"] = 19] = "AUTH_TOKEN_CACHE_OVERFLOW";
|
|
1544
|
-
TerminationCode2[TerminationCode2["DUPLICATE_AUTH_TOKEN_ALIAS"] = 20] = "DUPLICATE_AUTH_TOKEN_ALIAS";
|
|
1545
|
-
TerminationCode2[TerminationCode2["VERSION_NEGOTIATION_FAILED"] = 21] = "VERSION_NEGOTIATION_FAILED";
|
|
1546
|
-
TerminationCode2[TerminationCode2["MALFORMED_AUTH_TOKEN"] = 22] = "MALFORMED_AUTH_TOKEN";
|
|
1547
|
-
TerminationCode2[TerminationCode2["UNKNOWN_AUTH_TOKEN_ALIAS"] = 23] = "UNKNOWN_AUTH_TOKEN_ALIAS";
|
|
1548
|
-
TerminationCode2[TerminationCode2["EXPIRED_AUTH_TOKEN"] = 24] = "EXPIRED_AUTH_TOKEN";
|
|
1549
|
-
TerminationCode2[TerminationCode2["INVALID_AUTHORITY"] = 25] = "INVALID_AUTHORITY";
|
|
1550
|
-
TerminationCode2[TerminationCode2["MALFORMED_AUTHORITY"] = 26] = "MALFORMED_AUTHORITY";
|
|
1551
|
-
return TerminationCode2;
|
|
1552
|
-
})(TerminationCode || {});
|
|
1553
|
-
((TerminationCode2) => {
|
|
1554
|
-
function tryFrom(code) {
|
|
1555
|
-
switch (code) {
|
|
1556
|
-
case 0 /* NO_ERROR */:
|
|
1557
|
-
return 0 /* NO_ERROR */;
|
|
1558
|
-
case 1 /* INTERNAL_ERROR */:
|
|
1559
|
-
return 1 /* INTERNAL_ERROR */;
|
|
1560
|
-
case 2 /* UNAUTHORIZED */:
|
|
1561
|
-
return 2 /* UNAUTHORIZED */;
|
|
1562
|
-
case 3 /* PROTOCOL_VIOLATION */:
|
|
1563
|
-
return 3 /* PROTOCOL_VIOLATION */;
|
|
1564
|
-
case 4 /* INVALID_REQUEST_ID */:
|
|
1565
|
-
return 4 /* INVALID_REQUEST_ID */;
|
|
1566
|
-
case 5 /* DUPLICATE_TRACK_ALIAS */:
|
|
1567
|
-
return 5 /* DUPLICATE_TRACK_ALIAS */;
|
|
1568
|
-
case 6 /* KEY_VALUE_FORMATTING_ERROR */:
|
|
1569
|
-
return 6 /* KEY_VALUE_FORMATTING_ERROR */;
|
|
1570
|
-
case 7 /* TOO_MANY_REQUESTS */:
|
|
1571
|
-
return 7 /* TOO_MANY_REQUESTS */;
|
|
1572
|
-
case 8 /* INVALID_PATH */:
|
|
1573
|
-
return 8 /* INVALID_PATH */;
|
|
1574
|
-
case 9 /* MALFORMED_PATH */:
|
|
1575
|
-
return 9 /* MALFORMED_PATH */;
|
|
1576
|
-
case 16 /* GOAWAY_TIMEOUT */:
|
|
1577
|
-
return 16 /* GOAWAY_TIMEOUT */;
|
|
1578
|
-
case 17 /* CONTROL_MESSAGE_TIMEOUT */:
|
|
1579
|
-
return 17 /* CONTROL_MESSAGE_TIMEOUT */;
|
|
1580
|
-
case 18 /* DATA_STREAM_TIMEOUT */:
|
|
1581
|
-
return 18 /* DATA_STREAM_TIMEOUT */;
|
|
1582
|
-
case 19 /* AUTH_TOKEN_CACHE_OVERFLOW */:
|
|
1583
|
-
return 19 /* AUTH_TOKEN_CACHE_OVERFLOW */;
|
|
1584
|
-
case 20 /* DUPLICATE_AUTH_TOKEN_ALIAS */:
|
|
1585
|
-
return 20 /* DUPLICATE_AUTH_TOKEN_ALIAS */;
|
|
1586
|
-
case 21 /* VERSION_NEGOTIATION_FAILED */:
|
|
1587
|
-
return 21 /* VERSION_NEGOTIATION_FAILED */;
|
|
1588
|
-
default:
|
|
1589
|
-
throw new InvalidTypeError("TerminationCode.tryFrom", `Unknown termination code: ${code}`);
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
TerminationCode2.tryFrom = tryFrom;
|
|
1593
|
-
})(TerminationCode || (TerminationCode = {}));
|
|
1594
|
-
|
|
1595
|
-
// src/model/extension_header/constant.ts
|
|
1596
|
-
var LOCHeaderExtensionId = /* @__PURE__ */ ((LOCHeaderExtensionId2) => {
|
|
1597
|
-
LOCHeaderExtensionId2[LOCHeaderExtensionId2["CaptureTimestamp"] = 2] = "CaptureTimestamp";
|
|
1598
|
-
LOCHeaderExtensionId2[LOCHeaderExtensionId2["VideoFrameMarking"] = 4] = "VideoFrameMarking";
|
|
1599
|
-
LOCHeaderExtensionId2[LOCHeaderExtensionId2["AudioLevel"] = 6] = "AudioLevel";
|
|
1600
|
-
LOCHeaderExtensionId2[LOCHeaderExtensionId2["VideoConfig"] = 13] = "VideoConfig";
|
|
1601
|
-
return LOCHeaderExtensionId2;
|
|
1602
|
-
})(LOCHeaderExtensionId || {});
|
|
1603
|
-
var TrackExtensionType = /* @__PURE__ */ ((TrackExtensionType2) => {
|
|
1604
|
-
TrackExtensionType2[TrackExtensionType2["DeliveryTimeout"] = 2] = "DeliveryTimeout";
|
|
1605
|
-
TrackExtensionType2[TrackExtensionType2["MaxCacheDuration"] = 4] = "MaxCacheDuration";
|
|
1606
|
-
TrackExtensionType2[TrackExtensionType2["ImmutableExtensions"] = 11] = "ImmutableExtensions";
|
|
1607
|
-
TrackExtensionType2[TrackExtensionType2["DefaultPublisherPriority"] = 14] = "DefaultPublisherPriority";
|
|
1608
|
-
TrackExtensionType2[TrackExtensionType2["DefaultPublisherGroupOrder"] = 34] = "DefaultPublisherGroupOrder";
|
|
1609
|
-
TrackExtensionType2[TrackExtensionType2["DynamicGroups"] = 48] = "DynamicGroups";
|
|
1610
|
-
TrackExtensionType2[TrackExtensionType2["PriorGroupIdGap"] = 60] = "PriorGroupIdGap";
|
|
1611
|
-
TrackExtensionType2[TrackExtensionType2["PriorObjectIdGap"] = 62] = "PriorObjectIdGap";
|
|
1612
|
-
return TrackExtensionType2;
|
|
1613
|
-
})(TrackExtensionType || {});
|
|
1614
|
-
function locHeaderExtensionIdFromNumber(value) {
|
|
1615
|
-
switch (value) {
|
|
1616
|
-
case 2:
|
|
1617
|
-
return 2 /* CaptureTimestamp */;
|
|
1618
|
-
case 4:
|
|
1619
|
-
return 4 /* VideoFrameMarking */;
|
|
1620
|
-
case 6:
|
|
1621
|
-
return 6 /* AudioLevel */;
|
|
1622
|
-
case 13:
|
|
1623
|
-
return 13 /* VideoConfig */;
|
|
1624
|
-
default:
|
|
1625
|
-
throw new InvalidTypeError("locHeaderExtensionIdFromNumber", `Invalid LOC header extension id: ${value}`);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
// src/model/extension_header/capture_time_stamp.ts
|
|
1630
|
-
var CaptureTimestamp = class _CaptureTimestamp {
|
|
1631
|
-
constructor(timestamp) {
|
|
1632
|
-
this.timestamp = timestamp;
|
|
1633
|
-
}
|
|
1634
|
-
timestamp;
|
|
1635
|
-
static TYPE = 2 /* CaptureTimestamp */;
|
|
1636
|
-
toKeyValuePair() {
|
|
1637
|
-
return KeyValuePair.tryNewVarInt(_CaptureTimestamp.TYPE, this.timestamp);
|
|
1638
|
-
}
|
|
1639
|
-
static fromKeyValuePair(pair) {
|
|
1640
|
-
const type = Number(pair.typeValue);
|
|
1641
|
-
if (type === _CaptureTimestamp.TYPE && typeof pair.value === "bigint") {
|
|
1642
|
-
return new _CaptureTimestamp(pair.value);
|
|
1643
|
-
}
|
|
1644
|
-
return void 0;
|
|
1645
|
-
}
|
|
1646
|
-
};
|
|
1647
|
-
|
|
1648
|
-
// src/model/extension_header/video_frame_marking.ts
|
|
1649
|
-
var VideoFrameMarking = class _VideoFrameMarking {
|
|
1650
|
-
constructor(value) {
|
|
1651
|
-
this.value = value;
|
|
1652
|
-
}
|
|
1653
|
-
value;
|
|
1654
|
-
static TYPE = 4 /* VideoFrameMarking */;
|
|
1655
|
-
toKeyValuePair() {
|
|
1656
|
-
return KeyValuePair.tryNewVarInt(_VideoFrameMarking.TYPE, this.value);
|
|
1657
|
-
}
|
|
1658
|
-
static fromKeyValuePair(pair) {
|
|
1659
|
-
const type = Number(pair.typeValue);
|
|
1660
|
-
if (type === _VideoFrameMarking.TYPE && typeof pair.value === "bigint") {
|
|
1661
|
-
return new _VideoFrameMarking(pair.value);
|
|
1662
|
-
}
|
|
1663
|
-
return void 0;
|
|
1664
|
-
}
|
|
1665
|
-
};
|
|
1666
|
-
|
|
1667
|
-
// src/model/extension_header/audio_level.ts
|
|
1668
|
-
var AudioLevel = class _AudioLevel {
|
|
1669
|
-
constructor(audioLevel) {
|
|
1670
|
-
this.audioLevel = audioLevel;
|
|
1671
|
-
}
|
|
1672
|
-
audioLevel;
|
|
1673
|
-
static TYPE = 6 /* AudioLevel */;
|
|
1674
|
-
toKeyValuePair() {
|
|
1675
|
-
return KeyValuePair.tryNewVarInt(_AudioLevel.TYPE, this.audioLevel);
|
|
1676
|
-
}
|
|
1677
|
-
static fromKeyValuePair(pair) {
|
|
1678
|
-
const type = Number(pair.typeValue);
|
|
1679
|
-
if (type === _AudioLevel.TYPE && typeof pair.value === "bigint") {
|
|
1680
|
-
return new _AudioLevel(pair.value);
|
|
1681
|
-
}
|
|
1682
|
-
return void 0;
|
|
1683
|
-
}
|
|
1684
|
-
};
|
|
1685
|
-
|
|
1686
|
-
// src/model/extension_header/video_config.ts
|
|
1687
|
-
var VideoConfig = class _VideoConfig {
|
|
1688
|
-
constructor(config) {
|
|
1689
|
-
this.config = config;
|
|
1690
|
-
}
|
|
1691
|
-
config;
|
|
1692
|
-
static TYPE = 13 /* VideoConfig */;
|
|
1693
|
-
toKeyValuePair() {
|
|
1694
|
-
return KeyValuePair.tryNewBytes(_VideoConfig.TYPE, this.config);
|
|
1695
|
-
}
|
|
1696
|
-
static fromKeyValuePair(pair) {
|
|
1697
|
-
const type = Number(pair.typeValue);
|
|
1698
|
-
if (type === _VideoConfig.TYPE && pair.value instanceof Uint8Array) {
|
|
1699
|
-
return new _VideoConfig(pair.value);
|
|
1700
|
-
}
|
|
1701
|
-
return void 0;
|
|
1702
|
-
}
|
|
1703
|
-
};
|
|
1704
|
-
|
|
1705
|
-
// src/model/extension_header/extension_header.ts
|
|
1706
|
-
var ExtensionHeader;
|
|
1707
|
-
((ExtensionHeader2) => {
|
|
1708
|
-
function fromKeyValuePair(pair) {
|
|
1709
|
-
return CaptureTimestamp.fromKeyValuePair(pair) || VideoFrameMarking.fromKeyValuePair(pair) || AudioLevel.fromKeyValuePair(pair) || VideoConfig.fromKeyValuePair(pair);
|
|
1710
|
-
}
|
|
1711
|
-
ExtensionHeader2.fromKeyValuePair = fromKeyValuePair;
|
|
1712
|
-
function toKeyValuePair(header) {
|
|
1713
|
-
return header.toKeyValuePair();
|
|
1714
|
-
}
|
|
1715
|
-
ExtensionHeader2.toKeyValuePair = toKeyValuePair;
|
|
1716
|
-
function isCaptureTimestamp(header) {
|
|
1717
|
-
return header instanceof CaptureTimestamp;
|
|
1718
|
-
}
|
|
1719
|
-
ExtensionHeader2.isCaptureTimestamp = isCaptureTimestamp;
|
|
1720
|
-
function isVideoFrameMarking(header) {
|
|
1721
|
-
return header instanceof VideoFrameMarking;
|
|
1722
|
-
}
|
|
1723
|
-
ExtensionHeader2.isVideoFrameMarking = isVideoFrameMarking;
|
|
1724
|
-
function isAudioLevel(header) {
|
|
1725
|
-
return header instanceof AudioLevel;
|
|
1726
|
-
}
|
|
1727
|
-
ExtensionHeader2.isAudioLevel = isAudioLevel;
|
|
1728
|
-
function isVideoConfig(header) {
|
|
1729
|
-
return header instanceof VideoConfig;
|
|
1730
|
-
}
|
|
1731
|
-
ExtensionHeader2.isVideoConfig = isVideoConfig;
|
|
1732
|
-
})(ExtensionHeader || (ExtensionHeader = {}));
|
|
1733
|
-
var ExtensionHeaders = class {
|
|
1734
|
-
kvps = [];
|
|
1735
|
-
addCaptureTimestamp(timestamp) {
|
|
1736
|
-
this.kvps.push(new CaptureTimestamp(BigInt(timestamp)).toKeyValuePair());
|
|
1737
|
-
return this;
|
|
1738
|
-
}
|
|
1739
|
-
addVideoFrameMarking(marking) {
|
|
1740
|
-
this.kvps.push(new VideoFrameMarking(BigInt(marking)).toKeyValuePair());
|
|
1741
|
-
return this;
|
|
1742
|
-
}
|
|
1743
|
-
addAudioLevel(audioLevel) {
|
|
1744
|
-
this.kvps.push(new AudioLevel(BigInt(audioLevel)).toKeyValuePair());
|
|
1745
|
-
return this;
|
|
1746
|
-
}
|
|
1747
|
-
addVideoConfig(config) {
|
|
1748
|
-
this.kvps.push(new VideoConfig(config).toKeyValuePair());
|
|
1749
|
-
return this;
|
|
1750
|
-
}
|
|
1751
|
-
addRaw(pair) {
|
|
1752
|
-
this.kvps.push(pair);
|
|
1753
|
-
return this;
|
|
1754
|
-
}
|
|
1755
|
-
build() {
|
|
1756
|
-
return this.kvps;
|
|
1757
|
-
}
|
|
1758
|
-
static fromKeyValuePairs(kvps) {
|
|
1759
|
-
const result = [];
|
|
1760
|
-
for (const kvp of kvps) {
|
|
1761
|
-
const parsed = ExtensionHeader.fromKeyValuePair(kvp);
|
|
1762
|
-
if (parsed) result.push(parsed);
|
|
1763
|
-
}
|
|
1764
|
-
return result;
|
|
1765
|
-
}
|
|
1766
|
-
};
|
|
1767
|
-
|
|
1768
|
-
// src/model/control/constant.ts
|
|
1769
|
-
var SUPPORTED_VERSIONS = ["moqt-16"];
|
|
1770
|
-
var ControlMessageType = /* @__PURE__ */ ((ControlMessageType2) => {
|
|
1771
|
-
ControlMessageType2[ControlMessageType2["ReservedSetupV00"] = 1] = "ReservedSetupV00";
|
|
1772
|
-
ControlMessageType2[ControlMessageType2["ReservedClientSetupV10"] = 64] = "ReservedClientSetupV10";
|
|
1773
|
-
ControlMessageType2[ControlMessageType2["ReservedServerSetupV10"] = 65] = "ReservedServerSetupV10";
|
|
1774
|
-
ControlMessageType2[ControlMessageType2["ClientSetup"] = 32] = "ClientSetup";
|
|
1775
|
-
ControlMessageType2[ControlMessageType2["ServerSetup"] = 33] = "ServerSetup";
|
|
1776
|
-
ControlMessageType2[ControlMessageType2["GoAway"] = 16] = "GoAway";
|
|
1777
|
-
ControlMessageType2[ControlMessageType2["MaxRequestId"] = 21] = "MaxRequestId";
|
|
1778
|
-
ControlMessageType2[ControlMessageType2["RequestsBlocked"] = 26] = "RequestsBlocked";
|
|
1779
|
-
ControlMessageType2[ControlMessageType2["Subscribe"] = 3] = "Subscribe";
|
|
1780
|
-
ControlMessageType2[ControlMessageType2["SubscribeOk"] = 4] = "SubscribeOk";
|
|
1781
|
-
ControlMessageType2[ControlMessageType2["RequestError"] = 5] = "RequestError";
|
|
1782
|
-
ControlMessageType2[ControlMessageType2["Unsubscribe"] = 10] = "Unsubscribe";
|
|
1783
|
-
ControlMessageType2[ControlMessageType2["RequestUpdate"] = 2] = "RequestUpdate";
|
|
1784
|
-
ControlMessageType2[ControlMessageType2["PublishDone"] = 11] = "PublishDone";
|
|
1785
|
-
ControlMessageType2[ControlMessageType2["Fetch"] = 22] = "Fetch";
|
|
1786
|
-
ControlMessageType2[ControlMessageType2["FetchOk"] = 24] = "FetchOk";
|
|
1787
|
-
ControlMessageType2[ControlMessageType2["FetchCancel"] = 23] = "FetchCancel";
|
|
1788
|
-
ControlMessageType2[ControlMessageType2["TrackStatus"] = 13] = "TrackStatus";
|
|
1789
|
-
ControlMessageType2[ControlMessageType2["PublishNamespace"] = 6] = "PublishNamespace";
|
|
1790
|
-
ControlMessageType2[ControlMessageType2["RequestOk"] = 7] = "RequestOk";
|
|
1791
|
-
ControlMessageType2[ControlMessageType2["Namespace"] = 8] = "Namespace";
|
|
1792
|
-
ControlMessageType2[ControlMessageType2["PublishNamespaceDone"] = 9] = "PublishNamespaceDone";
|
|
1793
|
-
ControlMessageType2[ControlMessageType2["NamespaceDone"] = 14] = "NamespaceDone";
|
|
1794
|
-
ControlMessageType2[ControlMessageType2["PublishNamespaceCancel"] = 12] = "PublishNamespaceCancel";
|
|
1795
|
-
ControlMessageType2[ControlMessageType2["SubscribeNamespace"] = 17] = "SubscribeNamespace";
|
|
1796
|
-
ControlMessageType2[ControlMessageType2["UnsubscribeNamespace"] = 20] = "UnsubscribeNamespace";
|
|
1797
|
-
ControlMessageType2[ControlMessageType2["Publish"] = 29] = "Publish";
|
|
1798
|
-
ControlMessageType2[ControlMessageType2["PublishOk"] = 30] = "PublishOk";
|
|
1799
|
-
ControlMessageType2[ControlMessageType2["Switch"] = 34] = "Switch";
|
|
1800
|
-
return ControlMessageType2;
|
|
1801
|
-
})(ControlMessageType || {});
|
|
1802
|
-
function controlMessageTypeFromBigInt(v) {
|
|
1803
|
-
switch (v) {
|
|
1804
|
-
case 0x01n:
|
|
1805
|
-
return 1 /* ReservedSetupV00 */;
|
|
1806
|
-
case 0x40n:
|
|
1807
|
-
return 64 /* ReservedClientSetupV10 */;
|
|
1808
|
-
case 0x41n:
|
|
1809
|
-
return 65 /* ReservedServerSetupV10 */;
|
|
1810
|
-
case 0x20n:
|
|
1811
|
-
return 32 /* ClientSetup */;
|
|
1812
|
-
case 0x21n:
|
|
1813
|
-
return 33 /* ServerSetup */;
|
|
1814
|
-
case 0x10n:
|
|
1815
|
-
return 16 /* GoAway */;
|
|
1816
|
-
case 0x15n:
|
|
1817
|
-
return 21 /* MaxRequestId */;
|
|
1818
|
-
case 0x1an:
|
|
1819
|
-
return 26 /* RequestsBlocked */;
|
|
1820
|
-
case 0x03n:
|
|
1821
|
-
return 3 /* Subscribe */;
|
|
1822
|
-
case 0x04n:
|
|
1823
|
-
return 4 /* SubscribeOk */;
|
|
1824
|
-
case 0x05n:
|
|
1825
|
-
return 5 /* RequestError */;
|
|
1826
|
-
case 0x0an:
|
|
1827
|
-
return 10 /* Unsubscribe */;
|
|
1828
|
-
case 0x02n:
|
|
1829
|
-
return 2 /* RequestUpdate */;
|
|
1830
|
-
case 0x0bn:
|
|
1831
|
-
return 11 /* PublishDone */;
|
|
1832
|
-
case 0x16n:
|
|
1833
|
-
return 22 /* Fetch */;
|
|
1834
|
-
case 0x18n:
|
|
1835
|
-
return 24 /* FetchOk */;
|
|
1836
|
-
case 0x17n:
|
|
1837
|
-
return 23 /* FetchCancel */;
|
|
1838
|
-
case 0x0dn:
|
|
1839
|
-
return 13 /* TrackStatus */;
|
|
1840
|
-
case 0x06n:
|
|
1841
|
-
return 6 /* PublishNamespace */;
|
|
1842
|
-
case 0x07n:
|
|
1843
|
-
return 7 /* RequestOk */;
|
|
1844
|
-
case 0x08n:
|
|
1845
|
-
return 8 /* Namespace */;
|
|
1846
|
-
case 0x09n:
|
|
1847
|
-
return 9 /* PublishNamespaceDone */;
|
|
1848
|
-
case 0x0en:
|
|
1849
|
-
return 14 /* NamespaceDone */;
|
|
1850
|
-
case 0x0cn:
|
|
1851
|
-
return 12 /* PublishNamespaceCancel */;
|
|
1852
|
-
case 0x11n:
|
|
1853
|
-
return 17 /* SubscribeNamespace */;
|
|
1854
|
-
case 0x14n:
|
|
1855
|
-
return 20 /* UnsubscribeNamespace */;
|
|
1856
|
-
case 0x1dn:
|
|
1857
|
-
return 29 /* Publish */;
|
|
1858
|
-
case 0x1en:
|
|
1859
|
-
return 30 /* PublishOk */;
|
|
1860
|
-
default:
|
|
1861
|
-
throw new Error(`Invalid ControlMessageType: ${v}`);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
var NamespaceSubscribeOptions = /* @__PURE__ */ ((NamespaceSubscribeOptions3) => {
|
|
1865
|
-
NamespaceSubscribeOptions3[NamespaceSubscribeOptions3["PublishOnly"] = 0] = "PublishOnly";
|
|
1866
|
-
NamespaceSubscribeOptions3[NamespaceSubscribeOptions3["NamespaceOnly"] = 1] = "NamespaceOnly";
|
|
1867
|
-
NamespaceSubscribeOptions3[NamespaceSubscribeOptions3["Both"] = 2] = "Both";
|
|
1868
|
-
return NamespaceSubscribeOptions3;
|
|
1869
|
-
})(NamespaceSubscribeOptions || {});
|
|
1870
|
-
var FilterType = /* @__PURE__ */ ((FilterType5) => {
|
|
1871
|
-
FilterType5[FilterType5["NextGroupStart"] = 1] = "NextGroupStart";
|
|
1872
|
-
FilterType5[FilterType5["LatestObject"] = 2] = "LatestObject";
|
|
1873
|
-
FilterType5[FilterType5["AbsoluteStart"] = 3] = "AbsoluteStart";
|
|
1874
|
-
FilterType5[FilterType5["AbsoluteRange"] = 4] = "AbsoluteRange";
|
|
1875
|
-
return FilterType5;
|
|
1876
|
-
})(FilterType || {});
|
|
1877
|
-
function filterTypeFromBigInt(v) {
|
|
1878
|
-
switch (v) {
|
|
1879
|
-
case 0x1n:
|
|
1880
|
-
return 1 /* NextGroupStart */;
|
|
1881
|
-
case 0x2n:
|
|
1882
|
-
return 2 /* LatestObject */;
|
|
1883
|
-
case 0x3n:
|
|
1884
|
-
return 3 /* AbsoluteStart */;
|
|
1885
|
-
case 0x4n:
|
|
1886
|
-
return 4 /* AbsoluteRange */;
|
|
1887
|
-
default:
|
|
1888
|
-
throw new Error(`Invalid FilterType: ${v}`);
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
var FetchType = /* @__PURE__ */ ((FetchType3) => {
|
|
1892
|
-
FetchType3[FetchType3["Standalone"] = 1] = "Standalone";
|
|
1893
|
-
FetchType3[FetchType3["Relative"] = 2] = "Relative";
|
|
1894
|
-
FetchType3[FetchType3["Absolute"] = 3] = "Absolute";
|
|
1895
|
-
return FetchType3;
|
|
1896
|
-
})(FetchType || {});
|
|
1897
|
-
function fetchTypeFromBigInt(v) {
|
|
1898
|
-
switch (v) {
|
|
1899
|
-
case 0x1n:
|
|
1900
|
-
return 1 /* Standalone */;
|
|
1901
|
-
case 0x2n:
|
|
1902
|
-
return 2 /* Relative */;
|
|
1903
|
-
case 0x3n:
|
|
1904
|
-
return 3 /* Absolute */;
|
|
1905
|
-
default:
|
|
1906
|
-
throw new CastingError("fetchTypeFromBigInt", "bigint", "FetchType", `Invalid FetchType:${v}`);
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
var GroupOrder = /* @__PURE__ */ ((GroupOrder8) => {
|
|
1910
|
-
GroupOrder8[GroupOrder8["Original"] = 0] = "Original";
|
|
1911
|
-
GroupOrder8[GroupOrder8["Ascending"] = 1] = "Ascending";
|
|
1912
|
-
GroupOrder8[GroupOrder8["Descending"] = 2] = "Descending";
|
|
1913
|
-
return GroupOrder8;
|
|
1914
|
-
})(GroupOrder || {});
|
|
1915
|
-
function groupOrderFromNumber(v) {
|
|
1916
|
-
switch (v) {
|
|
1917
|
-
case 0:
|
|
1918
|
-
return 0 /* Original */;
|
|
1919
|
-
case 1:
|
|
1920
|
-
return 1 /* Ascending */;
|
|
1921
|
-
case 2:
|
|
1922
|
-
return 2 /* Descending */;
|
|
1923
|
-
default:
|
|
1924
|
-
throw new CastingError("groupOrderFromNumber", "number", "GroupOrder", `Invalid GroupOrder: ${v}`);
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
var TrackStatusCode = /* @__PURE__ */ ((TrackStatusCode2) => {
|
|
1928
|
-
TrackStatusCode2[TrackStatusCode2["InProgress"] = 0] = "InProgress";
|
|
1929
|
-
TrackStatusCode2[TrackStatusCode2["DoesNotExist"] = 1] = "DoesNotExist";
|
|
1930
|
-
TrackStatusCode2[TrackStatusCode2["NotYetBegun"] = 2] = "NotYetBegun";
|
|
1931
|
-
TrackStatusCode2[TrackStatusCode2["Finished"] = 3] = "Finished";
|
|
1932
|
-
TrackStatusCode2[TrackStatusCode2["RelayUnavailable"] = 4] = "RelayUnavailable";
|
|
1933
|
-
return TrackStatusCode2;
|
|
1934
|
-
})(TrackStatusCode || {});
|
|
1935
|
-
function trackStatusCodeFromBigInt(v) {
|
|
1936
|
-
switch (v) {
|
|
1937
|
-
case 0x00n:
|
|
1938
|
-
return 0 /* InProgress */;
|
|
1939
|
-
case 0x01n:
|
|
1940
|
-
return 1 /* DoesNotExist */;
|
|
1941
|
-
case 0x02n:
|
|
1942
|
-
return 2 /* NotYetBegun */;
|
|
1943
|
-
case 0x03n:
|
|
1944
|
-
return 3 /* Finished */;
|
|
1945
|
-
case 0x04n:
|
|
1946
|
-
return 4 /* RelayUnavailable */;
|
|
1947
|
-
default:
|
|
1948
|
-
throw new Error(`Invalid TrackStatusCode: ${v}`);
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
var PublishDoneStatusCode = /* @__PURE__ */ ((PublishDoneStatusCode3) => {
|
|
1952
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["InternalError"] = 0] = "InternalError";
|
|
1953
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["Unauthorized"] = 1] = "Unauthorized";
|
|
1954
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["TrackEnded"] = 2] = "TrackEnded";
|
|
1955
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["SubscriptionEnded"] = 3] = "SubscriptionEnded";
|
|
1956
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["GoingAway"] = 4] = "GoingAway";
|
|
1957
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["Expired"] = 5] = "Expired";
|
|
1958
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["TooFarBehind"] = 6] = "TooFarBehind";
|
|
1959
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["UpdateFailed"] = 8] = "UpdateFailed";
|
|
1960
|
-
PublishDoneStatusCode3[PublishDoneStatusCode3["MalformedTrack"] = 18] = "MalformedTrack";
|
|
1961
|
-
return PublishDoneStatusCode3;
|
|
1962
|
-
})(PublishDoneStatusCode || {});
|
|
1963
|
-
function publishDoneStatusCodeFromBigInt(v) {
|
|
1964
|
-
switch (v) {
|
|
1965
|
-
case 0x0n:
|
|
1966
|
-
return 0 /* InternalError */;
|
|
1967
|
-
case 0x1n:
|
|
1968
|
-
return 1 /* Unauthorized */;
|
|
1969
|
-
case 0x2n:
|
|
1970
|
-
return 2 /* TrackEnded */;
|
|
1971
|
-
case 0x3n:
|
|
1972
|
-
return 3 /* SubscriptionEnded */;
|
|
1973
|
-
case 0x4n:
|
|
1974
|
-
return 4 /* GoingAway */;
|
|
1975
|
-
case 0x5n:
|
|
1976
|
-
return 5 /* Expired */;
|
|
1977
|
-
case 0x6n:
|
|
1978
|
-
return 6 /* TooFarBehind */;
|
|
1979
|
-
case 0x8n:
|
|
1980
|
-
return 8 /* UpdateFailed */;
|
|
1981
|
-
case 0x12n:
|
|
1982
|
-
return 18 /* MalformedTrack */;
|
|
1983
|
-
default:
|
|
1984
|
-
throw new Error(`Invalid PublishDoneStatusCode: ${v}`);
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
var RequestErrorCode = /* @__PURE__ */ ((RequestErrorCode4) => {
|
|
1988
|
-
RequestErrorCode4[RequestErrorCode4["InternalError"] = 0] = "InternalError";
|
|
1989
|
-
RequestErrorCode4[RequestErrorCode4["Unauthorized"] = 1] = "Unauthorized";
|
|
1990
|
-
RequestErrorCode4[RequestErrorCode4["Timeout"] = 2] = "Timeout";
|
|
1991
|
-
RequestErrorCode4[RequestErrorCode4["NotSupported"] = 3] = "NotSupported";
|
|
1992
|
-
RequestErrorCode4[RequestErrorCode4["MalformedAuthToken"] = 4] = "MalformedAuthToken";
|
|
1993
|
-
RequestErrorCode4[RequestErrorCode4["ExpiredAuthToken"] = 5] = "ExpiredAuthToken";
|
|
1994
|
-
RequestErrorCode4[RequestErrorCode4["DoesNotExist"] = 16] = "DoesNotExist";
|
|
1995
|
-
RequestErrorCode4[RequestErrorCode4["InvalidRange"] = 17] = "InvalidRange";
|
|
1996
|
-
RequestErrorCode4[RequestErrorCode4["MalformedTrack"] = 18] = "MalformedTrack";
|
|
1997
|
-
RequestErrorCode4[RequestErrorCode4["DuplicateSubscription"] = 25] = "DuplicateSubscription";
|
|
1998
|
-
RequestErrorCode4[RequestErrorCode4["Uninterested"] = 32] = "Uninterested";
|
|
1999
|
-
RequestErrorCode4[RequestErrorCode4["PrefixOverlap"] = 48] = "PrefixOverlap";
|
|
2000
|
-
RequestErrorCode4[RequestErrorCode4["InvalidJoiningRequestId"] = 50] = "InvalidJoiningRequestId";
|
|
2001
|
-
return RequestErrorCode4;
|
|
2002
|
-
})(RequestErrorCode || {});
|
|
2003
|
-
function requestErrorCodeFromBigInt(v) {
|
|
2004
|
-
switch (v) {
|
|
2005
|
-
case 0x0n:
|
|
2006
|
-
return 0 /* InternalError */;
|
|
2007
|
-
case 0x1n:
|
|
2008
|
-
return 1 /* Unauthorized */;
|
|
2009
|
-
case 0x2n:
|
|
2010
|
-
return 2 /* Timeout */;
|
|
2011
|
-
case 0x3n:
|
|
2012
|
-
return 3 /* NotSupported */;
|
|
2013
|
-
case 0x4n:
|
|
2014
|
-
return 4 /* MalformedAuthToken */;
|
|
2015
|
-
case 0x5n:
|
|
2016
|
-
return 5 /* ExpiredAuthToken */;
|
|
2017
|
-
case 0x10n:
|
|
2018
|
-
return 16 /* DoesNotExist */;
|
|
2019
|
-
case 0x11n:
|
|
2020
|
-
return 17 /* InvalidRange */;
|
|
2021
|
-
case 0x12n:
|
|
2022
|
-
return 18 /* MalformedTrack */;
|
|
2023
|
-
case 0x19n:
|
|
2024
|
-
return 25 /* DuplicateSubscription */;
|
|
2025
|
-
case 0x20n:
|
|
2026
|
-
return 32 /* Uninterested */;
|
|
2027
|
-
case 0x30n:
|
|
2028
|
-
return 48 /* PrefixOverlap */;
|
|
2029
|
-
case 0x32n:
|
|
2030
|
-
return 50 /* InvalidJoiningRequestId */;
|
|
2031
|
-
default:
|
|
2032
|
-
throw new CastingError(
|
|
2033
|
-
"requestErrorCodeFromBigInt",
|
|
2034
|
-
"bigint",
|
|
2035
|
-
"RequestErrorCode",
|
|
2036
|
-
`Invalid RequestErrorCode: ${v}`
|
|
2037
|
-
);
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
// src/model/extension_header/track_extension.ts
|
|
2042
|
-
var DeliveryTimeoutExtension = class _DeliveryTimeoutExtension {
|
|
2043
|
-
constructor(timeoutMs) {
|
|
2044
|
-
this.timeoutMs = timeoutMs;
|
|
2045
|
-
}
|
|
2046
|
-
timeoutMs;
|
|
2047
|
-
static TYPE = 2 /* DeliveryTimeout */;
|
|
2048
|
-
toKeyValuePair() {
|
|
2049
|
-
return KeyValuePair.tryNewVarInt(_DeliveryTimeoutExtension.TYPE, this.timeoutMs);
|
|
2050
|
-
}
|
|
2051
|
-
static fromKeyValuePair(pair) {
|
|
2052
|
-
if (Number(pair.typeValue) !== _DeliveryTimeoutExtension.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
2053
|
-
if (pair.value === 0n) {
|
|
2054
|
-
throw new ProtocolViolationError(
|
|
2055
|
-
"DeliveryTimeoutExtension.fromKeyValuePair",
|
|
2056
|
-
"DELIVERY_TIMEOUT must be greater than 0"
|
|
2057
|
-
);
|
|
2058
|
-
}
|
|
2059
|
-
return new _DeliveryTimeoutExtension(pair.value);
|
|
2060
|
-
}
|
|
2061
|
-
};
|
|
2062
|
-
var MaxCacheDurationExtension = class _MaxCacheDurationExtension {
|
|
2063
|
-
constructor(durationMs) {
|
|
2064
|
-
this.durationMs = durationMs;
|
|
2065
|
-
}
|
|
2066
|
-
durationMs;
|
|
2067
|
-
static TYPE = 4 /* MaxCacheDuration */;
|
|
2068
|
-
toKeyValuePair() {
|
|
2069
|
-
return KeyValuePair.tryNewVarInt(_MaxCacheDurationExtension.TYPE, this.durationMs);
|
|
2070
|
-
}
|
|
2071
|
-
static fromKeyValuePair(pair) {
|
|
2072
|
-
if (Number(pair.typeValue) !== _MaxCacheDurationExtension.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
2073
|
-
return new _MaxCacheDurationExtension(pair.value);
|
|
2074
|
-
}
|
|
2075
|
-
};
|
|
2076
|
-
var ImmutableExtensionsExtension = class _ImmutableExtensionsExtension {
|
|
2077
|
-
constructor(extensions) {
|
|
2078
|
-
this.extensions = extensions;
|
|
2079
|
-
}
|
|
2080
|
-
extensions;
|
|
2081
|
-
static TYPE = 11 /* ImmutableExtensions */;
|
|
2082
|
-
toKeyValuePair() {
|
|
2083
|
-
return KeyValuePair.tryNewBytes(_ImmutableExtensionsExtension.TYPE, serializeKvpList(this.extensions).toUint8Array());
|
|
2084
|
-
}
|
|
2085
|
-
static fromKeyValuePair(pair) {
|
|
2086
|
-
if (Number(pair.typeValue) !== _ImmutableExtensionsExtension.TYPE || !(pair.value instanceof Uint8Array))
|
|
2087
|
-
return void 0;
|
|
2088
|
-
const buf = new FrozenByteBuffer5(pair.value);
|
|
2089
|
-
const extensions = deserializeKvpListUntilEmpty(buf);
|
|
2090
|
-
if (extensions.some((inner) => Number(inner.typeValue) === 11 /* ImmutableExtensions */)) {
|
|
2091
|
-
throw new ProtocolViolationError(
|
|
2092
|
-
"ImmutableExtensionsExtension.fromKeyValuePair",
|
|
2093
|
-
"ImmutableExtensions must not contain nested ImmutableExtensions (0x0B)"
|
|
2094
|
-
);
|
|
2095
|
-
}
|
|
2096
|
-
return new _ImmutableExtensionsExtension(extensions);
|
|
2097
|
-
}
|
|
2098
|
-
};
|
|
2099
|
-
var DefaultPublisherPriorityExtension = class _DefaultPublisherPriorityExtension {
|
|
2100
|
-
constructor(priority) {
|
|
2101
|
-
this.priority = priority;
|
|
2102
|
-
}
|
|
2103
|
-
priority;
|
|
2104
|
-
static TYPE = 14 /* DefaultPublisherPriority */;
|
|
2105
|
-
toKeyValuePair() {
|
|
2106
|
-
return KeyValuePair.tryNewVarInt(_DefaultPublisherPriorityExtension.TYPE, this.priority);
|
|
2107
|
-
}
|
|
2108
|
-
static fromKeyValuePair(pair) {
|
|
2109
|
-
if (Number(pair.typeValue) !== _DefaultPublisherPriorityExtension.TYPE || typeof pair.value !== "bigint")
|
|
2110
|
-
return void 0;
|
|
2111
|
-
if (pair.value > 255n) {
|
|
2112
|
-
throw new ProtocolViolationError(
|
|
2113
|
-
"DefaultPublisherPriorityExtension.fromKeyValuePair",
|
|
2114
|
-
`Priority must be 0-255, got ${pair.value}`
|
|
2115
|
-
);
|
|
2116
|
-
}
|
|
2117
|
-
return new _DefaultPublisherPriorityExtension(Number(pair.value));
|
|
2118
|
-
}
|
|
2119
|
-
};
|
|
2120
|
-
var DefaultPublisherGroupOrderExtension = class _DefaultPublisherGroupOrderExtension {
|
|
2121
|
-
constructor(order) {
|
|
2122
|
-
this.order = order;
|
|
2123
|
-
}
|
|
2124
|
-
order;
|
|
2125
|
-
static TYPE = 34 /* DefaultPublisherGroupOrder */;
|
|
2126
|
-
toKeyValuePair() {
|
|
2127
|
-
return KeyValuePair.tryNewVarInt(_DefaultPublisherGroupOrderExtension.TYPE, this.order);
|
|
2128
|
-
}
|
|
2129
|
-
static fromKeyValuePair(pair) {
|
|
2130
|
-
if (Number(pair.typeValue) !== _DefaultPublisherGroupOrderExtension.TYPE || typeof pair.value !== "bigint")
|
|
2131
|
-
return void 0;
|
|
2132
|
-
if (pair.value !== 1n && pair.value !== 2n) {
|
|
2133
|
-
throw new ProtocolViolationError(
|
|
2134
|
-
"DefaultPublisherGroupOrderExtension.fromKeyValuePair",
|
|
2135
|
-
`GroupOrder must be Ascending(1) or Descending(2), got ${pair.value}`
|
|
2136
|
-
);
|
|
2137
|
-
}
|
|
2138
|
-
return new _DefaultPublisherGroupOrderExtension(Number(pair.value));
|
|
2139
|
-
}
|
|
2140
|
-
};
|
|
2141
|
-
var DynamicGroupsExtension = class _DynamicGroupsExtension {
|
|
2142
|
-
constructor(enabled) {
|
|
2143
|
-
this.enabled = enabled;
|
|
2144
|
-
}
|
|
2145
|
-
enabled;
|
|
2146
|
-
static TYPE = 48 /* DynamicGroups */;
|
|
2147
|
-
toKeyValuePair() {
|
|
2148
|
-
return KeyValuePair.tryNewVarInt(_DynamicGroupsExtension.TYPE, this.enabled ? 1 : 0);
|
|
2149
|
-
}
|
|
2150
|
-
static fromKeyValuePair(pair) {
|
|
2151
|
-
if (Number(pair.typeValue) !== _DynamicGroupsExtension.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
2152
|
-
if (pair.value > 1n) {
|
|
2153
|
-
throw new ProtocolViolationError(
|
|
2154
|
-
"DynamicGroupsExtension.fromKeyValuePair",
|
|
2155
|
-
`DynamicGroups must be 0 or 1, got ${pair.value}`
|
|
2156
|
-
);
|
|
2157
|
-
}
|
|
2158
|
-
return new _DynamicGroupsExtension(pair.value === 1n);
|
|
2159
|
-
}
|
|
2160
|
-
};
|
|
2161
|
-
var UnknownTrackExtension = class {
|
|
2162
|
-
constructor(kvp) {
|
|
2163
|
-
this.kvp = kvp;
|
|
2164
|
-
}
|
|
2165
|
-
kvp;
|
|
2166
|
-
toKeyValuePair() {
|
|
2167
|
-
return this.kvp;
|
|
2168
|
-
}
|
|
2169
|
-
};
|
|
2170
|
-
var TrackExtension;
|
|
2171
|
-
((TrackExtension2) => {
|
|
2172
|
-
function fromKeyValuePair(pair) {
|
|
2173
|
-
return DeliveryTimeoutExtension.fromKeyValuePair(pair) ?? MaxCacheDurationExtension.fromKeyValuePair(pair) ?? ImmutableExtensionsExtension.fromKeyValuePair(pair) ?? DefaultPublisherPriorityExtension.fromKeyValuePair(pair) ?? DefaultPublisherGroupOrderExtension.fromKeyValuePair(pair) ?? DynamicGroupsExtension.fromKeyValuePair(pair) ?? new UnknownTrackExtension(pair);
|
|
2174
|
-
}
|
|
2175
|
-
TrackExtension2.fromKeyValuePair = fromKeyValuePair;
|
|
2176
|
-
function toKeyValuePair(ext) {
|
|
2177
|
-
return ext.toKeyValuePair();
|
|
2178
|
-
}
|
|
2179
|
-
TrackExtension2.toKeyValuePair = toKeyValuePair;
|
|
2180
|
-
function deserializeAll(buf) {
|
|
2181
|
-
return deserializeKvpListUntilEmpty(buf).map(fromKeyValuePair);
|
|
2182
|
-
}
|
|
2183
|
-
TrackExtension2.deserializeAll = deserializeAll;
|
|
2184
|
-
function serializeInto(exts, payload) {
|
|
2185
|
-
payload.putBytes(serializeKvpList(exts.map((ext) => ext.toKeyValuePair())).toUint8Array());
|
|
2186
|
-
}
|
|
2187
|
-
TrackExtension2.serializeInto = serializeInto;
|
|
2188
|
-
function isDeliveryTimeout(ext) {
|
|
2189
|
-
return ext instanceof DeliveryTimeoutExtension;
|
|
2190
|
-
}
|
|
2191
|
-
TrackExtension2.isDeliveryTimeout = isDeliveryTimeout;
|
|
2192
|
-
function isMaxCacheDuration(ext) {
|
|
2193
|
-
return ext instanceof MaxCacheDurationExtension;
|
|
2194
|
-
}
|
|
2195
|
-
TrackExtension2.isMaxCacheDuration = isMaxCacheDuration;
|
|
2196
|
-
function isImmutableExtensions(ext) {
|
|
2197
|
-
return ext instanceof ImmutableExtensionsExtension;
|
|
2198
|
-
}
|
|
2199
|
-
TrackExtension2.isImmutableExtensions = isImmutableExtensions;
|
|
2200
|
-
function isDefaultPublisherPriority(ext) {
|
|
2201
|
-
return ext instanceof DefaultPublisherPriorityExtension;
|
|
2202
|
-
}
|
|
2203
|
-
TrackExtension2.isDefaultPublisherPriority = isDefaultPublisherPriority;
|
|
2204
|
-
function isDefaultPublisherGroupOrder(ext) {
|
|
2205
|
-
return ext instanceof DefaultPublisherGroupOrderExtension;
|
|
2206
|
-
}
|
|
2207
|
-
TrackExtension2.isDefaultPublisherGroupOrder = isDefaultPublisherGroupOrder;
|
|
2208
|
-
function isDynamicGroups(ext) {
|
|
2209
|
-
return ext instanceof DynamicGroupsExtension;
|
|
2210
|
-
}
|
|
2211
|
-
TrackExtension2.isDynamicGroups = isDynamicGroups;
|
|
2212
|
-
function isUnknown(ext) {
|
|
2213
|
-
return ext instanceof UnknownTrackExtension;
|
|
2214
|
-
}
|
|
2215
|
-
TrackExtension2.isUnknown = isUnknown;
|
|
2216
|
-
})(TrackExtension || (TrackExtension = {}));
|
|
2217
|
-
|
|
2218
|
-
// src/model/extension_header/object_extension.ts
|
|
2219
|
-
var ImmutableExtensionsObjectExtension = class _ImmutableExtensionsObjectExtension {
|
|
2220
|
-
constructor(extensions) {
|
|
2221
|
-
this.extensions = extensions;
|
|
2222
|
-
}
|
|
2223
|
-
extensions;
|
|
2224
|
-
static TYPE = 11 /* ImmutableExtensions */;
|
|
2225
|
-
toKeyValuePair() {
|
|
2226
|
-
return KeyValuePair.tryNewBytes(
|
|
2227
|
-
_ImmutableExtensionsObjectExtension.TYPE,
|
|
2228
|
-
serializeKvpList(this.extensions).toUint8Array()
|
|
2229
|
-
);
|
|
2230
|
-
}
|
|
2231
|
-
static fromKeyValuePair(pair) {
|
|
2232
|
-
if (Number(pair.typeValue) !== _ImmutableExtensionsObjectExtension.TYPE || !(pair.value instanceof Uint8Array))
|
|
2233
|
-
return void 0;
|
|
2234
|
-
const buf = new FrozenByteBuffer5(pair.value);
|
|
2235
|
-
const extensions = deserializeKvpListUntilEmpty(buf);
|
|
2236
|
-
if (extensions.some((inner) => Number(inner.typeValue) === 11 /* ImmutableExtensions */)) {
|
|
2237
|
-
throw new ProtocolViolationError(
|
|
2238
|
-
"ImmutableExtensionsObjectExtension.fromKeyValuePair",
|
|
2239
|
-
"ImmutableExtensions must not contain nested ImmutableExtensions (0x0B)"
|
|
2240
|
-
);
|
|
2241
|
-
}
|
|
2242
|
-
return new _ImmutableExtensionsObjectExtension(extensions);
|
|
2243
|
-
}
|
|
2244
|
-
};
|
|
2245
|
-
var PriorGroupIdGapExtension = class _PriorGroupIdGapExtension {
|
|
2246
|
-
constructor(gap) {
|
|
2247
|
-
this.gap = gap;
|
|
2248
|
-
}
|
|
2249
|
-
gap;
|
|
2250
|
-
static TYPE = 60 /* PriorGroupIdGap */;
|
|
2251
|
-
toKeyValuePair() {
|
|
2252
|
-
return KeyValuePair.tryNewVarInt(_PriorGroupIdGapExtension.TYPE, this.gap);
|
|
2253
|
-
}
|
|
2254
|
-
static fromKeyValuePair(pair) {
|
|
2255
|
-
if (Number(pair.typeValue) !== _PriorGroupIdGapExtension.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
2256
|
-
return new _PriorGroupIdGapExtension(pair.value);
|
|
2257
|
-
}
|
|
2258
|
-
};
|
|
2259
|
-
var PriorObjectIdGapExtension = class _PriorObjectIdGapExtension {
|
|
2260
|
-
constructor(gap) {
|
|
2261
|
-
this.gap = gap;
|
|
2262
|
-
}
|
|
2263
|
-
gap;
|
|
2264
|
-
static TYPE = 62 /* PriorObjectIdGap */;
|
|
2265
|
-
toKeyValuePair() {
|
|
2266
|
-
return KeyValuePair.tryNewVarInt(_PriorObjectIdGapExtension.TYPE, this.gap);
|
|
2267
|
-
}
|
|
2268
|
-
static fromKeyValuePair(pair) {
|
|
2269
|
-
if (Number(pair.typeValue) !== _PriorObjectIdGapExtension.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
2270
|
-
return new _PriorObjectIdGapExtension(pair.value);
|
|
2271
|
-
}
|
|
2272
|
-
};
|
|
2273
|
-
var UnknownObjectExtension = class {
|
|
2274
|
-
constructor(kvp) {
|
|
2275
|
-
this.kvp = kvp;
|
|
2276
|
-
}
|
|
2277
|
-
kvp;
|
|
2278
|
-
toKeyValuePair() {
|
|
2279
|
-
return this.kvp;
|
|
2280
|
-
}
|
|
2281
|
-
};
|
|
2282
|
-
var ObjectExtension;
|
|
2283
|
-
((ObjectExtension2) => {
|
|
2284
|
-
function fromKeyValuePair(pair) {
|
|
2285
|
-
return ImmutableExtensionsObjectExtension.fromKeyValuePair(pair) ?? PriorGroupIdGapExtension.fromKeyValuePair(pair) ?? PriorObjectIdGapExtension.fromKeyValuePair(pair) ?? new UnknownObjectExtension(pair);
|
|
2286
|
-
}
|
|
2287
|
-
ObjectExtension2.fromKeyValuePair = fromKeyValuePair;
|
|
2288
|
-
function toKeyValuePair(ext) {
|
|
2289
|
-
return ext.toKeyValuePair();
|
|
2290
|
-
}
|
|
2291
|
-
ObjectExtension2.toKeyValuePair = toKeyValuePair;
|
|
2292
|
-
function deserializeAll(buf) {
|
|
2293
|
-
return deserializeKvpListUntilEmpty(buf).map(fromKeyValuePair);
|
|
2294
|
-
}
|
|
2295
|
-
ObjectExtension2.deserializeAll = deserializeAll;
|
|
2296
|
-
function serializeInto(exts, payload) {
|
|
2297
|
-
payload.putBytes(serializeKvpList(exts.map((ext) => ext.toKeyValuePair())).toUint8Array());
|
|
2298
|
-
}
|
|
2299
|
-
ObjectExtension2.serializeInto = serializeInto;
|
|
2300
|
-
function isImmutableExtensions(ext) {
|
|
2301
|
-
return ext instanceof ImmutableExtensionsObjectExtension;
|
|
2302
|
-
}
|
|
2303
|
-
ObjectExtension2.isImmutableExtensions = isImmutableExtensions;
|
|
2304
|
-
function isPriorGroupIdGap(ext) {
|
|
2305
|
-
return ext instanceof PriorGroupIdGapExtension;
|
|
2306
|
-
}
|
|
2307
|
-
ObjectExtension2.isPriorGroupIdGap = isPriorGroupIdGap;
|
|
2308
|
-
function isPriorObjectIdGap(ext) {
|
|
2309
|
-
return ext instanceof PriorObjectIdGapExtension;
|
|
2310
|
-
}
|
|
2311
|
-
ObjectExtension2.isPriorObjectIdGap = isPriorObjectIdGap;
|
|
2312
|
-
function isUnknown(ext) {
|
|
2313
|
-
return ext instanceof UnknownObjectExtension;
|
|
2314
|
-
}
|
|
2315
|
-
ObjectExtension2.isUnknown = isUnknown;
|
|
2316
|
-
})(ObjectExtension || (ObjectExtension = {}));
|
|
2317
|
-
|
|
2318
|
-
// src/model/data/subgroup_object.ts
|
|
2319
|
-
function normalizeExtensionHeaders(extensionHeaders) {
|
|
2320
|
-
if (extensionHeaders === null || extensionHeaders.length === 0) {
|
|
2321
|
-
return null;
|
|
2322
|
-
}
|
|
2323
|
-
return extensionHeaders;
|
|
2324
|
-
}
|
|
2325
|
-
var SubgroupObject = class _SubgroupObject {
|
|
2326
|
-
constructor(objectId, extensionHeaders, objectStatus, payload) {
|
|
2327
|
-
this.extensionHeaders = extensionHeaders;
|
|
2328
|
-
this.objectStatus = objectStatus;
|
|
2329
|
-
this.payload = payload;
|
|
2330
|
-
this.objectId = BigInt(objectId);
|
|
2331
|
-
}
|
|
2332
|
-
extensionHeaders;
|
|
2333
|
-
objectStatus;
|
|
2334
|
-
payload;
|
|
2335
|
-
objectId;
|
|
2336
|
-
static newWithStatus(objectId, extensionHeaders, objectStatus) {
|
|
2337
|
-
return new _SubgroupObject(objectId, normalizeExtensionHeaders(extensionHeaders), objectStatus, null);
|
|
2338
|
-
}
|
|
2339
|
-
static newWithPayload(objectId, extensionHeaders, payload) {
|
|
2340
|
-
return new _SubgroupObject(objectId, normalizeExtensionHeaders(extensionHeaders), null, payload);
|
|
2341
|
-
}
|
|
2342
|
-
serialize(previousObjectId) {
|
|
2343
|
-
let objectIdDelta = previousObjectId ? this.objectId - previousObjectId - BigInt(1) : this.objectId;
|
|
2344
|
-
const buf = new ByteBuffer();
|
|
2345
|
-
buf.putVI(objectIdDelta);
|
|
2346
|
-
if (this.extensionHeaders !== null) {
|
|
2347
|
-
buf.putLengthPrefixedBytes(serializeKvpList(this.extensionHeaders).toUint8Array());
|
|
2348
|
-
}
|
|
2349
|
-
if (this.payload) {
|
|
2350
|
-
buf.putLengthPrefixedBytes(this.payload);
|
|
2351
|
-
} else {
|
|
2352
|
-
buf.putVI(0);
|
|
2353
|
-
buf.putVI(this.objectStatus);
|
|
2354
|
-
}
|
|
2355
|
-
return buf.freeze();
|
|
2356
|
-
}
|
|
2357
|
-
static deserialize(buf, hasExtensions, previousObjectId) {
|
|
2358
|
-
const objectDelta = buf.getVI();
|
|
2359
|
-
let objectId = previousObjectId !== void 0 ? previousObjectId + objectDelta + BigInt(1) : objectDelta;
|
|
2360
|
-
let extensionHeaders = null;
|
|
2361
|
-
if (hasExtensions) {
|
|
2362
|
-
const extLen = buf.getNumberVI();
|
|
2363
|
-
const headerBytes = new FrozenByteBuffer5(buf.getBytes(extLen));
|
|
2364
|
-
extensionHeaders = deserializeKvpListUntilEmpty(headerBytes);
|
|
2365
|
-
}
|
|
2366
|
-
const payloadLen = buf.getNumberVI();
|
|
2367
|
-
let objectStatus = null;
|
|
2368
|
-
let payload = null;
|
|
2369
|
-
if (payloadLen === 0) {
|
|
2370
|
-
objectStatus = ObjectStatus.tryFrom(buf.getVI());
|
|
2371
|
-
} else {
|
|
2372
|
-
payload = buf.getBytes(payloadLen);
|
|
2373
|
-
}
|
|
2374
|
-
return new _SubgroupObject(objectId, normalizeExtensionHeaders(extensionHeaders), objectStatus, payload);
|
|
2375
|
-
}
|
|
2376
|
-
};
|
|
2377
|
-
|
|
2378
|
-
// src/model/data/object.ts
|
|
2379
|
-
var MoqtObject = class _MoqtObject {
|
|
2380
|
-
constructor(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, objectStatus, extensionHeaders, payload) {
|
|
2381
|
-
this.fullTrackName = fullTrackName;
|
|
2382
|
-
this.publisherPriority = publisherPriority;
|
|
2383
|
-
this.objectForwardingPreference = objectForwardingPreference;
|
|
2384
|
-
this.objectStatus = objectStatus;
|
|
2385
|
-
this.extensionHeaders = extensionHeaders;
|
|
2386
|
-
this.payload = payload;
|
|
2387
|
-
this.location = location;
|
|
2388
|
-
this.subgroupId = subgroupId !== null ? BigInt(subgroupId) : null;
|
|
2389
|
-
}
|
|
2390
|
-
fullTrackName;
|
|
2391
|
-
publisherPriority;
|
|
2392
|
-
objectForwardingPreference;
|
|
2393
|
-
objectStatus;
|
|
2394
|
-
extensionHeaders;
|
|
2395
|
-
payload;
|
|
2396
|
-
location;
|
|
2397
|
-
subgroupId;
|
|
2398
|
-
get groupId() {
|
|
2399
|
-
return this.location.group;
|
|
2400
|
-
}
|
|
2401
|
-
get objectId() {
|
|
2402
|
-
return this.location.object;
|
|
2403
|
-
}
|
|
2404
|
-
getSubgroupHeaderType(containsEnd, useDefaultPriority = false) {
|
|
2405
|
-
const hasExtensions = !!this.extensionHeaders && this.extensionHeaders.length > 0;
|
|
2406
|
-
let subgroupIdMode;
|
|
2407
|
-
if (this.subgroupId === null) {
|
|
2408
|
-
subgroupIdMode = 1;
|
|
2409
|
-
} else if (this.subgroupId === 0n) {
|
|
2410
|
-
subgroupIdMode = 0;
|
|
2411
|
-
} else {
|
|
2412
|
-
subgroupIdMode = 2;
|
|
2413
|
-
}
|
|
2414
|
-
return SubgroupHeaderType.fromProperties(hasExtensions, subgroupIdMode, containsEnd, useDefaultPriority);
|
|
2415
|
-
}
|
|
2416
|
-
isDatagram() {
|
|
2417
|
-
return this.objectForwardingPreference === "Datagram" /* Datagram */;
|
|
2418
|
-
}
|
|
2419
|
-
isSubgroup() {
|
|
2420
|
-
return this.objectForwardingPreference === "Subgroup" /* Subgroup */;
|
|
2421
|
-
}
|
|
2422
|
-
isEndOfGroup() {
|
|
2423
|
-
return this.objectStatus === 3 /* EndOfGroup */;
|
|
2424
|
-
}
|
|
2425
|
-
isEndOfTrack() {
|
|
2426
|
-
return this.objectStatus === 4 /* EndOfTrack */;
|
|
2427
|
-
}
|
|
2428
|
-
hasPayload() {
|
|
2429
|
-
return this.payload !== null;
|
|
2430
|
-
}
|
|
2431
|
-
hasStatus() {
|
|
2432
|
-
return this.objectStatus !== 0 /* Normal */;
|
|
2433
|
-
}
|
|
2434
|
-
static newWithPayload(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, extensionHeaders, payload) {
|
|
2435
|
-
return new _MoqtObject(
|
|
2436
|
-
fullTrackName,
|
|
2437
|
-
location,
|
|
2438
|
-
publisherPriority,
|
|
2439
|
-
objectForwardingPreference,
|
|
2440
|
-
subgroupId,
|
|
2441
|
-
0 /* Normal */,
|
|
2442
|
-
extensionHeaders,
|
|
2443
|
-
payload
|
|
2444
|
-
);
|
|
2445
|
-
}
|
|
2446
|
-
static newWithStatus(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, extensionHeaders, objectStatus) {
|
|
2447
|
-
return new _MoqtObject(
|
|
2448
|
-
fullTrackName,
|
|
2449
|
-
location,
|
|
2450
|
-
publisherPriority,
|
|
2451
|
-
objectForwardingPreference,
|
|
2452
|
-
subgroupId,
|
|
2453
|
-
objectStatus,
|
|
2454
|
-
extensionHeaders,
|
|
2455
|
-
null
|
|
2456
|
-
);
|
|
2457
|
-
}
|
|
2458
|
-
/**
|
|
2459
|
-
* Create a MoqtObject from a Datagram (Draft-16).
|
|
2460
|
-
* @param datagram - The received Datagram.
|
|
2461
|
-
* @param fullTrackName - The resolved full track name.
|
|
2462
|
-
* @param defaultPriority - The default publisher priority from the control message (used when DEFAULT_PRIORITY bit is set).
|
|
2463
|
-
*/
|
|
2464
|
-
static fromDatagram(datagram, fullTrackName, defaultPriority = 0) {
|
|
2465
|
-
const priority = datagram.publisherPriority ?? defaultPriority;
|
|
2466
|
-
if (ObjectDatagramType.isStatus(datagram.type)) {
|
|
2467
|
-
return new _MoqtObject(
|
|
2468
|
-
fullTrackName,
|
|
2469
|
-
datagram.location,
|
|
2470
|
-
priority,
|
|
2471
|
-
"Datagram" /* Datagram */,
|
|
2472
|
-
null,
|
|
2473
|
-
datagram.objectStatus,
|
|
2474
|
-
datagram.extensionHeaders,
|
|
2475
|
-
null
|
|
2476
|
-
);
|
|
2477
|
-
} else {
|
|
2478
|
-
return new _MoqtObject(
|
|
2479
|
-
fullTrackName,
|
|
2480
|
-
datagram.location,
|
|
2481
|
-
priority,
|
|
2482
|
-
"Datagram" /* Datagram */,
|
|
2483
|
-
null,
|
|
2484
|
-
0 /* Normal */,
|
|
2485
|
-
datagram.extensionHeaders,
|
|
2486
|
-
datagram.payload
|
|
2487
|
-
);
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
/**
|
|
2491
|
-
* Returns the endOfGroup flag from the source Datagram.
|
|
2492
|
-
* This is separate from ObjectStatus.EndOfGroup - the flag indicates
|
|
2493
|
-
* this is the last object in the group even with Normal status.
|
|
2494
|
-
*/
|
|
2495
|
-
static isDatagramEndOfGroup(datagram) {
|
|
2496
|
-
return datagram.endOfGroup;
|
|
2497
|
-
}
|
|
2498
|
-
static fromFetchObject(fetchObject, fullTrackName) {
|
|
2499
|
-
if (fetchObject.kind !== "object") {
|
|
2500
|
-
throw new ProtocolViolationError(
|
|
2501
|
-
"MoqtObject.fromFetchObject",
|
|
2502
|
-
"EndOfRange markers cannot be converted to MoqtObject"
|
|
2503
|
-
);
|
|
2504
|
-
}
|
|
2505
|
-
const subgroupId = fetchObject.forwardingPreference === "Subgroup" /* Subgroup */ ? fetchObject.subgroupId : null;
|
|
2506
|
-
return new _MoqtObject(
|
|
2507
|
-
fullTrackName,
|
|
2508
|
-
fetchObject.location,
|
|
2509
|
-
fetchObject.publisherPriority,
|
|
2510
|
-
fetchObject.forwardingPreference,
|
|
2511
|
-
subgroupId,
|
|
2512
|
-
0 /* Normal */,
|
|
2513
|
-
fetchObject.extensionHeaders,
|
|
2514
|
-
fetchObject.payload && fetchObject.payload.length > 0 ? fetchObject.payload : null
|
|
2515
|
-
);
|
|
2516
|
-
}
|
|
2517
|
-
static fromSubgroupObject(subgroupObject, groupId, publisherPriority, subgroupId, fullTrackName) {
|
|
2518
|
-
return new _MoqtObject(
|
|
2519
|
-
fullTrackName,
|
|
2520
|
-
new Location(groupId, subgroupObject.objectId),
|
|
2521
|
-
publisherPriority ?? 0,
|
|
2522
|
-
"Subgroup" /* Subgroup */,
|
|
2523
|
-
subgroupId,
|
|
2524
|
-
subgroupObject.objectStatus || 0 /* Normal */,
|
|
2525
|
-
subgroupObject.extensionHeaders,
|
|
2526
|
-
subgroupObject.payload
|
|
2527
|
-
);
|
|
2528
|
-
}
|
|
2529
|
-
/**
|
|
2530
|
-
* Convert to Datagram for wire transmission (Draft-16).
|
|
2531
|
-
* Automatically creates a payload or status Datagram based on the object's state.
|
|
2532
|
-
* @param trackAlias - The track alias to use.
|
|
2533
|
-
* @param endOfGroup - Whether this is the last object in the group (only for payload datagrams).
|
|
2534
|
-
* @param defaultPriority - If provided and matches this object's priority, the DEFAULT_PRIORITY bit is set.
|
|
2535
|
-
*/
|
|
2536
|
-
tryIntoDatagram(trackAlias, endOfGroup = false, defaultPriority) {
|
|
2537
|
-
if (this.objectForwardingPreference !== "Datagram" /* Datagram */) {
|
|
2538
|
-
throw new CastingError(
|
|
2539
|
-
"MoqtObject.tryIntoDatagram",
|
|
2540
|
-
"MoqtObject",
|
|
2541
|
-
"Datagram",
|
|
2542
|
-
"Object Forwarding Preference must be Datagram"
|
|
2543
|
-
);
|
|
2544
|
-
}
|
|
2545
|
-
const alias = BigInt(trackAlias);
|
|
2546
|
-
const priority = defaultPriority !== void 0 && defaultPriority === this.publisherPriority ? null : this.publisherPriority;
|
|
2547
|
-
if (this.hasStatus()) {
|
|
2548
|
-
return Datagram.newStatus(alias, this.groupId, this.objectId, priority, this.extensionHeaders, this.objectStatus);
|
|
2549
|
-
} else {
|
|
2550
|
-
if (!this.payload) {
|
|
2551
|
-
throw new ProtocolViolationError(
|
|
2552
|
-
"MoqtObject.tryIntoDatagram",
|
|
2553
|
-
"Object must have payload for payload Datagram conversion"
|
|
2554
|
-
);
|
|
2555
|
-
}
|
|
2556
|
-
return Datagram.newPayload(
|
|
2557
|
-
alias,
|
|
2558
|
-
this.groupId,
|
|
2559
|
-
this.objectId,
|
|
2560
|
-
priority,
|
|
2561
|
-
this.extensionHeaders,
|
|
2562
|
-
this.payload,
|
|
2563
|
-
endOfGroup
|
|
2564
|
-
);
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
tryIntoFetchObject() {
|
|
2568
|
-
if (this.objectStatus !== 0 /* Normal */) {
|
|
2569
|
-
throw new CastingError(
|
|
2570
|
-
"MoqtObject.tryIntoFetchObject",
|
|
2571
|
-
"MoqtObject",
|
|
2572
|
-
"FetchObject",
|
|
2573
|
-
"non-Normal status cannot be serialized as a fetch payload; use EndOfRange instead"
|
|
2574
|
-
);
|
|
2575
|
-
}
|
|
2576
|
-
let subgroupId;
|
|
2577
|
-
if (this.objectForwardingPreference === "Subgroup" /* Subgroup */) {
|
|
2578
|
-
if (this.subgroupId === null) {
|
|
2579
|
-
throw new ProtocolViolationError(
|
|
2580
|
-
"MoqtObject.tryIntoFetchObject",
|
|
2581
|
-
"Subgroup ID is required for Subgroup forwarding preference"
|
|
2582
|
-
);
|
|
2583
|
-
}
|
|
2584
|
-
subgroupId = this.subgroupId;
|
|
2585
|
-
} else {
|
|
2586
|
-
if (this.subgroupId !== null) {
|
|
2587
|
-
throw new ProtocolViolationError(
|
|
2588
|
-
"MoqtObject.tryIntoFetchObject",
|
|
2589
|
-
"Subgroup ID must not be set for Datagram forwarding preference"
|
|
2590
|
-
);
|
|
2591
|
-
}
|
|
2592
|
-
subgroupId = this.objectId;
|
|
2593
|
-
}
|
|
2594
|
-
return FetchObject.newObject(
|
|
2595
|
-
this.groupId,
|
|
2596
|
-
subgroupId,
|
|
2597
|
-
this.objectId,
|
|
2598
|
-
this.publisherPriority,
|
|
2599
|
-
this.objectForwardingPreference,
|
|
2600
|
-
this.extensionHeaders,
|
|
2601
|
-
this.payload ?? new Uint8Array(0)
|
|
2602
|
-
);
|
|
2603
|
-
}
|
|
2604
|
-
tryIntoSubgroupObject() {
|
|
2605
|
-
if (this.objectForwardingPreference !== "Subgroup" /* Subgroup */) {
|
|
2606
|
-
throw new CastingError(
|
|
2607
|
-
"MoqtObject.tryIntoSubgroupObject",
|
|
2608
|
-
"MoqtObject",
|
|
2609
|
-
"SubgroupObject",
|
|
2610
|
-
"Object Forwarding Preference must be Subgroup"
|
|
2611
|
-
);
|
|
2612
|
-
}
|
|
2613
|
-
if (this.objectStatus === 0 /* Normal */ && this.payload) {
|
|
2614
|
-
return SubgroupObject.newWithPayload(this.location.object, this.extensionHeaders, this.payload);
|
|
2615
|
-
} else {
|
|
2616
|
-
return SubgroupObject.newWithStatus(this.location.object, this.extensionHeaders, this.objectStatus);
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
};
|
|
2620
|
-
|
|
2621
|
-
// src/model/data/subgroup_header.ts
|
|
2622
|
-
var SubgroupHeader = class _SubgroupHeader {
|
|
2623
|
-
constructor(type, trackAlias, groupId, subgroupId, publisherPriority) {
|
|
2624
|
-
this.type = type;
|
|
2625
|
-
this.publisherPriority = publisherPriority;
|
|
2626
|
-
this.trackAlias = BigInt(trackAlias);
|
|
2627
|
-
this.groupId = BigInt(groupId);
|
|
2628
|
-
if (subgroupId !== void 0) {
|
|
2629
|
-
this.subgroupId = BigInt(subgroupId);
|
|
2630
|
-
} else {
|
|
2631
|
-
this.subgroupId = subgroupId;
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
type;
|
|
2635
|
-
publisherPriority;
|
|
2636
|
-
subgroupId;
|
|
2637
|
-
trackAlias;
|
|
2638
|
-
groupId;
|
|
2639
|
-
serialize() {
|
|
2640
|
-
const buf = new ByteBuffer();
|
|
2641
|
-
buf.putVI(this.type);
|
|
2642
|
-
buf.putVI(this.trackAlias);
|
|
2643
|
-
buf.putVI(this.groupId);
|
|
2644
|
-
if (SubgroupHeaderType.hasExplicitSubgroupId(this.type)) {
|
|
2645
|
-
if (this.subgroupId === void 0) {
|
|
2646
|
-
throw new ProtocolViolationError(
|
|
2647
|
-
"SubgroupHeader.serialize",
|
|
2648
|
-
"Subgroup_id field is required for this header type"
|
|
2649
|
-
);
|
|
2650
|
-
}
|
|
2651
|
-
buf.putVI(this.subgroupId);
|
|
2652
|
-
}
|
|
2653
|
-
if (!SubgroupHeaderType.hasDefaultPriority(this.type)) {
|
|
2654
|
-
if (this.publisherPriority === void 0) {
|
|
2655
|
-
throw new ProtocolViolationError(
|
|
2656
|
-
"SubgroupHeader.serialize",
|
|
2657
|
-
"Publisher_priority field is required when DEFAULT_PRIORITY bit is not set"
|
|
2658
|
-
);
|
|
2659
|
-
}
|
|
2660
|
-
buf.putU8(this.publisherPriority);
|
|
2661
|
-
}
|
|
2662
|
-
return buf.freeze();
|
|
2663
|
-
}
|
|
2664
|
-
static deserialize(buf) {
|
|
2665
|
-
const headerType = SubgroupHeaderType.tryFrom(buf.getNumberVI());
|
|
2666
|
-
const trackAlias = buf.getVI();
|
|
2667
|
-
const groupId = buf.getVI();
|
|
2668
|
-
let subgroupId;
|
|
2669
|
-
if (SubgroupHeaderType.hasExplicitSubgroupId(headerType)) {
|
|
2670
|
-
subgroupId = buf.getVI();
|
|
2671
|
-
} else if (SubgroupHeaderType.isSubgroupIdZero(headerType)) {
|
|
2672
|
-
subgroupId = 0n;
|
|
2673
|
-
}
|
|
2674
|
-
let publisherPriority;
|
|
2675
|
-
if (!SubgroupHeaderType.hasDefaultPriority(headerType)) {
|
|
2676
|
-
publisherPriority = buf.getU8();
|
|
2677
|
-
}
|
|
2678
|
-
return new _SubgroupHeader(headerType, trackAlias, groupId, subgroupId, publisherPriority);
|
|
2679
|
-
}
|
|
2680
|
-
};
|
|
2681
|
-
|
|
2682
|
-
// src/model/data/request_id.ts
|
|
2683
|
-
var RequestIdMap = class {
|
|
2684
|
-
requestIdToName = /* @__PURE__ */ new Map();
|
|
2685
|
-
nameToRequestId = /* @__PURE__ */ new Map();
|
|
2686
|
-
/**
|
|
2687
|
-
* @public
|
|
2688
|
-
* Adds a mapping between a requestId and a full track name.
|
|
2689
|
-
*
|
|
2690
|
-
* @param requestId - The requestId to associate.
|
|
2691
|
-
* @param name - The full track name to associate.
|
|
2692
|
-
* @throws :{@link RequestIdError} if the requestId or name is already mapped to a different value.
|
|
2693
|
-
*/
|
|
2694
|
-
addMapping(requestId, name) {
|
|
2695
|
-
if (this.requestIdToName.has(requestId)) {
|
|
2696
|
-
const existingName = this.requestIdToName.get(requestId);
|
|
2697
|
-
if (existingName === name) return;
|
|
2698
|
-
throw new RequestIdError(
|
|
2699
|
-
"RequestIdMap::addMapping(existingName)",
|
|
2700
|
-
`Full track name already exists for requestId: ${requestId}`
|
|
2701
|
-
);
|
|
2702
|
-
}
|
|
2703
|
-
this.requestIdToName.set(requestId, name);
|
|
2704
|
-
this.nameToRequestId.set(name, requestId);
|
|
2705
|
-
}
|
|
2706
|
-
/**
|
|
2707
|
-
* @public
|
|
2708
|
-
* Gets the full track name for a given requestId.
|
|
2709
|
-
*
|
|
2710
|
-
* @param requestId - The requestId to look up.
|
|
2711
|
-
* @returns The associated full track name.
|
|
2712
|
-
* @throws :{@link RequestIdError} if the requestId does not exist.
|
|
2713
|
-
*/
|
|
2714
|
-
getNameByRequestId(requestId) {
|
|
2715
|
-
const name = this.requestIdToName.get(requestId);
|
|
2716
|
-
if (!name)
|
|
2717
|
-
throw new RequestIdError("RequestIdMap::getNameByRequestId(name)", `RequestId: ${requestId} doesn't exist`);
|
|
2718
|
-
return name;
|
|
2719
|
-
}
|
|
2720
|
-
/**
|
|
2721
|
-
* @public
|
|
2722
|
-
* Gets the requestId for a given full track name.
|
|
2723
|
-
*
|
|
2724
|
-
* @param name - The full track name to look up.
|
|
2725
|
-
* @returns The associated requestId.
|
|
2726
|
-
* @throws :{@link RequestIdError} if the name does not exist.
|
|
2727
|
-
*/
|
|
2728
|
-
getRequestIdByName(name) {
|
|
2729
|
-
const requestId = this.nameToRequestId.get(name);
|
|
2730
|
-
if (requestId === void 0)
|
|
2731
|
-
throw new RequestIdError("RequestIdMap::getRequestIdByName(requestId)", `Name does not exist`);
|
|
2732
|
-
return requestId;
|
|
2733
|
-
}
|
|
2734
|
-
/**
|
|
2735
|
-
* @public
|
|
2736
|
-
* Removes a mapping by requestId.
|
|
2737
|
-
*
|
|
2738
|
-
* @param requestId - The requestId to remove.
|
|
2739
|
-
* @returns The removed full track name, or undefined if not found.
|
|
2740
|
-
*/
|
|
2741
|
-
removeMappingByRequestId(requestId) {
|
|
2742
|
-
const name = this.requestIdToName.get(requestId);
|
|
2743
|
-
if (name) {
|
|
2744
|
-
this.requestIdToName.delete(requestId);
|
|
2745
|
-
this.nameToRequestId.delete(name);
|
|
2746
|
-
return name;
|
|
2747
|
-
}
|
|
2748
|
-
return void 0;
|
|
2749
|
-
}
|
|
2750
|
-
/**
|
|
2751
|
-
* @public
|
|
2752
|
-
* Removes a mapping by full track name.
|
|
2753
|
-
*
|
|
2754
|
-
* @param name - The full track name to remove.
|
|
2755
|
-
* @returns The removed requestId, or undefined if not found.
|
|
2756
|
-
*/
|
|
2757
|
-
removeMappingByName(name) {
|
|
2758
|
-
const requestId = this.nameToRequestId.get(name);
|
|
2759
|
-
if (requestId !== void 0) {
|
|
2760
|
-
this.nameToRequestId.delete(name);
|
|
2761
|
-
this.requestIdToName.delete(requestId);
|
|
2762
|
-
return requestId;
|
|
2763
|
-
}
|
|
2764
|
-
return void 0;
|
|
2765
|
-
}
|
|
2766
|
-
/**
|
|
2767
|
-
* @public
|
|
2768
|
-
* Checks if the map contains a given requestId.
|
|
2769
|
-
*
|
|
2770
|
-
* @param requestId - The requestId to check.
|
|
2771
|
-
* @returns True if the requestId exists, false otherwise.
|
|
2772
|
-
*/
|
|
2773
|
-
containsRequestId(requestId) {
|
|
2774
|
-
return this.requestIdToName.has(requestId);
|
|
2775
|
-
}
|
|
2776
|
-
/**
|
|
2777
|
-
* @public
|
|
2778
|
-
* Checks if the map contains a given full track name.
|
|
2779
|
-
*
|
|
2780
|
-
* @param name - The full track name to check.
|
|
2781
|
-
* @returns True if the name exists, false otherwise.
|
|
2782
|
-
*/
|
|
2783
|
-
containsName(name) {
|
|
2784
|
-
return this.nameToRequestId.has(name);
|
|
2785
|
-
}
|
|
2786
|
-
};
|
|
2787
|
-
|
|
2788
|
-
// src/model/data/header.ts
|
|
2789
|
-
var Header;
|
|
2790
|
-
((Header2) => {
|
|
2791
|
-
function newFetch(...args) {
|
|
2792
|
-
return new FetchHeader(...args);
|
|
2793
|
-
}
|
|
2794
|
-
Header2.newFetch = newFetch;
|
|
2795
|
-
function newSubgroup(...args) {
|
|
2796
|
-
return new SubgroupHeader(...args);
|
|
2797
|
-
}
|
|
2798
|
-
Header2.newSubgroup = newSubgroup;
|
|
2799
|
-
function isFetch(header) {
|
|
2800
|
-
return header instanceof FetchHeader;
|
|
2801
|
-
}
|
|
2802
|
-
Header2.isFetch = isFetch;
|
|
2803
|
-
function isSubgroup(header) {
|
|
2804
|
-
return header instanceof SubgroupHeader;
|
|
2805
|
-
}
|
|
2806
|
-
Header2.isSubgroup = isSubgroup;
|
|
2807
|
-
function serialize(header) {
|
|
2808
|
-
return header.serialize();
|
|
2809
|
-
}
|
|
2810
|
-
Header2.serialize = serialize;
|
|
2811
|
-
function deserialize(buf) {
|
|
2812
|
-
buf.checkpoint();
|
|
2813
|
-
const type = buf.getNumberVI();
|
|
2814
|
-
buf.restore();
|
|
2815
|
-
if (type === 5) {
|
|
2816
|
-
return FetchHeader.deserialize(buf);
|
|
2817
|
-
} else if ((type & SubgroupHeaderType.REQUIRED_BIT) !== 0 && (type & 192) === 0) {
|
|
2818
|
-
return SubgroupHeader.deserialize(buf);
|
|
2819
|
-
} else {
|
|
2820
|
-
throw new InvalidTypeError("Header::deserialize(type)", `Unknown header type: ${type}`);
|
|
2821
|
-
}
|
|
2822
|
-
}
|
|
2823
|
-
Header2.deserialize = deserialize;
|
|
2824
|
-
})(Header || (Header = {}));
|
|
2825
|
-
|
|
2826
|
-
// src/model/common/byte_buffer.ts
|
|
2827
|
-
var MAX_VARINT_1BYTE = 2n ** 6n - 1n;
|
|
2828
|
-
var MAX_VARINT_2BYTE = 2n ** 14n - 1n;
|
|
2829
|
-
var MAX_VARINT_4BYTE = 2n ** 30n - 1n;
|
|
2830
|
-
var MAX_VARINT_8BYTE = 2n ** 62n - 1n;
|
|
2831
|
-
var BaseByteBuffer13 = class {
|
|
2832
|
-
buf;
|
|
2833
|
-
view;
|
|
2834
|
-
_offset = 0;
|
|
2835
|
-
_checkpoint = 0;
|
|
2836
|
-
constructor(buf) {
|
|
2837
|
-
this.buf = buf;
|
|
2838
|
-
this.view = new DataView(buf.buffer, buf.byteOffset, buf.length);
|
|
2839
|
-
}
|
|
2840
|
-
get offset() {
|
|
2841
|
-
return this._offset;
|
|
2842
|
-
}
|
|
2843
|
-
get remaining() {
|
|
2844
|
-
return this.length - this._offset;
|
|
2845
|
-
}
|
|
2846
|
-
/**
|
|
2847
|
-
* Save current read position for potential rollback
|
|
2848
|
-
*/
|
|
2849
|
-
checkpoint() {
|
|
2850
|
-
this._checkpoint = this._offset;
|
|
2851
|
-
}
|
|
2852
|
-
/**
|
|
2853
|
-
* Restore read position to last checkpoint
|
|
2854
|
-
*/
|
|
2855
|
-
restore() {
|
|
2856
|
-
this._offset = this._checkpoint;
|
|
2857
|
-
}
|
|
2858
|
-
toUint8Array() {
|
|
2859
|
-
return this.buf.slice();
|
|
2860
|
-
}
|
|
2861
|
-
getU8() {
|
|
2862
|
-
if (this.remaining < 1) throw new NotEnoughBytesError("getU8", 1, this.remaining);
|
|
2863
|
-
return this.view.getUint8(this._offset++);
|
|
2864
|
-
}
|
|
2865
|
-
getU16() {
|
|
2866
|
-
if (this.remaining < 2) throw new NotEnoughBytesError("getU16", 2, this.remaining);
|
|
2867
|
-
const v = this.view.getUint16(this._offset, false);
|
|
2868
|
-
this._offset += 2;
|
|
2869
|
-
return v;
|
|
2870
|
-
}
|
|
2871
|
-
getVI() {
|
|
2872
|
-
if (this.remaining < 1) throw new NotEnoughBytesError("getVI.first_byte", 1, this.remaining);
|
|
2873
|
-
const first = this.getU8();
|
|
2874
|
-
const prefix = first >> 6;
|
|
2875
|
-
let numBytes;
|
|
2876
|
-
switch (prefix) {
|
|
2877
|
-
case 0:
|
|
2878
|
-
numBytes = 1;
|
|
2879
|
-
break;
|
|
2880
|
-
case 1:
|
|
2881
|
-
numBytes = 2;
|
|
2882
|
-
break;
|
|
2883
|
-
case 2:
|
|
2884
|
-
numBytes = 4;
|
|
2885
|
-
break;
|
|
2886
|
-
case 3:
|
|
2887
|
-
numBytes = 8;
|
|
2888
|
-
break;
|
|
2889
|
-
default:
|
|
2890
|
-
throw new Error("Invalid varint prefix");
|
|
2891
|
-
}
|
|
2892
|
-
if (numBytes > 1 && this.remaining < numBytes - 1) {
|
|
2893
|
-
this._offset--;
|
|
2894
|
-
throw new NotEnoughBytesError("getVI.continuation", numBytes, this.remaining + 1);
|
|
2895
|
-
}
|
|
2896
|
-
let result = BigInt(first & 63);
|
|
2897
|
-
if (numBytes > 1) {
|
|
2898
|
-
result <<= BigInt((numBytes - 1) * 8);
|
|
2899
|
-
for (let i = 1; i < numBytes; i++) {
|
|
2900
|
-
const b = BigInt(this.getU8());
|
|
2901
|
-
result |= b << BigInt((numBytes - 1 - i) * 8);
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
return result;
|
|
2905
|
-
}
|
|
2906
|
-
getNumberVI() {
|
|
2907
|
-
let big = this.getVI();
|
|
2908
|
-
if (big > Number.MAX_SAFE_INTEGER)
|
|
2909
|
-
throw new CastingError(
|
|
2910
|
-
"BaseByteBuffer.getNumberVI()",
|
|
2911
|
-
"bigint",
|
|
2912
|
-
"number",
|
|
2913
|
-
"bigint exceeds Number.MAX_SAFE_INTEGER"
|
|
2914
|
-
);
|
|
2915
|
-
return Number(big);
|
|
2916
|
-
}
|
|
2917
|
-
getBytes(len) {
|
|
2918
|
-
if (this.remaining < len) throw new NotEnoughBytesError("getBytes", len, this.remaining);
|
|
2919
|
-
const slice = this.buf.slice(this._offset, this._offset + len);
|
|
2920
|
-
this._offset += len;
|
|
2921
|
-
return slice;
|
|
2922
|
-
}
|
|
2923
|
-
getLengthPrefixedBytes() {
|
|
2924
|
-
const len = this.getNumberVI();
|
|
2925
|
-
if (this.length < this.offset + len)
|
|
2926
|
-
throw new NotEnoughBytesError("BaseByteBuffer.getLengthPrefixedBytes", len, this.length - this.offset);
|
|
2927
|
-
return this.getBytes(len);
|
|
2928
|
-
}
|
|
2929
|
-
getKeyValuePair() {
|
|
2930
|
-
return KeyValuePair.deserialize(this);
|
|
2931
|
-
}
|
|
2932
|
-
getReasonPhrase() {
|
|
2933
|
-
return ReasonPhrase.deserialize(this);
|
|
2934
|
-
}
|
|
2935
|
-
getLocation() {
|
|
2936
|
-
return Location.deserialize(this);
|
|
2937
|
-
}
|
|
2938
|
-
getTuple() {
|
|
2939
|
-
return Tuple.deserialize(this);
|
|
2940
|
-
}
|
|
2941
|
-
getFullTrackName() {
|
|
2942
|
-
return FullTrackName.deserialize(this);
|
|
2943
|
-
}
|
|
2944
|
-
};
|
|
2945
|
-
var ByteBuffer = class extends BaseByteBuffer13 {
|
|
2946
|
-
_length = 0;
|
|
2947
|
-
constructor(initialSize = 128) {
|
|
2948
|
-
super(new Uint8Array(initialSize));
|
|
2949
|
-
}
|
|
2950
|
-
get length() {
|
|
2951
|
-
return this._length;
|
|
2952
|
-
}
|
|
2953
|
-
/**
|
|
2954
|
-
* Clear all data and reset all positions
|
|
2955
|
-
*/
|
|
2956
|
-
clear() {
|
|
2957
|
-
this._length = 0;
|
|
2958
|
-
this._offset = 0;
|
|
2959
|
-
this._checkpoint = 0;
|
|
2960
|
-
this.buf = new Uint8Array();
|
|
2961
|
-
this.view = new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.length);
|
|
2962
|
-
}
|
|
2963
|
-
/**
|
|
2964
|
-
* Drop all data before current offset and reset positions
|
|
2965
|
-
* This is the key method for memory management - removes processed data
|
|
2966
|
-
*/
|
|
2967
|
-
commit() {
|
|
2968
|
-
if (this._offset === 0) {
|
|
2969
|
-
return;
|
|
2970
|
-
}
|
|
2971
|
-
if (this._offset >= this._length) {
|
|
2972
|
-
this.clear();
|
|
2973
|
-
return;
|
|
2974
|
-
}
|
|
2975
|
-
this.buf.set(this.buf.subarray(this._offset, this._length), 0);
|
|
2976
|
-
this._length = this._length - this._offset;
|
|
2977
|
-
this._offset = 0;
|
|
2978
|
-
this._checkpoint = 0;
|
|
2979
|
-
this.view = new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.length);
|
|
2980
|
-
}
|
|
2981
|
-
ensureCapacity(add) {
|
|
2982
|
-
const need = this._length + add;
|
|
2983
|
-
if (need <= this.buf.length) return;
|
|
2984
|
-
let newSize = this.buf.length * 2 + 1;
|
|
2985
|
-
while (newSize < need) newSize *= 2;
|
|
2986
|
-
const newBuf = new Uint8Array(newSize);
|
|
2987
|
-
newBuf.set(this.buf.subarray(0, this._length));
|
|
2988
|
-
this.buf = newBuf;
|
|
2989
|
-
this.view = new DataView(this.buf.buffer);
|
|
2990
|
-
}
|
|
2991
|
-
// --------- WRITE OPERATIONS ---------
|
|
2992
|
-
putU8(v) {
|
|
2993
|
-
if (v < 0 || v > 255) {
|
|
2994
|
-
throw new RangeError(`Value ${v} is out of range for a U8 (0-255).`);
|
|
2995
|
-
}
|
|
2996
|
-
this.ensureCapacity(1);
|
|
2997
|
-
this.view.setUint8(this._length++, v);
|
|
2998
|
-
}
|
|
2999
|
-
putU16(v) {
|
|
3000
|
-
if (v < 0 || v > 65535) {
|
|
3001
|
-
throw new RangeError(`Value ${v} is out of range for a U16 (0-65535).`);
|
|
3002
|
-
}
|
|
3003
|
-
this.ensureCapacity(2);
|
|
3004
|
-
this.view.setUint16(this._length, v, false);
|
|
3005
|
-
this._length += 2;
|
|
3006
|
-
}
|
|
3007
|
-
/**
|
|
3008
|
-
* Write a variable-length integer (QUIC-style varint)
|
|
3009
|
-
* Encoding:
|
|
3010
|
-
* - 2 MSB = 00: 1 byte (6 bits) for values 0-63
|
|
3011
|
-
* - 2 MSB = 01: 2 bytes (14 bits) for values 0-16383
|
|
3012
|
-
* - 2 MSB = 10: 4 bytes (30 bits) for values 0-1073741823
|
|
3013
|
-
* - 2 MSB = 11: 8 bytes (62 bits) for values 0-4611686018427387903
|
|
3014
|
-
*/
|
|
3015
|
-
putVI(v) {
|
|
3016
|
-
const value = typeof v === "number" ? BigInt(v) : v;
|
|
3017
|
-
if (value < 0) {
|
|
3018
|
-
throw new CastingError("putVI", typeof v, "unsigned varint", "negative values are not supported");
|
|
3019
|
-
}
|
|
3020
|
-
if (value <= MAX_VARINT_1BYTE) {
|
|
3021
|
-
this.putU8(Number(value));
|
|
3022
|
-
} else if (value <= MAX_VARINT_2BYTE) {
|
|
3023
|
-
this.ensureCapacity(2);
|
|
3024
|
-
this.view.setUint8(this._length++, Number(value >> 8n | 0b01000000n));
|
|
3025
|
-
this.view.setUint8(this._length++, Number(value & 0xffn));
|
|
3026
|
-
} else if (value <= MAX_VARINT_4BYTE) {
|
|
3027
|
-
this.ensureCapacity(4);
|
|
3028
|
-
this.view.setUint8(this._length++, Number(value >> 24n | 0b10000000n));
|
|
3029
|
-
this.view.setUint8(this._length++, Number(value >> 16n & 0xffn));
|
|
3030
|
-
this.view.setUint8(this._length++, Number(value >> 8n & 0xffn));
|
|
3031
|
-
this.view.setUint8(this._length++, Number(value & 0xffn));
|
|
3032
|
-
} else if (value <= MAX_VARINT_8BYTE) {
|
|
3033
|
-
this.ensureCapacity(8);
|
|
3034
|
-
this.view.setUint8(this._length++, Number(value >> 56n | 0b11000000n));
|
|
3035
|
-
this.view.setUint8(this._length++, Number(value >> 48n & 0xffn));
|
|
3036
|
-
this.view.setUint8(this._length++, Number(value >> 40n & 0xffn));
|
|
3037
|
-
this.view.setUint8(this._length++, Number(value >> 32n & 0xffn));
|
|
3038
|
-
this.view.setUint8(this._length++, Number(value >> 24n & 0xffn));
|
|
3039
|
-
this.view.setUint8(this._length++, Number(value >> 16n & 0xffn));
|
|
3040
|
-
this.view.setUint8(this._length++, Number(value >> 8n & 0xffn));
|
|
3041
|
-
this.view.setUint8(this._length++, Number(value & 0xffn));
|
|
3042
|
-
} else {
|
|
3043
|
-
throw new VarIntOverflowError("putVI", Number(value));
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3046
|
-
putBytes(src) {
|
|
3047
|
-
this.ensureCapacity(src.length);
|
|
3048
|
-
this.buf.set(src, this._length);
|
|
3049
|
-
this._length += src.length;
|
|
3050
|
-
}
|
|
3051
|
-
putLengthPrefixedBytes(src) {
|
|
3052
|
-
this.putVI(src.length);
|
|
3053
|
-
this.putBytes(src);
|
|
3054
|
-
}
|
|
3055
|
-
putKeyValuePair(pair) {
|
|
3056
|
-
const b = pair.serialize().toUint8Array();
|
|
3057
|
-
this.putBytes(b);
|
|
3058
|
-
}
|
|
3059
|
-
putReasonPhrase(reason) {
|
|
3060
|
-
const b = reason.serialize().toUint8Array();
|
|
3061
|
-
this.putBytes(b);
|
|
3062
|
-
}
|
|
3063
|
-
toUint8Array() {
|
|
3064
|
-
return this.buf.slice(0, this._length);
|
|
3065
|
-
}
|
|
3066
|
-
freeze() {
|
|
3067
|
-
const snap = this.buf.slice(0, this._length);
|
|
3068
|
-
return new FrozenByteBuffer5(snap);
|
|
3069
|
-
}
|
|
3070
|
-
putLocation(loc) {
|
|
3071
|
-
this.putVI(loc.group);
|
|
3072
|
-
this.putVI(loc.object);
|
|
3073
|
-
}
|
|
3074
|
-
putTuple(tuple) {
|
|
3075
|
-
const serialized = tuple.serialize();
|
|
3076
|
-
this.putBytes(serialized.toUint8Array());
|
|
3077
|
-
}
|
|
3078
|
-
putFullTrackName(fullTrackName) {
|
|
3079
|
-
const serialized = fullTrackName.serialize();
|
|
3080
|
-
this.putBytes(serialized.toUint8Array());
|
|
3081
|
-
}
|
|
3082
|
-
};
|
|
3083
|
-
var FrozenByteBuffer5 = class extends BaseByteBuffer13 {
|
|
3084
|
-
constructor(buf) {
|
|
3085
|
-
super(buf);
|
|
3086
|
-
}
|
|
3087
|
-
get length() {
|
|
3088
|
-
return this.buf.length;
|
|
3089
|
-
}
|
|
3090
|
-
};
|
|
3091
|
-
|
|
3092
|
-
// src/model/parameter/constant.ts
|
|
3093
|
-
var SetupParameterType = /* @__PURE__ */ ((SetupParameterType2) => {
|
|
3094
|
-
SetupParameterType2[SetupParameterType2["Path"] = 1] = "Path";
|
|
3095
|
-
SetupParameterType2[SetupParameterType2["MaxRequestId"] = 2] = "MaxRequestId";
|
|
3096
|
-
SetupParameterType2[SetupParameterType2["AuthorizationToken"] = 3] = "AuthorizationToken";
|
|
3097
|
-
SetupParameterType2[SetupParameterType2["MaxAuthTokenCacheSize"] = 4] = "MaxAuthTokenCacheSize";
|
|
3098
|
-
return SetupParameterType2;
|
|
3099
|
-
})(SetupParameterType || {});
|
|
3100
|
-
function setupParameterTypeFromNumber(value) {
|
|
3101
|
-
switch (value) {
|
|
3102
|
-
case 1:
|
|
3103
|
-
return 1 /* Path */;
|
|
3104
|
-
case 2:
|
|
3105
|
-
return 2 /* MaxRequestId */;
|
|
3106
|
-
case 3:
|
|
3107
|
-
return 3 /* AuthorizationToken */;
|
|
3108
|
-
case 4:
|
|
3109
|
-
return 4 /* MaxAuthTokenCacheSize */;
|
|
3110
|
-
default:
|
|
3111
|
-
throw new InvalidTypeError("setupParameterTypeFromNumber", `Invalid setup parameter type: ${value}`);
|
|
3112
|
-
}
|
|
3113
|
-
}
|
|
3114
|
-
var MessageParameterType = /* @__PURE__ */ ((MessageParameterType2) => {
|
|
3115
|
-
MessageParameterType2[MessageParameterType2["DeliveryTimeout"] = 2] = "DeliveryTimeout";
|
|
3116
|
-
MessageParameterType2[MessageParameterType2["AuthorizationToken"] = 3] = "AuthorizationToken";
|
|
3117
|
-
MessageParameterType2[MessageParameterType2["Expires"] = 8] = "Expires";
|
|
3118
|
-
MessageParameterType2[MessageParameterType2["LargestObject"] = 9] = "LargestObject";
|
|
3119
|
-
MessageParameterType2[MessageParameterType2["Forward"] = 16] = "Forward";
|
|
3120
|
-
MessageParameterType2[MessageParameterType2["SubscriberPriority"] = 32] = "SubscriberPriority";
|
|
3121
|
-
MessageParameterType2[MessageParameterType2["SubscriptionFilter"] = 33] = "SubscriptionFilter";
|
|
3122
|
-
MessageParameterType2[MessageParameterType2["GroupOrder"] = 34] = "GroupOrder";
|
|
3123
|
-
MessageParameterType2[MessageParameterType2["NewGroupRequest"] = 50] = "NewGroupRequest";
|
|
3124
|
-
return MessageParameterType2;
|
|
3125
|
-
})(MessageParameterType || {});
|
|
3126
|
-
function messageParameterTypeFromNumber(value) {
|
|
3127
|
-
const numValue = Number(value);
|
|
3128
|
-
switch (numValue) {
|
|
3129
|
-
case 2:
|
|
3130
|
-
return 2 /* DeliveryTimeout */;
|
|
3131
|
-
case 3:
|
|
3132
|
-
return 3 /* AuthorizationToken */;
|
|
3133
|
-
case 8:
|
|
3134
|
-
return 8 /* Expires */;
|
|
3135
|
-
case 9:
|
|
3136
|
-
return 9 /* LargestObject */;
|
|
3137
|
-
case 16:
|
|
3138
|
-
return 16 /* Forward */;
|
|
3139
|
-
case 32:
|
|
3140
|
-
return 32 /* SubscriberPriority */;
|
|
3141
|
-
case 33:
|
|
3142
|
-
return 33 /* SubscriptionFilter */;
|
|
3143
|
-
case 34:
|
|
3144
|
-
return 34 /* GroupOrder */;
|
|
3145
|
-
case 50:
|
|
3146
|
-
return 50 /* NewGroupRequest */;
|
|
3147
|
-
default:
|
|
3148
|
-
throw new InvalidTypeError("messageParameterTypeFromNumber", `Unknown message parameter type: ${value}`);
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
var TokenAliasType = /* @__PURE__ */ ((TokenAliasType3) => {
|
|
3152
|
-
TokenAliasType3[TokenAliasType3["Delete"] = 0] = "Delete";
|
|
3153
|
-
TokenAliasType3[TokenAliasType3["Register"] = 1] = "Register";
|
|
3154
|
-
TokenAliasType3[TokenAliasType3["UseAlias"] = 2] = "UseAlias";
|
|
3155
|
-
TokenAliasType3[TokenAliasType3["UseValue"] = 3] = "UseValue";
|
|
3156
|
-
return TokenAliasType3;
|
|
3157
|
-
})(TokenAliasType || {});
|
|
3158
|
-
function tokenAliasTypeFromNumber(value) {
|
|
3159
|
-
switch (value) {
|
|
3160
|
-
case 0:
|
|
3161
|
-
return 0 /* Delete */;
|
|
3162
|
-
case 1:
|
|
3163
|
-
return 1 /* Register */;
|
|
3164
|
-
case 2:
|
|
3165
|
-
return 2 /* UseAlias */;
|
|
3166
|
-
case 3:
|
|
3167
|
-
return 3 /* UseValue */;
|
|
3168
|
-
default:
|
|
3169
|
-
throw new InvalidTypeError("tokenAliasTypeFromNumber", `Invalid token alias type: ${value}`);
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
|
|
3173
|
-
// src/model/parameter/common/authorization_token.ts
|
|
3174
|
-
var AuthorizationToken = class _AuthorizationToken {
|
|
3175
|
-
constructor(variant) {
|
|
3176
|
-
this.variant = variant;
|
|
3177
|
-
}
|
|
3178
|
-
variant;
|
|
3179
|
-
static TYPE = 3 /* AuthorizationToken */;
|
|
3180
|
-
static newDelete(tokenAlias) {
|
|
3181
|
-
return new _AuthorizationToken({
|
|
3182
|
-
aliasType: 0 /* Delete */,
|
|
3183
|
-
tokenAlias: BigInt(tokenAlias)
|
|
3184
|
-
});
|
|
3185
|
-
}
|
|
3186
|
-
static newRegister(tokenAlias, tokenType, tokenValue) {
|
|
3187
|
-
return new _AuthorizationToken({
|
|
3188
|
-
aliasType: 1 /* Register */,
|
|
3189
|
-
tokenAlias: BigInt(tokenAlias),
|
|
3190
|
-
tokenType: BigInt(tokenType),
|
|
3191
|
-
tokenValue
|
|
3192
|
-
});
|
|
3193
|
-
}
|
|
3194
|
-
static newUseAlias(tokenAlias) {
|
|
3195
|
-
return new _AuthorizationToken({
|
|
3196
|
-
aliasType: 2 /* UseAlias */,
|
|
3197
|
-
tokenAlias: BigInt(tokenAlias)
|
|
3198
|
-
});
|
|
3199
|
-
}
|
|
3200
|
-
static newUseValue(tokenType, tokenValue) {
|
|
3201
|
-
return new _AuthorizationToken({
|
|
3202
|
-
aliasType: 3 /* UseValue */,
|
|
3203
|
-
tokenType: BigInt(tokenType),
|
|
3204
|
-
tokenValue
|
|
3205
|
-
});
|
|
3206
|
-
}
|
|
3207
|
-
toKeyValuePair() {
|
|
3208
|
-
const payload = new ByteBuffer();
|
|
3209
|
-
payload.putVI(this.variant.aliasType);
|
|
3210
|
-
switch (this.variant.aliasType) {
|
|
3211
|
-
case 0 /* Delete */:
|
|
3212
|
-
payload.putVI(this.variant.tokenAlias);
|
|
3213
|
-
break;
|
|
3214
|
-
case 1 /* Register */:
|
|
3215
|
-
payload.putVI(this.variant.tokenAlias);
|
|
3216
|
-
payload.putVI(this.variant.tokenType);
|
|
3217
|
-
payload.putBytes(this.variant.tokenValue);
|
|
3218
|
-
break;
|
|
3219
|
-
case 2 /* UseAlias */:
|
|
3220
|
-
payload.putVI(this.variant.tokenAlias);
|
|
3221
|
-
break;
|
|
3222
|
-
case 3 /* UseValue */:
|
|
3223
|
-
payload.putVI(this.variant.tokenType);
|
|
3224
|
-
payload.putBytes(this.variant.tokenValue);
|
|
3225
|
-
break;
|
|
3226
|
-
}
|
|
3227
|
-
return KeyValuePair.tryNewBytes(_AuthorizationToken.TYPE, payload.toUint8Array());
|
|
3228
|
-
}
|
|
3229
|
-
static fromKeyValuePair(pair) {
|
|
3230
|
-
if (Number(pair.typeValue) !== _AuthorizationToken.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
3231
|
-
const frozen = new FrozenByteBuffer5(pair.value);
|
|
3232
|
-
const aliasTypeRaw = frozen.getNumberVI();
|
|
3233
|
-
const aliasType = tokenAliasTypeFromNumber(aliasTypeRaw);
|
|
3234
|
-
switch (aliasType) {
|
|
3235
|
-
case 0 /* Delete */: {
|
|
3236
|
-
const tokenAlias = frozen.getVI();
|
|
3237
|
-
return new _AuthorizationToken({ aliasType, tokenAlias });
|
|
3238
|
-
}
|
|
3239
|
-
case 1 /* Register */: {
|
|
3240
|
-
const tokenAlias = frozen.getVI();
|
|
3241
|
-
const tokenType = frozen.getVI();
|
|
3242
|
-
const tokenValue = frozen.getBytes(frozen.remaining);
|
|
3243
|
-
return new _AuthorizationToken({ aliasType, tokenAlias, tokenType, tokenValue });
|
|
3244
|
-
}
|
|
3245
|
-
case 2 /* UseAlias */: {
|
|
3246
|
-
const tokenAlias = frozen.getVI();
|
|
3247
|
-
return new _AuthorizationToken({ aliasType, tokenAlias });
|
|
3248
|
-
}
|
|
3249
|
-
case 3 /* UseValue */: {
|
|
3250
|
-
const tokenType = frozen.getVI();
|
|
3251
|
-
const tokenValue = frozen.getBytes(frozen.remaining);
|
|
3252
|
-
return new _AuthorizationToken({ aliasType, tokenType, tokenValue });
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
}
|
|
3256
|
-
};
|
|
3257
|
-
|
|
3258
|
-
// src/model/parameter/message/delivery_timeout.ts
|
|
3259
|
-
var DeliveryTimeout = class _DeliveryTimeout {
|
|
3260
|
-
constructor(timeout) {
|
|
3261
|
-
this.timeout = timeout;
|
|
3262
|
-
}
|
|
3263
|
-
timeout;
|
|
3264
|
-
static TYPE = 2 /* DeliveryTimeout */;
|
|
3265
|
-
toKeyValuePair() {
|
|
3266
|
-
return KeyValuePair.tryNewVarInt(_DeliveryTimeout.TYPE, this.timeout);
|
|
3267
|
-
}
|
|
3268
|
-
static fromKeyValuePair(pair) {
|
|
3269
|
-
if (Number(pair.typeValue) !== _DeliveryTimeout.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
3270
|
-
if (pair.value === 0n) {
|
|
3271
|
-
throw new ProtocolViolationError("DeliveryTimeout.fromKeyValuePair", "DELIVERY_TIMEOUT must be greater than 0");
|
|
3272
|
-
}
|
|
3273
|
-
return new _DeliveryTimeout(pair.value);
|
|
3274
|
-
}
|
|
3275
|
-
};
|
|
3276
|
-
|
|
3277
|
-
// src/model/parameter/message/expires.ts
|
|
3278
|
-
var Expires = class _Expires {
|
|
3279
|
-
constructor(expires) {
|
|
3280
|
-
this.expires = expires;
|
|
3281
|
-
}
|
|
3282
|
-
expires;
|
|
3283
|
-
static TYPE = 8 /* Expires */;
|
|
3284
|
-
toKeyValuePair() {
|
|
3285
|
-
return KeyValuePair.tryNewVarInt(_Expires.TYPE, this.expires);
|
|
3286
|
-
}
|
|
3287
|
-
static fromKeyValuePair(pair) {
|
|
3288
|
-
if (Number(pair.typeValue) !== _Expires.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
3289
|
-
return new _Expires(pair.value);
|
|
3290
|
-
}
|
|
3291
|
-
};
|
|
3292
|
-
|
|
3293
|
-
// src/model/parameter/message/forward.ts
|
|
3294
|
-
var Forward = class _Forward {
|
|
3295
|
-
constructor(forward) {
|
|
3296
|
-
this.forward = forward;
|
|
3297
|
-
}
|
|
3298
|
-
forward;
|
|
3299
|
-
static TYPE = 16 /* Forward */;
|
|
3300
|
-
toKeyValuePair() {
|
|
3301
|
-
return KeyValuePair.tryNewVarInt(_Forward.TYPE, this.forward ? 1n : 0n);
|
|
3302
|
-
}
|
|
3303
|
-
static fromKeyValuePair(pair) {
|
|
3304
|
-
if (Number(pair.typeValue) !== _Forward.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
3305
|
-
if (pair.value !== 0n && pair.value !== 1n) {
|
|
3306
|
-
throw new ProtocolViolationError("Forward.fromKeyValuePair", `FORWARD must be 0 or 1, got ${pair.value}`);
|
|
3307
|
-
}
|
|
3308
|
-
return new _Forward(pair.value === 1n);
|
|
3309
|
-
}
|
|
3310
|
-
};
|
|
3311
|
-
|
|
3312
|
-
// src/model/parameter/message/group_order_param.ts
|
|
3313
|
-
var GroupOrderParam = class _GroupOrderParam {
|
|
3314
|
-
constructor(order) {
|
|
3315
|
-
this.order = order;
|
|
3316
|
-
}
|
|
3317
|
-
order;
|
|
3318
|
-
static TYPE = 34 /* GroupOrder */;
|
|
3319
|
-
toKeyValuePair() {
|
|
3320
|
-
return KeyValuePair.tryNewVarInt(_GroupOrderParam.TYPE, BigInt(this.order));
|
|
3321
|
-
}
|
|
3322
|
-
static fromKeyValuePair(pair) {
|
|
3323
|
-
if (Number(pair.typeValue) !== _GroupOrderParam.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
3324
|
-
if (pair.value !== 1n && pair.value !== 2n) {
|
|
3325
|
-
throw new ProtocolViolationError(
|
|
3326
|
-
"GroupOrderParam.fromKeyValuePair",
|
|
3327
|
-
`GROUP_ORDER must be 1 (Ascending) or 2 (Descending), got ${pair.value}`
|
|
3328
|
-
);
|
|
3329
|
-
}
|
|
3330
|
-
return new _GroupOrderParam(Number(pair.value));
|
|
3331
|
-
}
|
|
3332
|
-
};
|
|
3333
|
-
|
|
3334
|
-
// src/model/parameter/message/largest_object.ts
|
|
3335
|
-
var LargestObject = class _LargestObject {
|
|
3336
|
-
constructor(location) {
|
|
3337
|
-
this.location = location;
|
|
3338
|
-
}
|
|
3339
|
-
location;
|
|
3340
|
-
static TYPE = 9 /* LargestObject */;
|
|
3341
|
-
toKeyValuePair() {
|
|
3342
|
-
const buf = new ByteBuffer();
|
|
3343
|
-
buf.putVI(this.location.group);
|
|
3344
|
-
buf.putVI(this.location.object);
|
|
3345
|
-
return KeyValuePair.tryNewBytes(_LargestObject.TYPE, buf.toUint8Array());
|
|
3346
|
-
}
|
|
3347
|
-
static fromKeyValuePair(pair) {
|
|
3348
|
-
if (Number(pair.typeValue) !== _LargestObject.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
3349
|
-
const buf = new ByteBuffer();
|
|
3350
|
-
buf.putBytes(pair.value);
|
|
3351
|
-
const location = buf.getLocation();
|
|
3352
|
-
return new _LargestObject(location);
|
|
3353
|
-
}
|
|
3354
|
-
};
|
|
3355
|
-
|
|
3356
|
-
// src/model/parameter/message/new_group_request.ts
|
|
3357
|
-
var NewGroupRequest = class _NewGroupRequest {
|
|
3358
|
-
constructor(group) {
|
|
3359
|
-
this.group = group;
|
|
3360
|
-
}
|
|
3361
|
-
group;
|
|
3362
|
-
static TYPE = 50 /* NewGroupRequest */;
|
|
3363
|
-
toKeyValuePair() {
|
|
3364
|
-
return KeyValuePair.tryNewVarInt(_NewGroupRequest.TYPE, this.group);
|
|
3365
|
-
}
|
|
3366
|
-
static fromKeyValuePair(pair) {
|
|
3367
|
-
if (Number(pair.typeValue) !== _NewGroupRequest.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
3368
|
-
return new _NewGroupRequest(pair.value);
|
|
3369
|
-
}
|
|
3370
|
-
};
|
|
3371
|
-
|
|
3372
|
-
// src/model/parameter/message/subscriber_priority.ts
|
|
3373
|
-
var SubscriberPriority = class _SubscriberPriority {
|
|
3374
|
-
constructor(priority) {
|
|
3375
|
-
this.priority = priority;
|
|
3376
|
-
}
|
|
3377
|
-
priority;
|
|
3378
|
-
static TYPE = 32 /* SubscriberPriority */;
|
|
3379
|
-
toKeyValuePair() {
|
|
3380
|
-
return KeyValuePair.tryNewVarInt(_SubscriberPriority.TYPE, BigInt(this.priority));
|
|
3381
|
-
}
|
|
3382
|
-
static fromKeyValuePair(pair) {
|
|
3383
|
-
if (Number(pair.typeValue) !== _SubscriberPriority.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
3384
|
-
if (pair.value < 0n || pair.value > 255n) {
|
|
3385
|
-
throw new ProtocolViolationError(
|
|
3386
|
-
"SubscriberPriority.fromKeyValuePair",
|
|
3387
|
-
`SUBSCRIBER_PRIORITY must be 0-255, got ${pair.value}`
|
|
3388
|
-
);
|
|
3389
|
-
}
|
|
3390
|
-
return new _SubscriberPriority(Number(pair.value));
|
|
3391
|
-
}
|
|
3392
|
-
};
|
|
3393
|
-
|
|
3394
|
-
// src/model/parameter/message/subscription_filter.ts
|
|
3395
|
-
var SubscriptionFilter = class _SubscriptionFilter {
|
|
3396
|
-
constructor(filterType, startLocation, endGroup) {
|
|
3397
|
-
this.filterType = filterType;
|
|
3398
|
-
this.startLocation = startLocation;
|
|
3399
|
-
this.endGroup = endGroup;
|
|
3400
|
-
}
|
|
3401
|
-
filterType;
|
|
3402
|
-
startLocation;
|
|
3403
|
-
endGroup;
|
|
3404
|
-
static TYPE = 33 /* SubscriptionFilter */;
|
|
3405
|
-
toKeyValuePair() {
|
|
3406
|
-
const buf = new ByteBuffer();
|
|
3407
|
-
buf.putVI(this.filterType);
|
|
3408
|
-
if (this.filterType === 3 /* AbsoluteStart */ || this.filterType === 4 /* AbsoluteRange */) {
|
|
3409
|
-
if (this.startLocation) {
|
|
3410
|
-
buf.putLocation(this.startLocation);
|
|
3411
|
-
}
|
|
3412
|
-
}
|
|
3413
|
-
if (this.filterType === 4 /* AbsoluteRange */ && this.endGroup != null) {
|
|
3414
|
-
buf.putVI(this.endGroup);
|
|
3415
|
-
}
|
|
3416
|
-
return KeyValuePair.tryNewBytes(_SubscriptionFilter.TYPE, buf.toUint8Array());
|
|
3417
|
-
}
|
|
3418
|
-
static fromKeyValuePair(pair) {
|
|
3419
|
-
if (Number(pair.typeValue) !== _SubscriptionFilter.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
3420
|
-
const buf = new ByteBuffer();
|
|
3421
|
-
buf.putBytes(pair.value);
|
|
3422
|
-
const filterType = Number(buf.getVI());
|
|
3423
|
-
let startLocation;
|
|
3424
|
-
let endGroup;
|
|
3425
|
-
if (filterType === 3 /* AbsoluteStart */ || filterType === 4 /* AbsoluteRange */) {
|
|
3426
|
-
startLocation = buf.getLocation();
|
|
3427
|
-
}
|
|
3428
|
-
if (filterType === 4 /* AbsoluteRange */) {
|
|
3429
|
-
endGroup = buf.getVI();
|
|
3430
|
-
}
|
|
3431
|
-
return new _SubscriptionFilter(filterType, startLocation, endGroup);
|
|
3432
|
-
}
|
|
3433
|
-
};
|
|
3434
|
-
|
|
3435
|
-
// src/model/parameter/message_parameter.ts
|
|
3436
|
-
var MessageParameter;
|
|
3437
|
-
((MessageParameter10) => {
|
|
3438
|
-
function fromKeyValuePair(pair) {
|
|
3439
|
-
return DeliveryTimeout.fromKeyValuePair(pair) ?? AuthorizationToken.fromKeyValuePair(pair) ?? Expires.fromKeyValuePair(pair) ?? LargestObject.fromKeyValuePair(pair) ?? Forward.fromKeyValuePair(pair) ?? SubscriberPriority.fromKeyValuePair(pair) ?? GroupOrderParam.fromKeyValuePair(pair) ?? SubscriptionFilter.fromKeyValuePair(pair) ?? NewGroupRequest.fromKeyValuePair(pair);
|
|
3440
|
-
}
|
|
3441
|
-
MessageParameter10.fromKeyValuePair = fromKeyValuePair;
|
|
3442
|
-
function toKeyValuePair(param) {
|
|
3443
|
-
return param.toKeyValuePair();
|
|
3444
|
-
}
|
|
3445
|
-
MessageParameter10.toKeyValuePair = toKeyValuePair;
|
|
3446
|
-
function isDeliveryTimeout(param) {
|
|
3447
|
-
return param instanceof DeliveryTimeout;
|
|
3448
|
-
}
|
|
3449
|
-
MessageParameter10.isDeliveryTimeout = isDeliveryTimeout;
|
|
3450
|
-
function isAuthorizationToken(param) {
|
|
3451
|
-
return param instanceof AuthorizationToken;
|
|
3452
|
-
}
|
|
3453
|
-
MessageParameter10.isAuthorizationToken = isAuthorizationToken;
|
|
3454
|
-
function isExpires(param) {
|
|
3455
|
-
return param instanceof Expires;
|
|
3456
|
-
}
|
|
3457
|
-
MessageParameter10.isExpires = isExpires;
|
|
3458
|
-
function isLargestObject(param) {
|
|
3459
|
-
return param instanceof LargestObject;
|
|
3460
|
-
}
|
|
3461
|
-
MessageParameter10.isLargestObject = isLargestObject;
|
|
3462
|
-
function isForward(param) {
|
|
3463
|
-
return param instanceof Forward;
|
|
3464
|
-
}
|
|
3465
|
-
MessageParameter10.isForward = isForward;
|
|
3466
|
-
function isSubscriberPriority(param) {
|
|
3467
|
-
return param instanceof SubscriberPriority;
|
|
3468
|
-
}
|
|
3469
|
-
MessageParameter10.isSubscriberPriority = isSubscriberPriority;
|
|
3470
|
-
function isGroupOrderParam(param) {
|
|
3471
|
-
return param instanceof GroupOrderParam;
|
|
3472
|
-
}
|
|
3473
|
-
MessageParameter10.isGroupOrderParam = isGroupOrderParam;
|
|
3474
|
-
function isSubscriptionFilter(param) {
|
|
3475
|
-
return param instanceof SubscriptionFilter;
|
|
3476
|
-
}
|
|
3477
|
-
MessageParameter10.isSubscriptionFilter = isSubscriptionFilter;
|
|
3478
|
-
function isNewGroupRequest(param) {
|
|
3479
|
-
return param instanceof NewGroupRequest;
|
|
3480
|
-
}
|
|
3481
|
-
MessageParameter10.isNewGroupRequest = isNewGroupRequest;
|
|
3482
|
-
})(MessageParameter || (MessageParameter = {}));
|
|
3483
|
-
var MessageParameters = class {
|
|
3484
|
-
params = [];
|
|
3485
|
-
add(param) {
|
|
3486
|
-
this.params.push(param);
|
|
3487
|
-
return this;
|
|
3488
|
-
}
|
|
3489
|
-
addDeliveryTimeout(timeout) {
|
|
3490
|
-
return this.add(new DeliveryTimeout(BigInt(timeout)));
|
|
3491
|
-
}
|
|
3492
|
-
addAuthorizationToken(token) {
|
|
3493
|
-
return this.add(token);
|
|
3494
|
-
}
|
|
3495
|
-
addExpires(expires) {
|
|
3496
|
-
return this.add(new Expires(BigInt(expires)));
|
|
3497
|
-
}
|
|
3498
|
-
addForward(forward) {
|
|
3499
|
-
return this.add(new Forward(forward));
|
|
3500
|
-
}
|
|
3501
|
-
addSubscriberPriority(priority) {
|
|
3502
|
-
return this.add(new SubscriberPriority(priority));
|
|
3503
|
-
}
|
|
3504
|
-
addGroupOrder(order) {
|
|
3505
|
-
return this.add(new GroupOrderParam(order));
|
|
3506
|
-
}
|
|
3507
|
-
addSubscriptionFilter(filter) {
|
|
3508
|
-
return this.add(filter);
|
|
3509
|
-
}
|
|
3510
|
-
addNewGroupRequest(group) {
|
|
3511
|
-
return this.add(new NewGroupRequest(BigInt(group)));
|
|
3512
|
-
}
|
|
3513
|
-
build() {
|
|
3514
|
-
return [...this.params];
|
|
3515
|
-
}
|
|
3516
|
-
/**
|
|
3517
|
-
* Parses an array of KeyValuePairs into a list of MessageParameters.
|
|
3518
|
-
* Unrecognized parameter types are silently skipped.
|
|
3519
|
-
* Known parameter types with invalid values still throw ProtocolViolationError.
|
|
3520
|
-
*/
|
|
3521
|
-
static fromKeyValuePairs(pairs) {
|
|
3522
|
-
const result = [];
|
|
3523
|
-
for (const pair of pairs) {
|
|
3524
|
-
const parsed = MessageParameter.fromKeyValuePair(pair);
|
|
3525
|
-
if (parsed !== void 0) result.push(parsed);
|
|
3526
|
-
}
|
|
3527
|
-
return result;
|
|
3528
|
-
}
|
|
3529
|
-
};
|
|
3530
|
-
function applyMessageParameterUpdate(current, updates) {
|
|
3531
|
-
for (const update of updates) {
|
|
3532
|
-
const updateType = update.toKeyValuePair().typeValue;
|
|
3533
|
-
const idx = current.findIndex((p) => p.toKeyValuePair().typeValue === updateType);
|
|
3534
|
-
if (idx >= 0) {
|
|
3535
|
-
current[idx] = update;
|
|
3536
|
-
} else {
|
|
3537
|
-
current.push(update);
|
|
3538
|
-
}
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
|
|
3542
|
-
// src/model/control/publish_namespace.ts
|
|
3543
|
-
var PublishNamespace = class _PublishNamespace {
|
|
3544
|
-
/**
|
|
3545
|
-
* @public
|
|
3546
|
-
* Constructs a PublishNamespace message.
|
|
3547
|
-
*
|
|
3548
|
-
* @param requestId - The request ID for this publish namespace message.
|
|
3549
|
-
* @param trackNamespace - The track namespace as a Tuple.
|
|
3550
|
-
* @param parameters - The list of strongly-typed message parameters for the track.
|
|
3551
|
-
*/
|
|
3552
|
-
constructor(requestId, trackNamespace, parameters) {
|
|
3553
|
-
this.requestId = requestId;
|
|
3554
|
-
this.trackNamespace = trackNamespace;
|
|
3555
|
-
this.parameters = parameters;
|
|
3556
|
-
}
|
|
3557
|
-
requestId;
|
|
3558
|
-
trackNamespace;
|
|
3559
|
-
parameters;
|
|
3560
|
-
/**
|
|
3561
|
-
* @public
|
|
3562
|
-
* Gets the message type for this PublishNamespace message.
|
|
3563
|
-
*
|
|
3564
|
-
* @returns The ControlMessageType.PublishNamespace value.
|
|
3565
|
-
*/
|
|
3566
|
-
getType() {
|
|
3567
|
-
return 6 /* PublishNamespace */;
|
|
3568
|
-
}
|
|
3569
|
-
/**
|
|
3570
|
-
* @public
|
|
3571
|
-
* Serializes the PublishNamespace message into a {@link FrozenByteBuffer}.
|
|
3572
|
-
*
|
|
3573
|
-
* @returns The serialized buffer.
|
|
3574
|
-
* @throws :{@link LengthExceedsMaxError} If the payload exceeds 65535 bytes.
|
|
3575
|
-
*/
|
|
3576
|
-
serialize() {
|
|
3577
|
-
const buf = new ByteBuffer();
|
|
3578
|
-
buf.putVI(6 /* PublishNamespace */);
|
|
3579
|
-
const payload = new ByteBuffer();
|
|
3580
|
-
payload.putVI(this.requestId);
|
|
3581
|
-
payload.putTuple(this.trackNamespace);
|
|
3582
|
-
payload.putVI(this.parameters.length);
|
|
3583
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
3584
|
-
const payloadBytes = payload.toUint8Array();
|
|
3585
|
-
if (payloadBytes.length > 65535) {
|
|
3586
|
-
throw new LengthExceedsMaxError("PublishNamespace::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3587
|
-
}
|
|
3588
|
-
buf.putU16(payloadBytes.length);
|
|
3589
|
-
buf.putBytes(payloadBytes);
|
|
3590
|
-
return buf.freeze();
|
|
3591
|
-
}
|
|
3592
|
-
/**
|
|
3593
|
-
* @public
|
|
3594
|
-
* Parses a PublishNamespace message from the given buffer.
|
|
3595
|
-
*
|
|
3596
|
-
* @param buf - The buffer to parse from.
|
|
3597
|
-
* @returns The parsed PublishNamespace message.
|
|
3598
|
-
* @throws :{@link NotEnoughBytesError} If the buffer does not contain enough bytes.
|
|
3599
|
-
*/
|
|
3600
|
-
static parsePayload(buf) {
|
|
3601
|
-
const requestId = buf.getVI();
|
|
3602
|
-
const trackNamespace = buf.getTuple();
|
|
3603
|
-
const paramCount = buf.getNumberVI();
|
|
3604
|
-
const rawParams = deserializeKvpList(buf, paramCount);
|
|
3605
|
-
const parameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
3606
|
-
return new _PublishNamespace(requestId, trackNamespace, parameters);
|
|
3607
|
-
}
|
|
3608
|
-
};
|
|
3609
|
-
|
|
3610
|
-
// src/model/control/subscribe.ts
|
|
3611
|
-
var Subscribe = class _Subscribe {
|
|
3612
|
-
constructor(requestId, fullTrackName, parameters) {
|
|
3613
|
-
this.requestId = requestId;
|
|
3614
|
-
this.fullTrackName = fullTrackName;
|
|
3615
|
-
this.parameters = parameters;
|
|
3616
|
-
}
|
|
3617
|
-
requestId;
|
|
3618
|
-
fullTrackName;
|
|
3619
|
-
parameters;
|
|
3620
|
-
static newNextGroupStart(requestId, fullTrackName, parameters) {
|
|
3621
|
-
return new _Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(1 /* NextGroupStart */)]);
|
|
3622
|
-
}
|
|
3623
|
-
static newLatestObject(requestId, fullTrackName, parameters) {
|
|
3624
|
-
return new _Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(2 /* LatestObject */)]);
|
|
3625
|
-
}
|
|
3626
|
-
static newAbsoluteStart(requestId, fullTrackName, startLocation, parameters) {
|
|
3627
|
-
return new _Subscribe(requestId, fullTrackName, [
|
|
3628
|
-
...parameters,
|
|
3629
|
-
new SubscriptionFilter(3 /* AbsoluteStart */, startLocation)
|
|
3630
|
-
]);
|
|
3631
|
-
}
|
|
3632
|
-
static newAbsoluteRange(requestId, fullTrackName, startLocation, endGroup, parameters) {
|
|
3633
|
-
if (endGroup < startLocation.group) {
|
|
3634
|
-
throw new Error("End Group must be >= Start Group");
|
|
3635
|
-
}
|
|
3636
|
-
return new _Subscribe(requestId, fullTrackName, [
|
|
3637
|
-
...parameters,
|
|
3638
|
-
new SubscriptionFilter(4 /* AbsoluteRange */, startLocation, endGroup)
|
|
3639
|
-
]);
|
|
3640
|
-
}
|
|
3641
|
-
serialize() {
|
|
3642
|
-
const buf = new ByteBuffer();
|
|
3643
|
-
buf.putVI(3 /* Subscribe */);
|
|
3644
|
-
const payload = new ByteBuffer();
|
|
3645
|
-
payload.putVI(this.requestId);
|
|
3646
|
-
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
3647
|
-
payload.putVI(this.parameters.length);
|
|
3648
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
3649
|
-
const payloadBytes = payload.toUint8Array();
|
|
3650
|
-
buf.putU16(payloadBytes.length);
|
|
3651
|
-
buf.putBytes(payloadBytes);
|
|
3652
|
-
return buf.freeze();
|
|
3653
|
-
}
|
|
3654
|
-
static parsePayload(buf) {
|
|
3655
|
-
const requestId = buf.getVI();
|
|
3656
|
-
const fullTrackName = buf.getFullTrackName();
|
|
3657
|
-
const paramCount = Number(buf.getVI());
|
|
3658
|
-
const parameters = [];
|
|
3659
|
-
for (const kvp of deserializeKvpList(buf, paramCount)) {
|
|
3660
|
-
const param = MessageParameter.fromKeyValuePair(kvp);
|
|
3661
|
-
if (param !== void 0) parameters.push(param);
|
|
3662
|
-
}
|
|
3663
|
-
return new _Subscribe(requestId, fullTrackName, parameters);
|
|
3664
|
-
}
|
|
3665
|
-
};
|
|
3666
|
-
|
|
3667
|
-
// src/model/control/switch.ts
|
|
3668
|
-
var Switch = class _Switch {
|
|
3669
|
-
constructor(requestId, fullTrackName, subscriptionRequestId, parameters) {
|
|
3670
|
-
this.requestId = requestId;
|
|
3671
|
-
this.fullTrackName = fullTrackName;
|
|
3672
|
-
this.subscriptionRequestId = subscriptionRequestId;
|
|
3673
|
-
this.parameters = parameters;
|
|
3674
|
-
}
|
|
3675
|
-
requestId;
|
|
3676
|
-
fullTrackName;
|
|
3677
|
-
subscriptionRequestId;
|
|
3678
|
-
parameters;
|
|
3679
|
-
serialize() {
|
|
3680
|
-
const buf = new ByteBuffer();
|
|
3681
|
-
buf.putVI(34 /* Switch */);
|
|
3682
|
-
const payload = new ByteBuffer();
|
|
3683
|
-
payload.putVI(this.requestId);
|
|
3684
|
-
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
3685
|
-
payload.putVI(this.subscriptionRequestId);
|
|
3686
|
-
payload.putVI(this.parameters.length);
|
|
3687
|
-
payload.putBytes(serializeKvpList(this.parameters).toUint8Array());
|
|
3688
|
-
const payloadBytes = payload.toUint8Array();
|
|
3689
|
-
buf.putU16(payloadBytes.length);
|
|
3690
|
-
buf.putBytes(payloadBytes);
|
|
3691
|
-
return buf.freeze();
|
|
3692
|
-
}
|
|
3693
|
-
static parsePayload(buf) {
|
|
3694
|
-
const requestId = buf.getVI();
|
|
3695
|
-
const fullTrackName = buf.getFullTrackName();
|
|
3696
|
-
const subscriptionRequestId = buf.getVI();
|
|
3697
|
-
const paramCount = Number(buf.getVI());
|
|
3698
|
-
const parameters = deserializeKvpList(buf, paramCount);
|
|
3699
|
-
return new _Switch(requestId, fullTrackName, subscriptionRequestId, parameters);
|
|
3700
|
-
}
|
|
3701
|
-
};
|
|
3702
|
-
|
|
3703
|
-
// src/model/control/namespace.ts
|
|
3704
|
-
var Namespace = class _Namespace {
|
|
3705
|
-
constructor(trackNamespaceSuffix) {
|
|
3706
|
-
this.trackNamespaceSuffix = trackNamespaceSuffix;
|
|
3707
|
-
}
|
|
3708
|
-
trackNamespaceSuffix;
|
|
3709
|
-
getType() {
|
|
3710
|
-
return 8 /* Namespace */;
|
|
3711
|
-
}
|
|
3712
|
-
serialize() {
|
|
3713
|
-
const buf = new ByteBuffer();
|
|
3714
|
-
buf.putVI(8 /* Namespace */);
|
|
3715
|
-
const payload = new ByteBuffer();
|
|
3716
|
-
payload.putTuple(this.trackNamespaceSuffix);
|
|
3717
|
-
const payloadBytes = payload.toUint8Array();
|
|
3718
|
-
if (payloadBytes.length > 65535) {
|
|
3719
|
-
throw new LengthExceedsMaxError("Namespace::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3720
|
-
}
|
|
3721
|
-
buf.putU16(payloadBytes.length);
|
|
3722
|
-
buf.putBytes(payloadBytes);
|
|
3723
|
-
return buf.freeze();
|
|
3724
|
-
}
|
|
3725
|
-
static parsePayload(buf) {
|
|
3726
|
-
const trackNamespaceSuffix = buf.getTuple();
|
|
3727
|
-
return new _Namespace(trackNamespaceSuffix);
|
|
3728
|
-
}
|
|
3729
|
-
};
|
|
3730
|
-
|
|
3731
|
-
// src/model/control/namespace_done.ts
|
|
3732
|
-
var NamespaceDone = class _NamespaceDone {
|
|
3733
|
-
constructor(trackNamespaceSuffix) {
|
|
3734
|
-
this.trackNamespaceSuffix = trackNamespaceSuffix;
|
|
3735
|
-
}
|
|
3736
|
-
trackNamespaceSuffix;
|
|
3737
|
-
getType() {
|
|
3738
|
-
return 14 /* NamespaceDone */;
|
|
3739
|
-
}
|
|
3740
|
-
serialize() {
|
|
3741
|
-
const buf = new ByteBuffer();
|
|
3742
|
-
buf.putVI(14 /* NamespaceDone */);
|
|
3743
|
-
const payload = new ByteBuffer();
|
|
3744
|
-
payload.putTuple(this.trackNamespaceSuffix);
|
|
3745
|
-
const payloadBytes = payload.toUint8Array();
|
|
3746
|
-
if (payloadBytes.length > 65535) {
|
|
3747
|
-
throw new LengthExceedsMaxError("NamespaceDone::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3748
|
-
}
|
|
3749
|
-
buf.putU16(payloadBytes.length);
|
|
3750
|
-
buf.putBytes(payloadBytes);
|
|
3751
|
-
return buf.freeze();
|
|
3752
|
-
}
|
|
3753
|
-
static parsePayload(buf) {
|
|
3754
|
-
const trackNamespaceSuffix = buf.getTuple();
|
|
3755
|
-
return new _NamespaceDone(trackNamespaceSuffix);
|
|
3756
|
-
}
|
|
3757
|
-
};
|
|
3758
|
-
|
|
3759
|
-
// src/model/control/publish_namespace_cancel.ts
|
|
3760
|
-
var PublishNamespaceCancel = class _PublishNamespaceCancel {
|
|
3761
|
-
constructor(requestId, errorCode, reasonPhrase) {
|
|
3762
|
-
this.requestId = requestId;
|
|
3763
|
-
this.errorCode = errorCode;
|
|
3764
|
-
this.reasonPhrase = reasonPhrase;
|
|
3765
|
-
}
|
|
3766
|
-
requestId;
|
|
3767
|
-
errorCode;
|
|
3768
|
-
reasonPhrase;
|
|
3769
|
-
getType() {
|
|
3770
|
-
return 12 /* PublishNamespaceCancel */;
|
|
3771
|
-
}
|
|
3772
|
-
serialize() {
|
|
3773
|
-
const buf = new ByteBuffer();
|
|
3774
|
-
buf.putVI(12 /* PublishNamespaceCancel */);
|
|
3775
|
-
const payload = new ByteBuffer();
|
|
3776
|
-
payload.putVI(this.requestId);
|
|
3777
|
-
payload.putVI(this.errorCode);
|
|
3778
|
-
payload.putReasonPhrase(this.reasonPhrase);
|
|
3779
|
-
const payloadBytes = payload.toUint8Array();
|
|
3780
|
-
if (payloadBytes.length > 65535) {
|
|
3781
|
-
throw new LengthExceedsMaxError(
|
|
3782
|
-
"PublishNamespaceCancel::serialize(payloadBytes.length)",
|
|
3783
|
-
65535,
|
|
3784
|
-
payloadBytes.length
|
|
3785
|
-
);
|
|
3786
|
-
}
|
|
3787
|
-
buf.putU16(payloadBytes.length);
|
|
3788
|
-
buf.putBytes(payloadBytes);
|
|
3789
|
-
return buf.freeze();
|
|
3790
|
-
}
|
|
3791
|
-
static parsePayload(buf) {
|
|
3792
|
-
const requestId = buf.getVI();
|
|
3793
|
-
const errorCodeRaw = buf.getVI();
|
|
3794
|
-
const errorCode = requestErrorCodeFromBigInt(errorCodeRaw);
|
|
3795
|
-
const reasonPhrase = buf.getReasonPhrase();
|
|
3796
|
-
return new _PublishNamespaceCancel(requestId, errorCode, reasonPhrase);
|
|
3797
|
-
}
|
|
3798
|
-
};
|
|
3799
|
-
|
|
3800
|
-
// src/model/control/client_setup.ts
|
|
3801
|
-
var ClientSetup = class _ClientSetup {
|
|
3802
|
-
constructor(setupParameters) {
|
|
3803
|
-
this.setupParameters = setupParameters;
|
|
3804
|
-
}
|
|
3805
|
-
setupParameters;
|
|
3806
|
-
getType() {
|
|
3807
|
-
return 32 /* ClientSetup */;
|
|
3808
|
-
}
|
|
3809
|
-
serialize() {
|
|
3810
|
-
const buf = new ByteBuffer();
|
|
3811
|
-
buf.putVI(32 /* ClientSetup */);
|
|
3812
|
-
const payload = new ByteBuffer();
|
|
3813
|
-
payload.putVI(this.setupParameters.length);
|
|
3814
|
-
payload.putBytes(serializeKvpList(this.setupParameters).toUint8Array());
|
|
3815
|
-
const payloadBytes = payload.toUint8Array();
|
|
3816
|
-
if (payloadBytes.length > 65535) {
|
|
3817
|
-
throw new LengthExceedsMaxError("ClientSetup::serialize(payload_length)", 65535, payloadBytes.length);
|
|
3818
|
-
}
|
|
3819
|
-
buf.putU16(payloadBytes.length);
|
|
3820
|
-
buf.putBytes(payloadBytes);
|
|
3821
|
-
return buf.freeze();
|
|
3822
|
-
}
|
|
3823
|
-
static parsePayload(buf) {
|
|
3824
|
-
const paramCount = buf.getNumberVI();
|
|
3825
|
-
const setupParameters = deserializeKvpList(buf, paramCount);
|
|
3826
|
-
return new _ClientSetup(setupParameters);
|
|
3827
|
-
}
|
|
3828
|
-
};
|
|
3829
|
-
|
|
3830
|
-
// src/model/control/fetch.ts
|
|
3831
|
-
var Fetch = class _Fetch {
|
|
3832
|
-
constructor(requestId, typeAndProps, parameters) {
|
|
3833
|
-
this.requestId = requestId;
|
|
3834
|
-
this.typeAndProps = typeAndProps;
|
|
3835
|
-
this.parameters = parameters;
|
|
3836
|
-
}
|
|
3837
|
-
requestId;
|
|
3838
|
-
typeAndProps;
|
|
3839
|
-
parameters;
|
|
3840
|
-
getType() {
|
|
3841
|
-
return 22 /* Fetch */;
|
|
3842
|
-
}
|
|
3843
|
-
serialize() {
|
|
3844
|
-
const buf = new ByteBuffer();
|
|
3845
|
-
buf.putVI(22 /* Fetch */);
|
|
3846
|
-
const payload = new ByteBuffer();
|
|
3847
|
-
payload.putVI(this.requestId);
|
|
3848
|
-
payload.putVI(this.typeAndProps.type);
|
|
3849
|
-
switch (this.typeAndProps.type) {
|
|
3850
|
-
case 3 /* Absolute */:
|
|
3851
|
-
case 2 /* Relative */: {
|
|
3852
|
-
payload.putVI(this.typeAndProps.props.joiningRequestId);
|
|
3853
|
-
payload.putVI(this.typeAndProps.props.joiningStart);
|
|
3854
|
-
break;
|
|
3855
|
-
}
|
|
3856
|
-
case 1 /* Standalone */: {
|
|
3857
|
-
payload.putFullTrackName(this.typeAndProps.props.fullTrackName);
|
|
3858
|
-
payload.putLocation(this.typeAndProps.props.startLocation);
|
|
3859
|
-
payload.putLocation(this.typeAndProps.props.endLocation);
|
|
3860
|
-
break;
|
|
3861
|
-
}
|
|
3862
|
-
}
|
|
3863
|
-
payload.putVI(this.parameters.length);
|
|
3864
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
3865
|
-
const payloadBytes = payload.toUint8Array();
|
|
3866
|
-
if (payloadBytes.length > 65535) {
|
|
3867
|
-
throw new LengthExceedsMaxError("Fetch::serialize(payload_length)", 65535, payloadBytes.length);
|
|
3868
|
-
}
|
|
3869
|
-
buf.putU16(payloadBytes.length);
|
|
3870
|
-
buf.putBytes(payloadBytes);
|
|
3871
|
-
return buf.freeze();
|
|
3872
|
-
}
|
|
3873
|
-
static parsePayload(buf) {
|
|
3874
|
-
const requestId = buf.getVI();
|
|
3875
|
-
const fetchTypeRaw = buf.getVI();
|
|
3876
|
-
const fetchType = fetchTypeFromBigInt(fetchTypeRaw);
|
|
3877
|
-
let props;
|
|
3878
|
-
switch (fetchType) {
|
|
3879
|
-
case 3 /* Absolute */:
|
|
3880
|
-
case 2 /* Relative */: {
|
|
3881
|
-
const joiningRequestId = buf.getVI();
|
|
3882
|
-
const joiningStart = buf.getVI();
|
|
3883
|
-
props = {
|
|
3884
|
-
type: fetchType,
|
|
3885
|
-
props: { joiningRequestId, joiningStart }
|
|
3886
|
-
};
|
|
3887
|
-
break;
|
|
3888
|
-
}
|
|
3889
|
-
case 1 /* Standalone */: {
|
|
3890
|
-
const fullTrackName = buf.getFullTrackName();
|
|
3891
|
-
const startLocation = buf.getLocation();
|
|
3892
|
-
const endLocation = buf.getLocation();
|
|
3893
|
-
props = {
|
|
3894
|
-
type: 1 /* Standalone */,
|
|
3895
|
-
props: { fullTrackName, startLocation, endLocation }
|
|
3896
|
-
};
|
|
3897
|
-
break;
|
|
3898
|
-
}
|
|
3899
|
-
default:
|
|
3900
|
-
throw new Error(`Unknown fetch type: ${fetchType}`);
|
|
3901
|
-
}
|
|
3902
|
-
const paramCount = buf.getNumberVI();
|
|
3903
|
-
const rawParams = deserializeKvpList(buf, paramCount);
|
|
3904
|
-
const parameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
3905
|
-
return new _Fetch(requestId, props, parameters);
|
|
3906
|
-
}
|
|
3907
|
-
};
|
|
3908
|
-
|
|
3909
|
-
// src/model/control/fetch_cancel.ts
|
|
3910
|
-
var FetchCancel = class _FetchCancel {
|
|
3911
|
-
requestId;
|
|
3912
|
-
constructor(requestId) {
|
|
3913
|
-
this.requestId = BigInt(requestId);
|
|
3914
|
-
}
|
|
3915
|
-
getType() {
|
|
3916
|
-
return 23 /* FetchCancel */;
|
|
3917
|
-
}
|
|
3918
|
-
serialize() {
|
|
3919
|
-
const buf = new ByteBuffer();
|
|
3920
|
-
buf.putVI(23 /* FetchCancel */);
|
|
3921
|
-
const payload = new ByteBuffer();
|
|
3922
|
-
payload.putVI(this.requestId);
|
|
3923
|
-
const payloadBytes = payload.toUint8Array();
|
|
3924
|
-
if (payloadBytes.length > 65535) {
|
|
3925
|
-
throw new LengthExceedsMaxError("FetchCancel::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3926
|
-
}
|
|
3927
|
-
buf.putU16(payloadBytes.length);
|
|
3928
|
-
buf.putBytes(payloadBytes);
|
|
3929
|
-
return buf.freeze();
|
|
3930
|
-
}
|
|
3931
|
-
static parsePayload(buf) {
|
|
3932
|
-
const requestId = buf.getVI();
|
|
3933
|
-
return new _FetchCancel(requestId);
|
|
3934
|
-
}
|
|
3935
|
-
};
|
|
3936
|
-
|
|
3937
|
-
// src/model/control/fetch_ok.ts
|
|
3938
|
-
var FetchOk = class _FetchOk {
|
|
3939
|
-
constructor(requestId, endOfTrack, endLocation, parameters, trackExtensions = []) {
|
|
3940
|
-
this.requestId = requestId;
|
|
3941
|
-
this.endOfTrack = endOfTrack;
|
|
3942
|
-
this.endLocation = endLocation;
|
|
3943
|
-
this.parameters = parameters;
|
|
3944
|
-
this.trackExtensions = trackExtensions;
|
|
3945
|
-
}
|
|
3946
|
-
requestId;
|
|
3947
|
-
endOfTrack;
|
|
3948
|
-
endLocation;
|
|
3949
|
-
parameters;
|
|
3950
|
-
trackExtensions;
|
|
3951
|
-
serialize() {
|
|
3952
|
-
const buf = new ByteBuffer();
|
|
3953
|
-
buf.putVI(BigInt(24 /* FetchOk */));
|
|
3954
|
-
const payload = new ByteBuffer();
|
|
3955
|
-
payload.putVI(this.requestId);
|
|
3956
|
-
payload.putU8(this.endOfTrack ? 1 : 0);
|
|
3957
|
-
payload.putLocation(this.endLocation);
|
|
3958
|
-
payload.putVI(this.parameters.length);
|
|
3959
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
3960
|
-
TrackExtension.serializeInto(this.trackExtensions, payload);
|
|
3961
|
-
const payloadBytes = payload.toUint8Array();
|
|
3962
|
-
if (payloadBytes.length > 65535) {
|
|
3963
|
-
throw new LengthExceedsMaxError("FetchOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
3964
|
-
}
|
|
3965
|
-
buf.putU16(payloadBytes.length);
|
|
3966
|
-
buf.putBytes(payloadBytes);
|
|
3967
|
-
return buf.freeze();
|
|
3968
|
-
}
|
|
3969
|
-
static parsePayload(buf) {
|
|
3970
|
-
const requestId = buf.getVI();
|
|
3971
|
-
if (buf.remaining < 1) {
|
|
3972
|
-
throw new NotEnoughBytesError("FetchOk::parsePayload(endOfTrack)", 1, 0);
|
|
3973
|
-
}
|
|
3974
|
-
const endOfTrackRaw = buf.getU8();
|
|
3975
|
-
let endOfTrack;
|
|
3976
|
-
if (endOfTrackRaw === 0) {
|
|
3977
|
-
endOfTrack = false;
|
|
3978
|
-
} else if (endOfTrackRaw === 1) {
|
|
3979
|
-
endOfTrack = true;
|
|
3980
|
-
} else {
|
|
3981
|
-
throw new ProtocolViolationError(
|
|
3982
|
-
"FetchOk::parsePayload(endOfTrack)",
|
|
3983
|
-
"End of track must be true(0x01) or false(0x00)"
|
|
3984
|
-
);
|
|
3985
|
-
}
|
|
3986
|
-
const endLocation = buf.getLocation();
|
|
3987
|
-
const paramCount = buf.getNumberVI();
|
|
3988
|
-
const rawParams = deserializeKvpList(buf, paramCount);
|
|
3989
|
-
const parameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
3990
|
-
const trackExtensions = TrackExtension.deserializeAll(buf);
|
|
3991
|
-
return new _FetchOk(requestId, endOfTrack, endLocation, parameters, trackExtensions);
|
|
3992
|
-
}
|
|
3993
|
-
};
|
|
3994
|
-
|
|
3995
|
-
// src/model/control/goaway.ts
|
|
3996
|
-
var GoAway = class _GoAway {
|
|
3997
|
-
newSessionUri;
|
|
3998
|
-
constructor(newSessionUri) {
|
|
3999
|
-
if (newSessionUri && newSessionUri.length === 0) {
|
|
4000
|
-
this.newSessionUri = void 0;
|
|
4001
|
-
} else {
|
|
4002
|
-
this.newSessionUri = newSessionUri;
|
|
4003
|
-
}
|
|
4004
|
-
}
|
|
4005
|
-
static getType() {
|
|
4006
|
-
return 16 /* GoAway */;
|
|
4007
|
-
}
|
|
4008
|
-
serialize() {
|
|
4009
|
-
const buf = new ByteBuffer();
|
|
4010
|
-
buf.putVI(16 /* GoAway */);
|
|
4011
|
-
const payload = new ByteBuffer();
|
|
4012
|
-
if (this.newSessionUri) {
|
|
4013
|
-
let uriBytes;
|
|
4014
|
-
try {
|
|
4015
|
-
const encoder = new TextEncoder();
|
|
4016
|
-
uriBytes = encoder.encode(this.newSessionUri);
|
|
4017
|
-
} catch (error) {
|
|
4018
|
-
throw new InvalidUTF8Error(
|
|
4019
|
-
"GoAway::serialize(newSessionUri)",
|
|
4020
|
-
error instanceof Error ? error.message : String(error)
|
|
4021
|
-
);
|
|
4022
|
-
}
|
|
4023
|
-
payload.putLengthPrefixedBytes(uriBytes);
|
|
4024
|
-
} else {
|
|
4025
|
-
payload.putVI(0);
|
|
4026
|
-
}
|
|
4027
|
-
const payloadBytes = payload.toUint8Array();
|
|
4028
|
-
if (payloadBytes.length > 65535) {
|
|
4029
|
-
throw new LengthExceedsMaxError("GoAway::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4030
|
-
}
|
|
4031
|
-
buf.putU16(payloadBytes.length);
|
|
4032
|
-
buf.putBytes(payloadBytes);
|
|
4033
|
-
return buf.freeze();
|
|
4034
|
-
}
|
|
4035
|
-
static parsePayload(buf) {
|
|
4036
|
-
const uriLength = buf.getNumberVI();
|
|
4037
|
-
if (uriLength === 0) {
|
|
4038
|
-
return new _GoAway(void 0);
|
|
4039
|
-
}
|
|
4040
|
-
if (buf.remaining < uriLength) {
|
|
4041
|
-
throw new NotEnoughBytesError("GoAway::parsePayload(uriLength)", uriLength, buf.remaining);
|
|
4042
|
-
}
|
|
4043
|
-
const uriBytes = buf.getBytes(uriLength);
|
|
4044
|
-
let newSessionUri;
|
|
4045
|
-
try {
|
|
4046
|
-
const decoder = new TextDecoder();
|
|
4047
|
-
newSessionUri = decoder.decode(uriBytes);
|
|
4048
|
-
} catch (error) {
|
|
4049
|
-
throw new InvalidUTF8Error(
|
|
4050
|
-
"GoAway::parsePayload(newSessionUri)",
|
|
4051
|
-
error instanceof Error ? error.message : String(error)
|
|
4052
|
-
);
|
|
4053
|
-
}
|
|
4054
|
-
return new _GoAway(newSessionUri);
|
|
4055
|
-
}
|
|
4056
|
-
};
|
|
4057
|
-
|
|
4058
|
-
// src/model/control/max_request_id.ts
|
|
4059
|
-
var MaxRequestId = class _MaxRequestId {
|
|
4060
|
-
maxRequestId;
|
|
4061
|
-
constructor(maxRequestId) {
|
|
4062
|
-
this.maxRequestId = BigInt(maxRequestId);
|
|
4063
|
-
}
|
|
4064
|
-
getType() {
|
|
4065
|
-
return 21 /* MaxRequestId */;
|
|
4066
|
-
}
|
|
4067
|
-
serialize() {
|
|
4068
|
-
const buf = new ByteBuffer();
|
|
4069
|
-
const payload = new ByteBuffer();
|
|
4070
|
-
payload.putVI(this.maxRequestId + 1n);
|
|
4071
|
-
buf.putVI(21 /* MaxRequestId */);
|
|
4072
|
-
const payloadBytes = payload.toUint8Array();
|
|
4073
|
-
if (payloadBytes.length > 65535) {
|
|
4074
|
-
throw new LengthExceedsMaxError("MaxRequestId::serialize(payload_length)", 65535, payloadBytes.length);
|
|
4075
|
-
}
|
|
4076
|
-
buf.putU16(payloadBytes.length);
|
|
4077
|
-
buf.putBytes(payloadBytes);
|
|
4078
|
-
return buf.freeze();
|
|
4079
|
-
}
|
|
4080
|
-
static parsePayload(buf) {
|
|
4081
|
-
const requestId = buf.getVI();
|
|
4082
|
-
return new _MaxRequestId(requestId);
|
|
4083
|
-
}
|
|
4084
|
-
};
|
|
4085
|
-
|
|
4086
|
-
// src/model/control/server_setup.ts
|
|
4087
|
-
var ServerSetup = class _ServerSetup {
|
|
4088
|
-
constructor(setupParameters) {
|
|
4089
|
-
this.setupParameters = setupParameters;
|
|
4090
|
-
}
|
|
4091
|
-
setupParameters;
|
|
4092
|
-
getType() {
|
|
4093
|
-
return 33 /* ServerSetup */;
|
|
4094
|
-
}
|
|
4095
|
-
serialize() {
|
|
4096
|
-
const buf = new ByteBuffer();
|
|
4097
|
-
buf.putVI(33 /* ServerSetup */);
|
|
4098
|
-
const payload = new ByteBuffer();
|
|
4099
|
-
payload.putVI(this.setupParameters.length);
|
|
4100
|
-
payload.putBytes(serializeKvpList(this.setupParameters).toUint8Array());
|
|
4101
|
-
const payloadBytes = payload.toUint8Array();
|
|
4102
|
-
if (payloadBytes.length > 65535) {
|
|
4103
|
-
throw new LengthExceedsMaxError("ServerSetup::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4104
|
-
}
|
|
4105
|
-
buf.putU16(payloadBytes.length);
|
|
4106
|
-
buf.putBytes(payloadBytes);
|
|
4107
|
-
return buf.freeze();
|
|
4108
|
-
}
|
|
4109
|
-
static parsePayload(buf) {
|
|
4110
|
-
const paramCount = buf.getNumberVI();
|
|
4111
|
-
const setupParameters = deserializeKvpList(buf, paramCount);
|
|
4112
|
-
return new _ServerSetup(setupParameters);
|
|
4113
|
-
}
|
|
4114
|
-
};
|
|
4115
|
-
|
|
4116
|
-
// src/model/control/publish_done.ts
|
|
4117
|
-
var PublishDone = class _PublishDone {
|
|
4118
|
-
constructor(requestId, statusCode, streamCount, errorReason) {
|
|
4119
|
-
this.requestId = requestId;
|
|
4120
|
-
this.statusCode = statusCode;
|
|
4121
|
-
this.streamCount = streamCount;
|
|
4122
|
-
this.errorReason = errorReason;
|
|
4123
|
-
}
|
|
4124
|
-
requestId;
|
|
4125
|
-
statusCode;
|
|
4126
|
-
streamCount;
|
|
4127
|
-
errorReason;
|
|
4128
|
-
static new(requestId, statusCode, streamCount, errorReason) {
|
|
4129
|
-
return new _PublishDone(BigInt(requestId), statusCode, streamCount, errorReason);
|
|
4130
|
-
}
|
|
4131
|
-
getType() {
|
|
4132
|
-
return 11 /* PublishDone */;
|
|
4133
|
-
}
|
|
4134
|
-
serialize() {
|
|
4135
|
-
const buf = new ByteBuffer();
|
|
4136
|
-
buf.putVI(11 /* PublishDone */);
|
|
4137
|
-
const payload = new ByteBuffer();
|
|
4138
|
-
payload.putVI(this.requestId);
|
|
4139
|
-
payload.putVI(this.statusCode);
|
|
4140
|
-
payload.putVI(this.streamCount);
|
|
4141
|
-
payload.putReasonPhrase(this.errorReason);
|
|
4142
|
-
const payloadBytes = payload.toUint8Array();
|
|
4143
|
-
if (payloadBytes.length > 65535) {
|
|
4144
|
-
throw new LengthExceedsMaxError("PublishDone::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4145
|
-
}
|
|
4146
|
-
buf.putU16(payloadBytes.length);
|
|
4147
|
-
buf.putBytes(payloadBytes);
|
|
4148
|
-
return buf.freeze();
|
|
4149
|
-
}
|
|
4150
|
-
static parsePayload(buf) {
|
|
4151
|
-
const requestId = buf.getVI();
|
|
4152
|
-
const statusCodeRaw = buf.getVI();
|
|
4153
|
-
const statusCode = publishDoneStatusCodeFromBigInt(statusCodeRaw);
|
|
4154
|
-
const streamCount = buf.getVI();
|
|
4155
|
-
const errorReason = buf.getReasonPhrase();
|
|
4156
|
-
return new _PublishDone(requestId, statusCode, streamCount, errorReason);
|
|
4157
|
-
}
|
|
4158
|
-
};
|
|
4159
|
-
|
|
4160
|
-
// src/model/control/publish.ts
|
|
4161
|
-
var Publish = class _Publish {
|
|
4162
|
-
constructor(requestId, fullTrackName, trackAlias, parameters, trackExtensions = []) {
|
|
4163
|
-
this.requestId = requestId;
|
|
4164
|
-
this.fullTrackName = fullTrackName;
|
|
4165
|
-
this.trackAlias = trackAlias;
|
|
4166
|
-
this.parameters = parameters;
|
|
4167
|
-
this.trackExtensions = trackExtensions;
|
|
4168
|
-
}
|
|
4169
|
-
requestId;
|
|
4170
|
-
fullTrackName;
|
|
4171
|
-
trackAlias;
|
|
4172
|
-
parameters;
|
|
4173
|
-
trackExtensions;
|
|
4174
|
-
getType() {
|
|
4175
|
-
return 29 /* Publish */;
|
|
4176
|
-
}
|
|
4177
|
-
serialize() {
|
|
4178
|
-
const buf = new ByteBuffer();
|
|
4179
|
-
buf.putVI(29 /* Publish */);
|
|
4180
|
-
const payload = new ByteBuffer();
|
|
4181
|
-
payload.putVI(this.requestId);
|
|
4182
|
-
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
4183
|
-
payload.putVI(this.trackAlias);
|
|
4184
|
-
payload.putVI(this.parameters.length);
|
|
4185
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4186
|
-
TrackExtension.serializeInto(this.trackExtensions, payload);
|
|
4187
|
-
const payloadBytes = payload.toUint8Array();
|
|
4188
|
-
if (payloadBytes.length > 65535) {
|
|
4189
|
-
throw new LengthExceedsMaxError("Publish::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4190
|
-
}
|
|
4191
|
-
buf.putU16(payloadBytes.length);
|
|
4192
|
-
buf.putBytes(payloadBytes);
|
|
4193
|
-
return buf.freeze();
|
|
4194
|
-
}
|
|
4195
|
-
static parsePayload(buf) {
|
|
4196
|
-
const requestId = buf.getVI();
|
|
4197
|
-
const fullTrackName = buf.getFullTrackName();
|
|
4198
|
-
const trackAlias = buf.getVI();
|
|
4199
|
-
const paramCount = buf.getNumberVI();
|
|
4200
|
-
const rawParams = deserializeKvpList(buf, paramCount);
|
|
4201
|
-
const parameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
4202
|
-
const trackExtensions = TrackExtension.deserializeAll(buf);
|
|
4203
|
-
return new _Publish(requestId, fullTrackName, trackAlias, parameters, trackExtensions);
|
|
4204
|
-
}
|
|
4205
|
-
};
|
|
4206
|
-
|
|
4207
|
-
// src/model/control/publish_ok.ts
|
|
4208
|
-
var PublishOk = class _PublishOk {
|
|
4209
|
-
constructor(requestId, parameters) {
|
|
4210
|
-
this.requestId = requestId;
|
|
4211
|
-
this.parameters = parameters;
|
|
4212
|
-
}
|
|
4213
|
-
requestId;
|
|
4214
|
-
parameters;
|
|
4215
|
-
getType() {
|
|
4216
|
-
return 30 /* PublishOk */;
|
|
4217
|
-
}
|
|
4218
|
-
serialize() {
|
|
4219
|
-
const buf = new ByteBuffer();
|
|
4220
|
-
buf.putVI(30 /* PublishOk */);
|
|
4221
|
-
const payload = new ByteBuffer();
|
|
4222
|
-
payload.putVI(this.requestId);
|
|
4223
|
-
payload.putVI(this.parameters.length);
|
|
4224
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4225
|
-
const payloadBytes = payload.toUint8Array();
|
|
4226
|
-
if (payloadBytes.length > 65535) {
|
|
4227
|
-
throw new LengthExceedsMaxError("PublishOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4228
|
-
}
|
|
4229
|
-
buf.putU16(payloadBytes.length);
|
|
4230
|
-
buf.putBytes(payloadBytes);
|
|
4231
|
-
return buf.freeze();
|
|
4232
|
-
}
|
|
4233
|
-
static parsePayload(buf) {
|
|
4234
|
-
const requestId = buf.getVI();
|
|
4235
|
-
const paramCount = buf.getVI();
|
|
4236
|
-
const kvps = deserializeKvpList(buf, paramCount);
|
|
4237
|
-
const parameters = MessageParameters.fromKeyValuePairs(kvps);
|
|
4238
|
-
return new _PublishOk(requestId, parameters);
|
|
4239
|
-
}
|
|
4240
|
-
};
|
|
4241
|
-
|
|
4242
|
-
// src/model/control/subscribe_ok.ts
|
|
4243
|
-
var SubscribeOk = class _SubscribeOk {
|
|
4244
|
-
requestId;
|
|
4245
|
-
trackAlias;
|
|
4246
|
-
parameters;
|
|
4247
|
-
trackExtensions;
|
|
4248
|
-
constructor(requestId, trackAlias, parameters, trackExtensions) {
|
|
4249
|
-
this.requestId = requestId;
|
|
4250
|
-
this.trackAlias = trackAlias;
|
|
4251
|
-
this.parameters = parameters;
|
|
4252
|
-
this.trackExtensions = trackExtensions;
|
|
4253
|
-
}
|
|
4254
|
-
static create(requestId, trackAlias, parameters, trackExtensions = []) {
|
|
4255
|
-
return new _SubscribeOk(requestId, trackAlias, parameters, trackExtensions);
|
|
4256
|
-
}
|
|
4257
|
-
serialize() {
|
|
4258
|
-
const buf = new ByteBuffer();
|
|
4259
|
-
buf.putVI(4 /* SubscribeOk */);
|
|
4260
|
-
const payload = new ByteBuffer();
|
|
4261
|
-
payload.putVI(this.requestId);
|
|
4262
|
-
payload.putVI(this.trackAlias);
|
|
4263
|
-
payload.putVI(this.parameters.length);
|
|
4264
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4265
|
-
TrackExtension.serializeInto(this.trackExtensions, payload);
|
|
4266
|
-
const payloadBytes = payload.toUint8Array();
|
|
4267
|
-
if (payloadBytes.length > 65535) {
|
|
4268
|
-
throw new LengthExceedsMaxError("SubscribeOk::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4269
|
-
}
|
|
4270
|
-
buf.putU16(payloadBytes.length);
|
|
4271
|
-
buf.putBytes(payloadBytes);
|
|
4272
|
-
return buf.freeze();
|
|
4273
|
-
}
|
|
4274
|
-
static parsePayload(buf) {
|
|
4275
|
-
const requestId = buf.getVI();
|
|
4276
|
-
const trackAlias = buf.getVI();
|
|
4277
|
-
const paramCount = buf.getNumberVI();
|
|
4278
|
-
const rawParams = deserializeKvpList(buf, paramCount);
|
|
4279
|
-
const parameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
4280
|
-
const trackExtensions = TrackExtension.deserializeAll(buf);
|
|
4281
|
-
return new _SubscribeOk(requestId, trackAlias, parameters, trackExtensions);
|
|
4282
|
-
}
|
|
4283
|
-
};
|
|
4284
|
-
|
|
4285
|
-
// src/model/control/request_update.ts
|
|
4286
|
-
var RequestUpdate = class _RequestUpdate {
|
|
4287
|
-
constructor(requestId, existingRequestId, parameters) {
|
|
4288
|
-
this.requestId = requestId;
|
|
4289
|
-
this.existingRequestId = existingRequestId;
|
|
4290
|
-
this.parameters = parameters;
|
|
4291
|
-
}
|
|
4292
|
-
requestId;
|
|
4293
|
-
existingRequestId;
|
|
4294
|
-
parameters;
|
|
4295
|
-
getType() {
|
|
4296
|
-
return 2 /* RequestUpdate */;
|
|
4297
|
-
}
|
|
4298
|
-
serialize() {
|
|
4299
|
-
const buf = new ByteBuffer();
|
|
4300
|
-
buf.putVI(2 /* RequestUpdate */);
|
|
4301
|
-
const payload = new ByteBuffer();
|
|
4302
|
-
payload.putVI(this.requestId);
|
|
4303
|
-
payload.putVI(this.existingRequestId);
|
|
4304
|
-
payload.putVI(this.parameters.length);
|
|
4305
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4306
|
-
const payloadBytes = payload.toUint8Array();
|
|
4307
|
-
if (payloadBytes.length > 65535) {
|
|
4308
|
-
throw new LengthExceedsMaxError("RequestUpdate::serialize(payloadBytes)", 65535, payloadBytes.length);
|
|
4309
|
-
}
|
|
4310
|
-
buf.putU16(payloadBytes.length);
|
|
4311
|
-
buf.putBytes(payloadBytes);
|
|
4312
|
-
return buf.freeze();
|
|
4313
|
-
}
|
|
4314
|
-
static parsePayload(buf) {
|
|
4315
|
-
const requestId = buf.getVI();
|
|
4316
|
-
const existingRequestId = buf.getVI();
|
|
4317
|
-
const paramCountBig = buf.getVI();
|
|
4318
|
-
const paramCount = Number(paramCountBig);
|
|
4319
|
-
if (BigInt(paramCount) !== paramCountBig) {
|
|
4320
|
-
throw new CastingError("RequestUpdate.deserialize paramCount", "bigint", "number", `${paramCountBig}`);
|
|
4321
|
-
}
|
|
4322
|
-
const parameters = [];
|
|
4323
|
-
for (const kvp of deserializeKvpList(buf, paramCount)) {
|
|
4324
|
-
const param = MessageParameter.fromKeyValuePair(kvp);
|
|
4325
|
-
if (param !== void 0) parameters.push(param);
|
|
4326
|
-
}
|
|
4327
|
-
return new _RequestUpdate(requestId, existingRequestId, parameters);
|
|
4328
|
-
}
|
|
4329
|
-
equals(other) {
|
|
4330
|
-
if (this.requestId !== other.requestId || this.existingRequestId !== other.existingRequestId || this.parameters.length !== other.parameters.length) {
|
|
4331
|
-
return false;
|
|
4332
|
-
}
|
|
4333
|
-
for (let i = 0; i < this.parameters.length; i++) {
|
|
4334
|
-
const a = this.parameters[i];
|
|
4335
|
-
const b = other.parameters[i];
|
|
4336
|
-
if (!a || !b) return false;
|
|
4337
|
-
const aKvp = a.toKeyValuePair();
|
|
4338
|
-
const bKvp = b.toKeyValuePair();
|
|
4339
|
-
if (!aKvp.equals(bKvp)) return false;
|
|
4340
|
-
}
|
|
4341
|
-
return true;
|
|
4342
|
-
}
|
|
4343
|
-
};
|
|
4344
|
-
|
|
4345
|
-
// src/model/control/requests_blocked.ts
|
|
4346
|
-
var RequestsBlocked = class _RequestsBlocked {
|
|
4347
|
-
maximumRequestId;
|
|
4348
|
-
constructor(maximumRequestId) {
|
|
4349
|
-
this.maximumRequestId = BigInt(maximumRequestId);
|
|
4350
|
-
}
|
|
4351
|
-
getType() {
|
|
4352
|
-
return 26 /* RequestsBlocked */;
|
|
4353
|
-
}
|
|
4354
|
-
serialize() {
|
|
4355
|
-
const buf = new ByteBuffer();
|
|
4356
|
-
buf.putVI(26 /* RequestsBlocked */);
|
|
4357
|
-
const payload = new ByteBuffer();
|
|
4358
|
-
payload.putVI(this.maximumRequestId);
|
|
4359
|
-
const payloadBytes = payload.toUint8Array();
|
|
4360
|
-
if (payloadBytes.length > 65535) {
|
|
4361
|
-
throw new LengthExceedsMaxError("RequestsBlocked::serialize", 65535, payloadBytes.length);
|
|
4362
|
-
}
|
|
4363
|
-
buf.putU16(payloadBytes.length);
|
|
4364
|
-
buf.putBytes(payloadBytes);
|
|
4365
|
-
return buf.freeze();
|
|
4366
|
-
}
|
|
4367
|
-
static parsePayload(buf) {
|
|
4368
|
-
const maximumRequestId = buf.getVI();
|
|
4369
|
-
return new _RequestsBlocked(maximumRequestId);
|
|
4370
|
-
}
|
|
4371
|
-
};
|
|
4372
|
-
|
|
4373
|
-
// src/model/control/track_status.ts
|
|
4374
|
-
var TrackStatus = class _TrackStatus {
|
|
4375
|
-
constructor(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, filterType, startLocation, endGroup, subscribeParameters) {
|
|
4376
|
-
this.requestId = requestId;
|
|
4377
|
-
this.trackAlias = trackAlias;
|
|
4378
|
-
this.fullTrackName = fullTrackName;
|
|
4379
|
-
this.subscriberPriority = subscriberPriority;
|
|
4380
|
-
this.groupOrder = groupOrder;
|
|
4381
|
-
this.forward = forward;
|
|
4382
|
-
this.filterType = filterType;
|
|
4383
|
-
this.startLocation = startLocation;
|
|
4384
|
-
this.endGroup = endGroup;
|
|
4385
|
-
this.subscribeParameters = subscribeParameters;
|
|
4386
|
-
}
|
|
4387
|
-
requestId;
|
|
4388
|
-
trackAlias;
|
|
4389
|
-
fullTrackName;
|
|
4390
|
-
subscriberPriority;
|
|
4391
|
-
groupOrder;
|
|
4392
|
-
forward;
|
|
4393
|
-
filterType;
|
|
4394
|
-
startLocation;
|
|
4395
|
-
endGroup;
|
|
4396
|
-
subscribeParameters;
|
|
4397
|
-
static newNextGroupStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
|
|
4398
|
-
return new _TrackStatus(
|
|
4399
|
-
requestId,
|
|
4400
|
-
trackAlias,
|
|
4401
|
-
fullTrackName,
|
|
4402
|
-
subscriberPriority,
|
|
4403
|
-
groupOrder,
|
|
4404
|
-
forward,
|
|
4405
|
-
1 /* NextGroupStart */,
|
|
4406
|
-
void 0,
|
|
4407
|
-
void 0,
|
|
4408
|
-
subscribeParameters
|
|
4409
|
-
);
|
|
4410
|
-
}
|
|
4411
|
-
static newLatestObject(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
|
|
4412
|
-
return new _TrackStatus(
|
|
4413
|
-
requestId,
|
|
4414
|
-
trackAlias,
|
|
4415
|
-
fullTrackName,
|
|
4416
|
-
subscriberPriority,
|
|
4417
|
-
groupOrder,
|
|
4418
|
-
forward,
|
|
4419
|
-
2 /* LatestObject */,
|
|
4420
|
-
void 0,
|
|
4421
|
-
void 0,
|
|
4422
|
-
subscribeParameters
|
|
4423
|
-
);
|
|
4424
|
-
}
|
|
4425
|
-
static newAbsoluteStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, subscribeParameters) {
|
|
4426
|
-
return new _TrackStatus(
|
|
4427
|
-
requestId,
|
|
4428
|
-
trackAlias,
|
|
4429
|
-
fullTrackName,
|
|
4430
|
-
subscriberPriority,
|
|
4431
|
-
groupOrder,
|
|
4432
|
-
forward,
|
|
4433
|
-
3 /* AbsoluteStart */,
|
|
4434
|
-
startLocation,
|
|
4435
|
-
void 0,
|
|
4436
|
-
subscribeParameters
|
|
4437
|
-
);
|
|
4438
|
-
}
|
|
4439
|
-
static newAbsoluteRange(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, endGroup, subscribeParameters) {
|
|
4440
|
-
if (endGroup < startLocation.group) {
|
|
4441
|
-
throw new Error("End Group must be >= Start Group");
|
|
4442
|
-
}
|
|
4443
|
-
return new _TrackStatus(
|
|
4444
|
-
requestId,
|
|
4445
|
-
trackAlias,
|
|
4446
|
-
fullTrackName,
|
|
4447
|
-
subscriberPriority,
|
|
4448
|
-
groupOrder,
|
|
4449
|
-
forward,
|
|
4450
|
-
4 /* AbsoluteRange */,
|
|
4451
|
-
startLocation,
|
|
4452
|
-
endGroup,
|
|
4453
|
-
subscribeParameters
|
|
4454
|
-
);
|
|
4455
|
-
}
|
|
4456
|
-
serialize() {
|
|
4457
|
-
const buf = new ByteBuffer();
|
|
4458
|
-
buf.putVI(13 /* TrackStatus */);
|
|
4459
|
-
const payload = new ByteBuffer();
|
|
4460
|
-
payload.putVI(this.requestId);
|
|
4461
|
-
payload.putVI(this.trackAlias);
|
|
4462
|
-
payload.putBytes(this.fullTrackName.serialize().toUint8Array());
|
|
4463
|
-
payload.putU8(this.subscriberPriority);
|
|
4464
|
-
payload.putU8(this.groupOrder);
|
|
4465
|
-
payload.putU8(this.forward ? 1 : 0);
|
|
4466
|
-
payload.putVI(this.filterType);
|
|
4467
|
-
if (this.filterType === 3 /* AbsoluteStart */ || this.filterType === 4 /* AbsoluteRange */) {
|
|
4468
|
-
if (!this.startLocation) {
|
|
4469
|
-
throw new Error("StartLocation required for selected filterType");
|
|
4470
|
-
}
|
|
4471
|
-
payload.putLocation(this.startLocation);
|
|
4472
|
-
}
|
|
4473
|
-
if (this.filterType === 4 /* AbsoluteRange */) {
|
|
4474
|
-
if (this.endGroup == null) {
|
|
4475
|
-
throw new Error("EndGroup required for AbsoluteRange");
|
|
4476
|
-
}
|
|
4477
|
-
payload.putVI(this.endGroup);
|
|
4478
|
-
}
|
|
4479
|
-
payload.putVI(this.subscribeParameters.length);
|
|
4480
|
-
payload.putBytes(serializeKvpList(this.subscribeParameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4481
|
-
const payloadBytes = payload.toUint8Array();
|
|
4482
|
-
buf.putU16(payloadBytes.length);
|
|
4483
|
-
buf.putBytes(payloadBytes);
|
|
4484
|
-
return buf.freeze();
|
|
4485
|
-
}
|
|
4486
|
-
static parsePayload(buf) {
|
|
4487
|
-
const requestId = buf.getVI();
|
|
4488
|
-
const trackAlias = buf.getVI();
|
|
4489
|
-
const fullTrackName = buf.getFullTrackName();
|
|
4490
|
-
const subscriberPriority = buf.getU8();
|
|
4491
|
-
const groupOrder = buf.getU8();
|
|
4492
|
-
const forward = buf.getU8() === 1;
|
|
4493
|
-
const filterType = Number(buf.getVI());
|
|
4494
|
-
let startLocation = void 0;
|
|
4495
|
-
let endGroup = void 0;
|
|
4496
|
-
if (filterType === 3 /* AbsoluteStart */ || filterType === 4 /* AbsoluteRange */) {
|
|
4497
|
-
startLocation = buf.getLocation();
|
|
4498
|
-
}
|
|
4499
|
-
if (filterType === 4 /* AbsoluteRange */) {
|
|
4500
|
-
endGroup = buf.getVI();
|
|
4501
|
-
}
|
|
4502
|
-
const paramCount = Number(buf.getVI());
|
|
4503
|
-
const rawParams = deserializeKvpList(buf, paramCount);
|
|
4504
|
-
const subscribeParameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
4505
|
-
return new _TrackStatus(
|
|
4506
|
-
requestId,
|
|
4507
|
-
trackAlias,
|
|
4508
|
-
fullTrackName,
|
|
4509
|
-
subscriberPriority,
|
|
4510
|
-
groupOrder,
|
|
4511
|
-
forward,
|
|
4512
|
-
filterType,
|
|
4513
|
-
startLocation,
|
|
4514
|
-
endGroup,
|
|
4515
|
-
subscribeParameters
|
|
4516
|
-
);
|
|
4517
|
-
}
|
|
4518
|
-
};
|
|
4519
|
-
|
|
4520
|
-
// src/model/control/publish_namespace_done.ts
|
|
4521
|
-
var PublishNamespaceDone = class _PublishNamespaceDone {
|
|
4522
|
-
/**
|
|
4523
|
-
* Constructs a PublishNamespaceDone message.
|
|
4524
|
-
* @param trackNamespace - The track namespace to unpublish.
|
|
4525
|
-
*/
|
|
4526
|
-
constructor(trackNamespace) {
|
|
4527
|
-
this.trackNamespace = trackNamespace;
|
|
4528
|
-
}
|
|
4529
|
-
trackNamespace;
|
|
4530
|
-
/**
|
|
4531
|
-
* Gets the control message type for this PublishNamespaceDone message.
|
|
4532
|
-
* @returns The ControlMessageType.PublishNamespaceDone enum value.
|
|
4533
|
-
*/
|
|
4534
|
-
getType() {
|
|
4535
|
-
return 9 /* PublishNamespaceDone */;
|
|
4536
|
-
}
|
|
4537
|
-
/**
|
|
4538
|
-
* Serializes the PublishNamespaceDone message to a frozen byte buffer.
|
|
4539
|
-
* @returns The serialized message as a FrozenByteBuffer.
|
|
4540
|
-
* @throws :{@link LengthExceedsMaxError} If the payload exceeds 65535 bytes.
|
|
4541
|
-
*/
|
|
4542
|
-
serialize() {
|
|
4543
|
-
const buf = new ByteBuffer();
|
|
4544
|
-
buf.putVI(9 /* PublishNamespaceDone */);
|
|
4545
|
-
const payload = new ByteBuffer();
|
|
4546
|
-
payload.putTuple(this.trackNamespace);
|
|
4547
|
-
const payloadBytes = payload.toUint8Array();
|
|
4548
|
-
if (payloadBytes.length > 65535) {
|
|
4549
|
-
throw new LengthExceedsMaxError(
|
|
4550
|
-
"PublishNamespaceDone::serialize(payloadBytes.length)",
|
|
4551
|
-
65535,
|
|
4552
|
-
payloadBytes.length
|
|
4553
|
-
);
|
|
4554
|
-
}
|
|
4555
|
-
buf.putU16(payloadBytes.length);
|
|
4556
|
-
buf.putBytes(payloadBytes);
|
|
4557
|
-
return buf.freeze();
|
|
4558
|
-
}
|
|
4559
|
-
/**
|
|
4560
|
-
* Parses a PublishNamespaceDone message payload from a buffer.
|
|
4561
|
-
* @param buf - The buffer containing the payload.
|
|
4562
|
-
* @returns The parsed PublishNamespaceDone message.
|
|
4563
|
-
*/
|
|
4564
|
-
static parsePayload(buf) {
|
|
4565
|
-
const trackNamespace = buf.getTuple();
|
|
4566
|
-
return new _PublishNamespaceDone(trackNamespace);
|
|
4567
|
-
}
|
|
4568
|
-
};
|
|
4569
|
-
|
|
4570
|
-
// src/model/control/unsubscribe.ts
|
|
4571
|
-
var Unsubscribe = class _Unsubscribe {
|
|
4572
|
-
requestId;
|
|
4573
|
-
constructor(requestId) {
|
|
4574
|
-
this.requestId = BigInt(requestId);
|
|
4575
|
-
}
|
|
4576
|
-
getType() {
|
|
4577
|
-
return 10 /* Unsubscribe */;
|
|
4578
|
-
}
|
|
4579
|
-
serialize() {
|
|
4580
|
-
const buf = new ByteBuffer();
|
|
4581
|
-
buf.putVI(10 /* Unsubscribe */);
|
|
4582
|
-
const payload = new ByteBuffer();
|
|
4583
|
-
payload.putVI(this.requestId);
|
|
4584
|
-
const payloadBytes = payload.toUint8Array();
|
|
4585
|
-
if (payloadBytes.length > 65535) {
|
|
4586
|
-
throw new LengthExceedsMaxError("Unsubscribe::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4587
|
-
}
|
|
4588
|
-
buf.putU16(payloadBytes.length);
|
|
4589
|
-
buf.putBytes(payloadBytes);
|
|
4590
|
-
return buf.freeze();
|
|
4591
|
-
}
|
|
4592
|
-
static parsePayload(buf) {
|
|
4593
|
-
const requestId = buf.getVI();
|
|
4594
|
-
return new _Unsubscribe(requestId);
|
|
4595
|
-
}
|
|
4596
|
-
};
|
|
4597
|
-
|
|
4598
|
-
// src/model/control/subscribe_namespace.ts
|
|
4599
|
-
var SubscribeNamespace = class _SubscribeNamespace {
|
|
4600
|
-
constructor(requestId, trackNamespacePrefix, subscribeOptions, parameters) {
|
|
4601
|
-
this.requestId = requestId;
|
|
4602
|
-
this.trackNamespacePrefix = trackNamespacePrefix;
|
|
4603
|
-
this.subscribeOptions = subscribeOptions;
|
|
4604
|
-
this.parameters = parameters;
|
|
4605
|
-
}
|
|
4606
|
-
requestId;
|
|
4607
|
-
trackNamespacePrefix;
|
|
4608
|
-
subscribeOptions;
|
|
4609
|
-
parameters;
|
|
4610
|
-
getType() {
|
|
4611
|
-
return 17 /* SubscribeNamespace */;
|
|
4612
|
-
}
|
|
4613
|
-
serialize() {
|
|
4614
|
-
const buf = new ByteBuffer();
|
|
4615
|
-
buf.putVI(17 /* SubscribeNamespace */);
|
|
4616
|
-
const payload = new ByteBuffer();
|
|
4617
|
-
payload.putVI(this.requestId);
|
|
4618
|
-
payload.putTuple(this.trackNamespacePrefix);
|
|
4619
|
-
payload.putVI(this.subscribeOptions);
|
|
4620
|
-
payload.putVI(this.parameters.length);
|
|
4621
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4622
|
-
const payloadBytes = payload.toUint8Array();
|
|
4623
|
-
if (payloadBytes.length > 65535) {
|
|
4624
|
-
throw new LengthExceedsMaxError("SubscribeNamespace::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4625
|
-
}
|
|
4626
|
-
buf.putU16(payloadBytes.length);
|
|
4627
|
-
buf.putBytes(payloadBytes);
|
|
4628
|
-
return buf.freeze();
|
|
4629
|
-
}
|
|
4630
|
-
static parsePayload(buf) {
|
|
4631
|
-
const requestId = buf.getVI();
|
|
4632
|
-
const trackNamespacePrefix = buf.getTuple();
|
|
4633
|
-
const subscribeOptions = Number(buf.getVI());
|
|
4634
|
-
const paramCount = buf.getNumberVI();
|
|
4635
|
-
const rawParams = deserializeKvpList(buf, paramCount);
|
|
4636
|
-
const parameters = MessageParameters.fromKeyValuePairs(rawParams);
|
|
4637
|
-
return new _SubscribeNamespace(requestId, trackNamespacePrefix, subscribeOptions, parameters);
|
|
4638
|
-
}
|
|
4639
|
-
};
|
|
4640
|
-
|
|
4641
|
-
// src/model/control/unsubscribe_namespace.ts
|
|
4642
|
-
var UnsubscribeNamespace = class _UnsubscribeNamespace {
|
|
4643
|
-
constructor(trackNamespacePrefix) {
|
|
4644
|
-
this.trackNamespacePrefix = trackNamespacePrefix;
|
|
4645
|
-
}
|
|
4646
|
-
trackNamespacePrefix;
|
|
4647
|
-
getType() {
|
|
4648
|
-
return 20 /* UnsubscribeNamespace */;
|
|
4649
|
-
}
|
|
4650
|
-
serialize() {
|
|
4651
|
-
const buf = new ByteBuffer();
|
|
4652
|
-
buf.putVI(20 /* UnsubscribeNamespace */);
|
|
4653
|
-
const payload = new ByteBuffer();
|
|
4654
|
-
payload.putTuple(this.trackNamespacePrefix);
|
|
4655
|
-
const payloadBytes = payload.toUint8Array();
|
|
4656
|
-
if (payloadBytes.length > 65535) {
|
|
4657
|
-
throw new LengthExceedsMaxError("UnsubscribeNamespace::serialize(payload_length)", 65535, payloadBytes.length);
|
|
4658
|
-
}
|
|
4659
|
-
buf.putU16(payloadBytes.length);
|
|
4660
|
-
buf.putBytes(payloadBytes);
|
|
4661
|
-
return buf.freeze();
|
|
4662
|
-
}
|
|
4663
|
-
static parsePayload(buf) {
|
|
4664
|
-
const trackNamespacePrefix = buf.getTuple();
|
|
4665
|
-
return new _UnsubscribeNamespace(trackNamespacePrefix);
|
|
4666
|
-
}
|
|
4667
|
-
};
|
|
4668
|
-
|
|
4669
|
-
// src/model/control/request_ok.ts
|
|
4670
|
-
var RequestOk = class _RequestOk {
|
|
4671
|
-
requestId;
|
|
4672
|
-
parameters;
|
|
4673
|
-
constructor(requestId, parameters = []) {
|
|
4674
|
-
this.requestId = BigInt(requestId);
|
|
4675
|
-
this.parameters = parameters;
|
|
4676
|
-
}
|
|
4677
|
-
getType() {
|
|
4678
|
-
return 7 /* RequestOk */;
|
|
4679
|
-
}
|
|
4680
|
-
serialize() {
|
|
4681
|
-
const buf = new ByteBuffer();
|
|
4682
|
-
buf.putVI(7 /* RequestOk */);
|
|
4683
|
-
const payload = new ByteBuffer();
|
|
4684
|
-
payload.putVI(this.requestId);
|
|
4685
|
-
payload.putVI(BigInt(this.parameters.length));
|
|
4686
|
-
payload.putBytes(serializeKvpList(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
|
|
4687
|
-
const payloadBytes = payload.toUint8Array();
|
|
4688
|
-
if (payloadBytes.length > 65535) {
|
|
4689
|
-
throw new LengthExceedsMaxError("RequestOk::serialize(payloadBytes)", 65535, payloadBytes.length);
|
|
4690
|
-
}
|
|
4691
|
-
buf.putU16(payloadBytes.length);
|
|
4692
|
-
buf.putBytes(payloadBytes);
|
|
4693
|
-
return buf.freeze();
|
|
4694
|
-
}
|
|
4695
|
-
static parsePayload(buf) {
|
|
4696
|
-
const requestId = buf.getVI();
|
|
4697
|
-
const numParamsBig = buf.getVI();
|
|
4698
|
-
const numParams = Number(numParamsBig);
|
|
4699
|
-
if (BigInt(numParams) !== numParamsBig) {
|
|
4700
|
-
throw new CastingError("RequestOk.parsePayload numParams", "bigint", "number", `${numParamsBig}`);
|
|
4701
|
-
}
|
|
4702
|
-
const parameters = [];
|
|
4703
|
-
for (const kvp of deserializeKvpList(buf, numParams)) {
|
|
4704
|
-
const param = MessageParameter.fromKeyValuePair(kvp);
|
|
4705
|
-
if (param !== void 0) parameters.push(param);
|
|
4706
|
-
}
|
|
4707
|
-
return new _RequestOk(requestId, parameters);
|
|
4708
|
-
}
|
|
4709
|
-
};
|
|
4710
|
-
|
|
4711
|
-
// src/model/control/request_error.ts
|
|
4712
|
-
var RequestError = class _RequestError {
|
|
4713
|
-
requestId;
|
|
4714
|
-
errorCode;
|
|
4715
|
-
retryInterval;
|
|
4716
|
-
reasonPhrase;
|
|
4717
|
-
constructor(requestId, errorCode, retryInterval, reasonPhrase) {
|
|
4718
|
-
this.requestId = requestId;
|
|
4719
|
-
this.errorCode = errorCode;
|
|
4720
|
-
this.retryInterval = retryInterval;
|
|
4721
|
-
this.reasonPhrase = reasonPhrase;
|
|
4722
|
-
}
|
|
4723
|
-
getType() {
|
|
4724
|
-
return 5 /* RequestError */;
|
|
4725
|
-
}
|
|
4726
|
-
serialize() {
|
|
4727
|
-
const buf = new ByteBuffer();
|
|
4728
|
-
buf.putVI(5 /* RequestError */);
|
|
4729
|
-
const payload = new ByteBuffer();
|
|
4730
|
-
payload.putVI(this.requestId);
|
|
4731
|
-
payload.putVI(this.errorCode);
|
|
4732
|
-
payload.putVI(this.retryInterval);
|
|
4733
|
-
payload.putReasonPhrase(this.reasonPhrase);
|
|
4734
|
-
const payloadBytes = payload.toUint8Array();
|
|
4735
|
-
if (payloadBytes.length > 65535) {
|
|
4736
|
-
throw new LengthExceedsMaxError("RequestError::serialize(payloadBytes.length)", 65535, payloadBytes.length);
|
|
4737
|
-
}
|
|
4738
|
-
buf.putU16(payloadBytes.length);
|
|
4739
|
-
buf.putBytes(payloadBytes);
|
|
4740
|
-
return buf.freeze();
|
|
4741
|
-
}
|
|
4742
|
-
static parsePayload(buf) {
|
|
4743
|
-
const requestId = buf.getVI();
|
|
4744
|
-
const errorCodeRaw = buf.getVI();
|
|
4745
|
-
const errorCode = requestErrorCodeFromBigInt(errorCodeRaw);
|
|
4746
|
-
const retryInterval = buf.getVI();
|
|
4747
|
-
const reasonPhrase = buf.getReasonPhrase();
|
|
4748
|
-
return new _RequestError(requestId, errorCode, retryInterval, reasonPhrase);
|
|
4749
|
-
}
|
|
4750
|
-
};
|
|
4751
|
-
|
|
4752
|
-
// src/model/control/control_message.ts
|
|
4753
|
-
var ControlMessage;
|
|
4754
|
-
((ControlMessage2) => {
|
|
4755
|
-
function deserialize(buf) {
|
|
4756
|
-
const messageTypeRaw = buf.getVI();
|
|
4757
|
-
const messageType = controlMessageTypeFromBigInt(messageTypeRaw);
|
|
4758
|
-
const payloadLength = buf.getU16();
|
|
4759
|
-
if (buf.remaining < payloadLength)
|
|
4760
|
-
throw new NotEnoughBytesError("ControlMessage.deserialize(payload_bytes)", payloadLength, buf.remaining);
|
|
4761
|
-
const payloadBytes = buf.getBytes(payloadLength);
|
|
4762
|
-
const payload = new FrozenByteBuffer5(payloadBytes);
|
|
4763
|
-
switch (messageType) {
|
|
4764
|
-
case 29 /* Publish */:
|
|
4765
|
-
return Publish.parsePayload(payload);
|
|
4766
|
-
case 30 /* PublishOk */:
|
|
4767
|
-
return PublishOk.parsePayload(payload);
|
|
4768
|
-
case 11 /* PublishDone */:
|
|
4769
|
-
return PublishDone.parsePayload(payload);
|
|
4770
|
-
case 6 /* PublishNamespace */:
|
|
4771
|
-
return PublishNamespace.parsePayload(payload);
|
|
4772
|
-
case 12 /* PublishNamespaceCancel */:
|
|
4773
|
-
return PublishNamespaceCancel.parsePayload(payload);
|
|
4774
|
-
case 8 /* Namespace */:
|
|
4775
|
-
return Namespace.parsePayload(payload);
|
|
4776
|
-
case 14 /* NamespaceDone */:
|
|
4777
|
-
return NamespaceDone.parsePayload(payload);
|
|
4778
|
-
case 7 /* RequestOk */:
|
|
4779
|
-
return RequestOk.parsePayload(payload);
|
|
4780
|
-
case 5 /* RequestError */:
|
|
4781
|
-
return RequestError.parsePayload(payload);
|
|
4782
|
-
case 32 /* ClientSetup */:
|
|
4783
|
-
return ClientSetup.parsePayload(payload);
|
|
4784
|
-
case 22 /* Fetch */:
|
|
4785
|
-
return Fetch.parsePayload(payload);
|
|
4786
|
-
case 23 /* FetchCancel */:
|
|
4787
|
-
return FetchCancel.parsePayload(payload);
|
|
4788
|
-
case 24 /* FetchOk */:
|
|
4789
|
-
return FetchOk.parsePayload(payload);
|
|
4790
|
-
case 16 /* GoAway */:
|
|
4791
|
-
return GoAway.parsePayload(payload);
|
|
4792
|
-
case 21 /* MaxRequestId */:
|
|
4793
|
-
return MaxRequestId.parsePayload(payload);
|
|
4794
|
-
case 33 /* ServerSetup */:
|
|
4795
|
-
return ServerSetup.parsePayload(payload);
|
|
4796
|
-
case 3 /* Subscribe */:
|
|
4797
|
-
return Subscribe.parsePayload(payload);
|
|
4798
|
-
case 4 /* SubscribeOk */:
|
|
4799
|
-
return SubscribeOk.parsePayload(payload);
|
|
4800
|
-
case 2 /* RequestUpdate */:
|
|
4801
|
-
return RequestUpdate.parsePayload(payload);
|
|
4802
|
-
case 26 /* RequestsBlocked */:
|
|
4803
|
-
return RequestsBlocked.parsePayload(payload);
|
|
4804
|
-
case 13 /* TrackStatus */:
|
|
4805
|
-
return TrackStatus.parsePayload(payload);
|
|
4806
|
-
case 9 /* PublishNamespaceDone */:
|
|
4807
|
-
return PublishNamespaceDone.parsePayload(payload);
|
|
4808
|
-
case 10 /* Unsubscribe */:
|
|
4809
|
-
return Unsubscribe.parsePayload(payload);
|
|
4810
|
-
case 17 /* SubscribeNamespace */:
|
|
4811
|
-
return SubscribeNamespace.parsePayload(payload);
|
|
4812
|
-
case 20 /* UnsubscribeNamespace */:
|
|
4813
|
-
return UnsubscribeNamespace.parsePayload(payload);
|
|
4814
|
-
default:
|
|
4815
|
-
throw new Error(`Unknown or unhandled ControlMessageType: ${messageType}`);
|
|
4816
|
-
}
|
|
4817
|
-
}
|
|
4818
|
-
ControlMessage2.deserialize = deserialize;
|
|
4819
|
-
function serialize(msg) {
|
|
4820
|
-
return msg.serialize();
|
|
4821
|
-
}
|
|
4822
|
-
ControlMessage2.serialize = serialize;
|
|
4823
|
-
})(ControlMessage || (ControlMessage = {}));
|
|
4824
|
-
|
|
4825
|
-
// src/model/parameter/setup/max_request_id.ts
|
|
4826
|
-
var MaxRequestId2 = class _MaxRequestId {
|
|
4827
|
-
constructor(maxId) {
|
|
4828
|
-
this.maxId = maxId;
|
|
4829
|
-
}
|
|
4830
|
-
maxId;
|
|
4831
|
-
static TYPE = 2 /* MaxRequestId */;
|
|
4832
|
-
toKeyValuePair() {
|
|
4833
|
-
return KeyValuePair.tryNewVarInt(_MaxRequestId.TYPE, this.maxId);
|
|
4834
|
-
}
|
|
4835
|
-
static fromKeyValuePair(pair) {
|
|
4836
|
-
if (Number(pair.typeValue) !== _MaxRequestId.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
4837
|
-
return new _MaxRequestId(pair.value);
|
|
4838
|
-
}
|
|
4839
|
-
};
|
|
4840
|
-
|
|
4841
|
-
// src/model/parameter/setup/path.ts
|
|
4842
|
-
var Path = class _Path {
|
|
4843
|
-
constructor(moqtPath) {
|
|
4844
|
-
this.moqtPath = moqtPath;
|
|
4845
|
-
}
|
|
4846
|
-
moqtPath;
|
|
4847
|
-
static TYPE = 1 /* Path */;
|
|
4848
|
-
toKeyValuePair() {
|
|
4849
|
-
const encoder = new TextEncoder();
|
|
4850
|
-
const bytes = encoder.encode(this.moqtPath);
|
|
4851
|
-
return KeyValuePair.tryNewBytes(_Path.TYPE, bytes);
|
|
4852
|
-
}
|
|
4853
|
-
static fromKeyValuePair(pair) {
|
|
4854
|
-
if (Number(pair.typeValue) !== _Path.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
|
|
4855
|
-
const moqtPath = new TextDecoder().decode(pair.value);
|
|
4856
|
-
return new _Path(moqtPath);
|
|
4857
|
-
}
|
|
4858
|
-
};
|
|
4859
|
-
|
|
4860
|
-
// src/model/parameter/setup/max_auth_token_cache_size.ts
|
|
4861
|
-
var MaxAuthTokenCacheSize = class _MaxAuthTokenCacheSize {
|
|
4862
|
-
constructor(maxSize) {
|
|
4863
|
-
this.maxSize = maxSize;
|
|
4864
|
-
}
|
|
4865
|
-
maxSize;
|
|
4866
|
-
static TYPE = 4 /* MaxAuthTokenCacheSize */;
|
|
4867
|
-
toKeyValuePair() {
|
|
4868
|
-
return KeyValuePair.tryNewVarInt(_MaxAuthTokenCacheSize.TYPE, this.maxSize);
|
|
4869
|
-
}
|
|
4870
|
-
static fromKeyValuePair(pair) {
|
|
4871
|
-
if (Number(pair.typeValue) !== _MaxAuthTokenCacheSize.TYPE || typeof pair.value !== "bigint") return void 0;
|
|
4872
|
-
return new _MaxAuthTokenCacheSize(pair.value);
|
|
4873
|
-
}
|
|
4874
|
-
};
|
|
4875
|
-
|
|
4876
|
-
// src/model/parameter/setup_parameter.ts
|
|
4877
|
-
var SetupParameter;
|
|
4878
|
-
((SetupParameter2) => {
|
|
4879
|
-
function fromKeyValuePair(pair) {
|
|
4880
|
-
return Path.fromKeyValuePair(pair) || MaxRequestId2.fromKeyValuePair(pair) || MaxAuthTokenCacheSize.fromKeyValuePair(pair) || AuthorizationToken.fromKeyValuePair(pair);
|
|
4881
|
-
}
|
|
4882
|
-
SetupParameter2.fromKeyValuePair = fromKeyValuePair;
|
|
4883
|
-
function toKeyValuePair(param) {
|
|
4884
|
-
return param.toKeyValuePair();
|
|
4885
|
-
}
|
|
4886
|
-
SetupParameter2.toKeyValuePair = toKeyValuePair;
|
|
4887
|
-
function isPath(param) {
|
|
4888
|
-
return param instanceof Path;
|
|
4889
|
-
}
|
|
4890
|
-
SetupParameter2.isPath = isPath;
|
|
4891
|
-
function isMaxRequestId(param) {
|
|
4892
|
-
return param instanceof MaxRequestId2;
|
|
4893
|
-
}
|
|
4894
|
-
SetupParameter2.isMaxRequestId = isMaxRequestId;
|
|
4895
|
-
function isMaxAuthTokenCacheSize(param) {
|
|
4896
|
-
return param instanceof MaxAuthTokenCacheSize;
|
|
4897
|
-
}
|
|
4898
|
-
SetupParameter2.isMaxAuthTokenCacheSize = isMaxAuthTokenCacheSize;
|
|
4899
|
-
function isAuthorizationToken(param) {
|
|
4900
|
-
return param instanceof AuthorizationToken;
|
|
4901
|
-
}
|
|
4902
|
-
SetupParameter2.isAuthorizationToken = isAuthorizationToken;
|
|
4903
|
-
})(SetupParameter || (SetupParameter = {}));
|
|
4904
|
-
var SetupParameters = class {
|
|
4905
|
-
kvps = [];
|
|
4906
|
-
addMaxAuthTokenCacheSize(maxSize) {
|
|
4907
|
-
this.kvps.push(new MaxAuthTokenCacheSize(BigInt(maxSize)).toKeyValuePair());
|
|
4908
|
-
return this;
|
|
4909
|
-
}
|
|
4910
|
-
addMaxRequestId(maxId) {
|
|
4911
|
-
this.kvps.push(new MaxRequestId2(BigInt(maxId)).toKeyValuePair());
|
|
4912
|
-
return this;
|
|
4913
|
-
}
|
|
4914
|
-
addPath(moqtPath) {
|
|
4915
|
-
this.kvps.push(new Path(moqtPath).toKeyValuePair());
|
|
4916
|
-
return this;
|
|
4917
|
-
}
|
|
4918
|
-
addAuthorizationToken(auth) {
|
|
4919
|
-
this.kvps.push(auth.toKeyValuePair());
|
|
4920
|
-
return this;
|
|
4921
|
-
}
|
|
4922
|
-
addRaw(pair) {
|
|
4923
|
-
this.kvps.push(pair);
|
|
4924
|
-
return this;
|
|
4925
|
-
}
|
|
4926
|
-
build() {
|
|
4927
|
-
return this.kvps;
|
|
4928
|
-
}
|
|
4929
|
-
static fromKeyValuePairs(kvps) {
|
|
4930
|
-
const result = [];
|
|
4931
|
-
for (const kvp of kvps) {
|
|
4932
|
-
const parsed = Path.fromKeyValuePair(kvp) || MaxRequestId2.fromKeyValuePair(kvp) || MaxAuthTokenCacheSize.fromKeyValuePair(kvp) || AuthorizationToken.fromKeyValuePair(kvp);
|
|
4933
|
-
if (parsed) result.push(parsed);
|
|
4934
|
-
}
|
|
4935
|
-
return result;
|
|
4936
|
-
}
|
|
4937
|
-
};
|
|
4938
|
-
|
|
4939
|
-
export { AudioLevel, AuthorizationToken, BaseByteBuffer13 as BaseByteBuffer, ByteBuffer, CMSFCatalog, CaptureTimestamp, CastingError, ClientSetup, ControlMessage, ControlMessageType, Datagram, DefaultPublisherGroupOrderExtension, DefaultPublisherPriorityExtension, DeliveryTimeout, DeliveryTimeoutExtension, DynamicGroupsExtension, EndOfRangeKind, Expires, ExtensionHeader, ExtensionHeaders, Fetch, FetchCancel, FetchHeader, FetchHeaderType, FetchObject, FetchOk, FetchType, FilterType, Forward, FrozenByteBuffer5 as FrozenByteBuffer, FullTrackName, GoAway, GroupOrder, GroupOrderParam, Header, ImmutableExtensionsExtension, ImmutableExtensionsObjectExtension, InternalError, InvalidTypeError, InvalidUTF8Error, KeyValueFormattingError, KeyValuePair, LOCHeaderExtensionId, LargestObject, LengthExceedsMaxError, Location, MAX_FULL_TRACK_NAME_LENGTH, MAX_NAMESPACE_TUPLE_COUNT, MAX_REASON_PHRASE_LEN, MOQtailError, MaxAuthTokenCacheSize, MaxCacheDurationExtension, MaxRequestId, MaxRequestId2 as MaxRequestIdParameter, MessageParameter, MessageParameterType, MessageParameters, MoqtObject, Namespace, NamespaceDone, NamespaceSubscribeOptions, NewGroupRequest, NotEnoughBytesError, ObjectDatagramType, ObjectExtension, ObjectForwardingPreference, ObjectStatus, Path, PriorGroupIdGapExtension, PriorObjectIdGapExtension, ProtocolViolationError, Publish, PublishDone, PublishDoneStatusCode, PublishNamespace, PublishNamespaceCancel, PublishNamespaceDone, PublishOk, ReasonPhrase, RequestError, RequestErrorCode, RequestIdError, RequestIdMap, RequestOk, RequestUpdate, RequestsBlocked, SUPPORTED_VERSIONS, ServerSetup, SetupParameter, SetupParameterType, SetupParameters, SubgroupHeader, SubgroupHeaderType, SubgroupObject, Subscribe, SubscribeNamespace, SubscribeOk, SubscriberPriority, SubscriptionFilter, Switch, TerminationCode, TerminationError, TimeoutError, TokenAliasType, TrackExtension, TrackExtensionType, TrackNameError, TrackStatus, TrackStatusCode, Tuple, TupleField, UnknownObjectExtension, UnknownTrackExtension, Unsubscribe, UnsubscribeNamespace, VarIntOverflowError, VideoConfig, VideoFrameMarking, applyMessageParameterUpdate, controlMessageTypeFromBigInt, deserializeKvpList, deserializeKvpListUntilEmpty, fetchTypeFromBigInt, filterTypeFromBigInt, groupOrderFromNumber, isBytes, isVarInt, locHeaderExtensionIdFromNumber, messageParameterTypeFromNumber, publishDoneStatusCodeFromBigInt, requestErrorCodeFromBigInt, serializeKvpList, setupParameterTypeFromNumber, tokenAliasTypeFromNumber, trackStatusCodeFromBigInt };
|