@azure/web-pubsub-client-protobuf 1.0.0-alpha.20240827.1 → 1.0.0-alpha.20240911.2
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/dist/{index.js → commonjs/generated/clientProto.js} +147 -3080
- package/dist/commonjs/index.d.ts +10 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +22 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/logger.d.ts +5 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +11 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/webPubSubProtobufProtocol.d.ts +25 -0
- package/dist/commonjs/webPubSubProtobufProtocol.d.ts.map +1 -0
- package/dist/commonjs/webPubSubProtobufProtocol.js +37 -0
- package/dist/commonjs/webPubSubProtobufProtocol.js.map +1 -0
- package/dist/commonjs/webPubSubProtobufProtocolBase.d.ts +20 -0
- package/dist/commonjs/webPubSubProtobufProtocolBase.d.ts.map +1 -0
- package/dist/commonjs/webPubSubProtobufProtocolBase.js +191 -0
- package/dist/commonjs/webPubSubProtobufProtocolBase.js.map +1 -0
- package/dist/commonjs/webPubSubProtobufReliableProtocol.d.ts +25 -0
- package/dist/commonjs/webPubSubProtobufReliableProtocol.d.ts.map +1 -0
- package/dist/commonjs/webPubSubProtobufReliableProtocol.js +37 -0
- package/dist/commonjs/webPubSubProtobufReliableProtocol.js.map +1 -0
- package/dist/esm/generated/clientProto.d.ts +1644 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/index.js +2 -2
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.d.ts +5 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/webPubSubProtobufProtocol.d.ts +25 -0
- package/dist/esm/webPubSubProtobufProtocol.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/webPubSubProtobufProtocol.js +1 -1
- package/dist/esm/webPubSubProtobufProtocol.js.map +1 -0
- package/dist/esm/webPubSubProtobufProtocolBase.d.ts +20 -0
- package/dist/esm/webPubSubProtobufProtocolBase.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/webPubSubProtobufProtocolBase.js +1 -1
- package/dist/esm/webPubSubProtobufProtocolBase.js.map +1 -0
- package/dist/esm/webPubSubProtobufReliableProtocol.d.ts +25 -0
- package/dist/esm/webPubSubProtobufReliableProtocol.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/webPubSubProtobufReliableProtocol.js +1 -1
- package/dist/esm/webPubSubProtobufReliableProtocol.js.map +1 -0
- package/package.json +54 -54
- package/dist/index.js.map +0 -1
- package/dist-esm/samples-dev/basicusage.js +0 -63
- package/dist-esm/samples-dev/basicusage.js.map +0 -1
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/webPubSubProtobufProtocol.js.map +0 -1
- package/dist-esm/src/webPubSubProtobufProtocolBase.js.map +0 -1
- package/dist-esm/src/webPubSubProtobufReliableProtocol.js.map +0 -1
- package/dist-esm/test/client.spec.js +0 -294
- package/dist-esm/test/client.spec.js.map +0 -1
- /package/{dist-esm/src → dist/esm}/generated/clientProto.js +0 -0
- /package/{dist-esm/src → dist/esm}/logger.js +0 -0
- /package/{dist-esm/src → dist/esm}/logger.js.map +0 -0
- /package/{types → dist}/web-pubsub-client-protobuf.d.ts +0 -0
|
@@ -1,2695 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
|
-
|
|
5
|
-
var indexMinimal = {};
|
|
6
|
-
|
|
7
|
-
var minimal$1 = {};
|
|
8
|
-
|
|
9
|
-
var aspromise = asPromise;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Callback as used by {@link util.asPromise}.
|
|
13
|
-
* @typedef asPromiseCallback
|
|
14
|
-
* @type {function}
|
|
15
|
-
* @param {Error|null} error Error, if any
|
|
16
|
-
* @param {...*} params Additional arguments
|
|
17
|
-
* @returns {undefined}
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Returns a promise from a node-style callback function.
|
|
22
|
-
* @memberof util
|
|
23
|
-
* @param {asPromiseCallback} fn Function to call
|
|
24
|
-
* @param {*} ctx Function context
|
|
25
|
-
* @param {...*} params Function arguments
|
|
26
|
-
* @returns {Promise<*>} Promisified function
|
|
27
|
-
*/
|
|
28
|
-
function asPromise(fn, ctx/*, varargs */) {
|
|
29
|
-
var params = new Array(arguments.length - 1),
|
|
30
|
-
offset = 0,
|
|
31
|
-
index = 2,
|
|
32
|
-
pending = true;
|
|
33
|
-
while (index < arguments.length)
|
|
34
|
-
params[offset++] = arguments[index++];
|
|
35
|
-
return new Promise(function executor(resolve, reject) {
|
|
36
|
-
params[offset] = function callback(err/*, varargs */) {
|
|
37
|
-
if (pending) {
|
|
38
|
-
pending = false;
|
|
39
|
-
if (err)
|
|
40
|
-
reject(err);
|
|
41
|
-
else {
|
|
42
|
-
var params = new Array(arguments.length - 1),
|
|
43
|
-
offset = 0;
|
|
44
|
-
while (offset < params.length)
|
|
45
|
-
params[offset++] = arguments[offset];
|
|
46
|
-
resolve.apply(null, params);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
try {
|
|
51
|
-
fn.apply(ctx || null, params);
|
|
52
|
-
} catch (err) {
|
|
53
|
-
if (pending) {
|
|
54
|
-
pending = false;
|
|
55
|
-
reject(err);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var base64$1 = {};
|
|
62
|
-
|
|
63
|
-
(function (exports) {
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* A minimal base64 implementation for number arrays.
|
|
67
|
-
* @memberof util
|
|
68
|
-
* @namespace
|
|
69
|
-
*/
|
|
70
|
-
var base64 = exports;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Calculates the byte length of a base64 encoded string.
|
|
74
|
-
* @param {string} string Base64 encoded string
|
|
75
|
-
* @returns {number} Byte length
|
|
76
|
-
*/
|
|
77
|
-
base64.length = function length(string) {
|
|
78
|
-
var p = string.length;
|
|
79
|
-
if (!p)
|
|
80
|
-
return 0;
|
|
81
|
-
var n = 0;
|
|
82
|
-
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
83
|
-
++n;
|
|
84
|
-
return Math.ceil(string.length * 3) / 4 - n;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// Base64 encoding table
|
|
88
|
-
var b64 = new Array(64);
|
|
89
|
-
|
|
90
|
-
// Base64 decoding table
|
|
91
|
-
var s64 = new Array(123);
|
|
92
|
-
|
|
93
|
-
// 65..90, 97..122, 48..57, 43, 47
|
|
94
|
-
for (var i = 0; i < 64;)
|
|
95
|
-
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Encodes a buffer to a base64 encoded string.
|
|
99
|
-
* @param {Uint8Array} buffer Source buffer
|
|
100
|
-
* @param {number} start Source start
|
|
101
|
-
* @param {number} end Source end
|
|
102
|
-
* @returns {string} Base64 encoded string
|
|
103
|
-
*/
|
|
104
|
-
base64.encode = function encode(buffer, start, end) {
|
|
105
|
-
var parts = null,
|
|
106
|
-
chunk = [];
|
|
107
|
-
var i = 0, // output index
|
|
108
|
-
j = 0, // goto index
|
|
109
|
-
t; // temporary
|
|
110
|
-
while (start < end) {
|
|
111
|
-
var b = buffer[start++];
|
|
112
|
-
switch (j) {
|
|
113
|
-
case 0:
|
|
114
|
-
chunk[i++] = b64[b >> 2];
|
|
115
|
-
t = (b & 3) << 4;
|
|
116
|
-
j = 1;
|
|
117
|
-
break;
|
|
118
|
-
case 1:
|
|
119
|
-
chunk[i++] = b64[t | b >> 4];
|
|
120
|
-
t = (b & 15) << 2;
|
|
121
|
-
j = 2;
|
|
122
|
-
break;
|
|
123
|
-
case 2:
|
|
124
|
-
chunk[i++] = b64[t | b >> 6];
|
|
125
|
-
chunk[i++] = b64[b & 63];
|
|
126
|
-
j = 0;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
if (i > 8191) {
|
|
130
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
131
|
-
i = 0;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (j) {
|
|
135
|
-
chunk[i++] = b64[t];
|
|
136
|
-
chunk[i++] = 61;
|
|
137
|
-
if (j === 1)
|
|
138
|
-
chunk[i++] = 61;
|
|
139
|
-
}
|
|
140
|
-
if (parts) {
|
|
141
|
-
if (i)
|
|
142
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
143
|
-
return parts.join("");
|
|
144
|
-
}
|
|
145
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
var invalidEncoding = "invalid encoding";
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Decodes a base64 encoded string to a buffer.
|
|
152
|
-
* @param {string} string Source string
|
|
153
|
-
* @param {Uint8Array} buffer Destination buffer
|
|
154
|
-
* @param {number} offset Destination offset
|
|
155
|
-
* @returns {number} Number of bytes written
|
|
156
|
-
* @throws {Error} If encoding is invalid
|
|
157
|
-
*/
|
|
158
|
-
base64.decode = function decode(string, buffer, offset) {
|
|
159
|
-
var start = offset;
|
|
160
|
-
var j = 0, // goto index
|
|
161
|
-
t; // temporary
|
|
162
|
-
for (var i = 0; i < string.length;) {
|
|
163
|
-
var c = string.charCodeAt(i++);
|
|
164
|
-
if (c === 61 && j > 1)
|
|
165
|
-
break;
|
|
166
|
-
if ((c = s64[c]) === undefined)
|
|
167
|
-
throw Error(invalidEncoding);
|
|
168
|
-
switch (j) {
|
|
169
|
-
case 0:
|
|
170
|
-
t = c;
|
|
171
|
-
j = 1;
|
|
172
|
-
break;
|
|
173
|
-
case 1:
|
|
174
|
-
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
175
|
-
t = c;
|
|
176
|
-
j = 2;
|
|
177
|
-
break;
|
|
178
|
-
case 2:
|
|
179
|
-
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
180
|
-
t = c;
|
|
181
|
-
j = 3;
|
|
182
|
-
break;
|
|
183
|
-
case 3:
|
|
184
|
-
buffer[offset++] = (t & 3) << 6 | c;
|
|
185
|
-
j = 0;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (j === 1)
|
|
190
|
-
throw Error(invalidEncoding);
|
|
191
|
-
return offset - start;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Tests if the specified string appears to be base64 encoded.
|
|
196
|
-
* @param {string} string String to test
|
|
197
|
-
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
198
|
-
*/
|
|
199
|
-
base64.test = function test(string) {
|
|
200
|
-
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
201
|
-
};
|
|
202
|
-
} (base64$1));
|
|
203
|
-
|
|
204
|
-
var eventemitter = EventEmitter;
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Constructs a new event emitter instance.
|
|
208
|
-
* @classdesc A minimal event emitter.
|
|
209
|
-
* @memberof util
|
|
210
|
-
* @constructor
|
|
211
|
-
*/
|
|
212
|
-
function EventEmitter() {
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Registered listeners.
|
|
216
|
-
* @type {Object.<string,*>}
|
|
217
|
-
* @private
|
|
218
|
-
*/
|
|
219
|
-
this._listeners = {};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Registers an event listener.
|
|
224
|
-
* @param {string} evt Event name
|
|
225
|
-
* @param {function} fn Listener
|
|
226
|
-
* @param {*} [ctx] Listener context
|
|
227
|
-
* @returns {util.EventEmitter} `this`
|
|
228
|
-
*/
|
|
229
|
-
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
230
|
-
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
231
|
-
fn : fn,
|
|
232
|
-
ctx : ctx || this
|
|
233
|
-
});
|
|
234
|
-
return this;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
239
|
-
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
240
|
-
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
241
|
-
* @returns {util.EventEmitter} `this`
|
|
242
|
-
*/
|
|
243
|
-
EventEmitter.prototype.off = function off(evt, fn) {
|
|
244
|
-
if (evt === undefined)
|
|
245
|
-
this._listeners = {};
|
|
246
|
-
else {
|
|
247
|
-
if (fn === undefined)
|
|
248
|
-
this._listeners[evt] = [];
|
|
249
|
-
else {
|
|
250
|
-
var listeners = this._listeners[evt];
|
|
251
|
-
for (var i = 0; i < listeners.length;)
|
|
252
|
-
if (listeners[i].fn === fn)
|
|
253
|
-
listeners.splice(i, 1);
|
|
254
|
-
else
|
|
255
|
-
++i;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return this;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Emits an event by calling its listeners with the specified arguments.
|
|
263
|
-
* @param {string} evt Event name
|
|
264
|
-
* @param {...*} args Arguments
|
|
265
|
-
* @returns {util.EventEmitter} `this`
|
|
266
|
-
*/
|
|
267
|
-
EventEmitter.prototype.emit = function emit(evt) {
|
|
268
|
-
var listeners = this._listeners[evt];
|
|
269
|
-
if (listeners) {
|
|
270
|
-
var args = [],
|
|
271
|
-
i = 1;
|
|
272
|
-
for (; i < arguments.length;)
|
|
273
|
-
args.push(arguments[i++]);
|
|
274
|
-
for (i = 0; i < listeners.length;)
|
|
275
|
-
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
276
|
-
}
|
|
277
|
-
return this;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
var float = factory(factory);
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Reads / writes floats / doubles from / to buffers.
|
|
284
|
-
* @name util.float
|
|
285
|
-
* @namespace
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Writes a 32 bit float to a buffer using little endian byte order.
|
|
290
|
-
* @name util.float.writeFloatLE
|
|
291
|
-
* @function
|
|
292
|
-
* @param {number} val Value to write
|
|
293
|
-
* @param {Uint8Array} buf Target buffer
|
|
294
|
-
* @param {number} pos Target buffer offset
|
|
295
|
-
* @returns {undefined}
|
|
296
|
-
*/
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Writes a 32 bit float to a buffer using big endian byte order.
|
|
300
|
-
* @name util.float.writeFloatBE
|
|
301
|
-
* @function
|
|
302
|
-
* @param {number} val Value to write
|
|
303
|
-
* @param {Uint8Array} buf Target buffer
|
|
304
|
-
* @param {number} pos Target buffer offset
|
|
305
|
-
* @returns {undefined}
|
|
306
|
-
*/
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Reads a 32 bit float from a buffer using little endian byte order.
|
|
310
|
-
* @name util.float.readFloatLE
|
|
311
|
-
* @function
|
|
312
|
-
* @param {Uint8Array} buf Source buffer
|
|
313
|
-
* @param {number} pos Source buffer offset
|
|
314
|
-
* @returns {number} Value read
|
|
315
|
-
*/
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Reads a 32 bit float from a buffer using big endian byte order.
|
|
319
|
-
* @name util.float.readFloatBE
|
|
320
|
-
* @function
|
|
321
|
-
* @param {Uint8Array} buf Source buffer
|
|
322
|
-
* @param {number} pos Source buffer offset
|
|
323
|
-
* @returns {number} Value read
|
|
324
|
-
*/
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Writes a 64 bit double to a buffer using little endian byte order.
|
|
328
|
-
* @name util.float.writeDoubleLE
|
|
329
|
-
* @function
|
|
330
|
-
* @param {number} val Value to write
|
|
331
|
-
* @param {Uint8Array} buf Target buffer
|
|
332
|
-
* @param {number} pos Target buffer offset
|
|
333
|
-
* @returns {undefined}
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Writes a 64 bit double to a buffer using big endian byte order.
|
|
338
|
-
* @name util.float.writeDoubleBE
|
|
339
|
-
* @function
|
|
340
|
-
* @param {number} val Value to write
|
|
341
|
-
* @param {Uint8Array} buf Target buffer
|
|
342
|
-
* @param {number} pos Target buffer offset
|
|
343
|
-
* @returns {undefined}
|
|
344
|
-
*/
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Reads a 64 bit double from a buffer using little endian byte order.
|
|
348
|
-
* @name util.float.readDoubleLE
|
|
349
|
-
* @function
|
|
350
|
-
* @param {Uint8Array} buf Source buffer
|
|
351
|
-
* @param {number} pos Source buffer offset
|
|
352
|
-
* @returns {number} Value read
|
|
353
|
-
*/
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Reads a 64 bit double from a buffer using big endian byte order.
|
|
357
|
-
* @name util.float.readDoubleBE
|
|
358
|
-
* @function
|
|
359
|
-
* @param {Uint8Array} buf Source buffer
|
|
360
|
-
* @param {number} pos Source buffer offset
|
|
361
|
-
* @returns {number} Value read
|
|
362
|
-
*/
|
|
363
|
-
|
|
364
|
-
// Factory function for the purpose of node-based testing in modified global environments
|
|
365
|
-
function factory(exports) {
|
|
366
|
-
|
|
367
|
-
// float: typed array
|
|
368
|
-
if (typeof Float32Array !== "undefined") (function() {
|
|
369
|
-
|
|
370
|
-
var f32 = new Float32Array([ -0 ]),
|
|
371
|
-
f8b = new Uint8Array(f32.buffer),
|
|
372
|
-
le = f8b[3] === 128;
|
|
373
|
-
|
|
374
|
-
function writeFloat_f32_cpy(val, buf, pos) {
|
|
375
|
-
f32[0] = val;
|
|
376
|
-
buf[pos ] = f8b[0];
|
|
377
|
-
buf[pos + 1] = f8b[1];
|
|
378
|
-
buf[pos + 2] = f8b[2];
|
|
379
|
-
buf[pos + 3] = f8b[3];
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function writeFloat_f32_rev(val, buf, pos) {
|
|
383
|
-
f32[0] = val;
|
|
384
|
-
buf[pos ] = f8b[3];
|
|
385
|
-
buf[pos + 1] = f8b[2];
|
|
386
|
-
buf[pos + 2] = f8b[1];
|
|
387
|
-
buf[pos + 3] = f8b[0];
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/* istanbul ignore next */
|
|
391
|
-
exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
|
|
392
|
-
/* istanbul ignore next */
|
|
393
|
-
exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
|
|
394
|
-
|
|
395
|
-
function readFloat_f32_cpy(buf, pos) {
|
|
396
|
-
f8b[0] = buf[pos ];
|
|
397
|
-
f8b[1] = buf[pos + 1];
|
|
398
|
-
f8b[2] = buf[pos + 2];
|
|
399
|
-
f8b[3] = buf[pos + 3];
|
|
400
|
-
return f32[0];
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function readFloat_f32_rev(buf, pos) {
|
|
404
|
-
f8b[3] = buf[pos ];
|
|
405
|
-
f8b[2] = buf[pos + 1];
|
|
406
|
-
f8b[1] = buf[pos + 2];
|
|
407
|
-
f8b[0] = buf[pos + 3];
|
|
408
|
-
return f32[0];
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/* istanbul ignore next */
|
|
412
|
-
exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
|
|
413
|
-
/* istanbul ignore next */
|
|
414
|
-
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
|
|
415
|
-
|
|
416
|
-
// float: ieee754
|
|
417
|
-
})(); else (function() {
|
|
418
|
-
|
|
419
|
-
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
420
|
-
var sign = val < 0 ? 1 : 0;
|
|
421
|
-
if (sign)
|
|
422
|
-
val = -val;
|
|
423
|
-
if (val === 0)
|
|
424
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
425
|
-
else if (isNaN(val))
|
|
426
|
-
writeUint(2143289344, buf, pos);
|
|
427
|
-
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
428
|
-
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
429
|
-
else if (val < 1.1754943508222875e-38) // denormal
|
|
430
|
-
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
431
|
-
else {
|
|
432
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
433
|
-
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
434
|
-
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
|
|
439
|
-
exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
|
|
440
|
-
|
|
441
|
-
function readFloat_ieee754(readUint, buf, pos) {
|
|
442
|
-
var uint = readUint(buf, pos),
|
|
443
|
-
sign = (uint >> 31) * 2 + 1,
|
|
444
|
-
exponent = uint >>> 23 & 255,
|
|
445
|
-
mantissa = uint & 8388607;
|
|
446
|
-
return exponent === 255
|
|
447
|
-
? mantissa
|
|
448
|
-
? NaN
|
|
449
|
-
: sign * Infinity
|
|
450
|
-
: exponent === 0 // denormal
|
|
451
|
-
? sign * 1.401298464324817e-45 * mantissa
|
|
452
|
-
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
|
|
456
|
-
exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
|
|
457
|
-
|
|
458
|
-
})();
|
|
459
|
-
|
|
460
|
-
// double: typed array
|
|
461
|
-
if (typeof Float64Array !== "undefined") (function() {
|
|
462
|
-
|
|
463
|
-
var f64 = new Float64Array([-0]),
|
|
464
|
-
f8b = new Uint8Array(f64.buffer),
|
|
465
|
-
le = f8b[7] === 128;
|
|
466
|
-
|
|
467
|
-
function writeDouble_f64_cpy(val, buf, pos) {
|
|
468
|
-
f64[0] = val;
|
|
469
|
-
buf[pos ] = f8b[0];
|
|
470
|
-
buf[pos + 1] = f8b[1];
|
|
471
|
-
buf[pos + 2] = f8b[2];
|
|
472
|
-
buf[pos + 3] = f8b[3];
|
|
473
|
-
buf[pos + 4] = f8b[4];
|
|
474
|
-
buf[pos + 5] = f8b[5];
|
|
475
|
-
buf[pos + 6] = f8b[6];
|
|
476
|
-
buf[pos + 7] = f8b[7];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
function writeDouble_f64_rev(val, buf, pos) {
|
|
480
|
-
f64[0] = val;
|
|
481
|
-
buf[pos ] = f8b[7];
|
|
482
|
-
buf[pos + 1] = f8b[6];
|
|
483
|
-
buf[pos + 2] = f8b[5];
|
|
484
|
-
buf[pos + 3] = f8b[4];
|
|
485
|
-
buf[pos + 4] = f8b[3];
|
|
486
|
-
buf[pos + 5] = f8b[2];
|
|
487
|
-
buf[pos + 6] = f8b[1];
|
|
488
|
-
buf[pos + 7] = f8b[0];
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/* istanbul ignore next */
|
|
492
|
-
exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
|
|
493
|
-
/* istanbul ignore next */
|
|
494
|
-
exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
|
|
495
|
-
|
|
496
|
-
function readDouble_f64_cpy(buf, pos) {
|
|
497
|
-
f8b[0] = buf[pos ];
|
|
498
|
-
f8b[1] = buf[pos + 1];
|
|
499
|
-
f8b[2] = buf[pos + 2];
|
|
500
|
-
f8b[3] = buf[pos + 3];
|
|
501
|
-
f8b[4] = buf[pos + 4];
|
|
502
|
-
f8b[5] = buf[pos + 5];
|
|
503
|
-
f8b[6] = buf[pos + 6];
|
|
504
|
-
f8b[7] = buf[pos + 7];
|
|
505
|
-
return f64[0];
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
function readDouble_f64_rev(buf, pos) {
|
|
509
|
-
f8b[7] = buf[pos ];
|
|
510
|
-
f8b[6] = buf[pos + 1];
|
|
511
|
-
f8b[5] = buf[pos + 2];
|
|
512
|
-
f8b[4] = buf[pos + 3];
|
|
513
|
-
f8b[3] = buf[pos + 4];
|
|
514
|
-
f8b[2] = buf[pos + 5];
|
|
515
|
-
f8b[1] = buf[pos + 6];
|
|
516
|
-
f8b[0] = buf[pos + 7];
|
|
517
|
-
return f64[0];
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/* istanbul ignore next */
|
|
521
|
-
exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
|
|
522
|
-
/* istanbul ignore next */
|
|
523
|
-
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
|
|
524
|
-
|
|
525
|
-
// double: ieee754
|
|
526
|
-
})(); else (function() {
|
|
527
|
-
|
|
528
|
-
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
529
|
-
var sign = val < 0 ? 1 : 0;
|
|
530
|
-
if (sign)
|
|
531
|
-
val = -val;
|
|
532
|
-
if (val === 0) {
|
|
533
|
-
writeUint(0, buf, pos + off0);
|
|
534
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
535
|
-
} else if (isNaN(val)) {
|
|
536
|
-
writeUint(0, buf, pos + off0);
|
|
537
|
-
writeUint(2146959360, buf, pos + off1);
|
|
538
|
-
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
539
|
-
writeUint(0, buf, pos + off0);
|
|
540
|
-
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
541
|
-
} else {
|
|
542
|
-
var mantissa;
|
|
543
|
-
if (val < 2.2250738585072014e-308) { // denormal
|
|
544
|
-
mantissa = val / 5e-324;
|
|
545
|
-
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
546
|
-
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
547
|
-
} else {
|
|
548
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
549
|
-
if (exponent === 1024)
|
|
550
|
-
exponent = 1023;
|
|
551
|
-
mantissa = val * Math.pow(2, -exponent);
|
|
552
|
-
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
553
|
-
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
|
|
559
|
-
exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
|
|
560
|
-
|
|
561
|
-
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
562
|
-
var lo = readUint(buf, pos + off0),
|
|
563
|
-
hi = readUint(buf, pos + off1);
|
|
564
|
-
var sign = (hi >> 31) * 2 + 1,
|
|
565
|
-
exponent = hi >>> 20 & 2047,
|
|
566
|
-
mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
567
|
-
return exponent === 2047
|
|
568
|
-
? mantissa
|
|
569
|
-
? NaN
|
|
570
|
-
: sign * Infinity
|
|
571
|
-
: exponent === 0 // denormal
|
|
572
|
-
? sign * 5e-324 * mantissa
|
|
573
|
-
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
|
|
577
|
-
exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
|
|
578
|
-
|
|
579
|
-
})();
|
|
580
|
-
|
|
581
|
-
return exports;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// uint helpers
|
|
585
|
-
|
|
586
|
-
function writeUintLE(val, buf, pos) {
|
|
587
|
-
buf[pos ] = val & 255;
|
|
588
|
-
buf[pos + 1] = val >>> 8 & 255;
|
|
589
|
-
buf[pos + 2] = val >>> 16 & 255;
|
|
590
|
-
buf[pos + 3] = val >>> 24;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
function writeUintBE(val, buf, pos) {
|
|
594
|
-
buf[pos ] = val >>> 24;
|
|
595
|
-
buf[pos + 1] = val >>> 16 & 255;
|
|
596
|
-
buf[pos + 2] = val >>> 8 & 255;
|
|
597
|
-
buf[pos + 3] = val & 255;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
function readUintLE(buf, pos) {
|
|
601
|
-
return (buf[pos ]
|
|
602
|
-
| buf[pos + 1] << 8
|
|
603
|
-
| buf[pos + 2] << 16
|
|
604
|
-
| buf[pos + 3] << 24) >>> 0;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
function readUintBE(buf, pos) {
|
|
608
|
-
return (buf[pos ] << 24
|
|
609
|
-
| buf[pos + 1] << 16
|
|
610
|
-
| buf[pos + 2] << 8
|
|
611
|
-
| buf[pos + 3]) >>> 0;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
var inquire_1 = inquire;
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Requires a module only if available.
|
|
618
|
-
* @memberof util
|
|
619
|
-
* @param {string} moduleName Module to require
|
|
620
|
-
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
621
|
-
*/
|
|
622
|
-
function inquire(moduleName) {
|
|
623
|
-
try {
|
|
624
|
-
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
625
|
-
if (mod && (mod.length || Object.keys(mod).length))
|
|
626
|
-
return mod;
|
|
627
|
-
} catch (e) {} // eslint-disable-line no-empty
|
|
628
|
-
return null;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
var utf8$2 = {};
|
|
632
|
-
|
|
633
|
-
(function (exports) {
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* A minimal UTF8 implementation for number arrays.
|
|
637
|
-
* @memberof util
|
|
638
|
-
* @namespace
|
|
639
|
-
*/
|
|
640
|
-
var utf8 = exports;
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* Calculates the UTF8 byte length of a string.
|
|
644
|
-
* @param {string} string String
|
|
645
|
-
* @returns {number} Byte length
|
|
646
|
-
*/
|
|
647
|
-
utf8.length = function utf8_length(string) {
|
|
648
|
-
var len = 0,
|
|
649
|
-
c = 0;
|
|
650
|
-
for (var i = 0; i < string.length; ++i) {
|
|
651
|
-
c = string.charCodeAt(i);
|
|
652
|
-
if (c < 128)
|
|
653
|
-
len += 1;
|
|
654
|
-
else if (c < 2048)
|
|
655
|
-
len += 2;
|
|
656
|
-
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
657
|
-
++i;
|
|
658
|
-
len += 4;
|
|
659
|
-
} else
|
|
660
|
-
len += 3;
|
|
661
|
-
}
|
|
662
|
-
return len;
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* Reads UTF8 bytes as a string.
|
|
667
|
-
* @param {Uint8Array} buffer Source buffer
|
|
668
|
-
* @param {number} start Source start
|
|
669
|
-
* @param {number} end Source end
|
|
670
|
-
* @returns {string} String read
|
|
671
|
-
*/
|
|
672
|
-
utf8.read = function utf8_read(buffer, start, end) {
|
|
673
|
-
var len = end - start;
|
|
674
|
-
if (len < 1)
|
|
675
|
-
return "";
|
|
676
|
-
var parts = null,
|
|
677
|
-
chunk = [],
|
|
678
|
-
i = 0, // char offset
|
|
679
|
-
t; // temporary
|
|
680
|
-
while (start < end) {
|
|
681
|
-
t = buffer[start++];
|
|
682
|
-
if (t < 128)
|
|
683
|
-
chunk[i++] = t;
|
|
684
|
-
else if (t > 191 && t < 224)
|
|
685
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
686
|
-
else if (t > 239 && t < 365) {
|
|
687
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
688
|
-
chunk[i++] = 0xD800 + (t >> 10);
|
|
689
|
-
chunk[i++] = 0xDC00 + (t & 1023);
|
|
690
|
-
} else
|
|
691
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
692
|
-
if (i > 8191) {
|
|
693
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
694
|
-
i = 0;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
if (parts) {
|
|
698
|
-
if (i)
|
|
699
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
700
|
-
return parts.join("");
|
|
701
|
-
}
|
|
702
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* Writes a string as UTF8 bytes.
|
|
707
|
-
* @param {string} string Source string
|
|
708
|
-
* @param {Uint8Array} buffer Destination buffer
|
|
709
|
-
* @param {number} offset Destination offset
|
|
710
|
-
* @returns {number} Bytes written
|
|
711
|
-
*/
|
|
712
|
-
utf8.write = function utf8_write(string, buffer, offset) {
|
|
713
|
-
var start = offset,
|
|
714
|
-
c1, // character 1
|
|
715
|
-
c2; // character 2
|
|
716
|
-
for (var i = 0; i < string.length; ++i) {
|
|
717
|
-
c1 = string.charCodeAt(i);
|
|
718
|
-
if (c1 < 128) {
|
|
719
|
-
buffer[offset++] = c1;
|
|
720
|
-
} else if (c1 < 2048) {
|
|
721
|
-
buffer[offset++] = c1 >> 6 | 192;
|
|
722
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
723
|
-
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
724
|
-
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
725
|
-
++i;
|
|
726
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
727
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
728
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
729
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
730
|
-
} else {
|
|
731
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
732
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
733
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
return offset - start;
|
|
737
|
-
};
|
|
738
|
-
} (utf8$2));
|
|
739
|
-
|
|
740
|
-
var pool_1 = pool;
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* An allocator as used by {@link util.pool}.
|
|
744
|
-
* @typedef PoolAllocator
|
|
745
|
-
* @type {function}
|
|
746
|
-
* @param {number} size Buffer size
|
|
747
|
-
* @returns {Uint8Array} Buffer
|
|
748
|
-
*/
|
|
749
|
-
|
|
750
|
-
/**
|
|
751
|
-
* A slicer as used by {@link util.pool}.
|
|
752
|
-
* @typedef PoolSlicer
|
|
753
|
-
* @type {function}
|
|
754
|
-
* @param {number} start Start offset
|
|
755
|
-
* @param {number} end End offset
|
|
756
|
-
* @returns {Uint8Array} Buffer slice
|
|
757
|
-
* @this {Uint8Array}
|
|
758
|
-
*/
|
|
759
|
-
|
|
760
|
-
/**
|
|
761
|
-
* A general purpose buffer pool.
|
|
762
|
-
* @memberof util
|
|
763
|
-
* @function
|
|
764
|
-
* @param {PoolAllocator} alloc Allocator
|
|
765
|
-
* @param {PoolSlicer} slice Slicer
|
|
766
|
-
* @param {number} [size=8192] Slab size
|
|
767
|
-
* @returns {PoolAllocator} Pooled allocator
|
|
768
|
-
*/
|
|
769
|
-
function pool(alloc, slice, size) {
|
|
770
|
-
var SIZE = size || 8192;
|
|
771
|
-
var MAX = SIZE >>> 1;
|
|
772
|
-
var slab = null;
|
|
773
|
-
var offset = SIZE;
|
|
774
|
-
return function pool_alloc(size) {
|
|
775
|
-
if (size < 1 || size > MAX)
|
|
776
|
-
return alloc(size);
|
|
777
|
-
if (offset + size > SIZE) {
|
|
778
|
-
slab = alloc(SIZE);
|
|
779
|
-
offset = 0;
|
|
780
|
-
}
|
|
781
|
-
var buf = slice.call(slab, offset, offset += size);
|
|
782
|
-
if (offset & 7) // align to 32 bit
|
|
783
|
-
offset = (offset | 7) + 1;
|
|
784
|
-
return buf;
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
var longbits;
|
|
789
|
-
var hasRequiredLongbits;
|
|
790
|
-
|
|
791
|
-
function requireLongbits () {
|
|
792
|
-
if (hasRequiredLongbits) return longbits;
|
|
793
|
-
hasRequiredLongbits = 1;
|
|
794
|
-
longbits = LongBits;
|
|
795
|
-
|
|
796
|
-
var util = requireMinimal();
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* Constructs new long bits.
|
|
800
|
-
* @classdesc Helper class for working with the low and high bits of a 64 bit value.
|
|
801
|
-
* @memberof util
|
|
802
|
-
* @constructor
|
|
803
|
-
* @param {number} lo Low 32 bits, unsigned
|
|
804
|
-
* @param {number} hi High 32 bits, unsigned
|
|
805
|
-
*/
|
|
806
|
-
function LongBits(lo, hi) {
|
|
807
|
-
|
|
808
|
-
// note that the casts below are theoretically unnecessary as of today, but older statically
|
|
809
|
-
// generated converter code might still call the ctor with signed 32bits. kept for compat.
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* Low bits.
|
|
813
|
-
* @type {number}
|
|
814
|
-
*/
|
|
815
|
-
this.lo = lo >>> 0;
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
* High bits.
|
|
819
|
-
* @type {number}
|
|
820
|
-
*/
|
|
821
|
-
this.hi = hi >>> 0;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
/**
|
|
825
|
-
* Zero bits.
|
|
826
|
-
* @memberof util.LongBits
|
|
827
|
-
* @type {util.LongBits}
|
|
828
|
-
*/
|
|
829
|
-
var zero = LongBits.zero = new LongBits(0, 0);
|
|
830
|
-
|
|
831
|
-
zero.toNumber = function() { return 0; };
|
|
832
|
-
zero.zzEncode = zero.zzDecode = function() { return this; };
|
|
833
|
-
zero.length = function() { return 1; };
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* Zero hash.
|
|
837
|
-
* @memberof util.LongBits
|
|
838
|
-
* @type {string}
|
|
839
|
-
*/
|
|
840
|
-
var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* Constructs new long bits from the specified number.
|
|
844
|
-
* @param {number} value Value
|
|
845
|
-
* @returns {util.LongBits} Instance
|
|
846
|
-
*/
|
|
847
|
-
LongBits.fromNumber = function fromNumber(value) {
|
|
848
|
-
if (value === 0)
|
|
849
|
-
return zero;
|
|
850
|
-
var sign = value < 0;
|
|
851
|
-
if (sign)
|
|
852
|
-
value = -value;
|
|
853
|
-
var lo = value >>> 0,
|
|
854
|
-
hi = (value - lo) / 4294967296 >>> 0;
|
|
855
|
-
if (sign) {
|
|
856
|
-
hi = ~hi >>> 0;
|
|
857
|
-
lo = ~lo >>> 0;
|
|
858
|
-
if (++lo > 4294967295) {
|
|
859
|
-
lo = 0;
|
|
860
|
-
if (++hi > 4294967295)
|
|
861
|
-
hi = 0;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
return new LongBits(lo, hi);
|
|
865
|
-
};
|
|
866
|
-
|
|
867
|
-
/**
|
|
868
|
-
* Constructs new long bits from a number, long or string.
|
|
869
|
-
* @param {Long|number|string} value Value
|
|
870
|
-
* @returns {util.LongBits} Instance
|
|
871
|
-
*/
|
|
872
|
-
LongBits.from = function from(value) {
|
|
873
|
-
if (typeof value === "number")
|
|
874
|
-
return LongBits.fromNumber(value);
|
|
875
|
-
if (util.isString(value)) {
|
|
876
|
-
/* istanbul ignore else */
|
|
877
|
-
if (util.Long)
|
|
878
|
-
value = util.Long.fromString(value);
|
|
879
|
-
else
|
|
880
|
-
return LongBits.fromNumber(parseInt(value, 10));
|
|
881
|
-
}
|
|
882
|
-
return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
/**
|
|
886
|
-
* Converts this long bits to a possibly unsafe JavaScript number.
|
|
887
|
-
* @param {boolean} [unsigned=false] Whether unsigned or not
|
|
888
|
-
* @returns {number} Possibly unsafe number
|
|
889
|
-
*/
|
|
890
|
-
LongBits.prototype.toNumber = function toNumber(unsigned) {
|
|
891
|
-
if (!unsigned && this.hi >>> 31) {
|
|
892
|
-
var lo = ~this.lo + 1 >>> 0,
|
|
893
|
-
hi = ~this.hi >>> 0;
|
|
894
|
-
if (!lo)
|
|
895
|
-
hi = hi + 1 >>> 0;
|
|
896
|
-
return -(lo + hi * 4294967296);
|
|
897
|
-
}
|
|
898
|
-
return this.lo + this.hi * 4294967296;
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
/**
|
|
902
|
-
* Converts this long bits to a long.
|
|
903
|
-
* @param {boolean} [unsigned=false] Whether unsigned or not
|
|
904
|
-
* @returns {Long} Long
|
|
905
|
-
*/
|
|
906
|
-
LongBits.prototype.toLong = function toLong(unsigned) {
|
|
907
|
-
return util.Long
|
|
908
|
-
? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
|
|
909
|
-
/* istanbul ignore next */
|
|
910
|
-
: { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
var charCodeAt = String.prototype.charCodeAt;
|
|
914
|
-
|
|
915
|
-
/**
|
|
916
|
-
* Constructs new long bits from the specified 8 characters long hash.
|
|
917
|
-
* @param {string} hash Hash
|
|
918
|
-
* @returns {util.LongBits} Bits
|
|
919
|
-
*/
|
|
920
|
-
LongBits.fromHash = function fromHash(hash) {
|
|
921
|
-
if (hash === zeroHash)
|
|
922
|
-
return zero;
|
|
923
|
-
return new LongBits(
|
|
924
|
-
( charCodeAt.call(hash, 0)
|
|
925
|
-
| charCodeAt.call(hash, 1) << 8
|
|
926
|
-
| charCodeAt.call(hash, 2) << 16
|
|
927
|
-
| charCodeAt.call(hash, 3) << 24) >>> 0
|
|
928
|
-
,
|
|
929
|
-
( charCodeAt.call(hash, 4)
|
|
930
|
-
| charCodeAt.call(hash, 5) << 8
|
|
931
|
-
| charCodeAt.call(hash, 6) << 16
|
|
932
|
-
| charCodeAt.call(hash, 7) << 24) >>> 0
|
|
933
|
-
);
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
/**
|
|
937
|
-
* Converts this long bits to a 8 characters long hash.
|
|
938
|
-
* @returns {string} Hash
|
|
939
|
-
*/
|
|
940
|
-
LongBits.prototype.toHash = function toHash() {
|
|
941
|
-
return String.fromCharCode(
|
|
942
|
-
this.lo & 255,
|
|
943
|
-
this.lo >>> 8 & 255,
|
|
944
|
-
this.lo >>> 16 & 255,
|
|
945
|
-
this.lo >>> 24 ,
|
|
946
|
-
this.hi & 255,
|
|
947
|
-
this.hi >>> 8 & 255,
|
|
948
|
-
this.hi >>> 16 & 255,
|
|
949
|
-
this.hi >>> 24
|
|
950
|
-
);
|
|
951
|
-
};
|
|
952
|
-
|
|
953
|
-
/**
|
|
954
|
-
* Zig-zag encodes this long bits.
|
|
955
|
-
* @returns {util.LongBits} `this`
|
|
956
|
-
*/
|
|
957
|
-
LongBits.prototype.zzEncode = function zzEncode() {
|
|
958
|
-
var mask = this.hi >> 31;
|
|
959
|
-
this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
|
|
960
|
-
this.lo = ( this.lo << 1 ^ mask) >>> 0;
|
|
961
|
-
return this;
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
/**
|
|
965
|
-
* Zig-zag decodes this long bits.
|
|
966
|
-
* @returns {util.LongBits} `this`
|
|
967
|
-
*/
|
|
968
|
-
LongBits.prototype.zzDecode = function zzDecode() {
|
|
969
|
-
var mask = -(this.lo & 1);
|
|
970
|
-
this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
|
|
971
|
-
this.hi = ( this.hi >>> 1 ^ mask) >>> 0;
|
|
972
|
-
return this;
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
/**
|
|
976
|
-
* Calculates the length of this longbits when encoded as a varint.
|
|
977
|
-
* @returns {number} Length
|
|
978
|
-
*/
|
|
979
|
-
LongBits.prototype.length = function length() {
|
|
980
|
-
var part0 = this.lo,
|
|
981
|
-
part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
|
|
982
|
-
part2 = this.hi >>> 24;
|
|
983
|
-
return part2 === 0
|
|
984
|
-
? part1 === 0
|
|
985
|
-
? part0 < 16384
|
|
986
|
-
? part0 < 128 ? 1 : 2
|
|
987
|
-
: part0 < 2097152 ? 3 : 4
|
|
988
|
-
: part1 < 16384
|
|
989
|
-
? part1 < 128 ? 5 : 6
|
|
990
|
-
: part1 < 2097152 ? 7 : 8
|
|
991
|
-
: part2 < 128 ? 9 : 10;
|
|
992
|
-
};
|
|
993
|
-
return longbits;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
var hasRequiredMinimal;
|
|
997
|
-
|
|
998
|
-
function requireMinimal () {
|
|
999
|
-
if (hasRequiredMinimal) return minimal$1;
|
|
1000
|
-
hasRequiredMinimal = 1;
|
|
1001
|
-
(function (exports) {
|
|
1002
|
-
var util = exports;
|
|
1003
|
-
|
|
1004
|
-
// used to return a Promise where callback is omitted
|
|
1005
|
-
util.asPromise = aspromise;
|
|
1006
|
-
|
|
1007
|
-
// converts to / from base64 encoded strings
|
|
1008
|
-
util.base64 = base64$1;
|
|
1009
|
-
|
|
1010
|
-
// base class of rpc.Service
|
|
1011
|
-
util.EventEmitter = eventemitter;
|
|
1012
|
-
|
|
1013
|
-
// float handling accross browsers
|
|
1014
|
-
util.float = float;
|
|
1015
|
-
|
|
1016
|
-
// requires modules optionally and hides the call from bundlers
|
|
1017
|
-
util.inquire = inquire_1;
|
|
1018
|
-
|
|
1019
|
-
// converts to / from utf8 encoded strings
|
|
1020
|
-
util.utf8 = utf8$2;
|
|
1021
|
-
|
|
1022
|
-
// provides a node-like buffer pool in the browser
|
|
1023
|
-
util.pool = pool_1;
|
|
1024
|
-
|
|
1025
|
-
// utility to work with the low and high bits of a 64 bit value
|
|
1026
|
-
util.LongBits = requireLongbits();
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* Whether running within node or not.
|
|
1030
|
-
* @memberof util
|
|
1031
|
-
* @type {boolean}
|
|
1032
|
-
*/
|
|
1033
|
-
util.isNode = Boolean(typeof commonjsGlobal !== "undefined"
|
|
1034
|
-
&& commonjsGlobal
|
|
1035
|
-
&& commonjsGlobal.process
|
|
1036
|
-
&& commonjsGlobal.process.versions
|
|
1037
|
-
&& commonjsGlobal.process.versions.node);
|
|
1038
|
-
|
|
1039
|
-
/**
|
|
1040
|
-
* Global object reference.
|
|
1041
|
-
* @memberof util
|
|
1042
|
-
* @type {Object}
|
|
1043
|
-
*/
|
|
1044
|
-
util.global = util.isNode && commonjsGlobal
|
|
1045
|
-
|| typeof window !== "undefined" && window
|
|
1046
|
-
|| typeof self !== "undefined" && self
|
|
1047
|
-
|| commonjsGlobal; // eslint-disable-line no-invalid-this
|
|
1048
|
-
|
|
1049
|
-
/**
|
|
1050
|
-
* An immuable empty array.
|
|
1051
|
-
* @memberof util
|
|
1052
|
-
* @type {Array.<*>}
|
|
1053
|
-
* @const
|
|
1054
|
-
*/
|
|
1055
|
-
util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes
|
|
1056
|
-
|
|
1057
|
-
/**
|
|
1058
|
-
* An immutable empty object.
|
|
1059
|
-
* @type {Object}
|
|
1060
|
-
* @const
|
|
1061
|
-
*/
|
|
1062
|
-
util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes
|
|
1063
|
-
|
|
1064
|
-
/**
|
|
1065
|
-
* Tests if the specified value is an integer.
|
|
1066
|
-
* @function
|
|
1067
|
-
* @param {*} value Value to test
|
|
1068
|
-
* @returns {boolean} `true` if the value is an integer
|
|
1069
|
-
*/
|
|
1070
|
-
util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {
|
|
1071
|
-
return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
|
|
1072
|
-
};
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Tests if the specified value is a string.
|
|
1076
|
-
* @param {*} value Value to test
|
|
1077
|
-
* @returns {boolean} `true` if the value is a string
|
|
1078
|
-
*/
|
|
1079
|
-
util.isString = function isString(value) {
|
|
1080
|
-
return typeof value === "string" || value instanceof String;
|
|
1081
|
-
};
|
|
1082
|
-
|
|
1083
|
-
/**
|
|
1084
|
-
* Tests if the specified value is a non-null object.
|
|
1085
|
-
* @param {*} value Value to test
|
|
1086
|
-
* @returns {boolean} `true` if the value is a non-null object
|
|
1087
|
-
*/
|
|
1088
|
-
util.isObject = function isObject(value) {
|
|
1089
|
-
return value && typeof value === "object";
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
|
-
/**
|
|
1093
|
-
* Checks if a property on a message is considered to be present.
|
|
1094
|
-
* This is an alias of {@link util.isSet}.
|
|
1095
|
-
* @function
|
|
1096
|
-
* @param {Object} obj Plain object or message instance
|
|
1097
|
-
* @param {string} prop Property name
|
|
1098
|
-
* @returns {boolean} `true` if considered to be present, otherwise `false`
|
|
1099
|
-
*/
|
|
1100
|
-
util.isset =
|
|
1101
|
-
|
|
1102
|
-
/**
|
|
1103
|
-
* Checks if a property on a message is considered to be present.
|
|
1104
|
-
* @param {Object} obj Plain object or message instance
|
|
1105
|
-
* @param {string} prop Property name
|
|
1106
|
-
* @returns {boolean} `true` if considered to be present, otherwise `false`
|
|
1107
|
-
*/
|
|
1108
|
-
util.isSet = function isSet(obj, prop) {
|
|
1109
|
-
var value = obj[prop];
|
|
1110
|
-
if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins
|
|
1111
|
-
return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
|
|
1112
|
-
return false;
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
/**
|
|
1116
|
-
* Any compatible Buffer instance.
|
|
1117
|
-
* This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
|
|
1118
|
-
* @interface Buffer
|
|
1119
|
-
* @extends Uint8Array
|
|
1120
|
-
*/
|
|
1121
|
-
|
|
1122
|
-
/**
|
|
1123
|
-
* Node's Buffer class if available.
|
|
1124
|
-
* @type {Constructor<Buffer>}
|
|
1125
|
-
*/
|
|
1126
|
-
util.Buffer = (function() {
|
|
1127
|
-
try {
|
|
1128
|
-
var Buffer = util.inquire("buffer").Buffer;
|
|
1129
|
-
// refuse to use non-node buffers if not explicitly assigned (perf reasons):
|
|
1130
|
-
return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;
|
|
1131
|
-
} catch (e) {
|
|
1132
|
-
/* istanbul ignore next */
|
|
1133
|
-
return null;
|
|
1134
|
-
}
|
|
1135
|
-
})();
|
|
1136
|
-
|
|
1137
|
-
// Internal alias of or polyfull for Buffer.from.
|
|
1138
|
-
util._Buffer_from = null;
|
|
1139
|
-
|
|
1140
|
-
// Internal alias of or polyfill for Buffer.allocUnsafe.
|
|
1141
|
-
util._Buffer_allocUnsafe = null;
|
|
1142
|
-
|
|
1143
|
-
/**
|
|
1144
|
-
* Creates a new buffer of whatever type supported by the environment.
|
|
1145
|
-
* @param {number|number[]} [sizeOrArray=0] Buffer size or number array
|
|
1146
|
-
* @returns {Uint8Array|Buffer} Buffer
|
|
1147
|
-
*/
|
|
1148
|
-
util.newBuffer = function newBuffer(sizeOrArray) {
|
|
1149
|
-
/* istanbul ignore next */
|
|
1150
|
-
return typeof sizeOrArray === "number"
|
|
1151
|
-
? util.Buffer
|
|
1152
|
-
? util._Buffer_allocUnsafe(sizeOrArray)
|
|
1153
|
-
: new util.Array(sizeOrArray)
|
|
1154
|
-
: util.Buffer
|
|
1155
|
-
? util._Buffer_from(sizeOrArray)
|
|
1156
|
-
: typeof Uint8Array === "undefined"
|
|
1157
|
-
? sizeOrArray
|
|
1158
|
-
: new Uint8Array(sizeOrArray);
|
|
1159
|
-
};
|
|
1160
|
-
|
|
1161
|
-
/**
|
|
1162
|
-
* Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
|
|
1163
|
-
* @type {Constructor<Uint8Array>}
|
|
1164
|
-
*/
|
|
1165
|
-
util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array;
|
|
1166
|
-
|
|
1167
|
-
/**
|
|
1168
|
-
* Any compatible Long instance.
|
|
1169
|
-
* This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
|
|
1170
|
-
* @interface Long
|
|
1171
|
-
* @property {number} low Low bits
|
|
1172
|
-
* @property {number} high High bits
|
|
1173
|
-
* @property {boolean} unsigned Whether unsigned or not
|
|
1174
|
-
*/
|
|
1175
|
-
|
|
1176
|
-
/**
|
|
1177
|
-
* Long.js's Long class if available.
|
|
1178
|
-
* @type {Constructor<Long>}
|
|
1179
|
-
*/
|
|
1180
|
-
util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
|
|
1181
|
-
|| /* istanbul ignore next */ util.global.Long
|
|
1182
|
-
|| util.inquire("long");
|
|
1183
|
-
|
|
1184
|
-
/**
|
|
1185
|
-
* Regular expression used to verify 2 bit (`bool`) map keys.
|
|
1186
|
-
* @type {RegExp}
|
|
1187
|
-
* @const
|
|
1188
|
-
*/
|
|
1189
|
-
util.key2Re = /^true|false|0|1$/;
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* Regular expression used to verify 32 bit (`int32` etc.) map keys.
|
|
1193
|
-
* @type {RegExp}
|
|
1194
|
-
* @const
|
|
1195
|
-
*/
|
|
1196
|
-
util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* Regular expression used to verify 64 bit (`int64` etc.) map keys.
|
|
1200
|
-
* @type {RegExp}
|
|
1201
|
-
* @const
|
|
1202
|
-
*/
|
|
1203
|
-
util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
|
|
1204
|
-
|
|
1205
|
-
/**
|
|
1206
|
-
* Converts a number or long to an 8 characters long hash string.
|
|
1207
|
-
* @param {Long|number} value Value to convert
|
|
1208
|
-
* @returns {string} Hash
|
|
1209
|
-
*/
|
|
1210
|
-
util.longToHash = function longToHash(value) {
|
|
1211
|
-
return value
|
|
1212
|
-
? util.LongBits.from(value).toHash()
|
|
1213
|
-
: util.LongBits.zeroHash;
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
/**
|
|
1217
|
-
* Converts an 8 characters long hash string to a long or number.
|
|
1218
|
-
* @param {string} hash Hash
|
|
1219
|
-
* @param {boolean} [unsigned=false] Whether unsigned or not
|
|
1220
|
-
* @returns {Long|number} Original value
|
|
1221
|
-
*/
|
|
1222
|
-
util.longFromHash = function longFromHash(hash, unsigned) {
|
|
1223
|
-
var bits = util.LongBits.fromHash(hash);
|
|
1224
|
-
if (util.Long)
|
|
1225
|
-
return util.Long.fromBits(bits.lo, bits.hi, unsigned);
|
|
1226
|
-
return bits.toNumber(Boolean(unsigned));
|
|
1227
|
-
};
|
|
1228
|
-
|
|
1229
|
-
/**
|
|
1230
|
-
* Merges the properties of the source object into the destination object.
|
|
1231
|
-
* @memberof util
|
|
1232
|
-
* @param {Object.<string,*>} dst Destination object
|
|
1233
|
-
* @param {Object.<string,*>} src Source object
|
|
1234
|
-
* @param {boolean} [ifNotSet=false] Merges only if the key is not already set
|
|
1235
|
-
* @returns {Object.<string,*>} Destination object
|
|
1236
|
-
*/
|
|
1237
|
-
function merge(dst, src, ifNotSet) { // used by converters
|
|
1238
|
-
for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
|
|
1239
|
-
if (dst[keys[i]] === undefined || !ifNotSet)
|
|
1240
|
-
dst[keys[i]] = src[keys[i]];
|
|
1241
|
-
return dst;
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
util.merge = merge;
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
* Converts the first character of a string to lower case.
|
|
1248
|
-
* @param {string} str String to convert
|
|
1249
|
-
* @returns {string} Converted string
|
|
1250
|
-
*/
|
|
1251
|
-
util.lcFirst = function lcFirst(str) {
|
|
1252
|
-
return str.charAt(0).toLowerCase() + str.substring(1);
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
|
-
/**
|
|
1256
|
-
* Creates a custom error constructor.
|
|
1257
|
-
* @memberof util
|
|
1258
|
-
* @param {string} name Error name
|
|
1259
|
-
* @returns {Constructor<Error>} Custom error constructor
|
|
1260
|
-
*/
|
|
1261
|
-
function newError(name) {
|
|
1262
|
-
|
|
1263
|
-
function CustomError(message, properties) {
|
|
1264
|
-
|
|
1265
|
-
if (!(this instanceof CustomError))
|
|
1266
|
-
return new CustomError(message, properties);
|
|
1267
|
-
|
|
1268
|
-
// Error.call(this, message);
|
|
1269
|
-
// ^ just returns a new error instance because the ctor can be called as a function
|
|
1270
|
-
|
|
1271
|
-
Object.defineProperty(this, "message", { get: function() { return message; } });
|
|
1272
|
-
|
|
1273
|
-
/* istanbul ignore next */
|
|
1274
|
-
if (Error.captureStackTrace) // node
|
|
1275
|
-
Error.captureStackTrace(this, CustomError);
|
|
1276
|
-
else
|
|
1277
|
-
Object.defineProperty(this, "stack", { value: new Error().stack || "" });
|
|
1278
|
-
|
|
1279
|
-
if (properties)
|
|
1280
|
-
merge(this, properties);
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
CustomError.prototype = Object.create(Error.prototype, {
|
|
1284
|
-
constructor: {
|
|
1285
|
-
value: CustomError,
|
|
1286
|
-
writable: true,
|
|
1287
|
-
enumerable: false,
|
|
1288
|
-
configurable: true,
|
|
1289
|
-
},
|
|
1290
|
-
name: {
|
|
1291
|
-
get: function get() { return name; },
|
|
1292
|
-
set: undefined,
|
|
1293
|
-
enumerable: false,
|
|
1294
|
-
// configurable: false would accurately preserve the behavior of
|
|
1295
|
-
// the original, but I'm guessing that was not intentional.
|
|
1296
|
-
// For an actual error subclass, this property would
|
|
1297
|
-
// be configurable.
|
|
1298
|
-
configurable: true,
|
|
1299
|
-
},
|
|
1300
|
-
toString: {
|
|
1301
|
-
value: function value() { return this.name + ": " + this.message; },
|
|
1302
|
-
writable: true,
|
|
1303
|
-
enumerable: false,
|
|
1304
|
-
configurable: true,
|
|
1305
|
-
},
|
|
1306
|
-
});
|
|
1307
|
-
|
|
1308
|
-
return CustomError;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
util.newError = newError;
|
|
1312
|
-
|
|
1313
|
-
/**
|
|
1314
|
-
* Constructs a new protocol error.
|
|
1315
|
-
* @classdesc Error subclass indicating a protocol specifc error.
|
|
1316
|
-
* @memberof util
|
|
1317
|
-
* @extends Error
|
|
1318
|
-
* @template T extends Message<T>
|
|
1319
|
-
* @constructor
|
|
1320
|
-
* @param {string} message Error message
|
|
1321
|
-
* @param {Object.<string,*>} [properties] Additional properties
|
|
1322
|
-
* @example
|
|
1323
|
-
* try {
|
|
1324
|
-
* MyMessage.decode(someBuffer); // throws if required fields are missing
|
|
1325
|
-
* } catch (e) {
|
|
1326
|
-
* if (e instanceof ProtocolError && e.instance)
|
|
1327
|
-
* console.log("decoded so far: " + JSON.stringify(e.instance));
|
|
1328
|
-
* }
|
|
1329
|
-
*/
|
|
1330
|
-
util.ProtocolError = newError("ProtocolError");
|
|
1331
|
-
|
|
1332
|
-
/**
|
|
1333
|
-
* So far decoded message instance.
|
|
1334
|
-
* @name util.ProtocolError#instance
|
|
1335
|
-
* @type {Message<T>}
|
|
1336
|
-
*/
|
|
1337
|
-
|
|
1338
|
-
/**
|
|
1339
|
-
* A OneOf getter as returned by {@link util.oneOfGetter}.
|
|
1340
|
-
* @typedef OneOfGetter
|
|
1341
|
-
* @type {function}
|
|
1342
|
-
* @returns {string|undefined} Set field name, if any
|
|
1343
|
-
*/
|
|
1344
|
-
|
|
1345
|
-
/**
|
|
1346
|
-
* Builds a getter for a oneof's present field name.
|
|
1347
|
-
* @param {string[]} fieldNames Field names
|
|
1348
|
-
* @returns {OneOfGetter} Unbound getter
|
|
1349
|
-
*/
|
|
1350
|
-
util.oneOfGetter = function getOneOf(fieldNames) {
|
|
1351
|
-
var fieldMap = {};
|
|
1352
|
-
for (var i = 0; i < fieldNames.length; ++i)
|
|
1353
|
-
fieldMap[fieldNames[i]] = 1;
|
|
1354
|
-
|
|
1355
|
-
/**
|
|
1356
|
-
* @returns {string|undefined} Set field name, if any
|
|
1357
|
-
* @this Object
|
|
1358
|
-
* @ignore
|
|
1359
|
-
*/
|
|
1360
|
-
return function() { // eslint-disable-line consistent-return
|
|
1361
|
-
for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i)
|
|
1362
|
-
if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null)
|
|
1363
|
-
return keys[i];
|
|
1364
|
-
};
|
|
1365
|
-
};
|
|
1366
|
-
|
|
1367
|
-
/**
|
|
1368
|
-
* A OneOf setter as returned by {@link util.oneOfSetter}.
|
|
1369
|
-
* @typedef OneOfSetter
|
|
1370
|
-
* @type {function}
|
|
1371
|
-
* @param {string|undefined} value Field name
|
|
1372
|
-
* @returns {undefined}
|
|
1373
|
-
*/
|
|
1374
|
-
|
|
1375
|
-
/**
|
|
1376
|
-
* Builds a setter for a oneof's present field name.
|
|
1377
|
-
* @param {string[]} fieldNames Field names
|
|
1378
|
-
* @returns {OneOfSetter} Unbound setter
|
|
1379
|
-
*/
|
|
1380
|
-
util.oneOfSetter = function setOneOf(fieldNames) {
|
|
1381
|
-
|
|
1382
|
-
/**
|
|
1383
|
-
* @param {string} name Field name
|
|
1384
|
-
* @returns {undefined}
|
|
1385
|
-
* @this Object
|
|
1386
|
-
* @ignore
|
|
1387
|
-
*/
|
|
1388
|
-
return function(name) {
|
|
1389
|
-
for (var i = 0; i < fieldNames.length; ++i)
|
|
1390
|
-
if (fieldNames[i] !== name)
|
|
1391
|
-
delete this[fieldNames[i]];
|
|
1392
|
-
};
|
|
1393
|
-
};
|
|
1394
|
-
|
|
1395
|
-
/**
|
|
1396
|
-
* Default conversion options used for {@link Message#toJSON} implementations.
|
|
1397
|
-
*
|
|
1398
|
-
* These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
|
|
1399
|
-
*
|
|
1400
|
-
* - Longs become strings
|
|
1401
|
-
* - Enums become string keys
|
|
1402
|
-
* - Bytes become base64 encoded strings
|
|
1403
|
-
* - (Sub-)Messages become plain objects
|
|
1404
|
-
* - Maps become plain objects with all string keys
|
|
1405
|
-
* - Repeated fields become arrays
|
|
1406
|
-
* - NaN and Infinity for float and double fields become strings
|
|
1407
|
-
*
|
|
1408
|
-
* @type {IConversionOptions}
|
|
1409
|
-
* @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
|
|
1410
|
-
*/
|
|
1411
|
-
util.toJSONOptions = {
|
|
1412
|
-
longs: String,
|
|
1413
|
-
enums: String,
|
|
1414
|
-
bytes: String,
|
|
1415
|
-
json: true
|
|
1416
|
-
};
|
|
1417
|
-
|
|
1418
|
-
// Sets up buffer utility according to the environment (called in index-minimal)
|
|
1419
|
-
util._configure = function() {
|
|
1420
|
-
var Buffer = util.Buffer;
|
|
1421
|
-
/* istanbul ignore if */
|
|
1422
|
-
if (!Buffer) {
|
|
1423
|
-
util._Buffer_from = util._Buffer_allocUnsafe = null;
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
// because node 4.x buffers are incompatible & immutable
|
|
1427
|
-
// see: https://github.com/dcodeIO/protobuf.js/pull/665
|
|
1428
|
-
util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||
|
|
1429
|
-
/* istanbul ignore next */
|
|
1430
|
-
function Buffer_from(value, encoding) {
|
|
1431
|
-
return new Buffer(value, encoding);
|
|
1432
|
-
};
|
|
1433
|
-
util._Buffer_allocUnsafe = Buffer.allocUnsafe ||
|
|
1434
|
-
/* istanbul ignore next */
|
|
1435
|
-
function Buffer_allocUnsafe(size) {
|
|
1436
|
-
return new Buffer(size);
|
|
1437
|
-
};
|
|
1438
|
-
};
|
|
1439
|
-
} (minimal$1));
|
|
1440
|
-
return minimal$1;
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
var writer = Writer$1;
|
|
1444
|
-
|
|
1445
|
-
var util$4 = requireMinimal();
|
|
1446
|
-
|
|
1447
|
-
var BufferWriter$1; // cyclic
|
|
1448
|
-
|
|
1449
|
-
var LongBits$1 = util$4.LongBits,
|
|
1450
|
-
base64 = util$4.base64,
|
|
1451
|
-
utf8$1 = util$4.utf8;
|
|
1452
|
-
|
|
1453
|
-
/**
|
|
1454
|
-
* Constructs a new writer operation instance.
|
|
1455
|
-
* @classdesc Scheduled writer operation.
|
|
1456
|
-
* @constructor
|
|
1457
|
-
* @param {function(*, Uint8Array, number)} fn Function to call
|
|
1458
|
-
* @param {number} len Value byte length
|
|
1459
|
-
* @param {*} val Value to write
|
|
1460
|
-
* @ignore
|
|
1461
|
-
*/
|
|
1462
|
-
function Op(fn, len, val) {
|
|
1463
|
-
|
|
1464
|
-
/**
|
|
1465
|
-
* Function to call.
|
|
1466
|
-
* @type {function(Uint8Array, number, *)}
|
|
1467
|
-
*/
|
|
1468
|
-
this.fn = fn;
|
|
1469
|
-
|
|
1470
|
-
/**
|
|
1471
|
-
* Value byte length.
|
|
1472
|
-
* @type {number}
|
|
1473
|
-
*/
|
|
1474
|
-
this.len = len;
|
|
1475
|
-
|
|
1476
|
-
/**
|
|
1477
|
-
* Next operation.
|
|
1478
|
-
* @type {Writer.Op|undefined}
|
|
1479
|
-
*/
|
|
1480
|
-
this.next = undefined;
|
|
1481
|
-
|
|
1482
|
-
/**
|
|
1483
|
-
* Value to write.
|
|
1484
|
-
* @type {*}
|
|
1485
|
-
*/
|
|
1486
|
-
this.val = val; // type varies
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
/* istanbul ignore next */
|
|
1490
|
-
function noop() {} // eslint-disable-line no-empty-function
|
|
1491
|
-
|
|
1492
|
-
/**
|
|
1493
|
-
* Constructs a new writer state instance.
|
|
1494
|
-
* @classdesc Copied writer state.
|
|
1495
|
-
* @memberof Writer
|
|
1496
|
-
* @constructor
|
|
1497
|
-
* @param {Writer} writer Writer to copy state from
|
|
1498
|
-
* @ignore
|
|
1499
|
-
*/
|
|
1500
|
-
function State(writer) {
|
|
1501
|
-
|
|
1502
|
-
/**
|
|
1503
|
-
* Current head.
|
|
1504
|
-
* @type {Writer.Op}
|
|
1505
|
-
*/
|
|
1506
|
-
this.head = writer.head;
|
|
1507
|
-
|
|
1508
|
-
/**
|
|
1509
|
-
* Current tail.
|
|
1510
|
-
* @type {Writer.Op}
|
|
1511
|
-
*/
|
|
1512
|
-
this.tail = writer.tail;
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
* Current buffer length.
|
|
1516
|
-
* @type {number}
|
|
1517
|
-
*/
|
|
1518
|
-
this.len = writer.len;
|
|
1519
|
-
|
|
1520
|
-
/**
|
|
1521
|
-
* Next state.
|
|
1522
|
-
* @type {State|null}
|
|
1523
|
-
*/
|
|
1524
|
-
this.next = writer.states;
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
/**
|
|
1528
|
-
* Constructs a new writer instance.
|
|
1529
|
-
* @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`.
|
|
1530
|
-
* @constructor
|
|
1531
|
-
*/
|
|
1532
|
-
function Writer$1() {
|
|
1533
|
-
|
|
1534
|
-
/**
|
|
1535
|
-
* Current length.
|
|
1536
|
-
* @type {number}
|
|
1537
|
-
*/
|
|
1538
|
-
this.len = 0;
|
|
1539
|
-
|
|
1540
|
-
/**
|
|
1541
|
-
* Operations head.
|
|
1542
|
-
* @type {Object}
|
|
1543
|
-
*/
|
|
1544
|
-
this.head = new Op(noop, 0, 0);
|
|
1545
|
-
|
|
1546
|
-
/**
|
|
1547
|
-
* Operations tail
|
|
1548
|
-
* @type {Object}
|
|
1549
|
-
*/
|
|
1550
|
-
this.tail = this.head;
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
* Linked forked states.
|
|
1554
|
-
* @type {Object|null}
|
|
1555
|
-
*/
|
|
1556
|
-
this.states = null;
|
|
1557
|
-
|
|
1558
|
-
// When a value is written, the writer calculates its byte length and puts it into a linked
|
|
1559
|
-
// list of operations to perform when finish() is called. This both allows us to allocate
|
|
1560
|
-
// buffers of the exact required size and reduces the amount of work we have to do compared
|
|
1561
|
-
// to first calculating over objects and then encoding over objects. In our case, the encoding
|
|
1562
|
-
// part is just a linked list walk calling operations with already prepared values.
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
var create$1 = function create() {
|
|
1566
|
-
return util$4.Buffer
|
|
1567
|
-
? function create_buffer_setup() {
|
|
1568
|
-
return (Writer$1.create = function create_buffer() {
|
|
1569
|
-
return new BufferWriter$1();
|
|
1570
|
-
})();
|
|
1571
|
-
}
|
|
1572
|
-
/* istanbul ignore next */
|
|
1573
|
-
: function create_array() {
|
|
1574
|
-
return new Writer$1();
|
|
1575
|
-
};
|
|
1576
|
-
};
|
|
1577
|
-
|
|
1578
|
-
/**
|
|
1579
|
-
* Creates a new writer.
|
|
1580
|
-
* @function
|
|
1581
|
-
* @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer}
|
|
1582
|
-
*/
|
|
1583
|
-
Writer$1.create = create$1();
|
|
1584
|
-
|
|
1585
|
-
/**
|
|
1586
|
-
* Allocates a buffer of the specified size.
|
|
1587
|
-
* @param {number} size Buffer size
|
|
1588
|
-
* @returns {Uint8Array} Buffer
|
|
1589
|
-
*/
|
|
1590
|
-
Writer$1.alloc = function alloc(size) {
|
|
1591
|
-
return new util$4.Array(size);
|
|
1592
|
-
};
|
|
1593
|
-
|
|
1594
|
-
// Use Uint8Array buffer pool in the browser, just like node does with buffers
|
|
1595
|
-
/* istanbul ignore else */
|
|
1596
|
-
if (util$4.Array !== Array)
|
|
1597
|
-
Writer$1.alloc = util$4.pool(Writer$1.alloc, util$4.Array.prototype.subarray);
|
|
1598
|
-
|
|
1599
|
-
/**
|
|
1600
|
-
* Pushes a new operation to the queue.
|
|
1601
|
-
* @param {function(Uint8Array, number, *)} fn Function to call
|
|
1602
|
-
* @param {number} len Value byte length
|
|
1603
|
-
* @param {number} val Value to write
|
|
1604
|
-
* @returns {Writer} `this`
|
|
1605
|
-
* @private
|
|
1606
|
-
*/
|
|
1607
|
-
Writer$1.prototype._push = function push(fn, len, val) {
|
|
1608
|
-
this.tail = this.tail.next = new Op(fn, len, val);
|
|
1609
|
-
this.len += len;
|
|
1610
|
-
return this;
|
|
1611
|
-
};
|
|
1612
|
-
|
|
1613
|
-
function writeByte(val, buf, pos) {
|
|
1614
|
-
buf[pos] = val & 255;
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
function writeVarint32(val, buf, pos) {
|
|
1618
|
-
while (val > 127) {
|
|
1619
|
-
buf[pos++] = val & 127 | 128;
|
|
1620
|
-
val >>>= 7;
|
|
1621
|
-
}
|
|
1622
|
-
buf[pos] = val;
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
/**
|
|
1626
|
-
* Constructs a new varint writer operation instance.
|
|
1627
|
-
* @classdesc Scheduled varint writer operation.
|
|
1628
|
-
* @extends Op
|
|
1629
|
-
* @constructor
|
|
1630
|
-
* @param {number} len Value byte length
|
|
1631
|
-
* @param {number} val Value to write
|
|
1632
|
-
* @ignore
|
|
1633
|
-
*/
|
|
1634
|
-
function VarintOp(len, val) {
|
|
1635
|
-
this.len = len;
|
|
1636
|
-
this.next = undefined;
|
|
1637
|
-
this.val = val;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
VarintOp.prototype = Object.create(Op.prototype);
|
|
1641
|
-
VarintOp.prototype.fn = writeVarint32;
|
|
1642
|
-
|
|
1643
|
-
/**
|
|
1644
|
-
* Writes an unsigned 32 bit value as a varint.
|
|
1645
|
-
* @param {number} value Value to write
|
|
1646
|
-
* @returns {Writer} `this`
|
|
1647
|
-
*/
|
|
1648
|
-
Writer$1.prototype.uint32 = function write_uint32(value) {
|
|
1649
|
-
// here, the call to this.push has been inlined and a varint specific Op subclass is used.
|
|
1650
|
-
// uint32 is by far the most frequently used operation and benefits significantly from this.
|
|
1651
|
-
this.len += (this.tail = this.tail.next = new VarintOp(
|
|
1652
|
-
(value = value >>> 0)
|
|
1653
|
-
< 128 ? 1
|
|
1654
|
-
: value < 16384 ? 2
|
|
1655
|
-
: value < 2097152 ? 3
|
|
1656
|
-
: value < 268435456 ? 4
|
|
1657
|
-
: 5,
|
|
1658
|
-
value)).len;
|
|
1659
|
-
return this;
|
|
1660
|
-
};
|
|
1661
|
-
|
|
1662
|
-
/**
|
|
1663
|
-
* Writes a signed 32 bit value as a varint.
|
|
1664
|
-
* @function
|
|
1665
|
-
* @param {number} value Value to write
|
|
1666
|
-
* @returns {Writer} `this`
|
|
1667
|
-
*/
|
|
1668
|
-
Writer$1.prototype.int32 = function write_int32(value) {
|
|
1669
|
-
return value < 0
|
|
1670
|
-
? this._push(writeVarint64, 10, LongBits$1.fromNumber(value)) // 10 bytes per spec
|
|
1671
|
-
: this.uint32(value);
|
|
1672
|
-
};
|
|
1673
|
-
|
|
1674
|
-
/**
|
|
1675
|
-
* Writes a 32 bit value as a varint, zig-zag encoded.
|
|
1676
|
-
* @param {number} value Value to write
|
|
1677
|
-
* @returns {Writer} `this`
|
|
1678
|
-
*/
|
|
1679
|
-
Writer$1.prototype.sint32 = function write_sint32(value) {
|
|
1680
|
-
return this.uint32((value << 1 ^ value >> 31) >>> 0);
|
|
1681
|
-
};
|
|
1682
|
-
|
|
1683
|
-
function writeVarint64(val, buf, pos) {
|
|
1684
|
-
while (val.hi) {
|
|
1685
|
-
buf[pos++] = val.lo & 127 | 128;
|
|
1686
|
-
val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
|
|
1687
|
-
val.hi >>>= 7;
|
|
1688
|
-
}
|
|
1689
|
-
while (val.lo > 127) {
|
|
1690
|
-
buf[pos++] = val.lo & 127 | 128;
|
|
1691
|
-
val.lo = val.lo >>> 7;
|
|
1692
|
-
}
|
|
1693
|
-
buf[pos++] = val.lo;
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
/**
|
|
1697
|
-
* Writes an unsigned 64 bit value as a varint.
|
|
1698
|
-
* @param {Long|number|string} value Value to write
|
|
1699
|
-
* @returns {Writer} `this`
|
|
1700
|
-
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
1701
|
-
*/
|
|
1702
|
-
Writer$1.prototype.uint64 = function write_uint64(value) {
|
|
1703
|
-
var bits = LongBits$1.from(value);
|
|
1704
|
-
return this._push(writeVarint64, bits.length(), bits);
|
|
1705
|
-
};
|
|
1706
|
-
|
|
1707
|
-
/**
|
|
1708
|
-
* Writes a signed 64 bit value as a varint.
|
|
1709
|
-
* @function
|
|
1710
|
-
* @param {Long|number|string} value Value to write
|
|
1711
|
-
* @returns {Writer} `this`
|
|
1712
|
-
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
1713
|
-
*/
|
|
1714
|
-
Writer$1.prototype.int64 = Writer$1.prototype.uint64;
|
|
1715
|
-
|
|
1716
|
-
/**
|
|
1717
|
-
* Writes a signed 64 bit value as a varint, zig-zag encoded.
|
|
1718
|
-
* @param {Long|number|string} value Value to write
|
|
1719
|
-
* @returns {Writer} `this`
|
|
1720
|
-
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
1721
|
-
*/
|
|
1722
|
-
Writer$1.prototype.sint64 = function write_sint64(value) {
|
|
1723
|
-
var bits = LongBits$1.from(value).zzEncode();
|
|
1724
|
-
return this._push(writeVarint64, bits.length(), bits);
|
|
1725
|
-
};
|
|
1726
|
-
|
|
1727
|
-
/**
|
|
1728
|
-
* Writes a boolish value as a varint.
|
|
1729
|
-
* @param {boolean} value Value to write
|
|
1730
|
-
* @returns {Writer} `this`
|
|
1731
|
-
*/
|
|
1732
|
-
Writer$1.prototype.bool = function write_bool(value) {
|
|
1733
|
-
return this._push(writeByte, 1, value ? 1 : 0);
|
|
1734
|
-
};
|
|
1735
|
-
|
|
1736
|
-
function writeFixed32(val, buf, pos) {
|
|
1737
|
-
buf[pos ] = val & 255;
|
|
1738
|
-
buf[pos + 1] = val >>> 8 & 255;
|
|
1739
|
-
buf[pos + 2] = val >>> 16 & 255;
|
|
1740
|
-
buf[pos + 3] = val >>> 24;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
/**
|
|
1744
|
-
* Writes an unsigned 32 bit value as fixed 32 bits.
|
|
1745
|
-
* @param {number} value Value to write
|
|
1746
|
-
* @returns {Writer} `this`
|
|
1747
|
-
*/
|
|
1748
|
-
Writer$1.prototype.fixed32 = function write_fixed32(value) {
|
|
1749
|
-
return this._push(writeFixed32, 4, value >>> 0);
|
|
1750
|
-
};
|
|
1751
|
-
|
|
1752
|
-
/**
|
|
1753
|
-
* Writes a signed 32 bit value as fixed 32 bits.
|
|
1754
|
-
* @function
|
|
1755
|
-
* @param {number} value Value to write
|
|
1756
|
-
* @returns {Writer} `this`
|
|
1757
|
-
*/
|
|
1758
|
-
Writer$1.prototype.sfixed32 = Writer$1.prototype.fixed32;
|
|
1759
|
-
|
|
1760
|
-
/**
|
|
1761
|
-
* Writes an unsigned 64 bit value as fixed 64 bits.
|
|
1762
|
-
* @param {Long|number|string} value Value to write
|
|
1763
|
-
* @returns {Writer} `this`
|
|
1764
|
-
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
1765
|
-
*/
|
|
1766
|
-
Writer$1.prototype.fixed64 = function write_fixed64(value) {
|
|
1767
|
-
var bits = LongBits$1.from(value);
|
|
1768
|
-
return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
|
|
1769
|
-
};
|
|
1770
|
-
|
|
1771
|
-
/**
|
|
1772
|
-
* Writes a signed 64 bit value as fixed 64 bits.
|
|
1773
|
-
* @function
|
|
1774
|
-
* @param {Long|number|string} value Value to write
|
|
1775
|
-
* @returns {Writer} `this`
|
|
1776
|
-
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
1777
|
-
*/
|
|
1778
|
-
Writer$1.prototype.sfixed64 = Writer$1.prototype.fixed64;
|
|
1779
|
-
|
|
1780
|
-
/**
|
|
1781
|
-
* Writes a float (32 bit).
|
|
1782
|
-
* @function
|
|
1783
|
-
* @param {number} value Value to write
|
|
1784
|
-
* @returns {Writer} `this`
|
|
1785
|
-
*/
|
|
1786
|
-
Writer$1.prototype.float = function write_float(value) {
|
|
1787
|
-
return this._push(util$4.float.writeFloatLE, 4, value);
|
|
1788
|
-
};
|
|
1789
|
-
|
|
1790
|
-
/**
|
|
1791
|
-
* Writes a double (64 bit float).
|
|
1792
|
-
* @function
|
|
1793
|
-
* @param {number} value Value to write
|
|
1794
|
-
* @returns {Writer} `this`
|
|
1795
|
-
*/
|
|
1796
|
-
Writer$1.prototype.double = function write_double(value) {
|
|
1797
|
-
return this._push(util$4.float.writeDoubleLE, 8, value);
|
|
1798
|
-
};
|
|
1799
|
-
|
|
1800
|
-
var writeBytes = util$4.Array.prototype.set
|
|
1801
|
-
? function writeBytes_set(val, buf, pos) {
|
|
1802
|
-
buf.set(val, pos); // also works for plain array values
|
|
1803
|
-
}
|
|
1804
|
-
/* istanbul ignore next */
|
|
1805
|
-
: function writeBytes_for(val, buf, pos) {
|
|
1806
|
-
for (var i = 0; i < val.length; ++i)
|
|
1807
|
-
buf[pos + i] = val[i];
|
|
1808
|
-
};
|
|
1809
|
-
|
|
1810
|
-
/**
|
|
1811
|
-
* Writes a sequence of bytes.
|
|
1812
|
-
* @param {Uint8Array|string} value Buffer or base64 encoded string to write
|
|
1813
|
-
* @returns {Writer} `this`
|
|
1814
|
-
*/
|
|
1815
|
-
Writer$1.prototype.bytes = function write_bytes(value) {
|
|
1816
|
-
var len = value.length >>> 0;
|
|
1817
|
-
if (!len)
|
|
1818
|
-
return this._push(writeByte, 1, 0);
|
|
1819
|
-
if (util$4.isString(value)) {
|
|
1820
|
-
var buf = Writer$1.alloc(len = base64.length(value));
|
|
1821
|
-
base64.decode(value, buf, 0);
|
|
1822
|
-
value = buf;
|
|
1823
|
-
}
|
|
1824
|
-
return this.uint32(len)._push(writeBytes, len, value);
|
|
1825
|
-
};
|
|
1826
|
-
|
|
1827
|
-
/**
|
|
1828
|
-
* Writes a string.
|
|
1829
|
-
* @param {string} value Value to write
|
|
1830
|
-
* @returns {Writer} `this`
|
|
1831
|
-
*/
|
|
1832
|
-
Writer$1.prototype.string = function write_string(value) {
|
|
1833
|
-
var len = utf8$1.length(value);
|
|
1834
|
-
return len
|
|
1835
|
-
? this.uint32(len)._push(utf8$1.write, len, value)
|
|
1836
|
-
: this._push(writeByte, 1, 0);
|
|
1837
|
-
};
|
|
1838
|
-
|
|
1839
|
-
/**
|
|
1840
|
-
* Forks this writer's state by pushing it to a stack.
|
|
1841
|
-
* Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
|
|
1842
|
-
* @returns {Writer} `this`
|
|
1843
|
-
*/
|
|
1844
|
-
Writer$1.prototype.fork = function fork() {
|
|
1845
|
-
this.states = new State(this);
|
|
1846
|
-
this.head = this.tail = new Op(noop, 0, 0);
|
|
1847
|
-
this.len = 0;
|
|
1848
|
-
return this;
|
|
1849
|
-
};
|
|
1850
|
-
|
|
1851
|
-
/**
|
|
1852
|
-
* Resets this instance to the last state.
|
|
1853
|
-
* @returns {Writer} `this`
|
|
1854
|
-
*/
|
|
1855
|
-
Writer$1.prototype.reset = function reset() {
|
|
1856
|
-
if (this.states) {
|
|
1857
|
-
this.head = this.states.head;
|
|
1858
|
-
this.tail = this.states.tail;
|
|
1859
|
-
this.len = this.states.len;
|
|
1860
|
-
this.states = this.states.next;
|
|
1861
|
-
} else {
|
|
1862
|
-
this.head = this.tail = new Op(noop, 0, 0);
|
|
1863
|
-
this.len = 0;
|
|
1864
|
-
}
|
|
1865
|
-
return this;
|
|
1866
|
-
};
|
|
1867
|
-
|
|
1868
|
-
/**
|
|
1869
|
-
* Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
|
|
1870
|
-
* @returns {Writer} `this`
|
|
1871
|
-
*/
|
|
1872
|
-
Writer$1.prototype.ldelim = function ldelim() {
|
|
1873
|
-
var head = this.head,
|
|
1874
|
-
tail = this.tail,
|
|
1875
|
-
len = this.len;
|
|
1876
|
-
this.reset().uint32(len);
|
|
1877
|
-
if (len) {
|
|
1878
|
-
this.tail.next = head.next; // skip noop
|
|
1879
|
-
this.tail = tail;
|
|
1880
|
-
this.len += len;
|
|
1881
|
-
}
|
|
1882
|
-
return this;
|
|
1883
|
-
};
|
|
1884
|
-
|
|
1885
|
-
/**
|
|
1886
|
-
* Finishes the write operation.
|
|
1887
|
-
* @returns {Uint8Array} Finished buffer
|
|
1888
|
-
*/
|
|
1889
|
-
Writer$1.prototype.finish = function finish() {
|
|
1890
|
-
var head = this.head.next, // skip noop
|
|
1891
|
-
buf = this.constructor.alloc(this.len),
|
|
1892
|
-
pos = 0;
|
|
1893
|
-
while (head) {
|
|
1894
|
-
head.fn(head.val, buf, pos);
|
|
1895
|
-
pos += head.len;
|
|
1896
|
-
head = head.next;
|
|
1897
|
-
}
|
|
1898
|
-
// this.head = this.tail = null;
|
|
1899
|
-
return buf;
|
|
1900
|
-
};
|
|
1901
|
-
|
|
1902
|
-
Writer$1._configure = function(BufferWriter_) {
|
|
1903
|
-
BufferWriter$1 = BufferWriter_;
|
|
1904
|
-
Writer$1.create = create$1();
|
|
1905
|
-
BufferWriter$1._configure();
|
|
1906
|
-
};
|
|
1907
|
-
|
|
1908
|
-
var writer_buffer = BufferWriter;
|
|
1909
|
-
|
|
1910
|
-
// extends Writer
|
|
1911
|
-
var Writer = writer;
|
|
1912
|
-
(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
|
|
1913
|
-
|
|
1914
|
-
var util$3 = requireMinimal();
|
|
1915
|
-
|
|
1916
|
-
/**
|
|
1917
|
-
* Constructs a new buffer writer instance.
|
|
1918
|
-
* @classdesc Wire format writer using node buffers.
|
|
1919
|
-
* @extends Writer
|
|
1920
|
-
* @constructor
|
|
1921
|
-
*/
|
|
1922
|
-
function BufferWriter() {
|
|
1923
|
-
Writer.call(this);
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
BufferWriter._configure = function () {
|
|
1927
|
-
/**
|
|
1928
|
-
* Allocates a buffer of the specified size.
|
|
1929
|
-
* @function
|
|
1930
|
-
* @param {number} size Buffer size
|
|
1931
|
-
* @returns {Buffer} Buffer
|
|
1932
|
-
*/
|
|
1933
|
-
BufferWriter.alloc = util$3._Buffer_allocUnsafe;
|
|
1934
|
-
|
|
1935
|
-
BufferWriter.writeBytesBuffer = util$3.Buffer && util$3.Buffer.prototype instanceof Uint8Array && util$3.Buffer.prototype.set.name === "set"
|
|
1936
|
-
? function writeBytesBuffer_set(val, buf, pos) {
|
|
1937
|
-
buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)
|
|
1938
|
-
// also works for plain array values
|
|
1939
|
-
}
|
|
1940
|
-
/* istanbul ignore next */
|
|
1941
|
-
: function writeBytesBuffer_copy(val, buf, pos) {
|
|
1942
|
-
if (val.copy) // Buffer values
|
|
1943
|
-
val.copy(buf, pos, 0, val.length);
|
|
1944
|
-
else for (var i = 0; i < val.length;) // plain array values
|
|
1945
|
-
buf[pos++] = val[i++];
|
|
1946
|
-
};
|
|
1947
|
-
};
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
/**
|
|
1951
|
-
* @override
|
|
1952
|
-
*/
|
|
1953
|
-
BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
|
|
1954
|
-
if (util$3.isString(value))
|
|
1955
|
-
value = util$3._Buffer_from(value, "base64");
|
|
1956
|
-
var len = value.length >>> 0;
|
|
1957
|
-
this.uint32(len);
|
|
1958
|
-
if (len)
|
|
1959
|
-
this._push(BufferWriter.writeBytesBuffer, len, value);
|
|
1960
|
-
return this;
|
|
1961
|
-
};
|
|
1962
|
-
|
|
1963
|
-
function writeStringBuffer(val, buf, pos) {
|
|
1964
|
-
if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)
|
|
1965
|
-
util$3.utf8.write(val, buf, pos);
|
|
1966
|
-
else if (buf.utf8Write)
|
|
1967
|
-
buf.utf8Write(val, pos);
|
|
1968
|
-
else
|
|
1969
|
-
buf.write(val, pos);
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
/**
|
|
1973
|
-
* @override
|
|
1974
|
-
*/
|
|
1975
|
-
BufferWriter.prototype.string = function write_string_buffer(value) {
|
|
1976
|
-
var len = util$3.Buffer.byteLength(value);
|
|
1977
|
-
this.uint32(len);
|
|
1978
|
-
if (len)
|
|
1979
|
-
this._push(writeStringBuffer, len, value);
|
|
1980
|
-
return this;
|
|
1981
|
-
};
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
/**
|
|
1985
|
-
* Finishes the write operation.
|
|
1986
|
-
* @name BufferWriter#finish
|
|
1987
|
-
* @function
|
|
1988
|
-
* @returns {Buffer} Finished buffer
|
|
1989
|
-
*/
|
|
1990
|
-
|
|
1991
|
-
BufferWriter._configure();
|
|
1992
|
-
|
|
1993
|
-
var reader = Reader$1;
|
|
1994
|
-
|
|
1995
|
-
var util$2 = requireMinimal();
|
|
1996
|
-
|
|
1997
|
-
var BufferReader$1; // cyclic
|
|
1998
|
-
|
|
1999
|
-
var LongBits = util$2.LongBits,
|
|
2000
|
-
utf8 = util$2.utf8;
|
|
2001
|
-
|
|
2002
|
-
/* istanbul ignore next */
|
|
2003
|
-
function indexOutOfRange(reader, writeLength) {
|
|
2004
|
-
return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len);
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
/**
|
|
2008
|
-
* Constructs a new reader instance using the specified buffer.
|
|
2009
|
-
* @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.
|
|
2010
|
-
* @constructor
|
|
2011
|
-
* @param {Uint8Array} buffer Buffer to read from
|
|
2012
|
-
*/
|
|
2013
|
-
function Reader$1(buffer) {
|
|
2014
|
-
|
|
2015
|
-
/**
|
|
2016
|
-
* Read buffer.
|
|
2017
|
-
* @type {Uint8Array}
|
|
2018
|
-
*/
|
|
2019
|
-
this.buf = buffer;
|
|
2020
|
-
|
|
2021
|
-
/**
|
|
2022
|
-
* Read buffer position.
|
|
2023
|
-
* @type {number}
|
|
2024
|
-
*/
|
|
2025
|
-
this.pos = 0;
|
|
2026
|
-
|
|
2027
|
-
/**
|
|
2028
|
-
* Read buffer length.
|
|
2029
|
-
* @type {number}
|
|
2030
|
-
*/
|
|
2031
|
-
this.len = buffer.length;
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
var create_array = typeof Uint8Array !== "undefined"
|
|
2035
|
-
? function create_typed_array(buffer) {
|
|
2036
|
-
if (buffer instanceof Uint8Array || Array.isArray(buffer))
|
|
2037
|
-
return new Reader$1(buffer);
|
|
2038
|
-
throw Error("illegal buffer");
|
|
2039
|
-
}
|
|
2040
|
-
/* istanbul ignore next */
|
|
2041
|
-
: function create_array(buffer) {
|
|
2042
|
-
if (Array.isArray(buffer))
|
|
2043
|
-
return new Reader$1(buffer);
|
|
2044
|
-
throw Error("illegal buffer");
|
|
2045
|
-
};
|
|
2046
|
-
|
|
2047
|
-
var create = function create() {
|
|
2048
|
-
return util$2.Buffer
|
|
2049
|
-
? function create_buffer_setup(buffer) {
|
|
2050
|
-
return (Reader$1.create = function create_buffer(buffer) {
|
|
2051
|
-
return util$2.Buffer.isBuffer(buffer)
|
|
2052
|
-
? new BufferReader$1(buffer)
|
|
2053
|
-
/* istanbul ignore next */
|
|
2054
|
-
: create_array(buffer);
|
|
2055
|
-
})(buffer);
|
|
2056
|
-
}
|
|
2057
|
-
/* istanbul ignore next */
|
|
2058
|
-
: create_array;
|
|
2059
|
-
};
|
|
2060
|
-
|
|
2061
|
-
/**
|
|
2062
|
-
* Creates a new reader using the specified buffer.
|
|
2063
|
-
* @function
|
|
2064
|
-
* @param {Uint8Array|Buffer} buffer Buffer to read from
|
|
2065
|
-
* @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}
|
|
2066
|
-
* @throws {Error} If `buffer` is not a valid buffer
|
|
2067
|
-
*/
|
|
2068
|
-
Reader$1.create = create();
|
|
2069
|
-
|
|
2070
|
-
Reader$1.prototype._slice = util$2.Array.prototype.subarray || /* istanbul ignore next */ util$2.Array.prototype.slice;
|
|
2071
|
-
|
|
2072
|
-
/**
|
|
2073
|
-
* Reads a varint as an unsigned 32 bit value.
|
|
2074
|
-
* @function
|
|
2075
|
-
* @returns {number} Value read
|
|
2076
|
-
*/
|
|
2077
|
-
Reader$1.prototype.uint32 = (function read_uint32_setup() {
|
|
2078
|
-
var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)
|
|
2079
|
-
return function read_uint32() {
|
|
2080
|
-
value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;
|
|
2081
|
-
value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;
|
|
2082
|
-
value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;
|
|
2083
|
-
value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;
|
|
2084
|
-
value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;
|
|
2085
|
-
|
|
2086
|
-
/* istanbul ignore if */
|
|
2087
|
-
if ((this.pos += 5) > this.len) {
|
|
2088
|
-
this.pos = this.len;
|
|
2089
|
-
throw indexOutOfRange(this, 10);
|
|
2090
|
-
}
|
|
2091
|
-
return value;
|
|
2092
|
-
};
|
|
2093
|
-
})();
|
|
2094
|
-
|
|
2095
|
-
/**
|
|
2096
|
-
* Reads a varint as a signed 32 bit value.
|
|
2097
|
-
* @returns {number} Value read
|
|
2098
|
-
*/
|
|
2099
|
-
Reader$1.prototype.int32 = function read_int32() {
|
|
2100
|
-
return this.uint32() | 0;
|
|
2101
|
-
};
|
|
2102
|
-
|
|
2103
|
-
/**
|
|
2104
|
-
* Reads a zig-zag encoded varint as a signed 32 bit value.
|
|
2105
|
-
* @returns {number} Value read
|
|
2106
|
-
*/
|
|
2107
|
-
Reader$1.prototype.sint32 = function read_sint32() {
|
|
2108
|
-
var value = this.uint32();
|
|
2109
|
-
return value >>> 1 ^ -(value & 1) | 0;
|
|
2110
|
-
};
|
|
2111
|
-
|
|
2112
|
-
/* eslint-disable no-invalid-this */
|
|
2113
|
-
|
|
2114
|
-
function readLongVarint() {
|
|
2115
|
-
// tends to deopt with local vars for octet etc.
|
|
2116
|
-
var bits = new LongBits(0, 0);
|
|
2117
|
-
var i = 0;
|
|
2118
|
-
if (this.len - this.pos > 4) { // fast route (lo)
|
|
2119
|
-
for (; i < 4; ++i) {
|
|
2120
|
-
// 1st..4th
|
|
2121
|
-
bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
|
|
2122
|
-
if (this.buf[this.pos++] < 128)
|
|
2123
|
-
return bits;
|
|
2124
|
-
}
|
|
2125
|
-
// 5th
|
|
2126
|
-
bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
|
|
2127
|
-
bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
|
|
2128
|
-
if (this.buf[this.pos++] < 128)
|
|
2129
|
-
return bits;
|
|
2130
|
-
i = 0;
|
|
2131
|
-
} else {
|
|
2132
|
-
for (; i < 3; ++i) {
|
|
2133
|
-
/* istanbul ignore if */
|
|
2134
|
-
if (this.pos >= this.len)
|
|
2135
|
-
throw indexOutOfRange(this);
|
|
2136
|
-
// 1st..3th
|
|
2137
|
-
bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
|
|
2138
|
-
if (this.buf[this.pos++] < 128)
|
|
2139
|
-
return bits;
|
|
2140
|
-
}
|
|
2141
|
-
// 4th
|
|
2142
|
-
bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
|
|
2143
|
-
return bits;
|
|
2144
|
-
}
|
|
2145
|
-
if (this.len - this.pos > 4) { // fast route (hi)
|
|
2146
|
-
for (; i < 5; ++i) {
|
|
2147
|
-
// 6th..10th
|
|
2148
|
-
bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
|
|
2149
|
-
if (this.buf[this.pos++] < 128)
|
|
2150
|
-
return bits;
|
|
2151
|
-
}
|
|
2152
|
-
} else {
|
|
2153
|
-
for (; i < 5; ++i) {
|
|
2154
|
-
/* istanbul ignore if */
|
|
2155
|
-
if (this.pos >= this.len)
|
|
2156
|
-
throw indexOutOfRange(this);
|
|
2157
|
-
// 6th..10th
|
|
2158
|
-
bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
|
|
2159
|
-
if (this.buf[this.pos++] < 128)
|
|
2160
|
-
return bits;
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
/* istanbul ignore next */
|
|
2164
|
-
throw Error("invalid varint encoding");
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
/* eslint-enable no-invalid-this */
|
|
2168
|
-
|
|
2169
|
-
/**
|
|
2170
|
-
* Reads a varint as a signed 64 bit value.
|
|
2171
|
-
* @name Reader#int64
|
|
2172
|
-
* @function
|
|
2173
|
-
* @returns {Long} Value read
|
|
2174
|
-
*/
|
|
2175
|
-
|
|
2176
|
-
/**
|
|
2177
|
-
* Reads a varint as an unsigned 64 bit value.
|
|
2178
|
-
* @name Reader#uint64
|
|
2179
|
-
* @function
|
|
2180
|
-
* @returns {Long} Value read
|
|
2181
|
-
*/
|
|
2182
|
-
|
|
2183
|
-
/**
|
|
2184
|
-
* Reads a zig-zag encoded varint as a signed 64 bit value.
|
|
2185
|
-
* @name Reader#sint64
|
|
2186
|
-
* @function
|
|
2187
|
-
* @returns {Long} Value read
|
|
2188
|
-
*/
|
|
2189
|
-
|
|
2190
|
-
/**
|
|
2191
|
-
* Reads a varint as a boolean.
|
|
2192
|
-
* @returns {boolean} Value read
|
|
2193
|
-
*/
|
|
2194
|
-
Reader$1.prototype.bool = function read_bool() {
|
|
2195
|
-
return this.uint32() !== 0;
|
|
2196
|
-
};
|
|
2197
|
-
|
|
2198
|
-
function readFixed32_end(buf, end) { // note that this uses `end`, not `pos`
|
|
2199
|
-
return (buf[end - 4]
|
|
2200
|
-
| buf[end - 3] << 8
|
|
2201
|
-
| buf[end - 2] << 16
|
|
2202
|
-
| buf[end - 1] << 24) >>> 0;
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
|
-
/**
|
|
2206
|
-
* Reads fixed 32 bits as an unsigned 32 bit integer.
|
|
2207
|
-
* @returns {number} Value read
|
|
2208
|
-
*/
|
|
2209
|
-
Reader$1.prototype.fixed32 = function read_fixed32() {
|
|
2210
|
-
|
|
2211
|
-
/* istanbul ignore if */
|
|
2212
|
-
if (this.pos + 4 > this.len)
|
|
2213
|
-
throw indexOutOfRange(this, 4);
|
|
2214
|
-
|
|
2215
|
-
return readFixed32_end(this.buf, this.pos += 4);
|
|
2216
|
-
};
|
|
2217
|
-
|
|
2218
|
-
/**
|
|
2219
|
-
* Reads fixed 32 bits as a signed 32 bit integer.
|
|
2220
|
-
* @returns {number} Value read
|
|
2221
|
-
*/
|
|
2222
|
-
Reader$1.prototype.sfixed32 = function read_sfixed32() {
|
|
2223
|
-
|
|
2224
|
-
/* istanbul ignore if */
|
|
2225
|
-
if (this.pos + 4 > this.len)
|
|
2226
|
-
throw indexOutOfRange(this, 4);
|
|
2227
|
-
|
|
2228
|
-
return readFixed32_end(this.buf, this.pos += 4) | 0;
|
|
2229
|
-
};
|
|
2230
|
-
|
|
2231
|
-
/* eslint-disable no-invalid-this */
|
|
2232
|
-
|
|
2233
|
-
function readFixed64(/* this: Reader */) {
|
|
2234
|
-
|
|
2235
|
-
/* istanbul ignore if */
|
|
2236
|
-
if (this.pos + 8 > this.len)
|
|
2237
|
-
throw indexOutOfRange(this, 8);
|
|
2238
|
-
|
|
2239
|
-
return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
/* eslint-enable no-invalid-this */
|
|
2243
|
-
|
|
2244
|
-
/**
|
|
2245
|
-
* Reads fixed 64 bits.
|
|
2246
|
-
* @name Reader#fixed64
|
|
2247
|
-
* @function
|
|
2248
|
-
* @returns {Long} Value read
|
|
2249
|
-
*/
|
|
2250
|
-
|
|
2251
|
-
/**
|
|
2252
|
-
* Reads zig-zag encoded fixed 64 bits.
|
|
2253
|
-
* @name Reader#sfixed64
|
|
2254
|
-
* @function
|
|
2255
|
-
* @returns {Long} Value read
|
|
2256
|
-
*/
|
|
2257
|
-
|
|
2258
|
-
/**
|
|
2259
|
-
* Reads a float (32 bit) as a number.
|
|
2260
|
-
* @function
|
|
2261
|
-
* @returns {number} Value read
|
|
2262
|
-
*/
|
|
2263
|
-
Reader$1.prototype.float = function read_float() {
|
|
2264
|
-
|
|
2265
|
-
/* istanbul ignore if */
|
|
2266
|
-
if (this.pos + 4 > this.len)
|
|
2267
|
-
throw indexOutOfRange(this, 4);
|
|
2268
|
-
|
|
2269
|
-
var value = util$2.float.readFloatLE(this.buf, this.pos);
|
|
2270
|
-
this.pos += 4;
|
|
2271
|
-
return value;
|
|
2272
|
-
};
|
|
2273
|
-
|
|
2274
|
-
/**
|
|
2275
|
-
* Reads a double (64 bit float) as a number.
|
|
2276
|
-
* @function
|
|
2277
|
-
* @returns {number} Value read
|
|
2278
|
-
*/
|
|
2279
|
-
Reader$1.prototype.double = function read_double() {
|
|
2280
|
-
|
|
2281
|
-
/* istanbul ignore if */
|
|
2282
|
-
if (this.pos + 8 > this.len)
|
|
2283
|
-
throw indexOutOfRange(this, 4);
|
|
2284
|
-
|
|
2285
|
-
var value = util$2.float.readDoubleLE(this.buf, this.pos);
|
|
2286
|
-
this.pos += 8;
|
|
2287
|
-
return value;
|
|
2288
|
-
};
|
|
2289
|
-
|
|
2290
|
-
/**
|
|
2291
|
-
* Reads a sequence of bytes preceeded by its length as a varint.
|
|
2292
|
-
* @returns {Uint8Array} Value read
|
|
2293
|
-
*/
|
|
2294
|
-
Reader$1.prototype.bytes = function read_bytes() {
|
|
2295
|
-
var length = this.uint32(),
|
|
2296
|
-
start = this.pos,
|
|
2297
|
-
end = this.pos + length;
|
|
2298
|
-
|
|
2299
|
-
/* istanbul ignore if */
|
|
2300
|
-
if (end > this.len)
|
|
2301
|
-
throw indexOutOfRange(this, length);
|
|
2302
|
-
|
|
2303
|
-
this.pos += length;
|
|
2304
|
-
if (Array.isArray(this.buf)) // plain array
|
|
2305
|
-
return this.buf.slice(start, end);
|
|
2306
|
-
|
|
2307
|
-
if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
|
|
2308
|
-
var nativeBuffer = util$2.Buffer;
|
|
2309
|
-
return nativeBuffer
|
|
2310
|
-
? nativeBuffer.alloc(0)
|
|
2311
|
-
: new this.buf.constructor(0);
|
|
2312
|
-
}
|
|
2313
|
-
return this._slice.call(this.buf, start, end);
|
|
2314
|
-
};
|
|
2315
|
-
|
|
2316
|
-
/**
|
|
2317
|
-
* Reads a string preceeded by its byte length as a varint.
|
|
2318
|
-
* @returns {string} Value read
|
|
2319
|
-
*/
|
|
2320
|
-
Reader$1.prototype.string = function read_string() {
|
|
2321
|
-
var bytes = this.bytes();
|
|
2322
|
-
return utf8.read(bytes, 0, bytes.length);
|
|
2323
|
-
};
|
|
2324
|
-
|
|
2325
|
-
/**
|
|
2326
|
-
* Skips the specified number of bytes if specified, otherwise skips a varint.
|
|
2327
|
-
* @param {number} [length] Length if known, otherwise a varint is assumed
|
|
2328
|
-
* @returns {Reader} `this`
|
|
2329
|
-
*/
|
|
2330
|
-
Reader$1.prototype.skip = function skip(length) {
|
|
2331
|
-
if (typeof length === "number") {
|
|
2332
|
-
/* istanbul ignore if */
|
|
2333
|
-
if (this.pos + length > this.len)
|
|
2334
|
-
throw indexOutOfRange(this, length);
|
|
2335
|
-
this.pos += length;
|
|
2336
|
-
} else {
|
|
2337
|
-
do {
|
|
2338
|
-
/* istanbul ignore if */
|
|
2339
|
-
if (this.pos >= this.len)
|
|
2340
|
-
throw indexOutOfRange(this);
|
|
2341
|
-
} while (this.buf[this.pos++] & 128);
|
|
2342
|
-
}
|
|
2343
|
-
return this;
|
|
2344
|
-
};
|
|
2345
|
-
|
|
2346
|
-
/**
|
|
2347
|
-
* Skips the next element of the specified wire type.
|
|
2348
|
-
* @param {number} wireType Wire type received
|
|
2349
|
-
* @returns {Reader} `this`
|
|
2350
|
-
*/
|
|
2351
|
-
Reader$1.prototype.skipType = function(wireType) {
|
|
2352
|
-
switch (wireType) {
|
|
2353
|
-
case 0:
|
|
2354
|
-
this.skip();
|
|
2355
|
-
break;
|
|
2356
|
-
case 1:
|
|
2357
|
-
this.skip(8);
|
|
2358
|
-
break;
|
|
2359
|
-
case 2:
|
|
2360
|
-
this.skip(this.uint32());
|
|
2361
|
-
break;
|
|
2362
|
-
case 3:
|
|
2363
|
-
while ((wireType = this.uint32() & 7) !== 4) {
|
|
2364
|
-
this.skipType(wireType);
|
|
2365
|
-
}
|
|
2366
|
-
break;
|
|
2367
|
-
case 5:
|
|
2368
|
-
this.skip(4);
|
|
2369
|
-
break;
|
|
2370
|
-
|
|
2371
|
-
/* istanbul ignore next */
|
|
2372
|
-
default:
|
|
2373
|
-
throw Error("invalid wire type " + wireType + " at offset " + this.pos);
|
|
2374
|
-
}
|
|
2375
|
-
return this;
|
|
2376
|
-
};
|
|
2377
|
-
|
|
2378
|
-
Reader$1._configure = function(BufferReader_) {
|
|
2379
|
-
BufferReader$1 = BufferReader_;
|
|
2380
|
-
Reader$1.create = create();
|
|
2381
|
-
BufferReader$1._configure();
|
|
2382
|
-
|
|
2383
|
-
var fn = util$2.Long ? "toLong" : /* istanbul ignore next */ "toNumber";
|
|
2384
|
-
util$2.merge(Reader$1.prototype, {
|
|
2385
|
-
|
|
2386
|
-
int64: function read_int64() {
|
|
2387
|
-
return readLongVarint.call(this)[fn](false);
|
|
2388
|
-
},
|
|
2389
|
-
|
|
2390
|
-
uint64: function read_uint64() {
|
|
2391
|
-
return readLongVarint.call(this)[fn](true);
|
|
2392
|
-
},
|
|
2393
|
-
|
|
2394
|
-
sint64: function read_sint64() {
|
|
2395
|
-
return readLongVarint.call(this).zzDecode()[fn](false);
|
|
2396
|
-
},
|
|
2397
|
-
|
|
2398
|
-
fixed64: function read_fixed64() {
|
|
2399
|
-
return readFixed64.call(this)[fn](true);
|
|
2400
|
-
},
|
|
2401
|
-
|
|
2402
|
-
sfixed64: function read_sfixed64() {
|
|
2403
|
-
return readFixed64.call(this)[fn](false);
|
|
2404
|
-
}
|
|
2405
|
-
|
|
2406
|
-
});
|
|
2407
|
-
};
|
|
2408
|
-
|
|
2409
|
-
var reader_buffer = BufferReader;
|
|
2410
|
-
|
|
2411
|
-
// extends Reader
|
|
2412
|
-
var Reader = reader;
|
|
2413
|
-
(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
|
|
2414
|
-
|
|
2415
|
-
var util$1 = requireMinimal();
|
|
2416
|
-
|
|
2417
|
-
/**
|
|
2418
|
-
* Constructs a new buffer reader instance.
|
|
2419
|
-
* @classdesc Wire format reader using node buffers.
|
|
2420
|
-
* @extends Reader
|
|
2421
|
-
* @constructor
|
|
2422
|
-
* @param {Buffer} buffer Buffer to read from
|
|
2423
|
-
*/
|
|
2424
|
-
function BufferReader(buffer) {
|
|
2425
|
-
Reader.call(this, buffer);
|
|
2426
|
-
|
|
2427
|
-
/**
|
|
2428
|
-
* Read buffer.
|
|
2429
|
-
* @name BufferReader#buf
|
|
2430
|
-
* @type {Buffer}
|
|
2431
|
-
*/
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
BufferReader._configure = function () {
|
|
2435
|
-
/* istanbul ignore else */
|
|
2436
|
-
if (util$1.Buffer)
|
|
2437
|
-
BufferReader.prototype._slice = util$1.Buffer.prototype.slice;
|
|
2438
|
-
};
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
/**
|
|
2442
|
-
* @override
|
|
2443
|
-
*/
|
|
2444
|
-
BufferReader.prototype.string = function read_string_buffer() {
|
|
2445
|
-
var len = this.uint32(); // modifies pos
|
|
2446
|
-
return this.buf.utf8Slice
|
|
2447
|
-
? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len))
|
|
2448
|
-
: this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len));
|
|
2449
|
-
};
|
|
2450
|
-
|
|
2451
|
-
/**
|
|
2452
|
-
* Reads a sequence of bytes preceeded by its length as a varint.
|
|
2453
|
-
* @name BufferReader#bytes
|
|
2454
|
-
* @function
|
|
2455
|
-
* @returns {Buffer} Value read
|
|
2456
|
-
*/
|
|
2457
|
-
|
|
2458
|
-
BufferReader._configure();
|
|
2459
|
-
|
|
2460
|
-
var rpc = {};
|
|
2461
|
-
|
|
2462
|
-
var service = Service;
|
|
2463
|
-
|
|
2464
|
-
var util = requireMinimal();
|
|
2465
|
-
|
|
2466
|
-
// Extends EventEmitter
|
|
2467
|
-
(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
|
|
2468
|
-
|
|
2469
|
-
/**
|
|
2470
|
-
* A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
|
|
2471
|
-
*
|
|
2472
|
-
* Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.
|
|
2473
|
-
* @typedef rpc.ServiceMethodCallback
|
|
2474
|
-
* @template TRes extends Message<TRes>
|
|
2475
|
-
* @type {function}
|
|
2476
|
-
* @param {Error|null} error Error, if any
|
|
2477
|
-
* @param {TRes} [response] Response message
|
|
2478
|
-
* @returns {undefined}
|
|
2479
|
-
*/
|
|
2480
|
-
|
|
2481
|
-
/**
|
|
2482
|
-
* A service method part of a {@link rpc.Service} as created by {@link Service.create}.
|
|
2483
|
-
* @typedef rpc.ServiceMethod
|
|
2484
|
-
* @template TReq extends Message<TReq>
|
|
2485
|
-
* @template TRes extends Message<TRes>
|
|
2486
|
-
* @type {function}
|
|
2487
|
-
* @param {TReq|Properties<TReq>} request Request message or plain object
|
|
2488
|
-
* @param {rpc.ServiceMethodCallback<TRes>} [callback] Node-style callback called with the error, if any, and the response message
|
|
2489
|
-
* @returns {Promise<Message<TRes>>} Promise if `callback` has been omitted, otherwise `undefined`
|
|
2490
|
-
*/
|
|
2491
|
-
|
|
2492
|
-
/**
|
|
2493
|
-
* Constructs a new RPC service instance.
|
|
2494
|
-
* @classdesc An RPC service as returned by {@link Service#create}.
|
|
2495
|
-
* @exports rpc.Service
|
|
2496
|
-
* @extends util.EventEmitter
|
|
2497
|
-
* @constructor
|
|
2498
|
-
* @param {RPCImpl} rpcImpl RPC implementation
|
|
2499
|
-
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
|
|
2500
|
-
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
|
|
2501
|
-
*/
|
|
2502
|
-
function Service(rpcImpl, requestDelimited, responseDelimited) {
|
|
2503
|
-
|
|
2504
|
-
if (typeof rpcImpl !== "function")
|
|
2505
|
-
throw TypeError("rpcImpl must be a function");
|
|
2506
|
-
|
|
2507
|
-
util.EventEmitter.call(this);
|
|
2508
|
-
|
|
2509
|
-
/**
|
|
2510
|
-
* RPC implementation. Becomes `null` once the service is ended.
|
|
2511
|
-
* @type {RPCImpl|null}
|
|
2512
|
-
*/
|
|
2513
|
-
this.rpcImpl = rpcImpl;
|
|
2514
|
-
|
|
2515
|
-
/**
|
|
2516
|
-
* Whether requests are length-delimited.
|
|
2517
|
-
* @type {boolean}
|
|
2518
|
-
*/
|
|
2519
|
-
this.requestDelimited = Boolean(requestDelimited);
|
|
2520
|
-
|
|
2521
|
-
/**
|
|
2522
|
-
* Whether responses are length-delimited.
|
|
2523
|
-
* @type {boolean}
|
|
2524
|
-
*/
|
|
2525
|
-
this.responseDelimited = Boolean(responseDelimited);
|
|
2526
|
-
}
|
|
2527
|
-
|
|
2528
|
-
/**
|
|
2529
|
-
* Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.
|
|
2530
|
-
* @param {Method|rpc.ServiceMethod<TReq,TRes>} method Reflected or static method
|
|
2531
|
-
* @param {Constructor<TReq>} requestCtor Request constructor
|
|
2532
|
-
* @param {Constructor<TRes>} responseCtor Response constructor
|
|
2533
|
-
* @param {TReq|Properties<TReq>} request Request message or plain object
|
|
2534
|
-
* @param {rpc.ServiceMethodCallback<TRes>} callback Service callback
|
|
2535
|
-
* @returns {undefined}
|
|
2536
|
-
* @template TReq extends Message<TReq>
|
|
2537
|
-
* @template TRes extends Message<TRes>
|
|
2538
|
-
*/
|
|
2539
|
-
Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {
|
|
2540
|
-
|
|
2541
|
-
if (!request)
|
|
2542
|
-
throw TypeError("request must be specified");
|
|
2543
|
-
|
|
2544
|
-
var self = this;
|
|
2545
|
-
if (!callback)
|
|
2546
|
-
return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);
|
|
2547
|
-
|
|
2548
|
-
if (!self.rpcImpl) {
|
|
2549
|
-
setTimeout(function() { callback(Error("already ended")); }, 0);
|
|
2550
|
-
return undefined;
|
|
2551
|
-
}
|
|
2552
|
-
|
|
2553
|
-
try {
|
|
2554
|
-
return self.rpcImpl(
|
|
2555
|
-
method,
|
|
2556
|
-
requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(),
|
|
2557
|
-
function rpcCallback(err, response) {
|
|
2558
|
-
|
|
2559
|
-
if (err) {
|
|
2560
|
-
self.emit("error", err, method);
|
|
2561
|
-
return callback(err);
|
|
2562
|
-
}
|
|
2563
|
-
|
|
2564
|
-
if (response === null) {
|
|
2565
|
-
self.end(/* endedByRPC */ true);
|
|
2566
|
-
return undefined;
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
|
-
if (!(response instanceof responseCtor)) {
|
|
2570
|
-
try {
|
|
2571
|
-
response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response);
|
|
2572
|
-
} catch (err) {
|
|
2573
|
-
self.emit("error", err, method);
|
|
2574
|
-
return callback(err);
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
self.emit("data", response, method);
|
|
2579
|
-
return callback(null, response);
|
|
2580
|
-
}
|
|
2581
|
-
);
|
|
2582
|
-
} catch (err) {
|
|
2583
|
-
self.emit("error", err, method);
|
|
2584
|
-
setTimeout(function() { callback(err); }, 0);
|
|
2585
|
-
return undefined;
|
|
2586
|
-
}
|
|
2587
|
-
};
|
|
2588
|
-
|
|
2589
|
-
/**
|
|
2590
|
-
* Ends this service and emits the `end` event.
|
|
2591
|
-
* @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation.
|
|
2592
|
-
* @returns {rpc.Service} `this`
|
|
2593
|
-
*/
|
|
2594
|
-
Service.prototype.end = function end(endedByRPC) {
|
|
2595
|
-
if (this.rpcImpl) {
|
|
2596
|
-
if (!endedByRPC) // signal end to rpcImpl
|
|
2597
|
-
this.rpcImpl(null, null, null);
|
|
2598
|
-
this.rpcImpl = null;
|
|
2599
|
-
this.emit("end").off();
|
|
2600
|
-
}
|
|
2601
|
-
return this;
|
|
2602
|
-
};
|
|
2603
|
-
|
|
2604
|
-
(function (exports) {
|
|
2605
|
-
|
|
2606
|
-
/**
|
|
2607
|
-
* Streaming RPC helpers.
|
|
2608
|
-
* @namespace
|
|
2609
|
-
*/
|
|
2610
|
-
var rpc = exports;
|
|
2611
|
-
|
|
2612
|
-
/**
|
|
2613
|
-
* RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.
|
|
2614
|
-
* @typedef RPCImpl
|
|
2615
|
-
* @type {function}
|
|
2616
|
-
* @param {Method|rpc.ServiceMethod<Message<{}>,Message<{}>>} method Reflected or static method being called
|
|
2617
|
-
* @param {Uint8Array} requestData Request data
|
|
2618
|
-
* @param {RPCImplCallback} callback Callback function
|
|
2619
|
-
* @returns {undefined}
|
|
2620
|
-
* @example
|
|
2621
|
-
* function rpcImpl(method, requestData, callback) {
|
|
2622
|
-
* if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code
|
|
2623
|
-
* throw Error("no such method");
|
|
2624
|
-
* asynchronouslyObtainAResponse(requestData, function(err, responseData) {
|
|
2625
|
-
* callback(err, responseData);
|
|
2626
|
-
* });
|
|
2627
|
-
* }
|
|
2628
|
-
*/
|
|
2629
|
-
|
|
2630
|
-
/**
|
|
2631
|
-
* Node-style callback as used by {@link RPCImpl}.
|
|
2632
|
-
* @typedef RPCImplCallback
|
|
2633
|
-
* @type {function}
|
|
2634
|
-
* @param {Error|null} error Error, if any, otherwise `null`
|
|
2635
|
-
* @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error
|
|
2636
|
-
* @returns {undefined}
|
|
2637
|
-
*/
|
|
2638
|
-
|
|
2639
|
-
rpc.Service = service;
|
|
2640
|
-
} (rpc));
|
|
2641
|
-
|
|
2642
|
-
var roots = {};
|
|
2643
|
-
|
|
2644
|
-
(function (exports) {
|
|
2645
|
-
var protobuf = exports;
|
|
2646
|
-
|
|
2647
|
-
/**
|
|
2648
|
-
* Build type, one of `"full"`, `"light"` or `"minimal"`.
|
|
2649
|
-
* @name build
|
|
2650
|
-
* @type {string}
|
|
2651
|
-
* @const
|
|
2652
|
-
*/
|
|
2653
|
-
protobuf.build = "minimal";
|
|
2654
|
-
|
|
2655
|
-
// Serialization
|
|
2656
|
-
protobuf.Writer = writer;
|
|
2657
|
-
protobuf.BufferWriter = writer_buffer;
|
|
2658
|
-
protobuf.Reader = reader;
|
|
2659
|
-
protobuf.BufferReader = reader_buffer;
|
|
2660
|
-
|
|
2661
|
-
// Utility
|
|
2662
|
-
protobuf.util = requireMinimal();
|
|
2663
|
-
protobuf.rpc = rpc;
|
|
2664
|
-
protobuf.roots = roots;
|
|
2665
|
-
protobuf.configure = configure;
|
|
2666
|
-
|
|
2667
|
-
/* istanbul ignore next */
|
|
2668
|
-
/**
|
|
2669
|
-
* Reconfigures the library according to the environment.
|
|
2670
|
-
* @returns {undefined}
|
|
2671
|
-
*/
|
|
2672
|
-
function configure() {
|
|
2673
|
-
protobuf.util._configure();
|
|
2674
|
-
protobuf.Writer._configure(protobuf.BufferWriter);
|
|
2675
|
-
protobuf.Reader._configure(protobuf.BufferReader);
|
|
2676
|
-
}
|
|
2677
|
-
|
|
2678
|
-
// Set up buffer utility according to the environment
|
|
2679
|
-
configure();
|
|
2680
|
-
} (indexMinimal));
|
|
2681
|
-
|
|
2682
|
-
var minimal = indexMinimal;
|
|
2683
|
-
|
|
2684
1
|
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var $protobuf = require("protobufjs/minimal");
|
|
2685
5
|
|
|
2686
6
|
// Common aliases
|
|
2687
|
-
|
|
7
|
+
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
|
|
2688
8
|
|
|
2689
9
|
// Exported root namespace
|
|
2690
|
-
|
|
10
|
+
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
|
|
2691
11
|
|
|
2692
|
-
|
|
12
|
+
$root.UpstreamMessage = (function() {
|
|
2693
13
|
|
|
2694
14
|
/**
|
|
2695
15
|
* Properties of an UpstreamMessage.
|
|
@@ -2712,7 +32,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2712
32
|
*/
|
|
2713
33
|
function UpstreamMessage(properties) {
|
|
2714
34
|
if (properties)
|
|
2715
|
-
for (
|
|
35
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
2716
36
|
if (properties[keys[i]] != null)
|
|
2717
37
|
this[keys[i]] = properties[keys[i]];
|
|
2718
38
|
}
|
|
@@ -2758,7 +78,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2758
78
|
UpstreamMessage.prototype.sequenceAckMessage = null;
|
|
2759
79
|
|
|
2760
80
|
// OneOf field names bound to virtual getters and setters
|
|
2761
|
-
|
|
81
|
+
var $oneOfFields;
|
|
2762
82
|
|
|
2763
83
|
/**
|
|
2764
84
|
* UpstreamMessage message.
|
|
@@ -2835,9 +155,9 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2835
155
|
UpstreamMessage.decode = function decode(reader, length) {
|
|
2836
156
|
if (!(reader instanceof $Reader))
|
|
2837
157
|
reader = $Reader.create(reader);
|
|
2838
|
-
|
|
158
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage();
|
|
2839
159
|
while (reader.pos < end) {
|
|
2840
|
-
|
|
160
|
+
var tag = reader.uint32();
|
|
2841
161
|
switch (tag >>> 3) {
|
|
2842
162
|
case 1: {
|
|
2843
163
|
message.sendToGroupMessage = $root.UpstreamMessage.SendToGroupMessage.decode(reader, reader.uint32());
|
|
@@ -2894,11 +214,11 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2894
214
|
UpstreamMessage.verify = function verify(message) {
|
|
2895
215
|
if (typeof message !== "object" || message === null)
|
|
2896
216
|
return "object expected";
|
|
2897
|
-
|
|
217
|
+
var properties = {};
|
|
2898
218
|
if (message.sendToGroupMessage != null && message.hasOwnProperty("sendToGroupMessage")) {
|
|
2899
219
|
properties.message = 1;
|
|
2900
220
|
{
|
|
2901
|
-
|
|
221
|
+
var error = $root.UpstreamMessage.SendToGroupMessage.verify(message.sendToGroupMessage);
|
|
2902
222
|
if (error)
|
|
2903
223
|
return "sendToGroupMessage." + error;
|
|
2904
224
|
}
|
|
@@ -2908,7 +228,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2908
228
|
return "message: multiple values";
|
|
2909
229
|
properties.message = 1;
|
|
2910
230
|
{
|
|
2911
|
-
|
|
231
|
+
var error = $root.UpstreamMessage.EventMessage.verify(message.eventMessage);
|
|
2912
232
|
if (error)
|
|
2913
233
|
return "eventMessage." + error;
|
|
2914
234
|
}
|
|
@@ -2918,7 +238,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2918
238
|
return "message: multiple values";
|
|
2919
239
|
properties.message = 1;
|
|
2920
240
|
{
|
|
2921
|
-
|
|
241
|
+
var error = $root.UpstreamMessage.JoinGroupMessage.verify(message.joinGroupMessage);
|
|
2922
242
|
if (error)
|
|
2923
243
|
return "joinGroupMessage." + error;
|
|
2924
244
|
}
|
|
@@ -2928,7 +248,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2928
248
|
return "message: multiple values";
|
|
2929
249
|
properties.message = 1;
|
|
2930
250
|
{
|
|
2931
|
-
|
|
251
|
+
var error = $root.UpstreamMessage.LeaveGroupMessage.verify(message.leaveGroupMessage);
|
|
2932
252
|
if (error)
|
|
2933
253
|
return "leaveGroupMessage." + error;
|
|
2934
254
|
}
|
|
@@ -2938,7 +258,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2938
258
|
return "message: multiple values";
|
|
2939
259
|
properties.message = 1;
|
|
2940
260
|
{
|
|
2941
|
-
|
|
261
|
+
var error = $root.UpstreamMessage.SequenceAckMessage.verify(message.sequenceAckMessage);
|
|
2942
262
|
if (error)
|
|
2943
263
|
return "sequenceAckMessage." + error;
|
|
2944
264
|
}
|
|
@@ -2957,7 +277,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2957
277
|
UpstreamMessage.fromObject = function fromObject(object) {
|
|
2958
278
|
if (object instanceof $root.UpstreamMessage)
|
|
2959
279
|
return object;
|
|
2960
|
-
|
|
280
|
+
var message = new $root.UpstreamMessage();
|
|
2961
281
|
if (object.sendToGroupMessage != null) {
|
|
2962
282
|
if (typeof object.sendToGroupMessage !== "object")
|
|
2963
283
|
throw TypeError(".UpstreamMessage.sendToGroupMessage: object expected");
|
|
@@ -2998,7 +318,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
2998
318
|
UpstreamMessage.toObject = function toObject(message, options) {
|
|
2999
319
|
if (!options)
|
|
3000
320
|
options = {};
|
|
3001
|
-
|
|
321
|
+
var object = {};
|
|
3002
322
|
if (message.sendToGroupMessage != null && message.hasOwnProperty("sendToGroupMessage")) {
|
|
3003
323
|
object.sendToGroupMessage = $root.UpstreamMessage.SendToGroupMessage.toObject(message.sendToGroupMessage, options);
|
|
3004
324
|
if (options.oneofs)
|
|
@@ -3035,7 +355,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3035
355
|
* @returns {Object.<string,*>} JSON object
|
|
3036
356
|
*/
|
|
3037
357
|
UpstreamMessage.prototype.toJSON = function toJSON() {
|
|
3038
|
-
return this.constructor.toObject(this,
|
|
358
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
3039
359
|
};
|
|
3040
360
|
|
|
3041
361
|
/**
|
|
@@ -3075,7 +395,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3075
395
|
*/
|
|
3076
396
|
function SendToGroupMessage(properties) {
|
|
3077
397
|
if (properties)
|
|
3078
|
-
for (
|
|
398
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
3079
399
|
if (properties[keys[i]] != null)
|
|
3080
400
|
this[keys[i]] = properties[keys[i]];
|
|
3081
401
|
}
|
|
@@ -3113,7 +433,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3113
433
|
SendToGroupMessage.prototype.noEcho = null;
|
|
3114
434
|
|
|
3115
435
|
// OneOf field names bound to virtual getters and setters
|
|
3116
|
-
|
|
436
|
+
var $oneOfFields;
|
|
3117
437
|
|
|
3118
438
|
// Virtual OneOf for proto3 optional field
|
|
3119
439
|
Object.defineProperty(SendToGroupMessage.prototype, "_ackId", {
|
|
@@ -3189,9 +509,9 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3189
509
|
SendToGroupMessage.decode = function decode(reader, length) {
|
|
3190
510
|
if (!(reader instanceof $Reader))
|
|
3191
511
|
reader = $Reader.create(reader);
|
|
3192
|
-
|
|
512
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.SendToGroupMessage();
|
|
3193
513
|
while (reader.pos < end) {
|
|
3194
|
-
|
|
514
|
+
var tag = reader.uint32();
|
|
3195
515
|
switch (tag >>> 3) {
|
|
3196
516
|
case 1: {
|
|
3197
517
|
message.group = reader.string();
|
|
@@ -3244,19 +564,22 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3244
564
|
SendToGroupMessage.verify = function verify(message) {
|
|
3245
565
|
if (typeof message !== "object" || message === null)
|
|
3246
566
|
return "object expected";
|
|
567
|
+
var properties = {};
|
|
3247
568
|
if (message.group != null && message.hasOwnProperty("group"))
|
|
3248
569
|
if (!$util.isString(message.group))
|
|
3249
570
|
return "group: string expected";
|
|
3250
571
|
if (message.ackId != null && message.hasOwnProperty("ackId")) {
|
|
572
|
+
properties._ackId = 1;
|
|
3251
573
|
if (!$util.isInteger(message.ackId) && !(message.ackId && $util.isInteger(message.ackId.low) && $util.isInteger(message.ackId.high)))
|
|
3252
574
|
return "ackId: integer|Long expected";
|
|
3253
575
|
}
|
|
3254
576
|
if (message.data != null && message.hasOwnProperty("data")) {
|
|
3255
|
-
|
|
577
|
+
var error = $root.MessageData.verify(message.data);
|
|
3256
578
|
if (error)
|
|
3257
579
|
return "data." + error;
|
|
3258
580
|
}
|
|
3259
581
|
if (message.noEcho != null && message.hasOwnProperty("noEcho")) {
|
|
582
|
+
properties._noEcho = 1;
|
|
3260
583
|
if (typeof message.noEcho !== "boolean")
|
|
3261
584
|
return "noEcho: boolean expected";
|
|
3262
585
|
}
|
|
@@ -3274,7 +597,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3274
597
|
SendToGroupMessage.fromObject = function fromObject(object) {
|
|
3275
598
|
if (object instanceof $root.UpstreamMessage.SendToGroupMessage)
|
|
3276
599
|
return object;
|
|
3277
|
-
|
|
600
|
+
var message = new $root.UpstreamMessage.SendToGroupMessage();
|
|
3278
601
|
if (object.group != null)
|
|
3279
602
|
message.group = String(object.group);
|
|
3280
603
|
if (object.ackId != null)
|
|
@@ -3308,7 +631,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3308
631
|
SendToGroupMessage.toObject = function toObject(message, options) {
|
|
3309
632
|
if (!options)
|
|
3310
633
|
options = {};
|
|
3311
|
-
|
|
634
|
+
var object = {};
|
|
3312
635
|
if (options.defaults) {
|
|
3313
636
|
object.group = "";
|
|
3314
637
|
object.data = null;
|
|
@@ -3341,7 +664,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3341
664
|
* @returns {Object.<string,*>} JSON object
|
|
3342
665
|
*/
|
|
3343
666
|
SendToGroupMessage.prototype.toJSON = function toJSON() {
|
|
3344
|
-
return this.constructor.toObject(this,
|
|
667
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
3345
668
|
};
|
|
3346
669
|
|
|
3347
670
|
/**
|
|
@@ -3383,7 +706,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3383
706
|
*/
|
|
3384
707
|
function EventMessage(properties) {
|
|
3385
708
|
if (properties)
|
|
3386
|
-
for (
|
|
709
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
3387
710
|
if (properties[keys[i]] != null)
|
|
3388
711
|
this[keys[i]] = properties[keys[i]];
|
|
3389
712
|
}
|
|
@@ -3413,7 +736,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3413
736
|
EventMessage.prototype.ackId = null;
|
|
3414
737
|
|
|
3415
738
|
// OneOf field names bound to virtual getters and setters
|
|
3416
|
-
|
|
739
|
+
var $oneOfFields;
|
|
3417
740
|
|
|
3418
741
|
// Virtual OneOf for proto3 optional field
|
|
3419
742
|
Object.defineProperty(EventMessage.prototype, "_ackId", {
|
|
@@ -3481,9 +804,9 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3481
804
|
EventMessage.decode = function decode(reader, length) {
|
|
3482
805
|
if (!(reader instanceof $Reader))
|
|
3483
806
|
reader = $Reader.create(reader);
|
|
3484
|
-
|
|
807
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.EventMessage();
|
|
3485
808
|
while (reader.pos < end) {
|
|
3486
|
-
|
|
809
|
+
var tag = reader.uint32();
|
|
3487
810
|
switch (tag >>> 3) {
|
|
3488
811
|
case 1: {
|
|
3489
812
|
message.event = reader.string();
|
|
@@ -3532,15 +855,17 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3532
855
|
EventMessage.verify = function verify(message) {
|
|
3533
856
|
if (typeof message !== "object" || message === null)
|
|
3534
857
|
return "object expected";
|
|
858
|
+
var properties = {};
|
|
3535
859
|
if (message.event != null && message.hasOwnProperty("event"))
|
|
3536
860
|
if (!$util.isString(message.event))
|
|
3537
861
|
return "event: string expected";
|
|
3538
862
|
if (message.data != null && message.hasOwnProperty("data")) {
|
|
3539
|
-
|
|
863
|
+
var error = $root.MessageData.verify(message.data);
|
|
3540
864
|
if (error)
|
|
3541
865
|
return "data." + error;
|
|
3542
866
|
}
|
|
3543
867
|
if (message.ackId != null && message.hasOwnProperty("ackId")) {
|
|
868
|
+
properties._ackId = 1;
|
|
3544
869
|
if (!$util.isInteger(message.ackId) && !(message.ackId && $util.isInteger(message.ackId.low) && $util.isInteger(message.ackId.high)))
|
|
3545
870
|
return "ackId: integer|Long expected";
|
|
3546
871
|
}
|
|
@@ -3558,7 +883,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3558
883
|
EventMessage.fromObject = function fromObject(object) {
|
|
3559
884
|
if (object instanceof $root.UpstreamMessage.EventMessage)
|
|
3560
885
|
return object;
|
|
3561
|
-
|
|
886
|
+
var message = new $root.UpstreamMessage.EventMessage();
|
|
3562
887
|
if (object.event != null)
|
|
3563
888
|
message.event = String(object.event);
|
|
3564
889
|
if (object.data != null) {
|
|
@@ -3590,7 +915,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3590
915
|
EventMessage.toObject = function toObject(message, options) {
|
|
3591
916
|
if (!options)
|
|
3592
917
|
options = {};
|
|
3593
|
-
|
|
918
|
+
var object = {};
|
|
3594
919
|
if (options.defaults) {
|
|
3595
920
|
object.event = "";
|
|
3596
921
|
object.data = null;
|
|
@@ -3618,7 +943,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3618
943
|
* @returns {Object.<string,*>} JSON object
|
|
3619
944
|
*/
|
|
3620
945
|
EventMessage.prototype.toJSON = function toJSON() {
|
|
3621
|
-
return this.constructor.toObject(this,
|
|
946
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
3622
947
|
};
|
|
3623
948
|
|
|
3624
949
|
/**
|
|
@@ -3659,7 +984,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3659
984
|
*/
|
|
3660
985
|
function JoinGroupMessage(properties) {
|
|
3661
986
|
if (properties)
|
|
3662
|
-
for (
|
|
987
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
3663
988
|
if (properties[keys[i]] != null)
|
|
3664
989
|
this[keys[i]] = properties[keys[i]];
|
|
3665
990
|
}
|
|
@@ -3681,7 +1006,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3681
1006
|
JoinGroupMessage.prototype.ackId = null;
|
|
3682
1007
|
|
|
3683
1008
|
// OneOf field names bound to virtual getters and setters
|
|
3684
|
-
|
|
1009
|
+
var $oneOfFields;
|
|
3685
1010
|
|
|
3686
1011
|
// Virtual OneOf for proto3 optional field
|
|
3687
1012
|
Object.defineProperty(JoinGroupMessage.prototype, "_ackId", {
|
|
@@ -3747,9 +1072,9 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3747
1072
|
JoinGroupMessage.decode = function decode(reader, length) {
|
|
3748
1073
|
if (!(reader instanceof $Reader))
|
|
3749
1074
|
reader = $Reader.create(reader);
|
|
3750
|
-
|
|
1075
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.JoinGroupMessage();
|
|
3751
1076
|
while (reader.pos < end) {
|
|
3752
|
-
|
|
1077
|
+
var tag = reader.uint32();
|
|
3753
1078
|
switch (tag >>> 3) {
|
|
3754
1079
|
case 1: {
|
|
3755
1080
|
message.group = reader.string();
|
|
@@ -3794,10 +1119,12 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3794
1119
|
JoinGroupMessage.verify = function verify(message) {
|
|
3795
1120
|
if (typeof message !== "object" || message === null)
|
|
3796
1121
|
return "object expected";
|
|
1122
|
+
var properties = {};
|
|
3797
1123
|
if (message.group != null && message.hasOwnProperty("group"))
|
|
3798
1124
|
if (!$util.isString(message.group))
|
|
3799
1125
|
return "group: string expected";
|
|
3800
1126
|
if (message.ackId != null && message.hasOwnProperty("ackId")) {
|
|
1127
|
+
properties._ackId = 1;
|
|
3801
1128
|
if (!$util.isInteger(message.ackId) && !(message.ackId && $util.isInteger(message.ackId.low) && $util.isInteger(message.ackId.high)))
|
|
3802
1129
|
return "ackId: integer|Long expected";
|
|
3803
1130
|
}
|
|
@@ -3815,7 +1142,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3815
1142
|
JoinGroupMessage.fromObject = function fromObject(object) {
|
|
3816
1143
|
if (object instanceof $root.UpstreamMessage.JoinGroupMessage)
|
|
3817
1144
|
return object;
|
|
3818
|
-
|
|
1145
|
+
var message = new $root.UpstreamMessage.JoinGroupMessage();
|
|
3819
1146
|
if (object.group != null)
|
|
3820
1147
|
message.group = String(object.group);
|
|
3821
1148
|
if (object.ackId != null)
|
|
@@ -3842,7 +1169,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3842
1169
|
JoinGroupMessage.toObject = function toObject(message, options) {
|
|
3843
1170
|
if (!options)
|
|
3844
1171
|
options = {};
|
|
3845
|
-
|
|
1172
|
+
var object = {};
|
|
3846
1173
|
if (options.defaults)
|
|
3847
1174
|
object.group = "";
|
|
3848
1175
|
if (message.group != null && message.hasOwnProperty("group"))
|
|
@@ -3866,7 +1193,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3866
1193
|
* @returns {Object.<string,*>} JSON object
|
|
3867
1194
|
*/
|
|
3868
1195
|
JoinGroupMessage.prototype.toJSON = function toJSON() {
|
|
3869
|
-
return this.constructor.toObject(this,
|
|
1196
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
3870
1197
|
};
|
|
3871
1198
|
|
|
3872
1199
|
/**
|
|
@@ -3907,7 +1234,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3907
1234
|
*/
|
|
3908
1235
|
function LeaveGroupMessage(properties) {
|
|
3909
1236
|
if (properties)
|
|
3910
|
-
for (
|
|
1237
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
3911
1238
|
if (properties[keys[i]] != null)
|
|
3912
1239
|
this[keys[i]] = properties[keys[i]];
|
|
3913
1240
|
}
|
|
@@ -3929,7 +1256,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3929
1256
|
LeaveGroupMessage.prototype.ackId = null;
|
|
3930
1257
|
|
|
3931
1258
|
// OneOf field names bound to virtual getters and setters
|
|
3932
|
-
|
|
1259
|
+
var $oneOfFields;
|
|
3933
1260
|
|
|
3934
1261
|
// Virtual OneOf for proto3 optional field
|
|
3935
1262
|
Object.defineProperty(LeaveGroupMessage.prototype, "_ackId", {
|
|
@@ -3995,9 +1322,9 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
3995
1322
|
LeaveGroupMessage.decode = function decode(reader, length) {
|
|
3996
1323
|
if (!(reader instanceof $Reader))
|
|
3997
1324
|
reader = $Reader.create(reader);
|
|
3998
|
-
|
|
1325
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.LeaveGroupMessage();
|
|
3999
1326
|
while (reader.pos < end) {
|
|
4000
|
-
|
|
1327
|
+
var tag = reader.uint32();
|
|
4001
1328
|
switch (tag >>> 3) {
|
|
4002
1329
|
case 1: {
|
|
4003
1330
|
message.group = reader.string();
|
|
@@ -4042,10 +1369,12 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4042
1369
|
LeaveGroupMessage.verify = function verify(message) {
|
|
4043
1370
|
if (typeof message !== "object" || message === null)
|
|
4044
1371
|
return "object expected";
|
|
1372
|
+
var properties = {};
|
|
4045
1373
|
if (message.group != null && message.hasOwnProperty("group"))
|
|
4046
1374
|
if (!$util.isString(message.group))
|
|
4047
1375
|
return "group: string expected";
|
|
4048
1376
|
if (message.ackId != null && message.hasOwnProperty("ackId")) {
|
|
1377
|
+
properties._ackId = 1;
|
|
4049
1378
|
if (!$util.isInteger(message.ackId) && !(message.ackId && $util.isInteger(message.ackId.low) && $util.isInteger(message.ackId.high)))
|
|
4050
1379
|
return "ackId: integer|Long expected";
|
|
4051
1380
|
}
|
|
@@ -4063,7 +1392,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4063
1392
|
LeaveGroupMessage.fromObject = function fromObject(object) {
|
|
4064
1393
|
if (object instanceof $root.UpstreamMessage.LeaveGroupMessage)
|
|
4065
1394
|
return object;
|
|
4066
|
-
|
|
1395
|
+
var message = new $root.UpstreamMessage.LeaveGroupMessage();
|
|
4067
1396
|
if (object.group != null)
|
|
4068
1397
|
message.group = String(object.group);
|
|
4069
1398
|
if (object.ackId != null)
|
|
@@ -4090,7 +1419,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4090
1419
|
LeaveGroupMessage.toObject = function toObject(message, options) {
|
|
4091
1420
|
if (!options)
|
|
4092
1421
|
options = {};
|
|
4093
|
-
|
|
1422
|
+
var object = {};
|
|
4094
1423
|
if (options.defaults)
|
|
4095
1424
|
object.group = "";
|
|
4096
1425
|
if (message.group != null && message.hasOwnProperty("group"))
|
|
@@ -4114,7 +1443,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4114
1443
|
* @returns {Object.<string,*>} JSON object
|
|
4115
1444
|
*/
|
|
4116
1445
|
LeaveGroupMessage.prototype.toJSON = function toJSON() {
|
|
4117
|
-
return this.constructor.toObject(this,
|
|
1446
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
4118
1447
|
};
|
|
4119
1448
|
|
|
4120
1449
|
/**
|
|
@@ -4154,7 +1483,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4154
1483
|
*/
|
|
4155
1484
|
function SequenceAckMessage(properties) {
|
|
4156
1485
|
if (properties)
|
|
4157
|
-
for (
|
|
1486
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
4158
1487
|
if (properties[keys[i]] != null)
|
|
4159
1488
|
this[keys[i]] = properties[keys[i]];
|
|
4160
1489
|
}
|
|
@@ -4223,9 +1552,9 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4223
1552
|
SequenceAckMessage.decode = function decode(reader, length) {
|
|
4224
1553
|
if (!(reader instanceof $Reader))
|
|
4225
1554
|
reader = $Reader.create(reader);
|
|
4226
|
-
|
|
1555
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.SequenceAckMessage();
|
|
4227
1556
|
while (reader.pos < end) {
|
|
4228
|
-
|
|
1557
|
+
var tag = reader.uint32();
|
|
4229
1558
|
switch (tag >>> 3) {
|
|
4230
1559
|
case 1: {
|
|
4231
1560
|
message.sequenceId = reader.uint64();
|
|
@@ -4283,7 +1612,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4283
1612
|
SequenceAckMessage.fromObject = function fromObject(object) {
|
|
4284
1613
|
if (object instanceof $root.UpstreamMessage.SequenceAckMessage)
|
|
4285
1614
|
return object;
|
|
4286
|
-
|
|
1615
|
+
var message = new $root.UpstreamMessage.SequenceAckMessage();
|
|
4287
1616
|
if (object.sequenceId != null)
|
|
4288
1617
|
if ($util.Long)
|
|
4289
1618
|
(message.sequenceId = $util.Long.fromValue(object.sequenceId)).unsigned = true;
|
|
@@ -4308,10 +1637,10 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4308
1637
|
SequenceAckMessage.toObject = function toObject(message, options) {
|
|
4309
1638
|
if (!options)
|
|
4310
1639
|
options = {};
|
|
4311
|
-
|
|
1640
|
+
var object = {};
|
|
4312
1641
|
if (options.defaults)
|
|
4313
1642
|
if ($util.Long) {
|
|
4314
|
-
|
|
1643
|
+
var long = new $util.Long(0, 0, true);
|
|
4315
1644
|
object.sequenceId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
|
4316
1645
|
} else
|
|
4317
1646
|
object.sequenceId = options.longs === String ? "0" : 0;
|
|
@@ -4331,7 +1660,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4331
1660
|
* @returns {Object.<string,*>} JSON object
|
|
4332
1661
|
*/
|
|
4333
1662
|
SequenceAckMessage.prototype.toJSON = function toJSON() {
|
|
4334
|
-
return this.constructor.toObject(this,
|
|
1663
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
4335
1664
|
};
|
|
4336
1665
|
|
|
4337
1666
|
/**
|
|
@@ -4355,7 +1684,7 @@ const UpstreamMessage = $root.UpstreamMessage = (() => {
|
|
|
4355
1684
|
return UpstreamMessage;
|
|
4356
1685
|
})();
|
|
4357
1686
|
|
|
4358
|
-
|
|
1687
|
+
$root.DownstreamMessage = (function() {
|
|
4359
1688
|
|
|
4360
1689
|
/**
|
|
4361
1690
|
* Properties of a DownstreamMessage.
|
|
@@ -4376,7 +1705,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4376
1705
|
*/
|
|
4377
1706
|
function DownstreamMessage(properties) {
|
|
4378
1707
|
if (properties)
|
|
4379
|
-
for (
|
|
1708
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
4380
1709
|
if (properties[keys[i]] != null)
|
|
4381
1710
|
this[keys[i]] = properties[keys[i]];
|
|
4382
1711
|
}
|
|
@@ -4406,7 +1735,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4406
1735
|
DownstreamMessage.prototype.systemMessage = null;
|
|
4407
1736
|
|
|
4408
1737
|
// OneOf field names bound to virtual getters and setters
|
|
4409
|
-
|
|
1738
|
+
var $oneOfFields;
|
|
4410
1739
|
|
|
4411
1740
|
/**
|
|
4412
1741
|
* DownstreamMessage message.
|
|
@@ -4479,9 +1808,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4479
1808
|
DownstreamMessage.decode = function decode(reader, length) {
|
|
4480
1809
|
if (!(reader instanceof $Reader))
|
|
4481
1810
|
reader = $Reader.create(reader);
|
|
4482
|
-
|
|
1811
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage();
|
|
4483
1812
|
while (reader.pos < end) {
|
|
4484
|
-
|
|
1813
|
+
var tag = reader.uint32();
|
|
4485
1814
|
switch (tag >>> 3) {
|
|
4486
1815
|
case 1: {
|
|
4487
1816
|
message.ackMessage = $root.DownstreamMessage.AckMessage.decode(reader, reader.uint32());
|
|
@@ -4530,11 +1859,11 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4530
1859
|
DownstreamMessage.verify = function verify(message) {
|
|
4531
1860
|
if (typeof message !== "object" || message === null)
|
|
4532
1861
|
return "object expected";
|
|
4533
|
-
|
|
1862
|
+
var properties = {};
|
|
4534
1863
|
if (message.ackMessage != null && message.hasOwnProperty("ackMessage")) {
|
|
4535
1864
|
properties.message = 1;
|
|
4536
1865
|
{
|
|
4537
|
-
|
|
1866
|
+
var error = $root.DownstreamMessage.AckMessage.verify(message.ackMessage);
|
|
4538
1867
|
if (error)
|
|
4539
1868
|
return "ackMessage." + error;
|
|
4540
1869
|
}
|
|
@@ -4544,7 +1873,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4544
1873
|
return "message: multiple values";
|
|
4545
1874
|
properties.message = 1;
|
|
4546
1875
|
{
|
|
4547
|
-
|
|
1876
|
+
var error = $root.DownstreamMessage.DataMessage.verify(message.dataMessage);
|
|
4548
1877
|
if (error)
|
|
4549
1878
|
return "dataMessage." + error;
|
|
4550
1879
|
}
|
|
@@ -4554,7 +1883,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4554
1883
|
return "message: multiple values";
|
|
4555
1884
|
properties.message = 1;
|
|
4556
1885
|
{
|
|
4557
|
-
|
|
1886
|
+
var error = $root.DownstreamMessage.SystemMessage.verify(message.systemMessage);
|
|
4558
1887
|
if (error)
|
|
4559
1888
|
return "systemMessage." + error;
|
|
4560
1889
|
}
|
|
@@ -4573,7 +1902,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4573
1902
|
DownstreamMessage.fromObject = function fromObject(object) {
|
|
4574
1903
|
if (object instanceof $root.DownstreamMessage)
|
|
4575
1904
|
return object;
|
|
4576
|
-
|
|
1905
|
+
var message = new $root.DownstreamMessage();
|
|
4577
1906
|
if (object.ackMessage != null) {
|
|
4578
1907
|
if (typeof object.ackMessage !== "object")
|
|
4579
1908
|
throw TypeError(".DownstreamMessage.ackMessage: object expected");
|
|
@@ -4604,7 +1933,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4604
1933
|
DownstreamMessage.toObject = function toObject(message, options) {
|
|
4605
1934
|
if (!options)
|
|
4606
1935
|
options = {};
|
|
4607
|
-
|
|
1936
|
+
var object = {};
|
|
4608
1937
|
if (message.ackMessage != null && message.hasOwnProperty("ackMessage")) {
|
|
4609
1938
|
object.ackMessage = $root.DownstreamMessage.AckMessage.toObject(message.ackMessage, options);
|
|
4610
1939
|
if (options.oneofs)
|
|
@@ -4631,7 +1960,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4631
1960
|
* @returns {Object.<string,*>} JSON object
|
|
4632
1961
|
*/
|
|
4633
1962
|
DownstreamMessage.prototype.toJSON = function toJSON() {
|
|
4634
|
-
return this.constructor.toObject(this,
|
|
1963
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
4635
1964
|
};
|
|
4636
1965
|
|
|
4637
1966
|
/**
|
|
@@ -4670,7 +1999,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4670
1999
|
*/
|
|
4671
2000
|
function AckMessage(properties) {
|
|
4672
2001
|
if (properties)
|
|
4673
|
-
for (
|
|
2002
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
4674
2003
|
if (properties[keys[i]] != null)
|
|
4675
2004
|
this[keys[i]] = properties[keys[i]];
|
|
4676
2005
|
}
|
|
@@ -4700,7 +2029,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4700
2029
|
AckMessage.prototype.error = null;
|
|
4701
2030
|
|
|
4702
2031
|
// OneOf field names bound to virtual getters and setters
|
|
4703
|
-
|
|
2032
|
+
var $oneOfFields;
|
|
4704
2033
|
|
|
4705
2034
|
// Virtual OneOf for proto3 optional field
|
|
4706
2035
|
Object.defineProperty(AckMessage.prototype, "_error", {
|
|
@@ -4768,9 +2097,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4768
2097
|
AckMessage.decode = function decode(reader, length) {
|
|
4769
2098
|
if (!(reader instanceof $Reader))
|
|
4770
2099
|
reader = $Reader.create(reader);
|
|
4771
|
-
|
|
2100
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.AckMessage();
|
|
4772
2101
|
while (reader.pos < end) {
|
|
4773
|
-
|
|
2102
|
+
var tag = reader.uint32();
|
|
4774
2103
|
switch (tag >>> 3) {
|
|
4775
2104
|
case 1: {
|
|
4776
2105
|
message.ackId = reader.uint64();
|
|
@@ -4819,6 +2148,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4819
2148
|
AckMessage.verify = function verify(message) {
|
|
4820
2149
|
if (typeof message !== "object" || message === null)
|
|
4821
2150
|
return "object expected";
|
|
2151
|
+
var properties = {};
|
|
4822
2152
|
if (message.ackId != null && message.hasOwnProperty("ackId"))
|
|
4823
2153
|
if (!$util.isInteger(message.ackId) && !(message.ackId && $util.isInteger(message.ackId.low) && $util.isInteger(message.ackId.high)))
|
|
4824
2154
|
return "ackId: integer|Long expected";
|
|
@@ -4826,8 +2156,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4826
2156
|
if (typeof message.success !== "boolean")
|
|
4827
2157
|
return "success: boolean expected";
|
|
4828
2158
|
if (message.error != null && message.hasOwnProperty("error")) {
|
|
2159
|
+
properties._error = 1;
|
|
4829
2160
|
{
|
|
4830
|
-
|
|
2161
|
+
var error = $root.DownstreamMessage.AckMessage.ErrorMessage.verify(message.error);
|
|
4831
2162
|
if (error)
|
|
4832
2163
|
return "error." + error;
|
|
4833
2164
|
}
|
|
@@ -4846,7 +2177,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4846
2177
|
AckMessage.fromObject = function fromObject(object) {
|
|
4847
2178
|
if (object instanceof $root.DownstreamMessage.AckMessage)
|
|
4848
2179
|
return object;
|
|
4849
|
-
|
|
2180
|
+
var message = new $root.DownstreamMessage.AckMessage();
|
|
4850
2181
|
if (object.ackId != null)
|
|
4851
2182
|
if ($util.Long)
|
|
4852
2183
|
(message.ackId = $util.Long.fromValue(object.ackId)).unsigned = true;
|
|
@@ -4878,10 +2209,10 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4878
2209
|
AckMessage.toObject = function toObject(message, options) {
|
|
4879
2210
|
if (!options)
|
|
4880
2211
|
options = {};
|
|
4881
|
-
|
|
2212
|
+
var object = {};
|
|
4882
2213
|
if (options.defaults) {
|
|
4883
2214
|
if ($util.Long) {
|
|
4884
|
-
|
|
2215
|
+
var long = new $util.Long(0, 0, true);
|
|
4885
2216
|
object.ackId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
|
4886
2217
|
} else
|
|
4887
2218
|
object.ackId = options.longs === String ? "0" : 0;
|
|
@@ -4910,7 +2241,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4910
2241
|
* @returns {Object.<string,*>} JSON object
|
|
4911
2242
|
*/
|
|
4912
2243
|
AckMessage.prototype.toJSON = function toJSON() {
|
|
4913
|
-
return this.constructor.toObject(this,
|
|
2244
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
4914
2245
|
};
|
|
4915
2246
|
|
|
4916
2247
|
/**
|
|
@@ -4948,7 +2279,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
4948
2279
|
*/
|
|
4949
2280
|
function ErrorMessage(properties) {
|
|
4950
2281
|
if (properties)
|
|
4951
|
-
for (
|
|
2282
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
4952
2283
|
if (properties[keys[i]] != null)
|
|
4953
2284
|
this[keys[i]] = properties[keys[i]];
|
|
4954
2285
|
}
|
|
@@ -5027,9 +2358,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5027
2358
|
ErrorMessage.decode = function decode(reader, length) {
|
|
5028
2359
|
if (!(reader instanceof $Reader))
|
|
5029
2360
|
reader = $Reader.create(reader);
|
|
5030
|
-
|
|
2361
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.AckMessage.ErrorMessage();
|
|
5031
2362
|
while (reader.pos < end) {
|
|
5032
|
-
|
|
2363
|
+
var tag = reader.uint32();
|
|
5033
2364
|
switch (tag >>> 3) {
|
|
5034
2365
|
case 1: {
|
|
5035
2366
|
message.name = reader.string();
|
|
@@ -5094,7 +2425,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5094
2425
|
ErrorMessage.fromObject = function fromObject(object) {
|
|
5095
2426
|
if (object instanceof $root.DownstreamMessage.AckMessage.ErrorMessage)
|
|
5096
2427
|
return object;
|
|
5097
|
-
|
|
2428
|
+
var message = new $root.DownstreamMessage.AckMessage.ErrorMessage();
|
|
5098
2429
|
if (object.name != null)
|
|
5099
2430
|
message.name = String(object.name);
|
|
5100
2431
|
if (object.message != null)
|
|
@@ -5114,7 +2445,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5114
2445
|
ErrorMessage.toObject = function toObject(message, options) {
|
|
5115
2446
|
if (!options)
|
|
5116
2447
|
options = {};
|
|
5117
|
-
|
|
2448
|
+
var object = {};
|
|
5118
2449
|
if (options.defaults) {
|
|
5119
2450
|
object.name = "";
|
|
5120
2451
|
object.message = "";
|
|
@@ -5134,7 +2465,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5134
2465
|
* @returns {Object.<string,*>} JSON object
|
|
5135
2466
|
*/
|
|
5136
2467
|
ErrorMessage.prototype.toJSON = function toJSON() {
|
|
5137
|
-
return this.constructor.toObject(this,
|
|
2468
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
5138
2469
|
};
|
|
5139
2470
|
|
|
5140
2471
|
/**
|
|
@@ -5180,7 +2511,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5180
2511
|
*/
|
|
5181
2512
|
function DataMessage(properties) {
|
|
5182
2513
|
if (properties)
|
|
5183
|
-
for (
|
|
2514
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
5184
2515
|
if (properties[keys[i]] != null)
|
|
5185
2516
|
this[keys[i]] = properties[keys[i]];
|
|
5186
2517
|
}
|
|
@@ -5218,7 +2549,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5218
2549
|
DataMessage.prototype.sequenceId = null;
|
|
5219
2550
|
|
|
5220
2551
|
// OneOf field names bound to virtual getters and setters
|
|
5221
|
-
|
|
2552
|
+
var $oneOfFields;
|
|
5222
2553
|
|
|
5223
2554
|
// Virtual OneOf for proto3 optional field
|
|
5224
2555
|
Object.defineProperty(DataMessage.prototype, "_group", {
|
|
@@ -5294,9 +2625,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5294
2625
|
DataMessage.decode = function decode(reader, length) {
|
|
5295
2626
|
if (!(reader instanceof $Reader))
|
|
5296
2627
|
reader = $Reader.create(reader);
|
|
5297
|
-
|
|
2628
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.DataMessage();
|
|
5298
2629
|
while (reader.pos < end) {
|
|
5299
|
-
|
|
2630
|
+
var tag = reader.uint32();
|
|
5300
2631
|
switch (tag >>> 3) {
|
|
5301
2632
|
case 1: {
|
|
5302
2633
|
message.from = reader.string();
|
|
@@ -5349,19 +2680,22 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5349
2680
|
DataMessage.verify = function verify(message) {
|
|
5350
2681
|
if (typeof message !== "object" || message === null)
|
|
5351
2682
|
return "object expected";
|
|
2683
|
+
var properties = {};
|
|
5352
2684
|
if (message.from != null && message.hasOwnProperty("from"))
|
|
5353
2685
|
if (!$util.isString(message.from))
|
|
5354
2686
|
return "from: string expected";
|
|
5355
2687
|
if (message.group != null && message.hasOwnProperty("group")) {
|
|
2688
|
+
properties._group = 1;
|
|
5356
2689
|
if (!$util.isString(message.group))
|
|
5357
2690
|
return "group: string expected";
|
|
5358
2691
|
}
|
|
5359
2692
|
if (message.data != null && message.hasOwnProperty("data")) {
|
|
5360
|
-
|
|
2693
|
+
var error = $root.MessageData.verify(message.data);
|
|
5361
2694
|
if (error)
|
|
5362
2695
|
return "data." + error;
|
|
5363
2696
|
}
|
|
5364
2697
|
if (message.sequenceId != null && message.hasOwnProperty("sequenceId")) {
|
|
2698
|
+
properties._sequenceId = 1;
|
|
5365
2699
|
if (!$util.isInteger(message.sequenceId) && !(message.sequenceId && $util.isInteger(message.sequenceId.low) && $util.isInteger(message.sequenceId.high)))
|
|
5366
2700
|
return "sequenceId: integer|Long expected";
|
|
5367
2701
|
}
|
|
@@ -5379,7 +2713,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5379
2713
|
DataMessage.fromObject = function fromObject(object) {
|
|
5380
2714
|
if (object instanceof $root.DownstreamMessage.DataMessage)
|
|
5381
2715
|
return object;
|
|
5382
|
-
|
|
2716
|
+
var message = new $root.DownstreamMessage.DataMessage();
|
|
5383
2717
|
if (object.from != null)
|
|
5384
2718
|
message.from = String(object.from);
|
|
5385
2719
|
if (object.group != null)
|
|
@@ -5413,7 +2747,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5413
2747
|
DataMessage.toObject = function toObject(message, options) {
|
|
5414
2748
|
if (!options)
|
|
5415
2749
|
options = {};
|
|
5416
|
-
|
|
2750
|
+
var object = {};
|
|
5417
2751
|
if (options.defaults) {
|
|
5418
2752
|
object.from = "";
|
|
5419
2753
|
object.data = null;
|
|
@@ -5446,7 +2780,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5446
2780
|
* @returns {Object.<string,*>} JSON object
|
|
5447
2781
|
*/
|
|
5448
2782
|
DataMessage.prototype.toJSON = function toJSON() {
|
|
5449
|
-
return this.constructor.toObject(this,
|
|
2783
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
5450
2784
|
};
|
|
5451
2785
|
|
|
5452
2786
|
/**
|
|
@@ -5487,7 +2821,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5487
2821
|
*/
|
|
5488
2822
|
function SystemMessage(properties) {
|
|
5489
2823
|
if (properties)
|
|
5490
|
-
for (
|
|
2824
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
5491
2825
|
if (properties[keys[i]] != null)
|
|
5492
2826
|
this[keys[i]] = properties[keys[i]];
|
|
5493
2827
|
}
|
|
@@ -5509,7 +2843,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5509
2843
|
SystemMessage.prototype.disconnectedMessage = null;
|
|
5510
2844
|
|
|
5511
2845
|
// OneOf field names bound to virtual getters and setters
|
|
5512
|
-
|
|
2846
|
+
var $oneOfFields;
|
|
5513
2847
|
|
|
5514
2848
|
/**
|
|
5515
2849
|
* SystemMessage message.
|
|
@@ -5580,9 +2914,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5580
2914
|
SystemMessage.decode = function decode(reader, length) {
|
|
5581
2915
|
if (!(reader instanceof $Reader))
|
|
5582
2916
|
reader = $Reader.create(reader);
|
|
5583
|
-
|
|
2917
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.SystemMessage();
|
|
5584
2918
|
while (reader.pos < end) {
|
|
5585
|
-
|
|
2919
|
+
var tag = reader.uint32();
|
|
5586
2920
|
switch (tag >>> 3) {
|
|
5587
2921
|
case 1: {
|
|
5588
2922
|
message.connectedMessage = $root.DownstreamMessage.SystemMessage.ConnectedMessage.decode(reader, reader.uint32());
|
|
@@ -5627,11 +2961,11 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5627
2961
|
SystemMessage.verify = function verify(message) {
|
|
5628
2962
|
if (typeof message !== "object" || message === null)
|
|
5629
2963
|
return "object expected";
|
|
5630
|
-
|
|
2964
|
+
var properties = {};
|
|
5631
2965
|
if (message.connectedMessage != null && message.hasOwnProperty("connectedMessage")) {
|
|
5632
2966
|
properties.message = 1;
|
|
5633
2967
|
{
|
|
5634
|
-
|
|
2968
|
+
var error = $root.DownstreamMessage.SystemMessage.ConnectedMessage.verify(message.connectedMessage);
|
|
5635
2969
|
if (error)
|
|
5636
2970
|
return "connectedMessage." + error;
|
|
5637
2971
|
}
|
|
@@ -5641,7 +2975,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5641
2975
|
return "message: multiple values";
|
|
5642
2976
|
properties.message = 1;
|
|
5643
2977
|
{
|
|
5644
|
-
|
|
2978
|
+
var error = $root.DownstreamMessage.SystemMessage.DisconnectedMessage.verify(message.disconnectedMessage);
|
|
5645
2979
|
if (error)
|
|
5646
2980
|
return "disconnectedMessage." + error;
|
|
5647
2981
|
}
|
|
@@ -5660,7 +2994,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5660
2994
|
SystemMessage.fromObject = function fromObject(object) {
|
|
5661
2995
|
if (object instanceof $root.DownstreamMessage.SystemMessage)
|
|
5662
2996
|
return object;
|
|
5663
|
-
|
|
2997
|
+
var message = new $root.DownstreamMessage.SystemMessage();
|
|
5664
2998
|
if (object.connectedMessage != null) {
|
|
5665
2999
|
if (typeof object.connectedMessage !== "object")
|
|
5666
3000
|
throw TypeError(".DownstreamMessage.SystemMessage.connectedMessage: object expected");
|
|
@@ -5686,7 +3020,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5686
3020
|
SystemMessage.toObject = function toObject(message, options) {
|
|
5687
3021
|
if (!options)
|
|
5688
3022
|
options = {};
|
|
5689
|
-
|
|
3023
|
+
var object = {};
|
|
5690
3024
|
if (message.connectedMessage != null && message.hasOwnProperty("connectedMessage")) {
|
|
5691
3025
|
object.connectedMessage = $root.DownstreamMessage.SystemMessage.ConnectedMessage.toObject(message.connectedMessage, options);
|
|
5692
3026
|
if (options.oneofs)
|
|
@@ -5708,7 +3042,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5708
3042
|
* @returns {Object.<string,*>} JSON object
|
|
5709
3043
|
*/
|
|
5710
3044
|
SystemMessage.prototype.toJSON = function toJSON() {
|
|
5711
|
-
return this.constructor.toObject(this,
|
|
3045
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
5712
3046
|
};
|
|
5713
3047
|
|
|
5714
3048
|
/**
|
|
@@ -5747,7 +3081,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5747
3081
|
*/
|
|
5748
3082
|
function ConnectedMessage(properties) {
|
|
5749
3083
|
if (properties)
|
|
5750
|
-
for (
|
|
3084
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
5751
3085
|
if (properties[keys[i]] != null)
|
|
5752
3086
|
this[keys[i]] = properties[keys[i]];
|
|
5753
3087
|
}
|
|
@@ -5836,9 +3170,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5836
3170
|
ConnectedMessage.decode = function decode(reader, length) {
|
|
5837
3171
|
if (!(reader instanceof $Reader))
|
|
5838
3172
|
reader = $Reader.create(reader);
|
|
5839
|
-
|
|
3173
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.SystemMessage.ConnectedMessage();
|
|
5840
3174
|
while (reader.pos < end) {
|
|
5841
|
-
|
|
3175
|
+
var tag = reader.uint32();
|
|
5842
3176
|
switch (tag >>> 3) {
|
|
5843
3177
|
case 1: {
|
|
5844
3178
|
message.connectionId = reader.string();
|
|
@@ -5910,7 +3244,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5910
3244
|
ConnectedMessage.fromObject = function fromObject(object) {
|
|
5911
3245
|
if (object instanceof $root.DownstreamMessage.SystemMessage.ConnectedMessage)
|
|
5912
3246
|
return object;
|
|
5913
|
-
|
|
3247
|
+
var message = new $root.DownstreamMessage.SystemMessage.ConnectedMessage();
|
|
5914
3248
|
if (object.connectionId != null)
|
|
5915
3249
|
message.connectionId = String(object.connectionId);
|
|
5916
3250
|
if (object.userId != null)
|
|
@@ -5932,7 +3266,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5932
3266
|
ConnectedMessage.toObject = function toObject(message, options) {
|
|
5933
3267
|
if (!options)
|
|
5934
3268
|
options = {};
|
|
5935
|
-
|
|
3269
|
+
var object = {};
|
|
5936
3270
|
if (options.defaults) {
|
|
5937
3271
|
object.connectionId = "";
|
|
5938
3272
|
object.userId = "";
|
|
@@ -5955,7 +3289,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5955
3289
|
* @returns {Object.<string,*>} JSON object
|
|
5956
3290
|
*/
|
|
5957
3291
|
ConnectedMessage.prototype.toJSON = function toJSON() {
|
|
5958
|
-
return this.constructor.toObject(this,
|
|
3292
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
5959
3293
|
};
|
|
5960
3294
|
|
|
5961
3295
|
/**
|
|
@@ -5995,7 +3329,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
5995
3329
|
*/
|
|
5996
3330
|
function DisconnectedMessage(properties) {
|
|
5997
3331
|
if (properties)
|
|
5998
|
-
for (
|
|
3332
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
5999
3333
|
if (properties[keys[i]] != null)
|
|
6000
3334
|
this[keys[i]] = properties[keys[i]];
|
|
6001
3335
|
}
|
|
@@ -6064,9 +3398,9 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
6064
3398
|
DisconnectedMessage.decode = function decode(reader, length) {
|
|
6065
3399
|
if (!(reader instanceof $Reader))
|
|
6066
3400
|
reader = $Reader.create(reader);
|
|
6067
|
-
|
|
3401
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.SystemMessage.DisconnectedMessage();
|
|
6068
3402
|
while (reader.pos < end) {
|
|
6069
|
-
|
|
3403
|
+
var tag = reader.uint32();
|
|
6070
3404
|
switch (tag >>> 3) {
|
|
6071
3405
|
case 2: {
|
|
6072
3406
|
message.reason = reader.string();
|
|
@@ -6124,7 +3458,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
6124
3458
|
DisconnectedMessage.fromObject = function fromObject(object) {
|
|
6125
3459
|
if (object instanceof $root.DownstreamMessage.SystemMessage.DisconnectedMessage)
|
|
6126
3460
|
return object;
|
|
6127
|
-
|
|
3461
|
+
var message = new $root.DownstreamMessage.SystemMessage.DisconnectedMessage();
|
|
6128
3462
|
if (object.reason != null)
|
|
6129
3463
|
message.reason = String(object.reason);
|
|
6130
3464
|
return message;
|
|
@@ -6142,7 +3476,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
6142
3476
|
DisconnectedMessage.toObject = function toObject(message, options) {
|
|
6143
3477
|
if (!options)
|
|
6144
3478
|
options = {};
|
|
6145
|
-
|
|
3479
|
+
var object = {};
|
|
6146
3480
|
if (options.defaults)
|
|
6147
3481
|
object.reason = "";
|
|
6148
3482
|
if (message.reason != null && message.hasOwnProperty("reason"))
|
|
@@ -6158,7 +3492,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
6158
3492
|
* @returns {Object.<string,*>} JSON object
|
|
6159
3493
|
*/
|
|
6160
3494
|
DisconnectedMessage.prototype.toJSON = function toJSON() {
|
|
6161
|
-
return this.constructor.toObject(this,
|
|
3495
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
6162
3496
|
};
|
|
6163
3497
|
|
|
6164
3498
|
/**
|
|
@@ -6185,7 +3519,7 @@ const DownstreamMessage = $root.DownstreamMessage = (() => {
|
|
|
6185
3519
|
return DownstreamMessage;
|
|
6186
3520
|
})();
|
|
6187
3521
|
|
|
6188
|
-
|
|
3522
|
+
$root.MessageData = (function() {
|
|
6189
3523
|
|
|
6190
3524
|
/**
|
|
6191
3525
|
* Properties of a MessageData.
|
|
@@ -6207,7 +3541,7 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6207
3541
|
*/
|
|
6208
3542
|
function MessageData(properties) {
|
|
6209
3543
|
if (properties)
|
|
6210
|
-
for (
|
|
3544
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
6211
3545
|
if (properties[keys[i]] != null)
|
|
6212
3546
|
this[keys[i]] = properties[keys[i]];
|
|
6213
3547
|
}
|
|
@@ -6245,7 +3579,7 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6245
3579
|
MessageData.prototype.jsonData = null;
|
|
6246
3580
|
|
|
6247
3581
|
// OneOf field names bound to virtual getters and setters
|
|
6248
|
-
|
|
3582
|
+
var $oneOfFields;
|
|
6249
3583
|
|
|
6250
3584
|
/**
|
|
6251
3585
|
* MessageData data.
|
|
@@ -6320,9 +3654,9 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6320
3654
|
MessageData.decode = function decode(reader, length) {
|
|
6321
3655
|
if (!(reader instanceof $Reader))
|
|
6322
3656
|
reader = $Reader.create(reader);
|
|
6323
|
-
|
|
3657
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.MessageData();
|
|
6324
3658
|
while (reader.pos < end) {
|
|
6325
|
-
|
|
3659
|
+
var tag = reader.uint32();
|
|
6326
3660
|
switch (tag >>> 3) {
|
|
6327
3661
|
case 1: {
|
|
6328
3662
|
message.textData = reader.string();
|
|
@@ -6375,7 +3709,7 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6375
3709
|
MessageData.verify = function verify(message) {
|
|
6376
3710
|
if (typeof message !== "object" || message === null)
|
|
6377
3711
|
return "object expected";
|
|
6378
|
-
|
|
3712
|
+
var properties = {};
|
|
6379
3713
|
if (message.textData != null && message.hasOwnProperty("textData")) {
|
|
6380
3714
|
properties.data = 1;
|
|
6381
3715
|
if (!$util.isString(message.textData))
|
|
@@ -6393,7 +3727,7 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6393
3727
|
return "data: multiple values";
|
|
6394
3728
|
properties.data = 1;
|
|
6395
3729
|
{
|
|
6396
|
-
|
|
3730
|
+
var error = $root.google.protobuf.Any.verify(message.protobufData);
|
|
6397
3731
|
if (error)
|
|
6398
3732
|
return "protobufData." + error;
|
|
6399
3733
|
}
|
|
@@ -6419,7 +3753,7 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6419
3753
|
MessageData.fromObject = function fromObject(object) {
|
|
6420
3754
|
if (object instanceof $root.MessageData)
|
|
6421
3755
|
return object;
|
|
6422
|
-
|
|
3756
|
+
var message = new $root.MessageData();
|
|
6423
3757
|
if (object.textData != null)
|
|
6424
3758
|
message.textData = String(object.textData);
|
|
6425
3759
|
if (object.binaryData != null)
|
|
@@ -6449,7 +3783,7 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6449
3783
|
MessageData.toObject = function toObject(message, options) {
|
|
6450
3784
|
if (!options)
|
|
6451
3785
|
options = {};
|
|
6452
|
-
|
|
3786
|
+
var object = {};
|
|
6453
3787
|
if (message.textData != null && message.hasOwnProperty("textData")) {
|
|
6454
3788
|
object.textData = message.textData;
|
|
6455
3789
|
if (options.oneofs)
|
|
@@ -6481,7 +3815,7 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6481
3815
|
* @returns {Object.<string,*>} JSON object
|
|
6482
3816
|
*/
|
|
6483
3817
|
MessageData.prototype.toJSON = function toJSON() {
|
|
6484
|
-
return this.constructor.toObject(this,
|
|
3818
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
6485
3819
|
};
|
|
6486
3820
|
|
|
6487
3821
|
/**
|
|
@@ -6502,14 +3836,14 @@ const MessageData = $root.MessageData = (() => {
|
|
|
6502
3836
|
return MessageData;
|
|
6503
3837
|
})();
|
|
6504
3838
|
|
|
6505
|
-
|
|
3839
|
+
$root.google = (function() {
|
|
6506
3840
|
|
|
6507
3841
|
/**
|
|
6508
3842
|
* Namespace google.
|
|
6509
3843
|
* @exports google
|
|
6510
3844
|
* @namespace
|
|
6511
3845
|
*/
|
|
6512
|
-
|
|
3846
|
+
var google = {};
|
|
6513
3847
|
|
|
6514
3848
|
google.protobuf = (function() {
|
|
6515
3849
|
|
|
@@ -6518,7 +3852,7 @@ const google = $root.google = (() => {
|
|
|
6518
3852
|
* @memberof google
|
|
6519
3853
|
* @namespace
|
|
6520
3854
|
*/
|
|
6521
|
-
|
|
3855
|
+
var protobuf = {};
|
|
6522
3856
|
|
|
6523
3857
|
protobuf.Any = (function() {
|
|
6524
3858
|
|
|
@@ -6540,7 +3874,7 @@ const google = $root.google = (() => {
|
|
|
6540
3874
|
*/
|
|
6541
3875
|
function Any(properties) {
|
|
6542
3876
|
if (properties)
|
|
6543
|
-
for (
|
|
3877
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
6544
3878
|
if (properties[keys[i]] != null)
|
|
6545
3879
|
this[keys[i]] = properties[keys[i]];
|
|
6546
3880
|
}
|
|
@@ -6619,9 +3953,9 @@ const google = $root.google = (() => {
|
|
|
6619
3953
|
Any.decode = function decode(reader, length) {
|
|
6620
3954
|
if (!(reader instanceof $Reader))
|
|
6621
3955
|
reader = $Reader.create(reader);
|
|
6622
|
-
|
|
3956
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Any();
|
|
6623
3957
|
while (reader.pos < end) {
|
|
6624
|
-
|
|
3958
|
+
var tag = reader.uint32();
|
|
6625
3959
|
switch (tag >>> 3) {
|
|
6626
3960
|
case 1: {
|
|
6627
3961
|
message.type_url = reader.string();
|
|
@@ -6686,7 +4020,7 @@ const google = $root.google = (() => {
|
|
|
6686
4020
|
Any.fromObject = function fromObject(object) {
|
|
6687
4021
|
if (object instanceof $root.google.protobuf.Any)
|
|
6688
4022
|
return object;
|
|
6689
|
-
|
|
4023
|
+
var message = new $root.google.protobuf.Any();
|
|
6690
4024
|
if (object.type_url != null)
|
|
6691
4025
|
message.type_url = String(object.type_url);
|
|
6692
4026
|
if (object.value != null)
|
|
@@ -6709,7 +4043,7 @@ const google = $root.google = (() => {
|
|
|
6709
4043
|
Any.toObject = function toObject(message, options) {
|
|
6710
4044
|
if (!options)
|
|
6711
4045
|
options = {};
|
|
6712
|
-
|
|
4046
|
+
var object = {};
|
|
6713
4047
|
if (options.defaults) {
|
|
6714
4048
|
object.type_url = "";
|
|
6715
4049
|
if (options.bytes === String)
|
|
@@ -6735,7 +4069,7 @@ const google = $root.google = (() => {
|
|
|
6735
4069
|
* @returns {Object.<string,*>} JSON object
|
|
6736
4070
|
*/
|
|
6737
4071
|
Any.prototype.toJSON = function toJSON() {
|
|
6738
|
-
return this.constructor.toObject(this,
|
|
4072
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
6739
4073
|
};
|
|
6740
4074
|
|
|
6741
4075
|
/**
|
|
@@ -6762,271 +4096,4 @@ const google = $root.google = (() => {
|
|
|
6762
4096
|
return google;
|
|
6763
4097
|
})();
|
|
6764
4098
|
|
|
6765
|
-
|
|
6766
|
-
// Licensed under the MIT License.
|
|
6767
|
-
/**
|
|
6768
|
-
* The "protobuf.reliable.webpubsub.azure.v1" protocol
|
|
6769
|
-
*/
|
|
6770
|
-
class WebPubSubProtobufProtocolBase {
|
|
6771
|
-
/**
|
|
6772
|
-
* Creates WebPubSubMessage objects from the specified serialized representation.
|
|
6773
|
-
* @param input - The serialized representation
|
|
6774
|
-
*/
|
|
6775
|
-
static parseMessages(input) {
|
|
6776
|
-
const downstream = DownstreamMessage.decode(new Uint8Array(input));
|
|
6777
|
-
if (downstream.ackMessage) {
|
|
6778
|
-
const ack = {
|
|
6779
|
-
kind: "ack",
|
|
6780
|
-
ackId: this._getNumber(downstream.ackMessage.ackId),
|
|
6781
|
-
success: downstream.ackMessage.success,
|
|
6782
|
-
};
|
|
6783
|
-
if (downstream.ackMessage.error) {
|
|
6784
|
-
ack.error = {
|
|
6785
|
-
name: downstream.ackMessage.error.name,
|
|
6786
|
-
message: downstream.ackMessage.error.message,
|
|
6787
|
-
};
|
|
6788
|
-
}
|
|
6789
|
-
return ack;
|
|
6790
|
-
}
|
|
6791
|
-
else if (downstream.systemMessage) {
|
|
6792
|
-
if (downstream.systemMessage.connectedMessage) {
|
|
6793
|
-
const msg = downstream.systemMessage.connectedMessage;
|
|
6794
|
-
return {
|
|
6795
|
-
kind: "connected",
|
|
6796
|
-
connectionId: msg.connectionId,
|
|
6797
|
-
userId: msg.userId,
|
|
6798
|
-
reconnectionToken: msg.reconnectionToken,
|
|
6799
|
-
};
|
|
6800
|
-
}
|
|
6801
|
-
else if (downstream.systemMessage.disconnectedMessage) {
|
|
6802
|
-
const msg = downstream.systemMessage.disconnectedMessage;
|
|
6803
|
-
return { kind: "disconnected", message: msg.reason };
|
|
6804
|
-
}
|
|
6805
|
-
else {
|
|
6806
|
-
return null;
|
|
6807
|
-
}
|
|
6808
|
-
}
|
|
6809
|
-
else if (downstream.dataMessage) {
|
|
6810
|
-
const sequenceId = this._getNumber(downstream.dataMessage.sequenceId);
|
|
6811
|
-
const messageData = downstream.dataMessage.data;
|
|
6812
|
-
let dataType;
|
|
6813
|
-
let data;
|
|
6814
|
-
if (messageData.textData) {
|
|
6815
|
-
dataType = "text";
|
|
6816
|
-
data = messageData.textData;
|
|
6817
|
-
}
|
|
6818
|
-
else if (messageData.jsonData) {
|
|
6819
|
-
dataType = "json";
|
|
6820
|
-
data = JSON.parse(messageData.jsonData);
|
|
6821
|
-
}
|
|
6822
|
-
else if (messageData.binaryData) {
|
|
6823
|
-
dataType = "binary";
|
|
6824
|
-
data = messageData.binaryData.buffer.slice(messageData.binaryData.byteOffset, messageData.binaryData.byteLength + messageData.binaryData.byteOffset);
|
|
6825
|
-
}
|
|
6826
|
-
else if (messageData.protobufData) {
|
|
6827
|
-
dataType = "protobuf";
|
|
6828
|
-
data = messageData.protobufData;
|
|
6829
|
-
}
|
|
6830
|
-
else {
|
|
6831
|
-
return null;
|
|
6832
|
-
}
|
|
6833
|
-
if (downstream.dataMessage.from === "group") {
|
|
6834
|
-
return {
|
|
6835
|
-
kind: "groupData",
|
|
6836
|
-
dataType: dataType,
|
|
6837
|
-
data: data,
|
|
6838
|
-
sequenceId: sequenceId,
|
|
6839
|
-
group: downstream.dataMessage.group,
|
|
6840
|
-
};
|
|
6841
|
-
}
|
|
6842
|
-
else if (downstream.dataMessage.from === "server") {
|
|
6843
|
-
return {
|
|
6844
|
-
kind: "serverData",
|
|
6845
|
-
dataType: dataType,
|
|
6846
|
-
data: data,
|
|
6847
|
-
sequenceId: sequenceId,
|
|
6848
|
-
};
|
|
6849
|
-
}
|
|
6850
|
-
else {
|
|
6851
|
-
return null;
|
|
6852
|
-
}
|
|
6853
|
-
}
|
|
6854
|
-
else {
|
|
6855
|
-
return null;
|
|
6856
|
-
}
|
|
6857
|
-
}
|
|
6858
|
-
/**
|
|
6859
|
-
* Write WebPubSubMessage to string
|
|
6860
|
-
* @param message - The message to be written
|
|
6861
|
-
*/
|
|
6862
|
-
static writeMessage(message) {
|
|
6863
|
-
let upstream;
|
|
6864
|
-
switch (message.kind) {
|
|
6865
|
-
case "joinGroup": {
|
|
6866
|
-
const joinGroup = UpstreamMessage.JoinGroupMessage.create({
|
|
6867
|
-
group: message.group,
|
|
6868
|
-
ackId: message.ackId,
|
|
6869
|
-
});
|
|
6870
|
-
upstream = UpstreamMessage.create({ joinGroupMessage: joinGroup });
|
|
6871
|
-
break;
|
|
6872
|
-
}
|
|
6873
|
-
case "leaveGroup": {
|
|
6874
|
-
const leaveGroup = UpstreamMessage.LeaveGroupMessage.create({
|
|
6875
|
-
group: message.group,
|
|
6876
|
-
ackId: message.ackId,
|
|
6877
|
-
});
|
|
6878
|
-
upstream = UpstreamMessage.create({ leaveGroupMessage: leaveGroup });
|
|
6879
|
-
break;
|
|
6880
|
-
}
|
|
6881
|
-
case "sendToGroup": {
|
|
6882
|
-
const sendToGroup = UpstreamMessage.SendToGroupMessage.create({
|
|
6883
|
-
group: message.group,
|
|
6884
|
-
ackId: message.ackId,
|
|
6885
|
-
data: this._getIMessageData(message.data, message.dataType),
|
|
6886
|
-
noEcho: message.noEcho,
|
|
6887
|
-
});
|
|
6888
|
-
upstream = UpstreamMessage.create({ sendToGroupMessage: sendToGroup });
|
|
6889
|
-
break;
|
|
6890
|
-
}
|
|
6891
|
-
case "sendEvent": {
|
|
6892
|
-
const sendEvent = UpstreamMessage.EventMessage.create({
|
|
6893
|
-
event: message.event,
|
|
6894
|
-
ackId: message.ackId,
|
|
6895
|
-
data: this._getIMessageData(message.data, message.dataType),
|
|
6896
|
-
});
|
|
6897
|
-
upstream = UpstreamMessage.create({ eventMessage: sendEvent });
|
|
6898
|
-
break;
|
|
6899
|
-
}
|
|
6900
|
-
case "sequenceAck": {
|
|
6901
|
-
const sequenceAck = UpstreamMessage.SequenceAckMessage.create({
|
|
6902
|
-
sequenceId: message.sequenceId,
|
|
6903
|
-
});
|
|
6904
|
-
upstream = UpstreamMessage.create({ sequenceAckMessage: sequenceAck });
|
|
6905
|
-
break;
|
|
6906
|
-
}
|
|
6907
|
-
default:
|
|
6908
|
-
throw new TypeError(`kind is not supported: ${message.kind}`);
|
|
6909
|
-
}
|
|
6910
|
-
return UpstreamMessage.encode(upstream).finish();
|
|
6911
|
-
}
|
|
6912
|
-
static _getIMessageData(data, dataType) {
|
|
6913
|
-
switch (dataType) {
|
|
6914
|
-
case "binary":
|
|
6915
|
-
if (!(data instanceof ArrayBuffer)) {
|
|
6916
|
-
throw new TypeError("Message must be a ArrayBuffer.");
|
|
6917
|
-
}
|
|
6918
|
-
return MessageData.create({ binaryData: new Uint8Array(data) });
|
|
6919
|
-
case "protobuf":
|
|
6920
|
-
if (WebPubSubProtobufProtocolBase._isIAny(data)) {
|
|
6921
|
-
return MessageData.create({
|
|
6922
|
-
protobufData: google.protobuf.Any.create({
|
|
6923
|
-
type_url: data.type_url,
|
|
6924
|
-
value: new Uint8Array(data.value),
|
|
6925
|
-
}),
|
|
6926
|
-
});
|
|
6927
|
-
}
|
|
6928
|
-
throw new TypeError("Message must be a google.protobuf.Any.");
|
|
6929
|
-
case "text":
|
|
6930
|
-
if (typeof data !== "string") {
|
|
6931
|
-
throw new TypeError("Message must be a string.");
|
|
6932
|
-
}
|
|
6933
|
-
return MessageData.create({ textData: data });
|
|
6934
|
-
case "json":
|
|
6935
|
-
return MessageData.create({ jsonData: JSON.stringify(data) });
|
|
6936
|
-
default:
|
|
6937
|
-
throw new TypeError(`dataType is not supported: ${dataType}`);
|
|
6938
|
-
}
|
|
6939
|
-
}
|
|
6940
|
-
static _getNumber(value) {
|
|
6941
|
-
if (value === null || value === undefined || typeof value === "number") {
|
|
6942
|
-
return value;
|
|
6943
|
-
}
|
|
6944
|
-
return value.toNumber();
|
|
6945
|
-
}
|
|
6946
|
-
static _isIAny(obj) {
|
|
6947
|
-
return "type_url" in obj && "value" in obj;
|
|
6948
|
-
}
|
|
6949
|
-
}
|
|
6950
|
-
|
|
6951
|
-
// Copyright (c) Microsoft Corporation.
|
|
6952
|
-
// Licensed under the MIT License.
|
|
6953
|
-
/**
|
|
6954
|
-
* The "protobuf.reliable.webpubsub.azure.v1" protocol
|
|
6955
|
-
*/
|
|
6956
|
-
class WebPubSubProtobufProtocolImpl {
|
|
6957
|
-
constructor() {
|
|
6958
|
-
/**
|
|
6959
|
-
* True if the protocol supports reliable features
|
|
6960
|
-
*/
|
|
6961
|
-
this.isReliableSubProtocol = false;
|
|
6962
|
-
/**
|
|
6963
|
-
* The name of subprotocol. Name will be used in websocket subprotocol
|
|
6964
|
-
*/
|
|
6965
|
-
this.name = "protobuf.webpubsub.azure.v1";
|
|
6966
|
-
}
|
|
6967
|
-
/**
|
|
6968
|
-
* Creates WebPubSubMessage objects from the specified serialized representation.
|
|
6969
|
-
* @param input - The serialized representation
|
|
6970
|
-
*/
|
|
6971
|
-
parseMessages(input) {
|
|
6972
|
-
return WebPubSubProtobufProtocolBase.parseMessages(input);
|
|
6973
|
-
}
|
|
6974
|
-
/**
|
|
6975
|
-
* Write WebPubSubMessage to string
|
|
6976
|
-
* @param message - The message to be written
|
|
6977
|
-
*/
|
|
6978
|
-
writeMessage(message) {
|
|
6979
|
-
return WebPubSubProtobufProtocolBase.writeMessage(message);
|
|
6980
|
-
}
|
|
6981
|
-
}
|
|
6982
|
-
|
|
6983
|
-
// Copyright (c) Microsoft Corporation.
|
|
6984
|
-
// Licensed under the MIT License.
|
|
6985
|
-
/**
|
|
6986
|
-
* The "protobuf.reliable.webpubsub.azure.v1" protocol
|
|
6987
|
-
*/
|
|
6988
|
-
class WebPubSubProtobufReliableProtocolImpl {
|
|
6989
|
-
constructor() {
|
|
6990
|
-
/**
|
|
6991
|
-
* True if the protocol supports reliable features
|
|
6992
|
-
*/
|
|
6993
|
-
this.isReliableSubProtocol = true;
|
|
6994
|
-
/**
|
|
6995
|
-
* The name of subprotocol. Name will be used in websocket subprotocol
|
|
6996
|
-
*/
|
|
6997
|
-
this.name = "protobuf.reliable.webpubsub.azure.v1";
|
|
6998
|
-
}
|
|
6999
|
-
/**
|
|
7000
|
-
* Creates WebPubSubMessage objects from the specified serialized representation.
|
|
7001
|
-
* @param input - The serialized representation
|
|
7002
|
-
*/
|
|
7003
|
-
parseMessages(input) {
|
|
7004
|
-
return WebPubSubProtobufProtocolBase.parseMessages(input);
|
|
7005
|
-
}
|
|
7006
|
-
/**
|
|
7007
|
-
* Write WebPubSubMessage to string
|
|
7008
|
-
* @param message - The message to be written
|
|
7009
|
-
*/
|
|
7010
|
-
writeMessage(message) {
|
|
7011
|
-
return WebPubSubProtobufProtocolBase.writeMessage(message);
|
|
7012
|
-
}
|
|
7013
|
-
}
|
|
7014
|
-
|
|
7015
|
-
// Copyright (c) Microsoft Corporation.
|
|
7016
|
-
// Licensed under the MIT License.
|
|
7017
|
-
/**
|
|
7018
|
-
* Return the "protobuf.webpubsub.azure.v1" protocol
|
|
7019
|
-
*/
|
|
7020
|
-
const WebPubSubProtobufProtocol = () => {
|
|
7021
|
-
return new WebPubSubProtobufProtocolImpl();
|
|
7022
|
-
};
|
|
7023
|
-
/**
|
|
7024
|
-
* Return the "protobuf.reliable.webpubsub.azure.v1" protocol
|
|
7025
|
-
*/
|
|
7026
|
-
const WebPubSubProtobufReliableProtocol = () => {
|
|
7027
|
-
return new WebPubSubProtobufReliableProtocolImpl();
|
|
7028
|
-
};
|
|
7029
|
-
|
|
7030
|
-
exports.WebPubSubProtobufProtocol = WebPubSubProtobufProtocol;
|
|
7031
|
-
exports.WebPubSubProtobufReliableProtocol = WebPubSubProtobufReliableProtocol;
|
|
7032
|
-
//# sourceMappingURL=index.js.map
|
|
4099
|
+
module.exports = $root;
|