@snap/push2web 0.11.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.
@@ -0,0 +1,767 @@
1
+ /* eslint-disable */
2
+ import Long from 'long';
3
+ import { grpc } from '@improbable-eng/grpc-web';
4
+ import _m0 from 'protobufjs/minimal';
5
+ import { Observable } from 'rxjs';
6
+ import { BrowserHeaders } from 'browser-headers';
7
+ import { share } from 'rxjs/operators';
8
+ import { Lens } from './lens';
9
+ export const protobufPackage = 'com.snap.camerakit.v3';
10
+ /** returned code */
11
+ export var PushLensSubscriptionResponse_ExcludedLens_Code;
12
+ (function (PushLensSubscriptionResponse_ExcludedLens_Code) {
13
+ /** UNSET - for linter */
14
+ PushLensSubscriptionResponse_ExcludedLens_Code["UNSET"] = "UNSET";
15
+ /** UNKNOWN - reason unknown */
16
+ PushLensSubscriptionResponse_ExcludedLens_Code["UNKNOWN"] = "UNKNOWN";
17
+ /** NOT_FOUND - lens not found */
18
+ PushLensSubscriptionResponse_ExcludedLens_Code["NOT_FOUND"] = "NOT_FOUND";
19
+ /** INCOMPATIBLE_LENS_CORE_VERSION - client has core version less than core version of the lens */
20
+ PushLensSubscriptionResponse_ExcludedLens_Code["INCOMPATIBLE_LENS_CORE_VERSION"] = "INCOMPATIBLE_LENS_CORE_VERSION";
21
+ /** ARCHIVED_OR_INVISIBLE - Lens archived or excluded due to visibility */
22
+ PushLensSubscriptionResponse_ExcludedLens_Code["ARCHIVED_OR_INVISIBLE"] = "ARCHIVED_OR_INVISIBLE";
23
+ /** CONTAINS_MUSIC - lens contains music and cannot be provided by CameraKit */
24
+ PushLensSubscriptionResponse_ExcludedLens_Code["CONTAINS_MUSIC"] = "CONTAINS_MUSIC";
25
+ PushLensSubscriptionResponse_ExcludedLens_Code["UNRECOGNIZED"] = "UNRECOGNIZED";
26
+ })(PushLensSubscriptionResponse_ExcludedLens_Code || (PushLensSubscriptionResponse_ExcludedLens_Code = {}));
27
+ export function pushLensSubscriptionResponse_ExcludedLens_CodeFromJSON(object) {
28
+ switch (object) {
29
+ case 0:
30
+ case "UNSET":
31
+ return PushLensSubscriptionResponse_ExcludedLens_Code.UNSET;
32
+ case 1:
33
+ case "UNKNOWN":
34
+ return PushLensSubscriptionResponse_ExcludedLens_Code.UNKNOWN;
35
+ case 2:
36
+ case "NOT_FOUND":
37
+ return PushLensSubscriptionResponse_ExcludedLens_Code.NOT_FOUND;
38
+ case 3:
39
+ case "INCOMPATIBLE_LENS_CORE_VERSION":
40
+ return PushLensSubscriptionResponse_ExcludedLens_Code.INCOMPATIBLE_LENS_CORE_VERSION;
41
+ case 4:
42
+ case "ARCHIVED_OR_INVISIBLE":
43
+ return PushLensSubscriptionResponse_ExcludedLens_Code.ARCHIVED_OR_INVISIBLE;
44
+ case 5:
45
+ case "CONTAINS_MUSIC":
46
+ return PushLensSubscriptionResponse_ExcludedLens_Code.CONTAINS_MUSIC;
47
+ case -1:
48
+ case "UNRECOGNIZED":
49
+ default:
50
+ return PushLensSubscriptionResponse_ExcludedLens_Code.UNRECOGNIZED;
51
+ }
52
+ }
53
+ export function pushLensSubscriptionResponse_ExcludedLens_CodeToJSON(object) {
54
+ switch (object) {
55
+ case PushLensSubscriptionResponse_ExcludedLens_Code.UNSET: return "UNSET";
56
+ case PushLensSubscriptionResponse_ExcludedLens_Code.UNKNOWN: return "UNKNOWN";
57
+ case PushLensSubscriptionResponse_ExcludedLens_Code.NOT_FOUND: return "NOT_FOUND";
58
+ case PushLensSubscriptionResponse_ExcludedLens_Code.INCOMPATIBLE_LENS_CORE_VERSION: return "INCOMPATIBLE_LENS_CORE_VERSION";
59
+ case PushLensSubscriptionResponse_ExcludedLens_Code.ARCHIVED_OR_INVISIBLE: return "ARCHIVED_OR_INVISIBLE";
60
+ case PushLensSubscriptionResponse_ExcludedLens_Code.CONTAINS_MUSIC: return "CONTAINS_MUSIC";
61
+ default: return "UNKNOWN";
62
+ }
63
+ }
64
+ export function pushLensSubscriptionResponse_ExcludedLens_CodeToNumber(object) {
65
+ switch (object) {
66
+ case PushLensSubscriptionResponse_ExcludedLens_Code.UNSET: return 0;
67
+ case PushLensSubscriptionResponse_ExcludedLens_Code.UNKNOWN: return 1;
68
+ case PushLensSubscriptionResponse_ExcludedLens_Code.NOT_FOUND: return 2;
69
+ case PushLensSubscriptionResponse_ExcludedLens_Code.INCOMPATIBLE_LENS_CORE_VERSION: return 3;
70
+ case PushLensSubscriptionResponse_ExcludedLens_Code.ARCHIVED_OR_INVISIBLE: return 4;
71
+ case PushLensSubscriptionResponse_ExcludedLens_Code.CONTAINS_MUSIC: return 5;
72
+ default: return 0;
73
+ }
74
+ }
75
+ /** returned code */
76
+ export var ListenLensPushResponse_ExcludedLens_Code;
77
+ (function (ListenLensPushResponse_ExcludedLens_Code) {
78
+ /** UNSET - for linter */
79
+ ListenLensPushResponse_ExcludedLens_Code["UNSET"] = "UNSET";
80
+ /** UNKNOWN - reason unknown */
81
+ ListenLensPushResponse_ExcludedLens_Code["UNKNOWN"] = "UNKNOWN";
82
+ /** NOT_FOUND - lens not found */
83
+ ListenLensPushResponse_ExcludedLens_Code["NOT_FOUND"] = "NOT_FOUND";
84
+ /** INCOMPATIBLE_LENS_CORE_VERSION - client has core version less than core version of the lens */
85
+ ListenLensPushResponse_ExcludedLens_Code["INCOMPATIBLE_LENS_CORE_VERSION"] = "INCOMPATIBLE_LENS_CORE_VERSION";
86
+ /** ARCHIVED_OR_INVISIBLE - Lens archived or excluded due to visibility */
87
+ ListenLensPushResponse_ExcludedLens_Code["ARCHIVED_OR_INVISIBLE"] = "ARCHIVED_OR_INVISIBLE";
88
+ /** CONTAINS_MUSIC - lens contains music and cannot be provided by CameraKit */
89
+ ListenLensPushResponse_ExcludedLens_Code["CONTAINS_MUSIC"] = "CONTAINS_MUSIC";
90
+ ListenLensPushResponse_ExcludedLens_Code["UNRECOGNIZED"] = "UNRECOGNIZED";
91
+ })(ListenLensPushResponse_ExcludedLens_Code || (ListenLensPushResponse_ExcludedLens_Code = {}));
92
+ export function listenLensPushResponse_ExcludedLens_CodeFromJSON(object) {
93
+ switch (object) {
94
+ case 0:
95
+ case "UNSET":
96
+ return ListenLensPushResponse_ExcludedLens_Code.UNSET;
97
+ case 1:
98
+ case "UNKNOWN":
99
+ return ListenLensPushResponse_ExcludedLens_Code.UNKNOWN;
100
+ case 2:
101
+ case "NOT_FOUND":
102
+ return ListenLensPushResponse_ExcludedLens_Code.NOT_FOUND;
103
+ case 3:
104
+ case "INCOMPATIBLE_LENS_CORE_VERSION":
105
+ return ListenLensPushResponse_ExcludedLens_Code.INCOMPATIBLE_LENS_CORE_VERSION;
106
+ case 4:
107
+ case "ARCHIVED_OR_INVISIBLE":
108
+ return ListenLensPushResponse_ExcludedLens_Code.ARCHIVED_OR_INVISIBLE;
109
+ case 5:
110
+ case "CONTAINS_MUSIC":
111
+ return ListenLensPushResponse_ExcludedLens_Code.CONTAINS_MUSIC;
112
+ case -1:
113
+ case "UNRECOGNIZED":
114
+ default:
115
+ return ListenLensPushResponse_ExcludedLens_Code.UNRECOGNIZED;
116
+ }
117
+ }
118
+ export function listenLensPushResponse_ExcludedLens_CodeToJSON(object) {
119
+ switch (object) {
120
+ case ListenLensPushResponse_ExcludedLens_Code.UNSET: return "UNSET";
121
+ case ListenLensPushResponse_ExcludedLens_Code.UNKNOWN: return "UNKNOWN";
122
+ case ListenLensPushResponse_ExcludedLens_Code.NOT_FOUND: return "NOT_FOUND";
123
+ case ListenLensPushResponse_ExcludedLens_Code.INCOMPATIBLE_LENS_CORE_VERSION: return "INCOMPATIBLE_LENS_CORE_VERSION";
124
+ case ListenLensPushResponse_ExcludedLens_Code.ARCHIVED_OR_INVISIBLE: return "ARCHIVED_OR_INVISIBLE";
125
+ case ListenLensPushResponse_ExcludedLens_Code.CONTAINS_MUSIC: return "CONTAINS_MUSIC";
126
+ default: return "UNKNOWN";
127
+ }
128
+ }
129
+ export function listenLensPushResponse_ExcludedLens_CodeToNumber(object) {
130
+ switch (object) {
131
+ case ListenLensPushResponse_ExcludedLens_Code.UNSET: return 0;
132
+ case ListenLensPushResponse_ExcludedLens_Code.UNKNOWN: return 1;
133
+ case ListenLensPushResponse_ExcludedLens_Code.NOT_FOUND: return 2;
134
+ case ListenLensPushResponse_ExcludedLens_Code.INCOMPATIBLE_LENS_CORE_VERSION: return 3;
135
+ case ListenLensPushResponse_ExcludedLens_Code.ARCHIVED_OR_INVISIBLE: return 4;
136
+ case ListenLensPushResponse_ExcludedLens_Code.CONTAINS_MUSIC: return 5;
137
+ default: return 0;
138
+ }
139
+ }
140
+ function createBasePushLensSubscriptionRequest() {
141
+ return { accountId: "", extensionRequestContext: new Uint8Array(), heartbeat: 0 };
142
+ }
143
+ export const PushLensSubscriptionRequest = {
144
+ encode(message, writer = _m0.Writer.create()) {
145
+ if (message.accountId !== "") {
146
+ writer.uint32(10).string(message.accountId);
147
+ }
148
+ if (message.extensionRequestContext.length !== 0) {
149
+ writer.uint32(18).bytes(message.extensionRequestContext);
150
+ }
151
+ if (message.heartbeat !== 0) {
152
+ writer.uint32(24).int32(message.heartbeat);
153
+ }
154
+ return writer;
155
+ },
156
+ decode(input, length) {
157
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
158
+ let end = length === undefined ? reader.len : reader.pos + length;
159
+ const message = createBasePushLensSubscriptionRequest();
160
+ while (reader.pos < end) {
161
+ const tag = reader.uint32();
162
+ switch (tag >>> 3) {
163
+ case 1:
164
+ message.accountId = reader.string();
165
+ break;
166
+ case 2:
167
+ message.extensionRequestContext = reader.bytes();
168
+ break;
169
+ case 3:
170
+ message.heartbeat = reader.int32();
171
+ break;
172
+ default:
173
+ reader.skipType(tag & 7);
174
+ break;
175
+ }
176
+ }
177
+ return message;
178
+ },
179
+ fromJSON(object) {
180
+ return {
181
+ accountId: isSet(object.accountId)
182
+ ? String(object.accountId)
183
+ : "",
184
+ extensionRequestContext: isSet(object.extensionRequestContext)
185
+ ? bytesFromBase64(object.extensionRequestContext)
186
+ : new Uint8Array(),
187
+ heartbeat: isSet(object.heartbeat)
188
+ ? Number(object.heartbeat)
189
+ : 0,
190
+ };
191
+ },
192
+ toJSON(message) {
193
+ const obj = {};
194
+ message.accountId !== undefined && (obj.accountId = message.accountId);
195
+ message.extensionRequestContext !== undefined && (obj.extensionRequestContext = base64FromBytes(message.extensionRequestContext !== undefined ? message.extensionRequestContext : new Uint8Array()));
196
+ message.heartbeat !== undefined && (obj.heartbeat = Math.round(message.heartbeat));
197
+ return obj;
198
+ },
199
+ fromPartial(object) {
200
+ const message = createBasePushLensSubscriptionRequest();
201
+ message.accountId = object.accountId ?? "";
202
+ message.extensionRequestContext = object.extensionRequestContext ?? new Uint8Array();
203
+ message.heartbeat = object.heartbeat ?? 0;
204
+ return message;
205
+ }
206
+ };
207
+ function createBasePushLensSubscriptionResponse() {
208
+ return { lens: undefined, excludedLens: undefined, heartbeat: 0, lenses: {} };
209
+ }
210
+ export const PushLensSubscriptionResponse = {
211
+ decode(input, length) {
212
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
213
+ let end = length === undefined ? reader.len : reader.pos + length;
214
+ const message = createBasePushLensSubscriptionResponse();
215
+ while (reader.pos < end) {
216
+ const tag = reader.uint32();
217
+ switch (tag >>> 3) {
218
+ case 1:
219
+ message.lens = Lens.decode(reader, reader.uint32());
220
+ break;
221
+ case 2:
222
+ message.excludedLens = PushLensSubscriptionResponse_ExcludedLens.decode(reader, reader.uint32());
223
+ break;
224
+ case 3:
225
+ message.heartbeat = reader.int32();
226
+ break;
227
+ case 4:
228
+ const entry4 = PushLensSubscriptionResponse_LensesEntry.decode(reader, reader.uint32());
229
+ if (entry4.value !== undefined) {
230
+ message.lenses[entry4.key] = entry4.value;
231
+ }
232
+ break;
233
+ default:
234
+ reader.skipType(tag & 7);
235
+ break;
236
+ }
237
+ }
238
+ return message;
239
+ },
240
+ fromJSON(object) {
241
+ return {
242
+ lens: isSet(object.lens)
243
+ ? Lens.fromJSON(object.lens)
244
+ : undefined,
245
+ excludedLens: isSet(object.excludedLens)
246
+ ? PushLensSubscriptionResponse_ExcludedLens.fromJSON(object.excludedLens)
247
+ : undefined,
248
+ heartbeat: isSet(object.heartbeat)
249
+ ? Number(object.heartbeat)
250
+ : 0,
251
+ lenses: isObject(object.lenses)
252
+ ? Object.entries(object.lenses).reduce((acc, [key, value]) => {
253
+ acc[key] = bytesFromBase64(value);
254
+ return acc;
255
+ }, {})
256
+ : {},
257
+ };
258
+ },
259
+ toJSON(message) {
260
+ const obj = {};
261
+ message.lens !== undefined && (obj.lens = message.lens ? Lens.toJSON(message.lens) : undefined);
262
+ message.excludedLens !== undefined && (obj.excludedLens = message.excludedLens ? PushLensSubscriptionResponse_ExcludedLens.toJSON(message.excludedLens) : undefined);
263
+ message.heartbeat !== undefined && (obj.heartbeat = Math.round(message.heartbeat));
264
+ obj.lenses = {};
265
+ if (message.lenses) {
266
+ Object.entries(message.lenses).forEach(([k, v]) => {
267
+ obj.lenses[k] = base64FromBytes(v);
268
+ });
269
+ }
270
+ return obj;
271
+ },
272
+ fromPartial(object) {
273
+ const message = createBasePushLensSubscriptionResponse();
274
+ message.lens = (object.lens !== undefined && object.lens !== null)
275
+ ? Lens.fromPartial(object.lens)
276
+ : undefined;
277
+ message.excludedLens = (object.excludedLens !== undefined && object.excludedLens !== null)
278
+ ? PushLensSubscriptionResponse_ExcludedLens.fromPartial(object.excludedLens)
279
+ : undefined;
280
+ message.heartbeat = object.heartbeat ?? 0;
281
+ message.lenses = Object.entries(object.lenses ?? {}).reduce((acc, [key, value]) => {
282
+ if (value !== undefined) {
283
+ acc[key] = value;
284
+ }
285
+ return acc;
286
+ }, {});
287
+ return message;
288
+ }
289
+ };
290
+ function createBasePushLensSubscriptionResponse_LensesEntry() {
291
+ return { key: "", value: new Uint8Array() };
292
+ }
293
+ export const PushLensSubscriptionResponse_LensesEntry = {
294
+ decode(input, length) {
295
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
296
+ let end = length === undefined ? reader.len : reader.pos + length;
297
+ const message = createBasePushLensSubscriptionResponse_LensesEntry();
298
+ while (reader.pos < end) {
299
+ const tag = reader.uint32();
300
+ switch (tag >>> 3) {
301
+ case 1:
302
+ message.key = reader.string();
303
+ break;
304
+ case 2:
305
+ message.value = reader.bytes();
306
+ break;
307
+ default:
308
+ reader.skipType(tag & 7);
309
+ break;
310
+ }
311
+ }
312
+ return message;
313
+ },
314
+ fromJSON(object) {
315
+ return {
316
+ key: isSet(object.key)
317
+ ? String(object.key)
318
+ : "",
319
+ value: isSet(object.value)
320
+ ? bytesFromBase64(object.value)
321
+ : new Uint8Array(),
322
+ };
323
+ },
324
+ toJSON(message) {
325
+ const obj = {};
326
+ message.key !== undefined && (obj.key = message.key);
327
+ message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
328
+ return obj;
329
+ },
330
+ fromPartial(object) {
331
+ const message = createBasePushLensSubscriptionResponse_LensesEntry();
332
+ message.key = object.key ?? "";
333
+ message.value = object.value ?? new Uint8Array();
334
+ return message;
335
+ }
336
+ };
337
+ function createBasePushLensSubscriptionResponse_ExcludedLens() {
338
+ return { lensId: 0, code: PushLensSubscriptionResponse_ExcludedLens_Code.UNSET };
339
+ }
340
+ export const PushLensSubscriptionResponse_ExcludedLens = {
341
+ decode(input, length) {
342
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
343
+ let end = length === undefined ? reader.len : reader.pos + length;
344
+ const message = createBasePushLensSubscriptionResponse_ExcludedLens();
345
+ while (reader.pos < end) {
346
+ const tag = reader.uint32();
347
+ switch (tag >>> 3) {
348
+ case 1:
349
+ message.lensId = longToNumber(reader.int64());
350
+ break;
351
+ case 2:
352
+ message.code = pushLensSubscriptionResponse_ExcludedLens_CodeFromJSON(reader.int32());
353
+ break;
354
+ default:
355
+ reader.skipType(tag & 7);
356
+ break;
357
+ }
358
+ }
359
+ return message;
360
+ },
361
+ fromJSON(object) {
362
+ return {
363
+ lensId: isSet(object.lensId)
364
+ ? Number(object.lensId)
365
+ : 0,
366
+ code: isSet(object.code)
367
+ ? pushLensSubscriptionResponse_ExcludedLens_CodeFromJSON(object.code)
368
+ : PushLensSubscriptionResponse_ExcludedLens_Code.UNSET,
369
+ };
370
+ },
371
+ toJSON(message) {
372
+ const obj = {};
373
+ message.lensId !== undefined && (obj.lensId = Math.round(message.lensId));
374
+ message.code !== undefined && (obj.code = pushLensSubscriptionResponse_ExcludedLens_CodeToJSON(message.code));
375
+ return obj;
376
+ },
377
+ fromPartial(object) {
378
+ const message = createBasePushLensSubscriptionResponse_ExcludedLens();
379
+ message.lensId = object.lensId ?? 0;
380
+ message.code = object.code ?? PushLensSubscriptionResponse_ExcludedLens_Code.UNSET;
381
+ return message;
382
+ }
383
+ };
384
+ function createBaseListenLensPushRequest() {
385
+ return { extensionRequestContext: new Uint8Array(), heartbeat: 0 };
386
+ }
387
+ export const ListenLensPushRequest = {
388
+ encode(message, writer = _m0.Writer.create()) {
389
+ if (message.extensionRequestContext.length !== 0) {
390
+ writer.uint32(18).bytes(message.extensionRequestContext);
391
+ }
392
+ if (message.heartbeat !== 0) {
393
+ writer.uint32(24).int32(message.heartbeat);
394
+ }
395
+ return writer;
396
+ },
397
+ decode(input, length) {
398
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
399
+ let end = length === undefined ? reader.len : reader.pos + length;
400
+ const message = createBaseListenLensPushRequest();
401
+ while (reader.pos < end) {
402
+ const tag = reader.uint32();
403
+ switch (tag >>> 3) {
404
+ case 2:
405
+ message.extensionRequestContext = reader.bytes();
406
+ break;
407
+ case 3:
408
+ message.heartbeat = reader.int32();
409
+ break;
410
+ default:
411
+ reader.skipType(tag & 7);
412
+ break;
413
+ }
414
+ }
415
+ return message;
416
+ },
417
+ fromJSON(object) {
418
+ return {
419
+ extensionRequestContext: isSet(object.extensionRequestContext)
420
+ ? bytesFromBase64(object.extensionRequestContext)
421
+ : new Uint8Array(),
422
+ heartbeat: isSet(object.heartbeat)
423
+ ? Number(object.heartbeat)
424
+ : 0,
425
+ };
426
+ },
427
+ toJSON(message) {
428
+ const obj = {};
429
+ message.extensionRequestContext !== undefined && (obj.extensionRequestContext = base64FromBytes(message.extensionRequestContext !== undefined ? message.extensionRequestContext : new Uint8Array()));
430
+ message.heartbeat !== undefined && (obj.heartbeat = Math.round(message.heartbeat));
431
+ return obj;
432
+ },
433
+ fromPartial(object) {
434
+ const message = createBaseListenLensPushRequest();
435
+ message.extensionRequestContext = object.extensionRequestContext ?? new Uint8Array();
436
+ message.heartbeat = object.heartbeat ?? 0;
437
+ return message;
438
+ }
439
+ };
440
+ function createBaseListenLensPushResponse() {
441
+ return { excludedLens: undefined, heartbeat: 0, lenses: {} };
442
+ }
443
+ export const ListenLensPushResponse = {
444
+ decode(input, length) {
445
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
446
+ let end = length === undefined ? reader.len : reader.pos + length;
447
+ const message = createBaseListenLensPushResponse();
448
+ while (reader.pos < end) {
449
+ const tag = reader.uint32();
450
+ switch (tag >>> 3) {
451
+ case 2:
452
+ message.excludedLens = ListenLensPushResponse_ExcludedLens.decode(reader, reader.uint32());
453
+ break;
454
+ case 3:
455
+ message.heartbeat = reader.int32();
456
+ break;
457
+ case 4:
458
+ const entry4 = ListenLensPushResponse_LensesEntry.decode(reader, reader.uint32());
459
+ if (entry4.value !== undefined) {
460
+ message.lenses[entry4.key] = entry4.value;
461
+ }
462
+ break;
463
+ default:
464
+ reader.skipType(tag & 7);
465
+ break;
466
+ }
467
+ }
468
+ return message;
469
+ },
470
+ fromJSON(object) {
471
+ return {
472
+ excludedLens: isSet(object.excludedLens)
473
+ ? ListenLensPushResponse_ExcludedLens.fromJSON(object.excludedLens)
474
+ : undefined,
475
+ heartbeat: isSet(object.heartbeat)
476
+ ? Number(object.heartbeat)
477
+ : 0,
478
+ lenses: isObject(object.lenses)
479
+ ? Object.entries(object.lenses).reduce((acc, [key, value]) => {
480
+ acc[key] = bytesFromBase64(value);
481
+ return acc;
482
+ }, {})
483
+ : {},
484
+ };
485
+ },
486
+ toJSON(message) {
487
+ const obj = {};
488
+ message.excludedLens !== undefined && (obj.excludedLens = message.excludedLens ? ListenLensPushResponse_ExcludedLens.toJSON(message.excludedLens) : undefined);
489
+ message.heartbeat !== undefined && (obj.heartbeat = Math.round(message.heartbeat));
490
+ obj.lenses = {};
491
+ if (message.lenses) {
492
+ Object.entries(message.lenses).forEach(([k, v]) => {
493
+ obj.lenses[k] = base64FromBytes(v);
494
+ });
495
+ }
496
+ return obj;
497
+ },
498
+ fromPartial(object) {
499
+ const message = createBaseListenLensPushResponse();
500
+ message.excludedLens = (object.excludedLens !== undefined && object.excludedLens !== null)
501
+ ? ListenLensPushResponse_ExcludedLens.fromPartial(object.excludedLens)
502
+ : undefined;
503
+ message.heartbeat = object.heartbeat ?? 0;
504
+ message.lenses = Object.entries(object.lenses ?? {}).reduce((acc, [key, value]) => {
505
+ if (value !== undefined) {
506
+ acc[key] = value;
507
+ }
508
+ return acc;
509
+ }, {});
510
+ return message;
511
+ }
512
+ };
513
+ function createBaseListenLensPushResponse_LensesEntry() {
514
+ return { key: "", value: new Uint8Array() };
515
+ }
516
+ export const ListenLensPushResponse_LensesEntry = {
517
+ decode(input, length) {
518
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
519
+ let end = length === undefined ? reader.len : reader.pos + length;
520
+ const message = createBaseListenLensPushResponse_LensesEntry();
521
+ while (reader.pos < end) {
522
+ const tag = reader.uint32();
523
+ switch (tag >>> 3) {
524
+ case 1:
525
+ message.key = reader.string();
526
+ break;
527
+ case 2:
528
+ message.value = reader.bytes();
529
+ break;
530
+ default:
531
+ reader.skipType(tag & 7);
532
+ break;
533
+ }
534
+ }
535
+ return message;
536
+ },
537
+ fromJSON(object) {
538
+ return {
539
+ key: isSet(object.key)
540
+ ? String(object.key)
541
+ : "",
542
+ value: isSet(object.value)
543
+ ? bytesFromBase64(object.value)
544
+ : new Uint8Array(),
545
+ };
546
+ },
547
+ toJSON(message) {
548
+ const obj = {};
549
+ message.key !== undefined && (obj.key = message.key);
550
+ message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
551
+ return obj;
552
+ },
553
+ fromPartial(object) {
554
+ const message = createBaseListenLensPushResponse_LensesEntry();
555
+ message.key = object.key ?? "";
556
+ message.value = object.value ?? new Uint8Array();
557
+ return message;
558
+ }
559
+ };
560
+ function createBaseListenLensPushResponse_ExcludedLens() {
561
+ return { lensId: 0, code: ListenLensPushResponse_ExcludedLens_Code.UNSET };
562
+ }
563
+ export const ListenLensPushResponse_ExcludedLens = {
564
+ decode(input, length) {
565
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
566
+ let end = length === undefined ? reader.len : reader.pos + length;
567
+ const message = createBaseListenLensPushResponse_ExcludedLens();
568
+ while (reader.pos < end) {
569
+ const tag = reader.uint32();
570
+ switch (tag >>> 3) {
571
+ case 1:
572
+ message.lensId = longToNumber(reader.int64());
573
+ break;
574
+ case 2:
575
+ message.code = listenLensPushResponse_ExcludedLens_CodeFromJSON(reader.int32());
576
+ break;
577
+ default:
578
+ reader.skipType(tag & 7);
579
+ break;
580
+ }
581
+ }
582
+ return message;
583
+ },
584
+ fromJSON(object) {
585
+ return {
586
+ lensId: isSet(object.lensId)
587
+ ? Number(object.lensId)
588
+ : 0,
589
+ code: isSet(object.code)
590
+ ? listenLensPushResponse_ExcludedLens_CodeFromJSON(object.code)
591
+ : ListenLensPushResponse_ExcludedLens_Code.UNSET,
592
+ };
593
+ },
594
+ toJSON(message) {
595
+ const obj = {};
596
+ message.lensId !== undefined && (obj.lensId = Math.round(message.lensId));
597
+ message.code !== undefined && (obj.code = listenLensPushResponse_ExcludedLens_CodeToJSON(message.code));
598
+ return obj;
599
+ },
600
+ fromPartial(object) {
601
+ const message = createBaseListenLensPushResponse_ExcludedLens();
602
+ message.lensId = object.lensId ?? 0;
603
+ message.code = object.code ?? ListenLensPushResponse_ExcludedLens_Code.UNSET;
604
+ return message;
605
+ }
606
+ };
607
+ export class PushToDeviceClientImpl {
608
+ rpc;
609
+ constructor(rpc) {
610
+ this.rpc = rpc;
611
+ this.PushLensSubscription = this.PushLensSubscription.bind(this);
612
+ this.ListenLensPush = this.ListenLensPush.bind(this);
613
+ }
614
+ PushLensSubscription(request, metadata) {
615
+ return this.rpc.invoke(PushToDevicePushLensSubscriptionDesc, request, metadata);
616
+ }
617
+ ListenLensPush(request, metadata) {
618
+ return this.rpc.invoke(PushToDeviceListenLensPushDesc, ListenLensPushRequest.fromPartial(request), metadata);
619
+ }
620
+ }
621
+ export const PushToDeviceDesc = {
622
+ serviceName: "com.snap.camerakit.v3.PushToDevice",
623
+ };
624
+ export const PushToDevicePushLensSubscriptionDesc = {
625
+ methodName: "PushLensSubscription",
626
+ service: PushToDeviceDesc,
627
+ requestStream: false,
628
+ responseStream: true,
629
+ requestType: {
630
+ serializeBinary() {
631
+ return PushLensSubscriptionRequest.encode(this).finish();
632
+ },
633
+ },
634
+ responseType: {
635
+ deserializeBinary(data) {
636
+ return { ...PushLensSubscriptionResponse.decode(data), toObject() { return this; } };
637
+ }
638
+ },
639
+ };
640
+ export const PushToDeviceListenLensPushDesc = {
641
+ methodName: "ListenLensPush",
642
+ service: PushToDeviceDesc,
643
+ requestStream: false,
644
+ responseStream: true,
645
+ requestType: {
646
+ serializeBinary() {
647
+ return ListenLensPushRequest.encode(this).finish();
648
+ },
649
+ },
650
+ responseType: {
651
+ deserializeBinary(data) {
652
+ return { ...ListenLensPushResponse.decode(data), toObject() { return this; } };
653
+ }
654
+ },
655
+ };
656
+ export class GrpcWebImpl {
657
+ host;
658
+ options;
659
+ constructor(host, options) {
660
+ this.host = host;
661
+ this.options = options;
662
+ }
663
+ unary(methodDesc, _request, metadata) {
664
+ const request = { ..._request, ...methodDesc.requestType };
665
+ const maybeCombinedMetadata = metadata && this.options.metadata
666
+ ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap })
667
+ : metadata || this.options.metadata;
668
+ return new Promise((resolve, reject) => {
669
+ grpc.unary(methodDesc, {
670
+ request,
671
+ host: this.host,
672
+ metadata: maybeCombinedMetadata,
673
+ transport: this.options.transport,
674
+ debug: this.options.debug,
675
+ onEnd: function (response) {
676
+ if (response.status === grpc.Code.OK) {
677
+ resolve(response.message);
678
+ }
679
+ else {
680
+ const err = new Error(response.statusMessage);
681
+ err.code = response.status;
682
+ err.metadata = response.trailers;
683
+ reject(err);
684
+ }
685
+ },
686
+ });
687
+ });
688
+ }
689
+ invoke(methodDesc, _request, metadata) {
690
+ // Status Response Codes (https://developers.google.com/maps-booking/reference/grpc-api/status_codes)
691
+ const upStreamCodes = [2, 4, 8, 9, 10, 13, 14, 15];
692
+ const DEFAULT_TIMEOUT_TIME = 3000;
693
+ const request = { ..._request, ...methodDesc.requestType };
694
+ const maybeCombinedMetadata = metadata && this.options.metadata
695
+ ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap })
696
+ : metadata || this.options.metadata;
697
+ return new Observable(observer => {
698
+ const upStream = (() => {
699
+ const client = grpc.invoke(methodDesc, {
700
+ host: this.host,
701
+ request,
702
+ transport: this.options.streamingTransport || this.options.transport,
703
+ metadata: maybeCombinedMetadata,
704
+ debug: this.options.debug,
705
+ onMessage: (next) => observer.next(next),
706
+ onEnd: (code, message) => {
707
+ if (code === 0) {
708
+ observer.complete();
709
+ }
710
+ else if (upStreamCodes.includes(code)) {
711
+ setTimeout(upStream, DEFAULT_TIMEOUT_TIME);
712
+ }
713
+ else {
714
+ observer.error(new Error(`Error ${code} ${message}`));
715
+ }
716
+ },
717
+ });
718
+ observer.add(() => client.close());
719
+ });
720
+ upStream();
721
+ }).pipe(share());
722
+ }
723
+ }
724
+ var globalThis = (() => {
725
+ if (typeof globalThis !== "undefined")
726
+ return globalThis;
727
+ if (typeof self !== "undefined")
728
+ return self;
729
+ if (typeof window !== "undefined")
730
+ return window;
731
+ if (typeof global !== "undefined")
732
+ return global;
733
+ throw "Unable to locate global object";
734
+ })();
735
+ const atob = globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
736
+ function bytesFromBase64(b64) {
737
+ const bin = atob(b64);
738
+ const arr = new Uint8Array(bin.length);
739
+ for (let i = 0; i < bin.length; ++i) {
740
+ arr[i] = bin.charCodeAt(i);
741
+ }
742
+ return arr;
743
+ }
744
+ const btoa = globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
745
+ function base64FromBytes(arr) {
746
+ const bin = [];
747
+ for (const byte of arr) {
748
+ bin.push(String.fromCharCode(byte));
749
+ }
750
+ return btoa(bin.join(''));
751
+ }
752
+ function longToNumber(long) {
753
+ if (long.gt(Number.MAX_SAFE_INTEGER)) {
754
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
755
+ }
756
+ return long.toNumber();
757
+ }
758
+ if (_m0.util.Long !== Long) {
759
+ _m0.util.Long = Long;
760
+ _m0.configure();
761
+ }
762
+ function isObject(value) {
763
+ return typeof value === 'object' && value !== null;
764
+ }
765
+ function isSet(value) {
766
+ return value !== null && value !== undefined;
767
+ }