@dcl/protocol 1.0.0-3243753014.commit-161bbc8 → 1.0.0-3244256590.commit-612d716

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.
@@ -0,0 +1,728 @@
1
+ /* eslint-disable */
2
+ import _m0 from "protobufjs/minimal";
3
+
4
+ export const protobufPackage = "decentraland.kernel.comms.rfc4";
5
+
6
+ export interface Packet {
7
+ position: Position | undefined;
8
+ profileVersion: AnnounceProfileVersion | undefined;
9
+ profileRequest: ProfileRequest | undefined;
10
+ profileResponse: ProfileResponse | undefined;
11
+ chat: Chat | undefined;
12
+ scene: Scene | undefined;
13
+ voice: Voice | undefined;
14
+ }
15
+
16
+ export interface Position {
17
+ /** command number */
18
+ index: number;
19
+ /** world position */
20
+ positionX: number;
21
+ positionY: number;
22
+ positionZ: number;
23
+ /** quaternion */
24
+ rotationX: number;
25
+ rotationY: number;
26
+ rotationZ: number;
27
+ rotationW: number;
28
+ }
29
+
30
+ export interface AnnounceProfileVersion {
31
+ profileVersion: number;
32
+ }
33
+
34
+ export interface ProfileRequest {
35
+ address: string;
36
+ profileVersion: number;
37
+ }
38
+
39
+ export interface ProfileResponse {
40
+ serializedProfile: string;
41
+ baseUrl: string;
42
+ }
43
+
44
+ export interface Chat {
45
+ message: string;
46
+ timestamp: number;
47
+ }
48
+
49
+ export interface Scene {
50
+ sceneId: string;
51
+ data: Uint8Array;
52
+ }
53
+
54
+ export interface Voice {
55
+ encodedSamples: Uint8Array;
56
+ index: number;
57
+ codec: Voice_VoiceCodec;
58
+ }
59
+
60
+ export enum Voice_VoiceCodec {
61
+ VC_OPUS = 0,
62
+ UNRECOGNIZED = -1,
63
+ }
64
+
65
+ export function voice_VoiceCodecFromJSON(object: any): Voice_VoiceCodec {
66
+ switch (object) {
67
+ case 0:
68
+ case "VC_OPUS":
69
+ return Voice_VoiceCodec.VC_OPUS;
70
+ case -1:
71
+ case "UNRECOGNIZED":
72
+ default:
73
+ return Voice_VoiceCodec.UNRECOGNIZED;
74
+ }
75
+ }
76
+
77
+ export function voice_VoiceCodecToJSON(object: Voice_VoiceCodec): string {
78
+ switch (object) {
79
+ case Voice_VoiceCodec.VC_OPUS:
80
+ return "VC_OPUS";
81
+ case Voice_VoiceCodec.UNRECOGNIZED:
82
+ default:
83
+ return "UNRECOGNIZED";
84
+ }
85
+ }
86
+
87
+ function createBasePacket(): Packet {
88
+ return {
89
+ position: undefined,
90
+ profileVersion: undefined,
91
+ profileRequest: undefined,
92
+ profileResponse: undefined,
93
+ chat: undefined,
94
+ scene: undefined,
95
+ voice: undefined,
96
+ };
97
+ }
98
+
99
+ export const Packet = {
100
+ encode(message: Packet, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
101
+ if (message.position !== undefined) {
102
+ Position.encode(message.position, writer.uint32(10).fork()).ldelim();
103
+ }
104
+ if (message.profileVersion !== undefined) {
105
+ AnnounceProfileVersion.encode(message.profileVersion, writer.uint32(18).fork()).ldelim();
106
+ }
107
+ if (message.profileRequest !== undefined) {
108
+ ProfileRequest.encode(message.profileRequest, writer.uint32(26).fork()).ldelim();
109
+ }
110
+ if (message.profileResponse !== undefined) {
111
+ ProfileResponse.encode(message.profileResponse, writer.uint32(34).fork()).ldelim();
112
+ }
113
+ if (message.chat !== undefined) {
114
+ Chat.encode(message.chat, writer.uint32(42).fork()).ldelim();
115
+ }
116
+ if (message.scene !== undefined) {
117
+ Scene.encode(message.scene, writer.uint32(50).fork()).ldelim();
118
+ }
119
+ if (message.voice !== undefined) {
120
+ Voice.encode(message.voice, writer.uint32(58).fork()).ldelim();
121
+ }
122
+ return writer;
123
+ },
124
+
125
+ decode(input: _m0.Reader | Uint8Array, length?: number): Packet {
126
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
127
+ let end = length === undefined ? reader.len : reader.pos + length;
128
+ const message = createBasePacket();
129
+ while (reader.pos < end) {
130
+ const tag = reader.uint32();
131
+ switch (tag >>> 3) {
132
+ case 1:
133
+ message.position = Position.decode(reader, reader.uint32());
134
+ break;
135
+ case 2:
136
+ message.profileVersion = AnnounceProfileVersion.decode(reader, reader.uint32());
137
+ break;
138
+ case 3:
139
+ message.profileRequest = ProfileRequest.decode(reader, reader.uint32());
140
+ break;
141
+ case 4:
142
+ message.profileResponse = ProfileResponse.decode(reader, reader.uint32());
143
+ break;
144
+ case 5:
145
+ message.chat = Chat.decode(reader, reader.uint32());
146
+ break;
147
+ case 6:
148
+ message.scene = Scene.decode(reader, reader.uint32());
149
+ break;
150
+ case 7:
151
+ message.voice = Voice.decode(reader, reader.uint32());
152
+ break;
153
+ default:
154
+ reader.skipType(tag & 7);
155
+ break;
156
+ }
157
+ }
158
+ return message;
159
+ },
160
+
161
+ fromJSON(object: any): Packet {
162
+ return {
163
+ position: isSet(object.position) ? Position.fromJSON(object.position) : undefined,
164
+ profileVersion: isSet(object.profileVersion) ? AnnounceProfileVersion.fromJSON(object.profileVersion) : undefined,
165
+ profileRequest: isSet(object.profileRequest) ? ProfileRequest.fromJSON(object.profileRequest) : undefined,
166
+ profileResponse: isSet(object.profileResponse) ? ProfileResponse.fromJSON(object.profileResponse) : undefined,
167
+ chat: isSet(object.chat) ? Chat.fromJSON(object.chat) : undefined,
168
+ scene: isSet(object.scene) ? Scene.fromJSON(object.scene) : undefined,
169
+ voice: isSet(object.voice) ? Voice.fromJSON(object.voice) : undefined,
170
+ };
171
+ },
172
+
173
+ toJSON(message: Packet): unknown {
174
+ const obj: any = {};
175
+ message.position !== undefined && (obj.position = message.position ? Position.toJSON(message.position) : undefined);
176
+ message.profileVersion !== undefined &&
177
+ (obj.profileVersion = message.profileVersion ? AnnounceProfileVersion.toJSON(message.profileVersion) : undefined);
178
+ message.profileRequest !== undefined &&
179
+ (obj.profileRequest = message.profileRequest ? ProfileRequest.toJSON(message.profileRequest) : undefined);
180
+ message.profileResponse !== undefined &&
181
+ (obj.profileResponse = message.profileResponse ? ProfileResponse.toJSON(message.profileResponse) : undefined);
182
+ message.chat !== undefined && (obj.chat = message.chat ? Chat.toJSON(message.chat) : undefined);
183
+ message.scene !== undefined && (obj.scene = message.scene ? Scene.toJSON(message.scene) : undefined);
184
+ message.voice !== undefined && (obj.voice = message.voice ? Voice.toJSON(message.voice) : undefined);
185
+ return obj;
186
+ },
187
+
188
+ fromPartial<I extends Exact<DeepPartial<Packet>, I>>(object: I): Packet {
189
+ const message = createBasePacket();
190
+ message.position = (object.position !== undefined && object.position !== null)
191
+ ? Position.fromPartial(object.position)
192
+ : undefined;
193
+ message.profileVersion = (object.profileVersion !== undefined && object.profileVersion !== null)
194
+ ? AnnounceProfileVersion.fromPartial(object.profileVersion)
195
+ : undefined;
196
+ message.profileRequest = (object.profileRequest !== undefined && object.profileRequest !== null)
197
+ ? ProfileRequest.fromPartial(object.profileRequest)
198
+ : undefined;
199
+ message.profileResponse = (object.profileResponse !== undefined && object.profileResponse !== null)
200
+ ? ProfileResponse.fromPartial(object.profileResponse)
201
+ : undefined;
202
+ message.chat = (object.chat !== undefined && object.chat !== null) ? Chat.fromPartial(object.chat) : undefined;
203
+ message.scene = (object.scene !== undefined && object.scene !== null) ? Scene.fromPartial(object.scene) : undefined;
204
+ message.voice = (object.voice !== undefined && object.voice !== null) ? Voice.fromPartial(object.voice) : undefined;
205
+ return message;
206
+ },
207
+ };
208
+
209
+ function createBasePosition(): Position {
210
+ return { index: 0, positionX: 0, positionY: 0, positionZ: 0, rotationX: 0, rotationY: 0, rotationZ: 0, rotationW: 0 };
211
+ }
212
+
213
+ export const Position = {
214
+ encode(message: Position, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
215
+ if (message.index !== 0) {
216
+ writer.uint32(8).uint32(message.index);
217
+ }
218
+ if (message.positionX !== 0) {
219
+ writer.uint32(29).float(message.positionX);
220
+ }
221
+ if (message.positionY !== 0) {
222
+ writer.uint32(37).float(message.positionY);
223
+ }
224
+ if (message.positionZ !== 0) {
225
+ writer.uint32(45).float(message.positionZ);
226
+ }
227
+ if (message.rotationX !== 0) {
228
+ writer.uint32(53).float(message.rotationX);
229
+ }
230
+ if (message.rotationY !== 0) {
231
+ writer.uint32(61).float(message.rotationY);
232
+ }
233
+ if (message.rotationZ !== 0) {
234
+ writer.uint32(69).float(message.rotationZ);
235
+ }
236
+ if (message.rotationW !== 0) {
237
+ writer.uint32(77).float(message.rotationW);
238
+ }
239
+ return writer;
240
+ },
241
+
242
+ decode(input: _m0.Reader | Uint8Array, length?: number): Position {
243
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
244
+ let end = length === undefined ? reader.len : reader.pos + length;
245
+ const message = createBasePosition();
246
+ while (reader.pos < end) {
247
+ const tag = reader.uint32();
248
+ switch (tag >>> 3) {
249
+ case 1:
250
+ message.index = reader.uint32();
251
+ break;
252
+ case 3:
253
+ message.positionX = reader.float();
254
+ break;
255
+ case 4:
256
+ message.positionY = reader.float();
257
+ break;
258
+ case 5:
259
+ message.positionZ = reader.float();
260
+ break;
261
+ case 6:
262
+ message.rotationX = reader.float();
263
+ break;
264
+ case 7:
265
+ message.rotationY = reader.float();
266
+ break;
267
+ case 8:
268
+ message.rotationZ = reader.float();
269
+ break;
270
+ case 9:
271
+ message.rotationW = reader.float();
272
+ break;
273
+ default:
274
+ reader.skipType(tag & 7);
275
+ break;
276
+ }
277
+ }
278
+ return message;
279
+ },
280
+
281
+ fromJSON(object: any): Position {
282
+ return {
283
+ index: isSet(object.index) ? Number(object.index) : 0,
284
+ positionX: isSet(object.positionX) ? Number(object.positionX) : 0,
285
+ positionY: isSet(object.positionY) ? Number(object.positionY) : 0,
286
+ positionZ: isSet(object.positionZ) ? Number(object.positionZ) : 0,
287
+ rotationX: isSet(object.rotationX) ? Number(object.rotationX) : 0,
288
+ rotationY: isSet(object.rotationY) ? Number(object.rotationY) : 0,
289
+ rotationZ: isSet(object.rotationZ) ? Number(object.rotationZ) : 0,
290
+ rotationW: isSet(object.rotationW) ? Number(object.rotationW) : 0,
291
+ };
292
+ },
293
+
294
+ toJSON(message: Position): unknown {
295
+ const obj: any = {};
296
+ message.index !== undefined && (obj.index = Math.round(message.index));
297
+ message.positionX !== undefined && (obj.positionX = message.positionX);
298
+ message.positionY !== undefined && (obj.positionY = message.positionY);
299
+ message.positionZ !== undefined && (obj.positionZ = message.positionZ);
300
+ message.rotationX !== undefined && (obj.rotationX = message.rotationX);
301
+ message.rotationY !== undefined && (obj.rotationY = message.rotationY);
302
+ message.rotationZ !== undefined && (obj.rotationZ = message.rotationZ);
303
+ message.rotationW !== undefined && (obj.rotationW = message.rotationW);
304
+ return obj;
305
+ },
306
+
307
+ fromPartial<I extends Exact<DeepPartial<Position>, I>>(object: I): Position {
308
+ const message = createBasePosition();
309
+ message.index = object.index ?? 0;
310
+ message.positionX = object.positionX ?? 0;
311
+ message.positionY = object.positionY ?? 0;
312
+ message.positionZ = object.positionZ ?? 0;
313
+ message.rotationX = object.rotationX ?? 0;
314
+ message.rotationY = object.rotationY ?? 0;
315
+ message.rotationZ = object.rotationZ ?? 0;
316
+ message.rotationW = object.rotationW ?? 0;
317
+ return message;
318
+ },
319
+ };
320
+
321
+ function createBaseAnnounceProfileVersion(): AnnounceProfileVersion {
322
+ return { profileVersion: 0 };
323
+ }
324
+
325
+ export const AnnounceProfileVersion = {
326
+ encode(message: AnnounceProfileVersion, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
327
+ if (message.profileVersion !== 0) {
328
+ writer.uint32(8).uint32(message.profileVersion);
329
+ }
330
+ return writer;
331
+ },
332
+
333
+ decode(input: _m0.Reader | Uint8Array, length?: number): AnnounceProfileVersion {
334
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
335
+ let end = length === undefined ? reader.len : reader.pos + length;
336
+ const message = createBaseAnnounceProfileVersion();
337
+ while (reader.pos < end) {
338
+ const tag = reader.uint32();
339
+ switch (tag >>> 3) {
340
+ case 1:
341
+ message.profileVersion = reader.uint32();
342
+ break;
343
+ default:
344
+ reader.skipType(tag & 7);
345
+ break;
346
+ }
347
+ }
348
+ return message;
349
+ },
350
+
351
+ fromJSON(object: any): AnnounceProfileVersion {
352
+ return { profileVersion: isSet(object.profileVersion) ? Number(object.profileVersion) : 0 };
353
+ },
354
+
355
+ toJSON(message: AnnounceProfileVersion): unknown {
356
+ const obj: any = {};
357
+ message.profileVersion !== undefined && (obj.profileVersion = Math.round(message.profileVersion));
358
+ return obj;
359
+ },
360
+
361
+ fromPartial<I extends Exact<DeepPartial<AnnounceProfileVersion>, I>>(object: I): AnnounceProfileVersion {
362
+ const message = createBaseAnnounceProfileVersion();
363
+ message.profileVersion = object.profileVersion ?? 0;
364
+ return message;
365
+ },
366
+ };
367
+
368
+ function createBaseProfileRequest(): ProfileRequest {
369
+ return { address: "", profileVersion: 0 };
370
+ }
371
+
372
+ export const ProfileRequest = {
373
+ encode(message: ProfileRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
374
+ if (message.address !== "") {
375
+ writer.uint32(34).string(message.address);
376
+ }
377
+ if (message.profileVersion !== 0) {
378
+ writer.uint32(24).uint32(message.profileVersion);
379
+ }
380
+ return writer;
381
+ },
382
+
383
+ decode(input: _m0.Reader | Uint8Array, length?: number): ProfileRequest {
384
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
385
+ let end = length === undefined ? reader.len : reader.pos + length;
386
+ const message = createBaseProfileRequest();
387
+ while (reader.pos < end) {
388
+ const tag = reader.uint32();
389
+ switch (tag >>> 3) {
390
+ case 4:
391
+ message.address = reader.string();
392
+ break;
393
+ case 3:
394
+ message.profileVersion = reader.uint32();
395
+ break;
396
+ default:
397
+ reader.skipType(tag & 7);
398
+ break;
399
+ }
400
+ }
401
+ return message;
402
+ },
403
+
404
+ fromJSON(object: any): ProfileRequest {
405
+ return {
406
+ address: isSet(object.address) ? String(object.address) : "",
407
+ profileVersion: isSet(object.profileVersion) ? Number(object.profileVersion) : 0,
408
+ };
409
+ },
410
+
411
+ toJSON(message: ProfileRequest): unknown {
412
+ const obj: any = {};
413
+ message.address !== undefined && (obj.address = message.address);
414
+ message.profileVersion !== undefined && (obj.profileVersion = Math.round(message.profileVersion));
415
+ return obj;
416
+ },
417
+
418
+ fromPartial<I extends Exact<DeepPartial<ProfileRequest>, I>>(object: I): ProfileRequest {
419
+ const message = createBaseProfileRequest();
420
+ message.address = object.address ?? "";
421
+ message.profileVersion = object.profileVersion ?? 0;
422
+ return message;
423
+ },
424
+ };
425
+
426
+ function createBaseProfileResponse(): ProfileResponse {
427
+ return { serializedProfile: "", baseUrl: "" };
428
+ }
429
+
430
+ export const ProfileResponse = {
431
+ encode(message: ProfileResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
432
+ if (message.serializedProfile !== "") {
433
+ writer.uint32(10).string(message.serializedProfile);
434
+ }
435
+ if (message.baseUrl !== "") {
436
+ writer.uint32(18).string(message.baseUrl);
437
+ }
438
+ return writer;
439
+ },
440
+
441
+ decode(input: _m0.Reader | Uint8Array, length?: number): ProfileResponse {
442
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
443
+ let end = length === undefined ? reader.len : reader.pos + length;
444
+ const message = createBaseProfileResponse();
445
+ while (reader.pos < end) {
446
+ const tag = reader.uint32();
447
+ switch (tag >>> 3) {
448
+ case 1:
449
+ message.serializedProfile = reader.string();
450
+ break;
451
+ case 2:
452
+ message.baseUrl = reader.string();
453
+ break;
454
+ default:
455
+ reader.skipType(tag & 7);
456
+ break;
457
+ }
458
+ }
459
+ return message;
460
+ },
461
+
462
+ fromJSON(object: any): ProfileResponse {
463
+ return {
464
+ serializedProfile: isSet(object.serializedProfile) ? String(object.serializedProfile) : "",
465
+ baseUrl: isSet(object.baseUrl) ? String(object.baseUrl) : "",
466
+ };
467
+ },
468
+
469
+ toJSON(message: ProfileResponse): unknown {
470
+ const obj: any = {};
471
+ message.serializedProfile !== undefined && (obj.serializedProfile = message.serializedProfile);
472
+ message.baseUrl !== undefined && (obj.baseUrl = message.baseUrl);
473
+ return obj;
474
+ },
475
+
476
+ fromPartial<I extends Exact<DeepPartial<ProfileResponse>, I>>(object: I): ProfileResponse {
477
+ const message = createBaseProfileResponse();
478
+ message.serializedProfile = object.serializedProfile ?? "";
479
+ message.baseUrl = object.baseUrl ?? "";
480
+ return message;
481
+ },
482
+ };
483
+
484
+ function createBaseChat(): Chat {
485
+ return { message: "", timestamp: 0 };
486
+ }
487
+
488
+ export const Chat = {
489
+ encode(message: Chat, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
490
+ if (message.message !== "") {
491
+ writer.uint32(10).string(message.message);
492
+ }
493
+ if (message.timestamp !== 0) {
494
+ writer.uint32(17).double(message.timestamp);
495
+ }
496
+ return writer;
497
+ },
498
+
499
+ decode(input: _m0.Reader | Uint8Array, length?: number): Chat {
500
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
501
+ let end = length === undefined ? reader.len : reader.pos + length;
502
+ const message = createBaseChat();
503
+ while (reader.pos < end) {
504
+ const tag = reader.uint32();
505
+ switch (tag >>> 3) {
506
+ case 1:
507
+ message.message = reader.string();
508
+ break;
509
+ case 2:
510
+ message.timestamp = reader.double();
511
+ break;
512
+ default:
513
+ reader.skipType(tag & 7);
514
+ break;
515
+ }
516
+ }
517
+ return message;
518
+ },
519
+
520
+ fromJSON(object: any): Chat {
521
+ return {
522
+ message: isSet(object.message) ? String(object.message) : "",
523
+ timestamp: isSet(object.timestamp) ? Number(object.timestamp) : 0,
524
+ };
525
+ },
526
+
527
+ toJSON(message: Chat): unknown {
528
+ const obj: any = {};
529
+ message.message !== undefined && (obj.message = message.message);
530
+ message.timestamp !== undefined && (obj.timestamp = message.timestamp);
531
+ return obj;
532
+ },
533
+
534
+ fromPartial<I extends Exact<DeepPartial<Chat>, I>>(object: I): Chat {
535
+ const message = createBaseChat();
536
+ message.message = object.message ?? "";
537
+ message.timestamp = object.timestamp ?? 0;
538
+ return message;
539
+ },
540
+ };
541
+
542
+ function createBaseScene(): Scene {
543
+ return { sceneId: "", data: new Uint8Array() };
544
+ }
545
+
546
+ export const Scene = {
547
+ encode(message: Scene, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
548
+ if (message.sceneId !== "") {
549
+ writer.uint32(10).string(message.sceneId);
550
+ }
551
+ if (message.data.length !== 0) {
552
+ writer.uint32(18).bytes(message.data);
553
+ }
554
+ return writer;
555
+ },
556
+
557
+ decode(input: _m0.Reader | Uint8Array, length?: number): Scene {
558
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
559
+ let end = length === undefined ? reader.len : reader.pos + length;
560
+ const message = createBaseScene();
561
+ while (reader.pos < end) {
562
+ const tag = reader.uint32();
563
+ switch (tag >>> 3) {
564
+ case 1:
565
+ message.sceneId = reader.string();
566
+ break;
567
+ case 2:
568
+ message.data = reader.bytes();
569
+ break;
570
+ default:
571
+ reader.skipType(tag & 7);
572
+ break;
573
+ }
574
+ }
575
+ return message;
576
+ },
577
+
578
+ fromJSON(object: any): Scene {
579
+ return {
580
+ sceneId: isSet(object.sceneId) ? String(object.sceneId) : "",
581
+ data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(),
582
+ };
583
+ },
584
+
585
+ toJSON(message: Scene): unknown {
586
+ const obj: any = {};
587
+ message.sceneId !== undefined && (obj.sceneId = message.sceneId);
588
+ message.data !== undefined &&
589
+ (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
590
+ return obj;
591
+ },
592
+
593
+ fromPartial<I extends Exact<DeepPartial<Scene>, I>>(object: I): Scene {
594
+ const message = createBaseScene();
595
+ message.sceneId = object.sceneId ?? "";
596
+ message.data = object.data ?? new Uint8Array();
597
+ return message;
598
+ },
599
+ };
600
+
601
+ function createBaseVoice(): Voice {
602
+ return { encodedSamples: new Uint8Array(), index: 0, codec: 0 };
603
+ }
604
+
605
+ export const Voice = {
606
+ encode(message: Voice, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
607
+ if (message.encodedSamples.length !== 0) {
608
+ writer.uint32(10).bytes(message.encodedSamples);
609
+ }
610
+ if (message.index !== 0) {
611
+ writer.uint32(16).uint32(message.index);
612
+ }
613
+ if (message.codec !== 0) {
614
+ writer.uint32(24).int32(message.codec);
615
+ }
616
+ return writer;
617
+ },
618
+
619
+ decode(input: _m0.Reader | Uint8Array, length?: number): Voice {
620
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
621
+ let end = length === undefined ? reader.len : reader.pos + length;
622
+ const message = createBaseVoice();
623
+ while (reader.pos < end) {
624
+ const tag = reader.uint32();
625
+ switch (tag >>> 3) {
626
+ case 1:
627
+ message.encodedSamples = reader.bytes();
628
+ break;
629
+ case 2:
630
+ message.index = reader.uint32();
631
+ break;
632
+ case 3:
633
+ message.codec = reader.int32() as any;
634
+ break;
635
+ default:
636
+ reader.skipType(tag & 7);
637
+ break;
638
+ }
639
+ }
640
+ return message;
641
+ },
642
+
643
+ fromJSON(object: any): Voice {
644
+ return {
645
+ encodedSamples: isSet(object.encodedSamples) ? bytesFromBase64(object.encodedSamples) : new Uint8Array(),
646
+ index: isSet(object.index) ? Number(object.index) : 0,
647
+ codec: isSet(object.codec) ? voice_VoiceCodecFromJSON(object.codec) : 0,
648
+ };
649
+ },
650
+
651
+ toJSON(message: Voice): unknown {
652
+ const obj: any = {};
653
+ message.encodedSamples !== undefined &&
654
+ (obj.encodedSamples = base64FromBytes(
655
+ message.encodedSamples !== undefined ? message.encodedSamples : new Uint8Array(),
656
+ ));
657
+ message.index !== undefined && (obj.index = Math.round(message.index));
658
+ message.codec !== undefined && (obj.codec = voice_VoiceCodecToJSON(message.codec));
659
+ return obj;
660
+ },
661
+
662
+ fromPartial<I extends Exact<DeepPartial<Voice>, I>>(object: I): Voice {
663
+ const message = createBaseVoice();
664
+ message.encodedSamples = object.encodedSamples ?? new Uint8Array();
665
+ message.index = object.index ?? 0;
666
+ message.codec = object.codec ?? 0;
667
+ return message;
668
+ },
669
+ };
670
+
671
+ declare var self: any | undefined;
672
+ declare var window: any | undefined;
673
+ declare var global: any | undefined;
674
+ var globalThis: any = (() => {
675
+ if (typeof globalThis !== "undefined") {
676
+ return globalThis;
677
+ }
678
+ if (typeof self !== "undefined") {
679
+ return self;
680
+ }
681
+ if (typeof window !== "undefined") {
682
+ return window;
683
+ }
684
+ if (typeof global !== "undefined") {
685
+ return global;
686
+ }
687
+ throw "Unable to locate global object";
688
+ })();
689
+
690
+ function bytesFromBase64(b64: string): Uint8Array {
691
+ if (globalThis.Buffer) {
692
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
693
+ } else {
694
+ const bin = globalThis.atob(b64);
695
+ const arr = new Uint8Array(bin.length);
696
+ for (let i = 0; i < bin.length; ++i) {
697
+ arr[i] = bin.charCodeAt(i);
698
+ }
699
+ return arr;
700
+ }
701
+ }
702
+
703
+ function base64FromBytes(arr: Uint8Array): string {
704
+ if (globalThis.Buffer) {
705
+ return globalThis.Buffer.from(arr).toString("base64");
706
+ } else {
707
+ const bin: string[] = [];
708
+ arr.forEach((byte) => {
709
+ bin.push(String.fromCharCode(byte));
710
+ });
711
+ return globalThis.btoa(bin.join(""));
712
+ }
713
+ }
714
+
715
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
716
+
717
+ export type DeepPartial<T> = T extends Builtin ? T
718
+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
719
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
720
+ : Partial<T>;
721
+
722
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
723
+ export type Exact<P, I extends P> = P extends Builtin ? P
724
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
725
+
726
+ function isSet(value: any): boolean {
727
+ return value !== null && value !== undefined;
728
+ }