vendor: 4,999 bytes, lines 1-160
1/*! 2 * protobuf.js v7.6.5 (c) 2016, daniel wirtz 3 * compiled sat, 04 jul 2026 01:13:07 utc 4 * licensed under the bsd-3-clause license 5 * see: https://github.com/dcodeio/protobuf.js for details 6 * 7 * Modify list for integration with Bitrix Framework: 8 * - removed integration with RequireJS and AMD package builders; 9 * - removed the source map reference, the map file is not shipped; 10 */ 11(function(undefined){"use strict";(function prelude(modules, cache, entries) { 12 13 // This is the prelude used to bundle protobuf.js for the browser. Wraps up the CommonJS 14 // sources through a conflict-free require shim and is again wrapped within an iife that 15 // provides a minification-friendly `undefined` var plus a global "use strict" directive 16 // so that minification can remove the directives of each module. 17 18 function $require(name) { 19 var $module = cache[name]; 20 if (!$module) 21 modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports); 22 return $module.exports; 23 } 24 25 var protobuf = $require(entries[0]); 26 27 // Expose globally 28 protobuf.util.global.protobuf = protobuf; 29 30 // Be nice to AMD 31 /*if (typeof define === "function" && define.amd) 32 define(["long"], function(Long) { 33 if (Long && Long.isLong) { 34 protobuf.util.Long = Long; 35 protobuf.configure(); 36 } 37 return protobuf; 38 });*/ 39 40 // Be nice to CommonJS 41 /*if (typeof module === "object" && module && module.exports) 42 module.exports = protobuf;*/ 43 44})/* end of prelude */({1:[function(require,module,exports){ 45"use strict"; 46module.exports = asPromise; 47 48/** 49 * Callback as used by {@link util.asPromise}. 50 * @typedef asPromiseCallback 51 * @type {function} 52 * @param {Error|null} error Error, if any 53 * @param {...*} params Additional arguments 54 * @returns {undefined} 55 */ 56 57/** 58 * Returns a promise from a node-style callback function. 59 * @memberof util 60 * @param {asPromiseCallback} fn Function to call 61 * @param {*} ctx Function context 62 * @param {...*} params Function arguments 63 * @returns {Promise<*>} Promisified function 64 */ 65function asPromise(fn, ctx/*, varargs */) { 66 var params = new Array(arguments.length - 1), 67 offset = 0, 68 index = 2, 69 pending = true; 70 while (index < arguments.length) 71 params[offset++] = arguments[index++]; 72 return new Promise(function executor(resolve, reject) { 73 params[offset] = function callback(err/*, varargs */) { 74 if (pending) { 75 pending = false; 76 if (err) 77 reject(err); 78 else { 79 var params = new Array(arguments.length - 1), 80 offset = 0; 81 while (offset < params.length) 82 params[offset++] = arguments[offset]; 83 resolve.apply(null, params); 84 } 85 } 86 }; 87 try { 88 fn.apply(ctx || null, params); 89 } catch (err) { 90 if (pending) { 91 pending = false; 92 reject(err); 93 } 94 } 95 }); 96} 97 98},{}],2:[function(require,module,exports){ 99"use strict"; 100 101/** 102 * A minimal base64 implementation for number arrays. 103 * @memberof util 104 * @namespace 105 */ 106var base64 = exports; 107 108/** 109 * Calculates the byte length of a base64 encoded string. 110 * @param {string} string Base64 encoded string 111 * @returns {number} Byte length 112 */ 113base64.length = function length(string) { 114 var p = string.length; 115 if (!p) 116 return 0; 117 var n = 0; 118 while (--p % 4 > 1 && string.charAt(p) === "=") 119 ++n; 120 return Math.ceil(string.length * 3) / 4 - n; 121}; 122 123// Base64 encoding table 124var b64 = new Array(64); 125 126// Base64 decoding table 127var s64 = new Array(123); 128 129// 65..90, 97..122, 48..57, 43, 47 130for (var i = 0; i < 64;) 131 s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++; 132 133/** 134 * Encodes a buffer to a base64 encoded string. 135 * @param {Uint8Array} buffer Source buffer 136 * @param {number} start Source start 137 * @param {number} end Source end 138 * @returns {string} Base64 encoded string 139 */ 140base64.encode = function encode(buffer, start, end) { 141 var parts = null, 142 chunk = []; 143 var i = 0, // output index 144 j = 0, // goto index 145 t; // temporary 146 while (start < end) { 147 var b = buffer[start++]; 148 switch (j) { 149 case 0: 150 chunk[i++] = b64[b >> 2]; 151 t = (b & 3) << 4; 152 j = 1; 153 break; 154 case 1: 155 chunk[i++] = b64[t | b >> 4]; 156 t = (b & 15) << 2; 157 j = 2; 158 break; 159 case 2: 160 chunk[i++] = b64[t | b >> 6];
vendor: 9,918 bytes, lines 161-489
161 chunk[i++] = b64[b & 63]; 162 j = 0; 163 break; 164 } 165 if (i > 8191) { 166 (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); 167 i = 0; 168 } 169 } 170 if (j) { 171 chunk[i++] = b64[t]; 172 chunk[i++] = 61; 173 if (j === 1) 174 chunk[i++] = 61; 175 } 176 if (parts) { 177 if (i) 178 parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); 179 return parts.join(""); 180 } 181 return String.fromCharCode.apply(String, chunk.slice(0, i)); 182}; 183 184var invalidEncoding = "invalid encoding"; 185 186/** 187 * Decodes a base64 encoded string to a buffer. 188 * @param {string} string Source string 189 * @param {Uint8Array} buffer Destination buffer 190 * @param {number} offset Destination offset 191 * @returns {number} Number of bytes written 192 * @throws {Error} If encoding is invalid 193 */ 194base64.decode = function decode(string, buffer, offset) { 195 var start = offset; 196 var j = 0, // goto index 197 t; // temporary 198 for (var i = 0; i < string.length;) { 199 var c = string.charCodeAt(i++); 200 if (c === 61 && j > 1) 201 break; 202 if ((c = s64[c]) === undefined) 203 throw Error(invalidEncoding); 204 switch (j) { 205 case 0: 206 t = c; 207 j = 1; 208 break; 209 case 1: 210 buffer[offset++] = t << 2 | (c & 48) >> 4; 211 t = c; 212 j = 2; 213 break; 214 case 2: 215 buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2; 216 t = c; 217 j = 3; 218 break; 219 case 3: 220 buffer[offset++] = (t & 3) << 6 | c; 221 j = 0; 222 break; 223 } 224 } 225 if (j === 1) 226 throw Error(invalidEncoding); 227 return offset - start; 228}; 229 230/** 231 * Tests if the specified string appears to be base64 encoded. 232 * @param {string} string String to test 233 * @returns {boolean} `true` if probably base64 encoded, otherwise false 234 */ 235base64.test = function test(string) { 236 return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string); 237}; 238 239},{}],3:[function(require,module,exports){ 240"use strict"; 241module.exports = EventEmitter; 242 243/** 244 * Constructs a new event emitter instance. 245 * @classdesc A minimal event emitter. 246 * @memberof util 247 * @constructor 248 */ 249function EventEmitter() { 250 251 /** 252 * Registered listeners. 253 * @type {Object.<string,*>} 254 * @private 255 */ 256 this._listeners = Object.create(null); 257} 258 259/** 260 * Event listener as used by {@link util.EventEmitter}. 261 * @typedef EventEmitterListener 262 * @type {function} 263 * @param {...*} args Arguments 264 * @returns {undefined} 265 */ 266 267/** 268 * Registers an event listener. 269 * @param {string} evt Event name 270 * @param {EventEmitterListener} fn Listener 271 * @param {*} [ctx] Listener context 272 * @returns {this} `this` 273 */ 274EventEmitter.prototype.on = function on(evt, fn, ctx) { 275 (this._listeners[evt] || (this._listeners[evt] = [])).push({ 276 fn : fn, 277 ctx : ctx || this 278 }); 279 return this; 280}; 281 282/** 283 * Removes an event listener or any matching listeners if arguments are omitted. 284 * @param {string} [evt] Event name. Removes all listeners if omitted. 285 * @param {EventEmitterListener} [fn] Listener to remove. Removes all listeners of `evt` if omitted. 286 * @returns {this} `this` 287 */ 288EventEmitter.prototype.off = function off(evt, fn) { 289 if (evt === undefined) 290 this._listeners = Object.create(null); 291 else { 292 if (fn === undefined) 293 this._listeners[evt] = []; 294 else { 295 var listeners = this._listeners[evt]; 296 if (!listeners) 297 return this; 298 for (var i = 0; i < listeners.length;) 299 if (listeners[i].fn === fn) 300 listeners.splice(i, 1); 301 else 302 ++i; 303 } 304 } 305 return this; 306}; 307 308/** 309 * Emits an event by calling its listeners with the specified arguments. 310 * @param {string} evt Event name 311 * @param {...*} args Arguments 312 * @returns {this} `this` 313 */ 314EventEmitter.prototype.emit = function emit(evt) { 315 var listeners = this._listeners[evt]; 316 if (listeners) { 317 var args = [], 318 i = 1; 319 for (; i < arguments.length;) 320 args.push(arguments[i++]); 321 for (i = 0; i < listeners.length;) 322 listeners[i].fn.apply(listeners[i++].ctx, args); 323 } 324 return this; 325}; 326 327},{}],4:[function(require,module,exports){ 328"use strict"; 329 330module.exports = factory(factory); 331 332/** 333 * Reads / writes floats / doubles from / to buffers. 334 * @name util.float 335 * @namespace 336 */ 337 338/** 339 * Writes a 32 bit float to a buffer using little endian byte order. 340 * @name util.float.writeFloatLE 341 * @function 342 * @param {number} val Value to write 343 * @param {Uint8Array} buf Target buffer 344 * @param {number} pos Target buffer offset 345 * @returns {undefined} 346 */ 347 348/** 349 * Writes a 32 bit float to a buffer using big endian byte order. 350 * @name util.float.writeFloatBE 351 * @function 352 * @param {number} val Value to write 353 * @param {Uint8Array} buf Target buffer 354 * @param {number} pos Target buffer offset 355 * @returns {undefined} 356 */ 357 358/** 359 * Reads a 32 bit float from a buffer using little endian byte order. 360 * @name util.float.readFloatLE 361 * @function 362 * @param {Uint8Array} buf Source buffer 363 * @param {number} pos Source buffer offset 364 * @returns {number} Value read 365 */ 366 367/** 368 * Reads a 32 bit float from a buffer using big endian byte order. 369 * @name util.float.readFloatBE 370 * @function 371 * @param {Uint8Array} buf Source buffer 372 * @param {number} pos Source buffer offset 373 * @returns {number} Value read 374 */ 375 376/** 377 * Writes a 64 bit double to a buffer using little endian byte order. 378 * @name util.float.writeDoubleLE 379 * @function 380 * @param {number} val Value to write 381 * @param {Uint8Array} buf Target buffer 382 * @param {number} pos Target buffer offset 383 * @returns {undefined} 384 */ 385 386/** 387 * Writes a 64 bit double to a buffer using big endian byte order. 388 * @name util.float.writeDoubleBE 389 * @function 390 * @param {number} val Value to write 391 * @param {Uint8Array} buf Target buffer 392 * @param {number} pos Target buffer offset 393 * @returns {undefined} 394 */ 395 396/** 397 * Reads a 64 bit double from a buffer using little endian byte order. 398 * @name util.float.readDoubleLE 399 * @function 400 * @param {Uint8Array} buf Source buffer 401 * @param {number} pos Source buffer offset 402 * @returns {number} Value read 403 */ 404 405/** 406 * Reads a 64 bit double from a buffer using big endian byte order. 407 * @name util.float.readDoubleBE 408 * @function 409 * @param {Uint8Array} buf Source buffer 410 * @param {number} pos Source buffer offset 411 * @returns {number} Value read 412 */ 413 414// Factory function for the purpose of node-based testing in modified global environments 415function factory(exports) { 416 417 // float: typed array 418 if (typeof Float32Array !== "undefined") (function() { 419 420 var f32 = new Float32Array([ -0 ]), 421 f8b = new Uint8Array(f32.buffer), 422 le = f8b[3] === 128; 423 424 function writeFloat_f32_cpy(val, buf, pos) { 425 f32[0] = val; 426 buf[pos ] = f8b[0]; 427 buf[pos + 1] = f8b[1]; 428 buf[pos + 2] = f8b[2]; 429 buf[pos + 3] = f8b[3]; 430 } 431 432 function writeFloat_f32_rev(val, buf, pos) { 433 f32[0] = val; 434 buf[pos ] = f8b[3]; 435 buf[pos + 1] = f8b[2]; 436 buf[pos + 2] = f8b[1]; 437 buf[pos + 3] = f8b[0]; 438 } 439 440 /* istanbul ignore next */ 441 exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev; 442 /* istanbul ignore next */ 443 exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy; 444 445 function readFloat_f32_cpy(buf, pos) { 446 f8b[0] = buf[pos ]; 447 f8b[1] = buf[pos + 1]; 448 f8b[2] = buf[pos + 2]; 449 f8b[3] = buf[pos + 3]; 450 return f32[0]; 451 } 452 453 function readFloat_f32_rev(buf, pos) { 454 f8b[3] = buf[pos ]; 455 f8b[2] = buf[pos + 1]; 456 f8b[1] = buf[pos + 2]; 457 f8b[0] = buf[pos + 3]; 458 return f32[0]; 459 } 460 461 /* istanbul ignore next */ 462 exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev; 463 /* istanbul ignore next */ 464 exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy; 465 466 // float: ieee754 467 })(); else (function() { 468 469 function writeFloat_ieee754(writeUint, val, buf, pos) { 470 var sign = val < 0 ? 1 : 0; 471 if (sign) 472 val = -val; 473 if (val === 0) 474 writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos); 475 else if (isNaN(val)) 476 writeUint(2143289344, buf, pos); 477 else if (val > 3.4028234663852886e+38) // +-Infinity 478 writeUint((sign << 31 | 2139095040) >>> 0, buf, pos); 479 else if (val < 1.1754943508222875e-38) // denormal 480 writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos); 481 else { 482 var exponent = Math.floor(Math.log(val) / Math.LN2), 483 mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607; 484 writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos); 485 } 486 } 487 488 exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE); 489 exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
vendor: 13,813 bytes, lines 490-926
490 491 function readFloat_ieee754(readUint, buf, pos) { 492 var uint = readUint(buf, pos), 493 sign = (uint >> 31) * 2 + 1, 494 exponent = uint >>> 23 & 255, 495 mantissa = uint & 8388607; 496 return exponent === 255 497 ? mantissa 498 ? NaN 499 : sign * Infinity 500 : exponent === 0 // denormal 501 ? sign * 1.401298464324817e-45 * mantissa 502 : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608); 503 } 504 505 exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE); 506 exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE); 507 508 })(); 509 510 // double: typed array 511 if (typeof Float64Array !== "undefined") (function() { 512 513 var f64 = new Float64Array([-0]), 514 f8b = new Uint8Array(f64.buffer), 515 le = f8b[7] === 128; 516 517 function writeDouble_f64_cpy(val, buf, pos) { 518 f64[0] = val; 519 buf[pos ] = f8b[0]; 520 buf[pos + 1] = f8b[1]; 521 buf[pos + 2] = f8b[2]; 522 buf[pos + 3] = f8b[3]; 523 buf[pos + 4] = f8b[4]; 524 buf[pos + 5] = f8b[5]; 525 buf[pos + 6] = f8b[6]; 526 buf[pos + 7] = f8b[7]; 527 } 528 529 function writeDouble_f64_rev(val, buf, pos) { 530 f64[0] = val; 531 buf[pos ] = f8b[7]; 532 buf[pos + 1] = f8b[6]; 533 buf[pos + 2] = f8b[5]; 534 buf[pos + 3] = f8b[4]; 535 buf[pos + 4] = f8b[3]; 536 buf[pos + 5] = f8b[2]; 537 buf[pos + 6] = f8b[1]; 538 buf[pos + 7] = f8b[0]; 539 } 540 541 /* istanbul ignore next */ 542 exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev; 543 /* istanbul ignore next */ 544 exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy; 545 546 function readDouble_f64_cpy(buf, pos) { 547 f8b[0] = buf[pos ]; 548 f8b[1] = buf[pos + 1]; 549 f8b[2] = buf[pos + 2]; 550 f8b[3] = buf[pos + 3]; 551 f8b[4] = buf[pos + 4]; 552 f8b[5] = buf[pos + 5]; 553 f8b[6] = buf[pos + 6]; 554 f8b[7] = buf[pos + 7]; 555 return f64[0]; 556 } 557 558 function readDouble_f64_rev(buf, pos) { 559 f8b[7] = buf[pos ]; 560 f8b[6] = buf[pos + 1]; 561 f8b[5] = buf[pos + 2]; 562 f8b[4] = buf[pos + 3]; 563 f8b[3] = buf[pos + 4]; 564 f8b[2] = buf[pos + 5]; 565 f8b[1] = buf[pos + 6]; 566 f8b[0] = buf[pos + 7]; 567 return f64[0]; 568 } 569 570 /* istanbul ignore next */ 571 exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev; 572 /* istanbul ignore next */ 573 exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy; 574 575 // double: ieee754 576 })(); else (function() { 577 578 function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) { 579 var sign = val < 0 ? 1 : 0; 580 if (sign) 581 val = -val; 582 if (val === 0) { 583 writeUint(0, buf, pos + off0); 584 writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1); 585 } else if (isNaN(val)) { 586 writeUint(0, buf, pos + off0); 587 writeUint(2146959360, buf, pos + off1); 588 } else if (val > 1.7976931348623157e+308) { // +-Infinity 589 writeUint(0, buf, pos + off0); 590 writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1); 591 } else { 592 var mantissa; 593 if (val < 2.2250738585072014e-308) { // denormal 594 mantissa = val / 5e-324; 595 writeUint(mantissa >>> 0, buf, pos + off0); 596 writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1); 597 } else { 598 var exponent = Math.floor(Math.log(val) / Math.LN2); 599 if (exponent === 1024) 600 exponent = 1023; 601 mantissa = val * Math.pow(2, -exponent); 602 writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0); 603 writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1); 604 } 605 } 606 } 607 608 exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4); 609 exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0); 610 611 function readDouble_ieee754(readUint, off0, off1, buf, pos) { 612 var lo = readUint(buf, pos + off0), 613 hi = readUint(buf, pos + off1); 614 var sign = (hi >> 31) * 2 + 1, 615 exponent = hi >>> 20 & 2047, 616 mantissa = 4294967296 * (hi & 1048575) + lo; 617 return exponent === 2047 618 ? mantissa 619 ? NaN 620 : sign * Infinity 621 : exponent === 0 // denormal 622 ? sign * 5e-324 * mantissa 623 : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496); 624 } 625 626 exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4); 627 exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0); 628 629 })(); 630 631 return exports; 632} 633 634// uint helpers 635 636function writeUintLE(val, buf, pos) { 637 buf[pos ] = val & 255; 638 buf[pos + 1] = val >>> 8 & 255; 639 buf[pos + 2] = val >>> 16 & 255; 640 buf[pos + 3] = val >>> 24; 641} 642 643function writeUintBE(val, buf, pos) { 644 buf[pos ] = val >>> 24; 645 buf[pos + 1] = val >>> 16 & 255; 646 buf[pos + 2] = val >>> 8 & 255; 647 buf[pos + 3] = val & 255; 648} 649 650function readUintLE(buf, pos) { 651 return (buf[pos ] 652 | buf[pos + 1] << 8 653 | buf[pos + 2] << 16 654 | buf[pos + 3] << 24) >>> 0; 655} 656 657function readUintBE(buf, pos) { 658 return (buf[pos ] << 24 659 | buf[pos + 1] << 16 660 | buf[pos + 2] << 8 661 | buf[pos + 3]) >>> 0; 662} 663 664},{}],5:[function(require,module,exports){ 665"use strict"; 666module.exports = pool; 667 668/** 669 * An allocator as used by {@link util.pool}. 670 * @typedef PoolAllocator 671 * @type {function} 672 * @param {number} size Buffer size 673 * @returns {Uint8Array} Buffer 674 */ 675 676/** 677 * A slicer as used by {@link util.pool}. 678 * @typedef PoolSlicer 679 * @type {function} 680 * @param {number} start Start offset 681 * @param {number} end End offset 682 * @returns {Uint8Array} Buffer slice 683 * @this {Uint8Array} 684 */ 685 686/** 687 * A general purpose buffer pool. 688 * @memberof util 689 * @function 690 * @param {PoolAllocator} alloc Allocator 691 * @param {PoolSlicer} slice Slicer 692 * @param {number} [size=8192] Slab size 693 * @returns {PoolAllocator} Pooled allocator 694 */ 695function pool(alloc, slice, size) { 696 var SIZE = size || 8192; 697 var MAX = SIZE >>> 1; 698 var slab = null; 699 var offset = SIZE; 700 return function pool_alloc(size) { 701 if (size < 1 || size > MAX) 702 return alloc(size); 703 if (offset + size > SIZE) { 704 slab = alloc(SIZE); 705 offset = 0; 706 } 707 var buf = slice.call(slab, offset, offset += size); 708 if (offset & 7) // align to 32 bit 709 offset = (offset | 7) + 1; 710 return buf; 711 }; 712} 713 714},{}],6:[function(require,module,exports){ 715"use strict"; 716 717/** 718 * A minimal UTF8 implementation for number arrays. 719 * @memberof util 720 * @namespace 721 */ 722var utf8 = exports, 723 replacementChar = "\ufffd"; 724 725/** 726 * Calculates the UTF8 byte length of a string. 727 * @param {string} string String 728 * @returns {number} Byte length 729 */ 730utf8.length = function utf8_length(string) { 731 var len = 0, 732 c = 0; 733 for (var i = 0; i < string.length; ++i) { 734 c = string.charCodeAt(i); 735 if (c < 128) 736 len += 1; 737 else if (c < 2048) 738 len += 2; 739 else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) { 740 ++i; 741 len += 4; 742 } else 743 len += 3; 744 } 745 return len; 746}; 747 748/** 749 * Reads UTF8 bytes as a string. 750 * @param {Uint8Array} buffer Source buffer 751 * @param {number} start Source start 752 * @param {number} end Source end 753 * @returns {string} String read 754 */ 755utf8.read = function utf8_read(buffer, start, end) { 756 if (end - start < 1) { 757 return ""; 758 } 759 760 var str = ""; 761 for (var i = start; i < end;) { 762 var t = buffer[i++]; 763 if (t <= 0x7F) { 764 str += String.fromCharCode(t); 765 } else if (t >= 0xC0 && t < 0xE0) { 766 var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F; 767 str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar; 768 } else if (t >= 0xE0 && t < 0xF0) { 769 var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F; 770 str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar; 771 } else if (t >= 0xF0) { 772 var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F; 773 if (t2 < 0x10000 || t2 > 0x10FFFF) 774 str += replacementChar; 775 else { 776 t2 -= 0x10000; 777 str += String.fromCharCode(0xD800 + (t2 >> 10)); 778 str += String.fromCharCode(0xDC00 + (t2 & 0x3FF)); 779 } 780 } 781 } 782 783 return str; 784}; 785 786/** 787 * Writes a string as UTF8 bytes. 788 * @param {string} string Source string 789 * @param {Uint8Array} buffer Destination buffer 790 * @param {number} offset Destination offset 791 * @returns {number} Bytes written 792 */ 793utf8.write = function utf8_write(string, buffer, offset) { 794 var start = offset, 795 c1, // character 1 796 c2; // character 2 797 for (var i = 0; i < string.length; ++i) { 798 c1 = string.charCodeAt(i); 799 if (c1 < 128) { 800 buffer[offset++] = c1; 801 } else if (c1 < 2048) { 802 buffer[offset++] = c1 >> 6 | 192; 803 buffer[offset++] = c1 & 63 | 128; 804 } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) { 805 c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF); 806 ++i; 807 buffer[offset++] = c1 >> 18 | 240; 808 buffer[offset++] = c1 >> 12 & 63 | 128; 809 buffer[offset++] = c1 >> 6 & 63 | 128; 810 buffer[offset++] = c1 & 63 | 128; 811 } else { 812 buffer[offset++] = c1 >> 12 | 224; 813 buffer[offset++] = c1 >> 6 & 63 | 128; 814 buffer[offset++] = c1 & 63 | 128; 815 } 816 } 817 return offset - start; 818}; 819 820},{}],7:[function(require,module,exports){ 821"use strict"; 822var protobuf = exports; 823 824/** 825 * Build type, one of `"full"`, `"light"` or `"minimal"`. 826 * @name build 827 * @type {string} 828 * @const 829 */ 830protobuf.build = "minimal"; 831 832// Serialization 833protobuf.Writer = require(15); 834protobuf.BufferWriter = require(16); 835protobuf.Reader = require(8); 836protobuf.BufferReader = require(9); 837 838// Utility 839protobuf.util = require(14); 840protobuf.rpc = require(11); 841protobuf.roots = require(10); 842protobuf.configure = configure; 843 844/* istanbul ignore next */ 845/** 846 * Reconfigures the library according to the environment. 847 * @returns {undefined} 848 */ 849function configure() { 850 protobuf.util._configure(); 851 protobuf.Writer._configure(protobuf.BufferWriter); 852 protobuf.Reader._configure(protobuf.BufferReader); 853} 854 855// Set up buffer utility according to the environment 856configure(); 857 858},{"10":10,"11":11,"14":14,"15":15,"16":16,"8":8,"9":9}],8:[function(require,module,exports){ 859"use strict"; 860module.exports = Reader; 861 862var util = require(14); 863 864var BufferReader; // cyclic 865 866var LongBits = util.LongBits, 867 utf8 = util.utf8; 868 869/* istanbul ignore next */ 870function indexOutOfRange(reader, writeLength) { 871 return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len); 872} 873 874/** 875 * Constructs a new reader instance using the specified buffer. 876 * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`. 877 * @constructor 878 * @param {Uint8Array} buffer Buffer to read from 879 */ 880function Reader(buffer) { 881 882 /** 883 * Read buffer. 884 * @type {Uint8Array} 885 */ 886 this.buf = buffer; 887 888 /** 889 * Read buffer position. 890 * @type {number} 891 */ 892 this.pos = 0; 893 894 /** 895 * Read buffer length. 896 * @type {number} 897 */ 898 this.len = buffer.length; 899} 900 901var create_array = typeof Uint8Array !== "undefined" 902 ? function create_typed_array(buffer) { 903 if (buffer instanceof Uint8Array || Array.isArray(buffer)) 904 return new Reader(buffer); 905 throw Error("illegal buffer"); 906 } 907 /* istanbul ignore next */ 908 : function create_array(buffer) { 909 if (Array.isArray(buffer)) 910 return new Reader(buffer); 911 throw Error("illegal buffer"); 912 }; 913 914var create = function create() { 915 return util.Buffer 916 ? function create_buffer_setup(buffer) { 917 return (Reader.create = function create_buffer(buffer) { 918 return util.Buffer.isBuffer(buffer) 919 ? new BufferReader(buffer) 920 /* istanbul ignore next */ 921 : create_array(buffer); 922 })(buffer); 923 } 924 /* istanbul ignore next */ 925 : create_array; 926};
vendor: 4,945 bytes, lines 927-1083
927 928/** 929 * Creates a new reader using the specified buffer. 930 * @function 931 * @param {Uint8Array|Buffer} buffer Buffer to read from 932 * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader} 933 * @throws {Error} If `buffer` is not a valid buffer 934 */ 935Reader.create = create(); 936 937Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice; 938 939/** 940 * Reads a varint as an unsigned 32 bit value. 941 * @function 942 * @returns {number} Value read 943 */ 944Reader.prototype.uint32 = (function read_uint32_setup() { 945 var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!) 946 return function read_uint32() { 947 value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value; 948 value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value; 949 value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value; 950 value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value; 951 value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value; 952 953 /* istanbul ignore if */ 954 if ((this.pos += 5) > this.len) { 955 this.pos = this.len; 956 throw indexOutOfRange(this, 10); 957 } 958 return value; 959 }; 960})(); 961 962/** 963 * Reads a varint as a signed 32 bit value. 964 * @returns {number} Value read 965 */ 966Reader.prototype.int32 = function read_int32() { 967 return this.uint32() | 0; 968}; 969 970/** 971 * Reads a zig-zag encoded varint as a signed 32 bit value. 972 * @returns {number} Value read 973 */ 974Reader.prototype.sint32 = function read_sint32() { 975 var value = this.uint32(); 976 return value >>> 1 ^ -(value & 1) | 0; 977}; 978 979/* eslint-disable no-invalid-this */ 980 981function readLongVarint() { 982 // tends to deopt with local vars for octet etc. 983 var bits = new LongBits(0, 0); 984 var i = 0; 985 if (this.len - this.pos > 4) { // fast route (lo) 986 for (; i < 4; ++i) { 987 // 1st..4th 988 bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; 989 if (this.buf[this.pos++] < 128) 990 return bits; 991 } 992 // 5th 993 bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0; 994 bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0; 995 if (this.buf[this.pos++] < 128) 996 return bits; 997 i = 0; 998 } else { 999 for (; i < 3; ++i) { 1000 /* istanbul ignore if */ 1001 if (this.pos >= this.len) 1002 throw indexOutOfRange(this); 1003 // 1st..3th 1004 bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; 1005 if (this.buf[this.pos++] < 128) 1006 return bits; 1007 } 1008 // 4th 1009 bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0; 1010 return bits; 1011 } 1012 if (this.len - this.pos > 4) { // fast route (hi) 1013 for (; i < 5; ++i) { 1014 // 6th..10th 1015 bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; 1016 if (this.buf[this.pos++] < 128) 1017 return bits; 1018 } 1019 } else { 1020 for (; i < 5; ++i) { 1021 /* istanbul ignore if */ 1022 if (this.pos >= this.len) 1023 throw indexOutOfRange(this); 1024 // 6th..10th 1025 bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; 1026 if (this.buf[this.pos++] < 128) 1027 return bits; 1028 } 1029 } 1030 /* istanbul ignore next */ 1031 throw Error("invalid varint encoding"); 1032} 1033 1034/* eslint-enable no-invalid-this */ 1035 1036/** 1037 * Reads a varint as a signed 64 bit value. 1038 * @name Reader#int64 1039 * @function 1040 * @returns {Long} Value read 1041 */ 1042 1043/** 1044 * Reads a varint as an unsigned 64 bit value. 1045 * @name Reader#uint64 1046 * @function 1047 * @returns {Long} Value read 1048 */ 1049 1050/** 1051 * Reads a zig-zag encoded varint as a signed 64 bit value. 1052 * @name Reader#sint64 1053 * @function 1054 * @returns {Long} Value read 1055 */ 1056 1057/** 1058 * Reads a varint as a boolean. 1059 * @returns {boolean} Value read 1060 */ 1061Reader.prototype.bool = function read_bool() { 1062 return this.uint32() !== 0; 1063}; 1064 1065function readFixed32_end(buf, end) { // note that this uses `end`, not `pos` 1066 return (buf[end - 4] 1067 | buf[end - 3] << 8 1068 | buf[end - 2] << 16 1069 | buf[end - 1] << 24) >>> 0; 1070} 1071 1072/** 1073 * Reads fixed 32 bits as an unsigned 32 bit integer. 1074 * @returns {number} Value read 1075 */ 1076Reader.prototype.fixed32 = function read_fixed32() { 1077 1078 /* istanbul ignore if */ 1079 if (this.pos + 4 > this.len) 1080 throw indexOutOfRange(this, 4); 1081 1082 return readFixed32_end(this.buf, this.pos += 4); 1083};
vendor: 4,491 bytes, lines 1084-1253
1084 1085/** 1086 * Reads fixed 32 bits as a signed 32 bit integer. 1087 * @returns {number} Value read 1088 */ 1089Reader.prototype.sfixed32 = function read_sfixed32() { 1090 1091 /* istanbul ignore if */ 1092 if (this.pos + 4 > this.len) 1093 throw indexOutOfRange(this, 4); 1094 1095 return readFixed32_end(this.buf, this.pos += 4) | 0; 1096}; 1097 1098/* eslint-disable no-invalid-this */ 1099 1100function readFixed64(/* this: Reader */) { 1101 1102 /* istanbul ignore if */ 1103 if (this.pos + 8 > this.len) 1104 throw indexOutOfRange(this, 8); 1105 1106 return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4)); 1107} 1108 1109/* eslint-enable no-invalid-this */ 1110 1111/** 1112 * Reads fixed 64 bits. 1113 * @name Reader#fixed64 1114 * @function 1115 * @returns {Long} Value read 1116 */ 1117 1118/** 1119 * Reads zig-zag encoded fixed 64 bits. 1120 * @name Reader#sfixed64 1121 * @function 1122 * @returns {Long} Value read 1123 */ 1124 1125/** 1126 * Reads a float (32 bit) as a number. 1127 * @function 1128 * @returns {number} Value read 1129 */ 1130Reader.prototype.float = function read_float() { 1131 1132 /* istanbul ignore if */ 1133 if (this.pos + 4 > this.len) 1134 throw indexOutOfRange(this, 4); 1135 1136 var value = util.float.readFloatLE(this.buf, this.pos); 1137 this.pos += 4; 1138 return value; 1139}; 1140 1141/** 1142 * Reads a double (64 bit float) as a number. 1143 * @function 1144 * @returns {number} Value read 1145 */ 1146Reader.prototype.double = function read_double() { 1147 1148 /* istanbul ignore if */ 1149 if (this.pos + 8 > this.len) 1150 throw indexOutOfRange(this, 4); 1151 1152 var value = util.float.readDoubleLE(this.buf, this.pos); 1153 this.pos += 8; 1154 return value; 1155}; 1156 1157/** 1158 * Reads a sequence of bytes preceeded by its length as a varint. 1159 * @returns {Uint8Array} Value read 1160 */ 1161Reader.prototype.bytes = function read_bytes() { 1162 var length = this.uint32(), 1163 start = this.pos, 1164 end = this.pos + length; 1165 1166 /* istanbul ignore if */ 1167 if (end > this.len) 1168 throw indexOutOfRange(this, length); 1169 1170 this.pos += length; 1171 if (Array.isArray(this.buf)) // plain array 1172 return this.buf.slice(start, end); 1173 1174 if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1 1175 var nativeBuffer = util.Buffer; 1176 return nativeBuffer 1177 ? nativeBuffer.alloc(0) 1178 : new this.buf.constructor(0); 1179 } 1180 return this._slice.call(this.buf, start, end); 1181}; 1182 1183/** 1184 * Reads a string preceeded by its byte length as a varint. 1185 * @returns {string} Value read 1186 */ 1187Reader.prototype.string = function read_string() { 1188 var bytes = this.bytes(); 1189 return utf8.read(bytes, 0, bytes.length); 1190}; 1191 1192/** 1193 * Skips the specified number of bytes if specified, otherwise skips a varint. 1194 * @param {number} [length] Length if known, otherwise a varint is assumed 1195 * @returns {Reader} `this` 1196 */ 1197Reader.prototype.skip = function skip(length) { 1198 if (typeof length === "number") { 1199 /* istanbul ignore if */ 1200 if (this.pos + length > this.len) 1201 throw indexOutOfRange(this, length); 1202 this.pos += length; 1203 } else { 1204 do { 1205 /* istanbul ignore if */ 1206 if (this.pos >= this.len) 1207 throw indexOutOfRange(this); 1208 } while (this.buf[this.pos++] & 128); 1209 } 1210 return this; 1211}; 1212 1213/** 1214 * Recursion limit. 1215 * @type {number} 1216 */ 1217Reader.recursionLimit = util.recursionLimit; 1218 1219/** 1220 * Skips the next element of the specified wire type. 1221 * @param {number} wireType Wire type received 1222 * @param {number} [depth] Depth of recursion to control nested calls; 0 if omitted 1223 * @returns {Reader} `this` 1224 */ 1225Reader.prototype.skipType = function(wireType, depth) { 1226 if (depth === undefined) depth = 0; 1227 if (depth > Reader.recursionLimit) 1228 throw Error("maximum nesting depth exceeded"); 1229 switch (wireType) { 1230 case 0: 1231 this.skip(); 1232 break; 1233 case 1: 1234 this.skip(8); 1235 break; 1236 case 2: 1237 this.skip(this.uint32()); 1238 break; 1239 case 3: 1240 while ((wireType = this.uint32() & 7) !== 4) { 1241 this.skipType(wireType, depth + 1); 1242 } 1243 break; 1244 case 5: 1245 this.skip(4); 1246 break; 1247 1248 /* istanbul ignore next */ 1249 default: 1250 throw Error("invalid wire type " + wireType + " at offset " + this.pos); 1251 } 1252 return this; 1253};
vendor: 8,890 bytes, lines 1254-1535
1254 1255Reader._configure = function(BufferReader_) { 1256 BufferReader = BufferReader_; 1257 Reader.create = create(); 1258 BufferReader._configure(); 1259 1260 var fn = util.Long ? "toLong" : /* istanbul ignore next */ "toNumber"; 1261 util.merge(Reader.prototype, { 1262 1263 int64: function read_int64() { 1264 return readLongVarint.call(this)[fn](false); 1265 }, 1266 1267 uint64: function read_uint64() { 1268 return readLongVarint.call(this)[fn](true); 1269 }, 1270 1271 sint64: function read_sint64() { 1272 return readLongVarint.call(this).zzDecode()[fn](false); 1273 }, 1274 1275 fixed64: function read_fixed64() { 1276 return readFixed64.call(this)[fn](true); 1277 }, 1278 1279 sfixed64: function read_sfixed64() { 1280 return readFixed64.call(this)[fn](false); 1281 } 1282 1283 }); 1284}; 1285 1286},{"14":14}],9:[function(require,module,exports){ 1287"use strict"; 1288module.exports = BufferReader; 1289 1290// extends Reader 1291var Reader = require(8); 1292(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader; 1293 1294var util = require(14); 1295 1296/** 1297 * Constructs a new buffer reader instance. 1298 * @classdesc Wire format reader using node buffers. 1299 * @extends Reader 1300 * @constructor 1301 * @param {Buffer} buffer Buffer to read from 1302 */ 1303function BufferReader(buffer) { 1304 Reader.call(this, buffer); 1305 1306 /** 1307 * Read buffer. 1308 * @name BufferReader#buf 1309 * @type {Buffer} 1310 */ 1311} 1312 1313BufferReader._configure = function () { 1314 /* istanbul ignore else */ 1315 if (util.Buffer) 1316 BufferReader.prototype._slice = util.Buffer.prototype.slice; 1317}; 1318 1319 1320/** 1321 * @override 1322 */ 1323BufferReader.prototype.string = function read_string_buffer() { 1324 var len = this.uint32(); // modifies pos 1325 return this.buf.utf8Slice 1326 ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)) 1327 : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len)); 1328}; 1329 1330/** 1331 * Reads a sequence of bytes preceeded by its length as a varint. 1332 * @name BufferReader#bytes 1333 * @function 1334 * @returns {Buffer} Value read 1335 */ 1336 1337BufferReader._configure(); 1338 1339},{"14":14,"8":8}],10:[function(require,module,exports){ 1340"use strict"; 1341module.exports = Object.create(null); 1342 1343/** 1344 * Named roots. 1345 * This is where pbjs stores generated structures (the option `-r, --root` specifies a name). 1346 * Can also be used manually to make roots available across modules. 1347 * @name roots 1348 * @type {Object.<string,Root>} 1349 * @example 1350 * // pbjs -r myroot -o compiled.js ... 1351 * 1352 * // in another module: 1353 * require("./compiled.js"); 1354 * 1355 * // in any subsequent module: 1356 * var root = protobuf.roots["myroot"]; 1357 */ 1358 1359},{}],11:[function(require,module,exports){ 1360"use strict"; 1361 1362/** 1363 * Streaming RPC helpers. 1364 * @namespace 1365 */ 1366var rpc = exports; 1367 1368/** 1369 * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets. 1370 * @typedef RPCImpl 1371 * @type {function} 1372 * @param {Method|rpc.ServiceMethod<Message<{}>,Message<{}>>} method Reflected or static method being called 1373 * @param {Uint8Array} requestData Request data 1374 * @param {RPCImplCallback} callback Callback function 1375 * @returns {undefined} 1376 * @example 1377 * function rpcImpl(method, requestData, callback) { 1378 * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code 1379 * throw Error("no such method"); 1380 * asynchronouslyObtainAResponse(requestData, function(err, responseData) { 1381 * callback(err, responseData); 1382 * }); 1383 * } 1384 */ 1385 1386/** 1387 * Node-style callback as used by {@link RPCImpl}. 1388 * @typedef RPCImplCallback 1389 * @type {function} 1390 * @param {Error|null} error Error, if any, otherwise `null` 1391 * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error 1392 * @returns {undefined} 1393 */ 1394 1395rpc.Service = require(12); 1396 1397},{"12":12}],12:[function(require,module,exports){ 1398"use strict"; 1399module.exports = Service; 1400 1401var util = require(14); 1402 1403// Extends EventEmitter 1404(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service; 1405 1406/** 1407 * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}. 1408 * 1409 * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`. 1410 * @typedef rpc.ServiceMethodCallback 1411 * @template TRes extends Message<TRes> 1412 * @type {function} 1413 * @param {Error|null} error Error, if any 1414 * @param {TRes} [response] Response message 1415 * @returns {undefined} 1416 */ 1417 1418/** 1419 * A service method part of a {@link rpc.Service} as created by {@link Service.create}. 1420 * @typedef rpc.ServiceMethod 1421 * @template TReq extends Message<TReq> 1422 * @template TRes extends Message<TRes> 1423 * @type {function} 1424 * @param {TReq|Properties<TReq>} request Request message or plain object 1425 * @param {rpc.ServiceMethodCallback<TRes>} [callback] Node-style callback called with the error, if any, and the response message 1426 * @returns {Promise<Message<TRes>>} Promise if `callback` has been omitted, otherwise `undefined` 1427 */ 1428 1429/** 1430 * Constructs a new RPC service instance. 1431 * @classdesc An RPC service as returned by {@link Service#create}. 1432 * @exports rpc.Service 1433 * @extends util.EventEmitter 1434 * @constructor 1435 * @param {RPCImpl} rpcImpl RPC implementation 1436 * @param {boolean} [requestDelimited=false] Whether requests are length-delimited 1437 * @param {boolean} [responseDelimited=false] Whether responses are length-delimited 1438 */ 1439function Service(rpcImpl, requestDelimited, responseDelimited) { 1440 1441 if (typeof rpcImpl !== "function") 1442 throw TypeError("rpcImpl must be a function"); 1443 1444 util.EventEmitter.call(this); 1445 1446 /** 1447 * RPC implementation. Becomes `null` once the service is ended. 1448 * @type {RPCImpl|null} 1449 */ 1450 this.rpcImpl = rpcImpl; 1451 1452 /** 1453 * Whether requests are length-delimited. 1454 * @type {boolean} 1455 */ 1456 this.requestDelimited = Boolean(requestDelimited); 1457 1458 /** 1459 * Whether responses are length-delimited. 1460 * @type {boolean} 1461 */ 1462 this.responseDelimited = Boolean(responseDelimited); 1463} 1464 1465/** 1466 * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}. 1467 * @param {Method|rpc.ServiceMethod<TReq,TRes>} method Reflected or static method 1468 * @param {Constructor<TReq>} requestCtor Request constructor 1469 * @param {Constructor<TRes>} responseCtor Response constructor 1470 * @param {TReq|Properties<TReq>} request Request message or plain object 1471 * @param {rpc.ServiceMethodCallback<TRes>} callback Service callback 1472 * @returns {undefined} 1473 * @template TReq extends Message<TReq> 1474 * @template TRes extends Message<TRes> 1475 */ 1476Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) { 1477 1478 if (!request) 1479 throw TypeError("request must be specified"); 1480 1481 var self = this; 1482 if (!callback) 1483 return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request); 1484 1485 if (!self.rpcImpl) { 1486 setTimeout(function() { callback(Error("already ended")); }, 0); 1487 return undefined; 1488 } 1489 1490 try { 1491 return self.rpcImpl( 1492 method, 1493 requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(), 1494 function rpcCallback(err, response) { 1495 1496 if (err) { 1497 self.emit("error", err, method); 1498 return callback(err); 1499 } 1500 1501 if (response === null) { 1502 self.end(/* endedByRPC */ true); 1503 return undefined; 1504 } 1505 1506 if (!(response instanceof responseCtor)) { 1507 try { 1508 response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response); 1509 } catch (err) { 1510 self.emit("error", err, method); 1511 return callback(err); 1512 } 1513 } 1514 1515 self.emit("data", response, method); 1516 return callback(null, response); 1517 } 1518 ); 1519 } catch (err) { 1520 self.emit("error", err, method); 1521 setTimeout(function() { callback(err); }, 0); 1522 return undefined; 1523 } 1524}; 1525 1526/** 1527 * Ends this service and emits the `end` event. 1528 * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation. 1529 * @returns {rpc.Service} `this` 1530 */ 1531Service.prototype.end = function end(endedByRPC) { 1532 if (this.rpcImpl) { 1533 if (!endedByRPC) // signal end to rpcImpl 1534 this.rpcImpl(null, null, null); 1535 this.rpcImpl = null;
vendor: 4,805 bytes, lines 1536-1711
1536 this.emit("end").off(); 1537 } 1538 return this; 1539}; 1540 1541},{"14":14}],13:[function(require,module,exports){ 1542"use strict"; 1543module.exports = LongBits; 1544 1545var util = require(14); 1546 1547/** 1548 * Constructs new long bits. 1549 * @classdesc Helper class for working with the low and high bits of a 64 bit value. 1550 * @memberof util 1551 * @constructor 1552 * @param {number} lo Low 32 bits, unsigned 1553 * @param {number} hi High 32 bits, unsigned 1554 */ 1555function LongBits(lo, hi) { 1556 1557 // note that the casts below are theoretically unnecessary as of today, but older statically 1558 // generated converter code might still call the ctor with signed 32bits. kept for compat. 1559 1560 /** 1561 * Low bits. 1562 * @type {number} 1563 */ 1564 this.lo = lo >>> 0; 1565 1566 /** 1567 * High bits. 1568 * @type {number} 1569 */ 1570 this.hi = hi >>> 0; 1571} 1572 1573/** 1574 * Zero bits. 1575 * @memberof util.LongBits 1576 * @type {util.LongBits} 1577 */ 1578var zero = LongBits.zero = new LongBits(0, 0); 1579 1580zero.toNumber = function() { return 0; }; 1581zero.zzEncode = zero.zzDecode = function() { return this; }; 1582zero.length = function() { return 1; }; 1583 1584/** 1585 * Zero hash. 1586 * @memberof util.LongBits 1587 * @type {string} 1588 */ 1589var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0"; 1590 1591/** 1592 * Constructs new long bits from the specified number. 1593 * @param {number} value Value 1594 * @returns {util.LongBits} Instance 1595 */ 1596LongBits.fromNumber = function fromNumber(value) { 1597 if (value === 0) 1598 return zero; 1599 var sign = value < 0; 1600 if (sign) 1601 value = -value; 1602 var lo = value >>> 0, 1603 hi = (value - lo) / 4294967296 >>> 0; 1604 if (sign) { 1605 hi = ~hi >>> 0; 1606 lo = ~lo >>> 0; 1607 if (++lo > 4294967295) { 1608 lo = 0; 1609 if (++hi > 4294967295) 1610 hi = 0; 1611 } 1612 } 1613 return new LongBits(lo, hi); 1614}; 1615 1616/** 1617 * Constructs new long bits from a number, long or string. 1618 * @param {Long|number|string} value Value 1619 * @returns {util.LongBits} Instance 1620 */ 1621LongBits.from = function from(value) { 1622 if (typeof value === "number") 1623 return LongBits.fromNumber(value); 1624 if (util.isString(value)) { 1625 /* istanbul ignore else */ 1626 if (util.Long) 1627 value = util.Long.fromString(value); 1628 else 1629 return LongBits.fromNumber(parseInt(value, 10)); 1630 } 1631 return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero; 1632}; 1633 1634/** 1635 * Converts this long bits to a possibly unsafe JavaScript number. 1636 * @param {boolean} [unsigned=false] Whether unsigned or not 1637 * @returns {number} Possibly unsafe number 1638 */ 1639LongBits.prototype.toNumber = function toNumber(unsigned) { 1640 if (!unsigned && this.hi >>> 31) { 1641 var lo = ~this.lo + 1 >>> 0, 1642 hi = ~this.hi >>> 0; 1643 if (!lo) 1644 hi = hi + 1 >>> 0; 1645 return -(lo + hi * 4294967296); 1646 } 1647 return this.lo + this.hi * 4294967296; 1648}; 1649 1650/** 1651 * Converts this long bits to a long. 1652 * @param {boolean} [unsigned=false] Whether unsigned or not 1653 * @returns {Long} Long 1654 */ 1655LongBits.prototype.toLong = function toLong(unsigned) { 1656 return util.Long 1657 ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) 1658 /* istanbul ignore next */ 1659 : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) }; 1660}; 1661 1662var charCodeAt = String.prototype.charCodeAt; 1663 1664/** 1665 * Constructs new long bits from the specified 8 characters long hash. 1666 * @param {string} hash Hash 1667 * @returns {util.LongBits} Bits 1668 */ 1669LongBits.fromHash = function fromHash(hash) { 1670 if (hash === zeroHash) 1671 return zero; 1672 return new LongBits( 1673 ( charCodeAt.call(hash, 0) 1674 | charCodeAt.call(hash, 1) << 8 1675 | charCodeAt.call(hash, 2) << 16 1676 | charCodeAt.call(hash, 3) << 24) >>> 0 1677 , 1678 ( charCodeAt.call(hash, 4) 1679 | charCodeAt.call(hash, 5) << 8 1680 | charCodeAt.call(hash, 6) << 16 1681 | charCodeAt.call(hash, 7) << 24) >>> 0 1682 ); 1683}; 1684 1685/** 1686 * Converts this long bits to a 8 characters long hash. 1687 * @returns {string} Hash 1688 */ 1689LongBits.prototype.toHash = function toHash() { 1690 return String.fromCharCode( 1691 this.lo & 255, 1692 this.lo >>> 8 & 255, 1693 this.lo >>> 16 & 255, 1694 this.lo >>> 24 , 1695 this.hi & 255, 1696 this.hi >>> 8 & 255, 1697 this.hi >>> 16 & 255, 1698 this.hi >>> 24 1699 ); 1700}; 1701 1702/** 1703 * Zig-zag encodes this long bits. 1704 * @returns {util.LongBits} `this` 1705 */ 1706LongBits.prototype.zzEncode = function zzEncode() { 1707 var mask = this.hi >> 31; 1708 this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0; 1709 this.lo = ( this.lo << 1 ^ mask) >>> 0; 1710 return this; 1711};
vendor: 11,670 bytes, lines 1712-2091
1712 1713/** 1714 * Zig-zag decodes this long bits. 1715 * @returns {util.LongBits} `this` 1716 */ 1717LongBits.prototype.zzDecode = function zzDecode() { 1718 var mask = -(this.lo & 1); 1719 this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0; 1720 this.hi = ( this.hi >>> 1 ^ mask) >>> 0; 1721 return this; 1722}; 1723 1724/** 1725 * Calculates the length of this longbits when encoded as a varint. 1726 * @returns {number} Length 1727 */ 1728LongBits.prototype.length = function length() { 1729 var part0 = this.lo, 1730 part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, 1731 part2 = this.hi >>> 24; 1732 return part2 === 0 1733 ? part1 === 0 1734 ? part0 < 16384 1735 ? part0 < 128 ? 1 : 2 1736 : part0 < 2097152 ? 3 : 4 1737 : part1 < 16384 1738 ? part1 < 128 ? 5 : 6 1739 : part1 < 2097152 ? 7 : 8 1740 : part2 < 128 ? 9 : 10; 1741}; 1742 1743},{"14":14}],14:[function(require,module,exports){ 1744"use strict"; 1745var util = exports; 1746 1747// used to return a Promise where callback is omitted 1748util.asPromise = require(1); 1749 1750// converts to / from base64 encoded strings 1751util.base64 = require(2); 1752 1753// base class of rpc.Service 1754util.EventEmitter = require(3); 1755 1756// float handling accross browsers 1757util.float = require(4); 1758 1759// converts to / from utf8 encoded strings 1760util.utf8 = require(6); 1761 1762// provides a node-like buffer pool in the browser 1763util.pool = require(5); 1764 1765// utility to work with the low and high bits of a 64 bit value 1766util.LongBits = require(13); 1767 1768/** 1769 * Tests if the specified key can affect object prototypes. 1770 * @memberof util 1771 * @param {string} key Key to test 1772 * @returns {boolean} `true` if the key is unsafe 1773 */ 1774function isUnsafeProperty(key) { 1775 return key === "__proto__" || key === "prototype" || key === "constructor"; 1776} 1777 1778util.isUnsafeProperty = isUnsafeProperty; 1779 1780/** 1781 * Whether running within node or not. 1782 * @memberof util 1783 * @type {boolean} 1784 */ 1785util.isNode = Boolean(typeof global !== "undefined" 1786 && global 1787 && global.process 1788 && global.process.versions 1789 && global.process.versions.node); 1790 1791/** 1792 * Global object reference. 1793 * @memberof util 1794 * @type {Object} 1795 */ 1796util.global = util.isNode && global 1797 || typeof window !== "undefined" && window 1798 || typeof self !== "undefined" && self 1799 || this; // eslint-disable-line no-invalid-this 1800 1801/** 1802 * An immuable empty array. 1803 * @memberof util 1804 * @type {Array.<*>} 1805 * @const 1806 */ 1807util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes 1808 1809/** 1810 * An immutable empty object. 1811 * @type {Object} 1812 * @const 1813 */ 1814util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes 1815 1816/** 1817 * Tests if the specified value is an integer. 1818 * @function 1819 * @param {*} value Value to test 1820 * @returns {boolean} `true` if the value is an integer 1821 */ 1822util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) { 1823 return typeof value === "number" && isFinite(value) && Math.floor(value) === value; 1824}; 1825 1826/** 1827 * Tests if the specified value is a string. 1828 * @param {*} value Value to test 1829 * @returns {boolean} `true` if the value is a string 1830 */ 1831util.isString = function isString(value) { 1832 return typeof value === "string" || value instanceof String; 1833}; 1834 1835/** 1836 * Tests if the specified value is a non-null object. 1837 * @param {*} value Value to test 1838 * @returns {boolean} `true` if the value is a non-null object 1839 */ 1840util.isObject = function isObject(value) { 1841 return value && typeof value === "object"; 1842}; 1843 1844/** 1845 * Checks if a property on a message is considered to be present. 1846 * This is an alias of {@link util.isSet}. 1847 * @function 1848 * @param {Object} obj Plain object or message instance 1849 * @param {string} prop Property name 1850 * @returns {boolean} `true` if considered to be present, otherwise `false` 1851 */ 1852util.isset = 1853 1854/** 1855 * Checks if a property on a message is considered to be present. 1856 * @param {Object} obj Plain object or message instance 1857 * @param {string} prop Property name 1858 * @returns {boolean} `true` if considered to be present, otherwise `false` 1859 */ 1860util.isSet = function isSet(obj, prop) { 1861 var value = obj[prop]; 1862 if (value != null && Object.hasOwnProperty.call(obj, prop)) // eslint-disable-line eqeqeq 1863 return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0; 1864 return false; 1865}; 1866 1867/** 1868 * Any compatible Buffer instance. 1869 * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings. 1870 * @interface Buffer 1871 * @extends Uint8Array 1872 */ 1873 1874/** 1875 * Node's Buffer class if available. 1876 * @type {Constructor<Buffer>} 1877 */ 1878util.Buffer = (function() { 1879 try { 1880 var Buffer = util.global.Buffer; 1881 // refuse to use non-node buffers if not explicitly assigned (perf reasons): 1882 return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null; 1883 } catch (e) { 1884 /* istanbul ignore next */ 1885 return null; 1886 } 1887})(); 1888 1889// Internal alias of or polyfull for Buffer.from. 1890util._Buffer_from = null; 1891 1892// Internal alias of or polyfill for Buffer.allocUnsafe. 1893util._Buffer_allocUnsafe = null; 1894 1895/** 1896 * Creates a new buffer of whatever type supported by the environment. 1897 * @param {number|number[]} [sizeOrArray=0] Buffer size or number array 1898 * @returns {Uint8Array|Buffer} Buffer 1899 */ 1900util.newBuffer = function newBuffer(sizeOrArray) { 1901 /* istanbul ignore next */ 1902 return typeof sizeOrArray === "number" 1903 ? util.Buffer 1904 ? util._Buffer_allocUnsafe(sizeOrArray) 1905 : new util.Array(sizeOrArray) 1906 : util.Buffer 1907 ? util._Buffer_from(sizeOrArray) 1908 : typeof Uint8Array === "undefined" 1909 ? sizeOrArray 1910 : new Uint8Array(sizeOrArray); 1911}; 1912 1913/** 1914 * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. 1915 * @type {Constructor<Uint8Array>} 1916 */ 1917util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array; 1918 1919/** 1920 * Any compatible Long instance. 1921 * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js. 1922 * @interface Long 1923 * @property {number} low Low bits 1924 * @property {number} high High bits 1925 * @property {boolean} unsigned Whether unsigned or not 1926 */ 1927 1928/** 1929 * Long.js's Long class if available. 1930 * @type {Constructor<Long>} 1931 */ 1932util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long 1933 || /* istanbul ignore next */ util.global.Long 1934 || (function() { 1935 try { 1936 var Long = require("long"); 1937 return Long && Long.isLong ? Long : null; 1938 } catch (e) { 1939 /* istanbul ignore next */ 1940 return null; 1941 } 1942 })(); 1943 1944/** 1945 * Regular expression used to verify 2 bit (`bool`) map keys. 1946 * @type {RegExp} 1947 * @const 1948 */ 1949util.key2Re = /^true|false|0|1$/; 1950 1951/** 1952 * Regular expression used to verify 32 bit (`int32` etc.) map keys. 1953 * @type {RegExp} 1954 * @const 1955 */ 1956util.key32Re = /^-?(?:0|[1-9][0-9]*)$/; 1957 1958/** 1959 * Regular expression used to verify 64 bit (`int64` etc.) map keys. 1960 * @type {RegExp} 1961 * @const 1962 */ 1963util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/; 1964 1965/** 1966 * Converts a number or long to an 8 characters long hash string. 1967 * @param {Long|number} value Value to convert 1968 * @returns {string} Hash 1969 */ 1970util.longToHash = function longToHash(value) { 1971 return value 1972 ? util.LongBits.from(value).toHash() 1973 : util.LongBits.zeroHash; 1974}; 1975 1976/** 1977 * Converts an 8 characters long hash string to a long or number. 1978 * @param {string} hash Hash 1979 * @param {boolean} [unsigned=false] Whether unsigned or not 1980 * @returns {Long|number} Original value 1981 */ 1982util.longFromHash = function longFromHash(hash, unsigned) { 1983 var bits = util.LongBits.fromHash(hash); 1984 if (util.Long) 1985 return util.Long.fromBits(bits.lo, bits.hi, unsigned); 1986 return bits.toNumber(Boolean(unsigned)); 1987}; 1988 1989/** 1990 * Merges the properties of the source object into the destination object. 1991 * @memberof util 1992 * @param {Object.<string,*>} dst Destination object 1993 * @param {...(Object.<string,*>|boolean)} src Source objects, optionally followed by an `ifNotSet` flag 1994 * @returns {Object.<string,*>} Destination object 1995 */ 1996function merge(dst) { // used by converters 1997 var ifNotSet = typeof arguments[arguments.length - 1] === "boolean", 1998 limit = ifNotSet ? arguments.length - 1 : arguments.length; 1999 ifNotSet = ifNotSet && arguments[arguments.length - 1]; 2000 for (var a = 1; a < limit; ++a) { 2001 var src = arguments[a]; 2002 if (!src) 2003 continue; 2004 for (var keys = Object.keys(src), i = 0; i < keys.length; ++i) 2005 if (!isUnsafeProperty(keys[i]) && (dst[keys[i]] === undefined || !ifNotSet)) 2006 dst[keys[i]] = src[keys[i]]; 2007 } 2008 return dst; 2009} 2010 2011util.merge = merge; 2012 2013/** 2014 * Schema declaration nesting limit. 2015 * @memberof util 2016 * @type {number} 2017 */ 2018util.nestingLimit = 32; // protoc: MaxMessageDeclarationNestingDepth 2019 2020/** 2021 * Recursion limit. 2022 * @memberof util 2023 * @type {number} 2024 */ 2025util.recursionLimit = 100; // protoc: CodedInputStream::default_recursion_limit_ 2026 2027/** 2028 * Makes a property safe for assignment as an own property. 2029 * @memberof util 2030 * @param {Object.<string,*>} obj Object 2031 * @param {string} key Property key 2032 * @returns {undefined} 2033 */ 2034util.makeProp = function makeProp(obj, key) { 2035 Object.defineProperty(obj, key, { 2036 enumerable: true, 2037 configurable: true, 2038 writable: true 2039 }); 2040}; 2041 2042/** 2043 * Converts the first character of a string to lower case. 2044 * @param {string} str String to convert 2045 * @returns {string} Converted string 2046 */ 2047util.lcFirst = function lcFirst(str) { 2048 return str.charAt(0).toLowerCase() + str.substring(1); 2049}; 2050 2051/** 2052 * Creates a custom error constructor. 2053 * @memberof util 2054 * @param {string} name Error name 2055 * @returns {Constructor<Error>} Custom error constructor 2056 */ 2057function newError(name) { 2058 2059 function CustomError(message, properties) { 2060 2061 if (!(this instanceof CustomError)) 2062 return new CustomError(message, properties); 2063 2064 // Error.call(this, message); 2065 // ^ just returns a new error instance because the ctor can be called as a function 2066 2067 Object.defineProperty(this, "message", { get: function() { return message; } }); 2068 2069 /* istanbul ignore next */ 2070 if (Error.captureStackTrace) // node 2071 Error.captureStackTrace(this, CustomError); 2072 else 2073 Object.defineProperty(this, "stack", { value: new Error().stack || "" }); 2074 2075 if (properties) 2076 merge(this, properties); 2077 } 2078 2079 CustomError.prototype = Object.create(Error.prototype, { 2080 constructor: { 2081 value: CustomError, 2082 writable: true, 2083 enumerable: false, 2084 configurable: true, 2085 }, 2086 name: { 2087 get: function get() { return name; }, 2088 set: undefined, 2089 enumerable: false, 2090 // configurable: false would accurately preserve the behavior of 2091 // the original, but I'm guessing that was not intentional.
vendor: 2,041 bytes, lines 2092-2161
2092 // For an actual error subclass, this property would 2093 // be configurable. 2094 configurable: true, 2095 }, 2096 toString: { 2097 value: function value() { return this.name + ": " + this.message; }, 2098 writable: true, 2099 enumerable: false, 2100 configurable: true, 2101 }, 2102 }); 2103 2104 return CustomError; 2105} 2106 2107util.newError = newError; 2108 2109/** 2110 * Constructs a new protocol error. 2111 * @classdesc Error subclass indicating a protocol specifc error. 2112 * @memberof util 2113 * @extends Error 2114 * @template T extends Message<T> 2115 * @constructor 2116 * @param {string} message Error message 2117 * @param {Object.<string,*>} [properties] Additional properties 2118 * @example 2119 * try { 2120 * MyMessage.decode(someBuffer); // throws if required fields are missing 2121 * } catch (e) { 2122 * if (e instanceof ProtocolError && e.instance) 2123 * console.log("decoded so far: " + JSON.stringify(e.instance)); 2124 * } 2125 */ 2126util.ProtocolError = newError("ProtocolError"); 2127 2128/** 2129 * So far decoded message instance. 2130 * @name util.ProtocolError#instance 2131 * @type {Message<T>} 2132 */ 2133 2134/** 2135 * A OneOf getter as returned by {@link util.oneOfGetter}. 2136 * @typedef OneOfGetter 2137 * @type {function} 2138 * @returns {string|undefined} Set field name, if any 2139 */ 2140 2141/** 2142 * Builds a getter for a oneof's present field name. 2143 * @param {string[]} fieldNames Field names 2144 * @returns {OneOfGetter} Unbound getter 2145 */ 2146util.oneOfGetter = function getOneOf(fieldNames) { 2147 var fieldMap = {}; 2148 for (var i = 0; i < fieldNames.length; ++i) 2149 fieldMap[fieldNames[i]] = 1; 2150 2151 /** 2152 * @returns {string|undefined} Set field name, if any 2153 * @this Object 2154 * @ignore 2155 */ 2156 return function() { // eslint-disable-line consistent-return 2157 for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i) 2158 if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null) 2159 return keys[i]; 2160 }; 2161};
vendor: 5,419 bytes, lines 2162-2371
2162 2163/** 2164 * A OneOf setter as returned by {@link util.oneOfSetter}. 2165 * @typedef OneOfSetter 2166 * @type {function} 2167 * @param {string|undefined} value Field name 2168 * @returns {undefined} 2169 */ 2170 2171/** 2172 * Builds a setter for a oneof's present field name. 2173 * @param {string[]} fieldNames Field names 2174 * @returns {OneOfSetter} Unbound setter 2175 */ 2176util.oneOfSetter = function setOneOf(fieldNames) { 2177 2178 /** 2179 * @param {string} name Field name 2180 * @returns {undefined} 2181 * @this Object 2182 * @ignore 2183 */ 2184 return function(name) { 2185 for (var i = 0; i < fieldNames.length; ++i) 2186 if (fieldNames[i] !== name) 2187 delete this[fieldNames[i]]; 2188 }; 2189}; 2190 2191/** 2192 * Default conversion options used for {@link Message#toJSON} implementations. 2193 * 2194 * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely: 2195 * 2196 * - Longs become strings 2197 * - Enums become string keys 2198 * - Bytes become base64 encoded strings 2199 * - (Sub-)Messages become plain objects 2200 * - Maps become plain objects with all string keys 2201 * - Repeated fields become arrays 2202 * - NaN and Infinity for float and double fields become strings 2203 * 2204 * @type {IConversionOptions} 2205 * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json 2206 */ 2207util.toJSONOptions = { 2208 longs: String, 2209 enums: String, 2210 bytes: String, 2211 json: true 2212}; 2213 2214// Sets up buffer utility according to the environment (called in index-minimal) 2215util._configure = function() { 2216 var Buffer = util.Buffer; 2217 /* istanbul ignore if */ 2218 if (!Buffer) { 2219 util._Buffer_from = util._Buffer_allocUnsafe = null; 2220 return; 2221 } 2222 // because node 4.x buffers are incompatible & immutable 2223 // see: https://github.com/dcodeIO/protobuf.js/pull/665 2224 util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from || 2225 /* istanbul ignore next */ 2226 function Buffer_from(value, encoding) { 2227 return new Buffer(value, encoding); 2228 }; 2229 util._Buffer_allocUnsafe = Buffer.allocUnsafe || 2230 /* istanbul ignore next */ 2231 function Buffer_allocUnsafe(size) { 2232 return new Buffer(size); 2233 }; 2234}; 2235 2236},{"1":1,"13":13,"2":2,"3":3,"4":4,"5":5,"6":6,"long":"long"}],15:[function(require,module,exports){ 2237"use strict"; 2238module.exports = Writer; 2239 2240var util = require(14); 2241 2242var BufferWriter; // cyclic 2243 2244var LongBits = util.LongBits, 2245 base64 = util.base64, 2246 utf8 = util.utf8; 2247 2248/** 2249 * Constructs a new writer operation instance. 2250 * @classdesc Scheduled writer operation. 2251 * @constructor 2252 * @param {function(*, Uint8Array, number)} fn Function to call 2253 * @param {number} len Value byte length 2254 * @param {*} val Value to write 2255 * @ignore 2256 */ 2257function Op(fn, len, val) { 2258 2259 /** 2260 * Function to call. 2261 * @type {function(Uint8Array, number, *)} 2262 */ 2263 this.fn = fn; 2264 2265 /** 2266 * Value byte length. 2267 * @type {number} 2268 */ 2269 this.len = len; 2270 2271 /** 2272 * Next operation. 2273 * @type {Writer.Op|undefined} 2274 */ 2275 this.next = undefined; 2276 2277 /** 2278 * Value to write. 2279 * @type {*} 2280 */ 2281 this.val = val; // type varies 2282} 2283 2284/* istanbul ignore next */ 2285function noop() {} // eslint-disable-line no-empty-function 2286 2287/** 2288 * Constructs a new writer state instance. 2289 * @classdesc Copied writer state. 2290 * @memberof Writer 2291 * @constructor 2292 * @param {Writer} writer Writer to copy state from 2293 * @ignore 2294 */ 2295function State(writer) { 2296 2297 /** 2298 * Current head. 2299 * @type {Writer.Op} 2300 */ 2301 this.head = writer.head; 2302 2303 /** 2304 * Current tail. 2305 * @type {Writer.Op} 2306 */ 2307 this.tail = writer.tail; 2308 2309 /** 2310 * Current buffer length. 2311 * @type {number} 2312 */ 2313 this.len = writer.len; 2314 2315 /** 2316 * Next state. 2317 * @type {State|null} 2318 */ 2319 this.next = writer.states; 2320} 2321 2322/** 2323 * Constructs a new writer instance. 2324 * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`. 2325 * @constructor 2326 */ 2327function Writer() { 2328 2329 /** 2330 * Current length. 2331 * @type {number} 2332 */ 2333 this.len = 0; 2334 2335 /** 2336 * Operations head. 2337 * @type {Object} 2338 */ 2339 this.head = new Op(noop, 0, 0); 2340 2341 /** 2342 * Operations tail 2343 * @type {Object} 2344 */ 2345 this.tail = this.head; 2346 2347 /** 2348 * Linked forked states. 2349 * @type {Object|null} 2350 */ 2351 this.states = null; 2352 2353 // When a value is written, the writer calculates its byte length and puts it into a linked 2354 // list of operations to perform when finish() is called. This both allows us to allocate 2355 // buffers of the exact required size and reduces the amount of work we have to do compared 2356 // to first calculating over objects and then encoding over objects. In our case, the encoding 2357 // part is just a linked list walk calling operations with already prepared values. 2358} 2359 2360var create = function create() { 2361 return util.Buffer 2362 ? function create_buffer_setup() { 2363 return (Writer.create = function create_buffer() { 2364 return new BufferWriter(); 2365 })(); 2366 } 2367 /* istanbul ignore next */ 2368 : function create_array() { 2369 return new Writer(); 2370 }; 2371};
vendor: 8,016 bytes, lines 2372-2646
2372 2373/** 2374 * Creates a new writer. 2375 * @function 2376 * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer} 2377 */ 2378Writer.create = create(); 2379 2380/** 2381 * Allocates a buffer of the specified size. 2382 * @param {number} size Buffer size 2383 * @returns {Uint8Array} Buffer 2384 */ 2385Writer.alloc = function alloc(size) { 2386 return new util.Array(size); 2387}; 2388 2389// Use Uint8Array buffer pool in the browser, just like node does with buffers 2390/* istanbul ignore else */ 2391if (util.Array !== Array) 2392 Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray); 2393 2394/** 2395 * Pushes a new operation to the queue. 2396 * @param {function(Uint8Array, number, *)} fn Function to call 2397 * @param {number} len Value byte length 2398 * @param {number} val Value to write 2399 * @returns {Writer} `this` 2400 * @private 2401 */ 2402Writer.prototype._push = function push(fn, len, val) { 2403 this.tail = this.tail.next = new Op(fn, len, val); 2404 this.len += len; 2405 return this; 2406}; 2407 2408function writeByte(val, buf, pos) { 2409 buf[pos] = val & 255; 2410} 2411 2412function writeVarint32(val, buf, pos) { 2413 while (val > 127) { 2414 buf[pos++] = val & 127 | 128; 2415 val >>>= 7; 2416 } 2417 buf[pos] = val; 2418} 2419 2420/** 2421 * Constructs a new varint writer operation instance. 2422 * @classdesc Scheduled varint writer operation. 2423 * @extends Op 2424 * @constructor 2425 * @param {number} len Value byte length 2426 * @param {number} val Value to write 2427 * @ignore 2428 */ 2429function VarintOp(len, val) { 2430 this.len = len; 2431 this.next = undefined; 2432 this.val = val; 2433} 2434 2435VarintOp.prototype = Object.create(Op.prototype); 2436VarintOp.prototype.fn = writeVarint32; 2437 2438/** 2439 * Writes an unsigned 32 bit value as a varint. 2440 * @param {number} value Value to write 2441 * @returns {Writer} `this` 2442 */ 2443Writer.prototype.uint32 = function write_uint32(value) { 2444 // here, the call to this.push has been inlined and a varint specific Op subclass is used. 2445 // uint32 is by far the most frequently used operation and benefits significantly from this. 2446 this.len += (this.tail = this.tail.next = new VarintOp( 2447 (value = value >>> 0) 2448 < 128 ? 1 2449 : value < 16384 ? 2 2450 : value < 2097152 ? 3 2451 : value < 268435456 ? 4 2452 : 5, 2453 value)).len; 2454 return this; 2455}; 2456 2457/** 2458 * Writes a signed 32 bit value as a varint. 2459 * @function 2460 * @param {number} value Value to write 2461 * @returns {Writer} `this` 2462 */ 2463Writer.prototype.int32 = function write_int32(value) { 2464 return (value |= 0) < 0 2465 ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec 2466 : this.uint32(value); 2467}; 2468 2469/** 2470 * Writes a 32 bit value as a varint, zig-zag encoded. 2471 * @param {number} value Value to write 2472 * @returns {Writer} `this` 2473 */ 2474Writer.prototype.sint32 = function write_sint32(value) { 2475 return this.uint32((value << 1 ^ value >> 31) >>> 0); 2476}; 2477 2478function writeVarint64(val, buf, pos) { 2479 var lo = val.lo, 2480 hi = val.hi; 2481 while (hi) { 2482 buf[pos++] = lo & 127 | 128; 2483 lo = (lo >>> 7 | hi << 25) >>> 0; 2484 hi >>>= 7; 2485 } 2486 while (lo > 127) { 2487 buf[pos++] = lo & 127 | 128; 2488 lo = lo >>> 7; 2489 } 2490 buf[pos++] = lo; 2491} 2492 2493/** 2494 * Writes an unsigned 64 bit value as a varint. 2495 * @param {Long|number|string} value Value to write 2496 * @returns {Writer} `this` 2497 * @throws {TypeError} If `value` is a string and no long library is present. 2498 */ 2499Writer.prototype.uint64 = function write_uint64(value) { 2500 var bits = LongBits.from(value); 2501 return this._push(writeVarint64, bits.length(), bits); 2502}; 2503 2504/** 2505 * Writes a signed 64 bit value as a varint. 2506 * @function 2507 * @param {Long|number|string} value Value to write 2508 * @returns {Writer} `this` 2509 * @throws {TypeError} If `value` is a string and no long library is present. 2510 */ 2511Writer.prototype.int64 = Writer.prototype.uint64; 2512 2513/** 2514 * Writes a signed 64 bit value as a varint, zig-zag encoded. 2515 * @param {Long|number|string} value Value to write 2516 * @returns {Writer} `this` 2517 * @throws {TypeError} If `value` is a string and no long library is present. 2518 */ 2519Writer.prototype.sint64 = function write_sint64(value) { 2520 var bits = LongBits.from(value).zzEncode(); 2521 return this._push(writeVarint64, bits.length(), bits); 2522}; 2523 2524/** 2525 * Writes a boolish value as a varint. 2526 * @param {boolean} value Value to write 2527 * @returns {Writer} `this` 2528 */ 2529Writer.prototype.bool = function write_bool(value) { 2530 return this._push(writeByte, 1, value ? 1 : 0); 2531}; 2532 2533function writeFixed32(val, buf, pos) { 2534 buf[pos ] = val & 255; 2535 buf[pos + 1] = val >>> 8 & 255; 2536 buf[pos + 2] = val >>> 16 & 255; 2537 buf[pos + 3] = val >>> 24; 2538} 2539 2540/** 2541 * Writes an unsigned 32 bit value as fixed 32 bits. 2542 * @param {number} value Value to write 2543 * @returns {Writer} `this` 2544 */ 2545Writer.prototype.fixed32 = function write_fixed32(value) { 2546 return this._push(writeFixed32, 4, value >>> 0); 2547}; 2548 2549/** 2550 * Writes a signed 32 bit value as fixed 32 bits. 2551 * @function 2552 * @param {number} value Value to write 2553 * @returns {Writer} `this` 2554 */ 2555Writer.prototype.sfixed32 = Writer.prototype.fixed32; 2556 2557/** 2558 * Writes an unsigned 64 bit value as fixed 64 bits. 2559 * @param {Long|number|string} value Value to write 2560 * @returns {Writer} `this` 2561 * @throws {TypeError} If `value` is a string and no long library is present. 2562 */ 2563Writer.prototype.fixed64 = function write_fixed64(value) { 2564 var bits = LongBits.from(value); 2565 return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi); 2566}; 2567 2568/** 2569 * Writes a signed 64 bit value as fixed 64 bits. 2570 * @function 2571 * @param {Long|number|string} value Value to write 2572 * @returns {Writer} `this` 2573 * @throws {TypeError} If `value` is a string and no long library is present. 2574 */ 2575Writer.prototype.sfixed64 = Writer.prototype.fixed64; 2576 2577/** 2578 * Writes a float (32 bit). 2579 * @function 2580 * @param {number} value Value to write 2581 * @returns {Writer} `this` 2582 */ 2583Writer.prototype.float = function write_float(value) { 2584 return this._push(util.float.writeFloatLE, 4, value); 2585}; 2586 2587/** 2588 * Writes a double (64 bit float). 2589 * @function 2590 * @param {number} value Value to write 2591 * @returns {Writer} `this` 2592 */ 2593Writer.prototype.double = function write_double(value) { 2594 return this._push(util.float.writeDoubleLE, 8, value); 2595}; 2596 2597var writeBytes = util.Array.prototype.set 2598 ? function writeBytes_set(val, buf, pos) { 2599 buf.set(val, pos); // also works for plain array values 2600 } 2601 /* istanbul ignore next */ 2602 : function writeBytes_for(val, buf, pos) { 2603 for (var i = 0; i < val.length; ++i) 2604 buf[pos + i] = val[i]; 2605 }; 2606 2607/** 2608 * Writes a sequence of bytes. 2609 * @param {Uint8Array|string} value Buffer or base64 encoded string to write 2610 * @returns {Writer} `this` 2611 */ 2612Writer.prototype.bytes = function write_bytes(value) { 2613 var len = value.length >>> 0; 2614 if (!len) 2615 return this._push(writeByte, 1, 0); 2616 if (util.isString(value)) { 2617 var buf = Writer.alloc(len = base64.length(value)); 2618 base64.decode(value, buf, 0); 2619 value = buf; 2620 } 2621 return this.uint32(len)._push(writeBytes, len, value); 2622}; 2623 2624/** 2625 * Writes a string. 2626 * @param {string} value Value to write 2627 * @returns {Writer} `this` 2628 */ 2629Writer.prototype.string = function write_string(value) { 2630 var len = utf8.length(value); 2631 return len 2632 ? this.uint32(len)._push(utf8.write, len, value) 2633 : this._push(writeByte, 1, 0); 2634}; 2635 2636/** 2637 * Forks this writer's state by pushing it to a stack. 2638 * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state. 2639 * @returns {Writer} `this` 2640 */ 2641Writer.prototype.fork = function fork() { 2642 this.states = new State(this); 2643 this.head = this.tail = new Op(noop, 0, 0); 2644 this.len = 0; 2645 return this; 2646};
vendor: 3,995 bytes, lines 2647-2794
2647 2648/** 2649 * Resets this instance to the last state. 2650 * @returns {Writer} `this` 2651 */ 2652Writer.prototype.reset = function reset() { 2653 if (this.states) { 2654 this.head = this.states.head; 2655 this.tail = this.states.tail; 2656 this.len = this.states.len; 2657 this.states = this.states.next; 2658 } else { 2659 this.head = this.tail = new Op(noop, 0, 0); 2660 this.len = 0; 2661 } 2662 return this; 2663}; 2664 2665/** 2666 * Resets to the last state and appends the fork state's current write length as a varint followed by its operations. 2667 * @returns {Writer} `this` 2668 */ 2669Writer.prototype.ldelim = function ldelim() { 2670 var head = this.head, 2671 tail = this.tail, 2672 len = this.len; 2673 this.reset().uint32(len); 2674 if (len) { 2675 this.tail.next = head.next; // skip noop 2676 this.tail = tail; 2677 this.len += len; 2678 } 2679 return this; 2680}; 2681 2682/** 2683 * Finishes the write operation. 2684 * @returns {Uint8Array} Finished buffer 2685 */ 2686Writer.prototype.finish = function finish() { 2687 var head = this.head.next, // skip noop 2688 buf = this.constructor.alloc(this.len), 2689 pos = 0; 2690 while (head) { 2691 head.fn(head.val, buf, pos); 2692 pos += head.len; 2693 head = head.next; 2694 } 2695 // this.head = this.tail = null; 2696 return buf; 2697}; 2698 2699Writer._configure = function(BufferWriter_) { 2700 BufferWriter = BufferWriter_; 2701 Writer.create = create(); 2702 BufferWriter._configure(); 2703}; 2704 2705},{"14":14}],16:[function(require,module,exports){ 2706"use strict"; 2707module.exports = BufferWriter; 2708 2709// extends Writer 2710var Writer = require(15); 2711(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter; 2712 2713var util = require(14); 2714 2715/** 2716 * Constructs a new buffer writer instance. 2717 * @classdesc Wire format writer using node buffers. 2718 * @extends Writer 2719 * @constructor 2720 */ 2721function BufferWriter() { 2722 Writer.call(this); 2723} 2724 2725BufferWriter._configure = function () { 2726 /** 2727 * Allocates a buffer of the specified size. 2728 * @function 2729 * @param {number} size Buffer size 2730 * @returns {Buffer} Buffer 2731 */ 2732 BufferWriter.alloc = util._Buffer_allocUnsafe; 2733 2734 BufferWriter.writeBytesBuffer = util.Buffer && util.Buffer.prototype instanceof Uint8Array && util.Buffer.prototype.set.name === "set" 2735 ? function writeBytesBuffer_set(val, buf, pos) { 2736 buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited) 2737 // also works for plain array values 2738 } 2739 /* istanbul ignore next */ 2740 : function writeBytesBuffer_copy(val, buf, pos) { 2741 if (val.copy) // Buffer values 2742 val.copy(buf, pos, 0, val.length); 2743 else for (var i = 0; i < val.length;) // plain array values 2744 buf[pos++] = val[i++]; 2745 }; 2746}; 2747 2748 2749/** 2750 * @override 2751 */ 2752BufferWriter.prototype.bytes = function write_bytes_buffer(value) { 2753 if (util.isString(value)) 2754 value = util._Buffer_from(value, "base64"); 2755 var len = value.length >>> 0; 2756 this.uint32(len); 2757 if (len) 2758 this._push(BufferWriter.writeBytesBuffer, len, value); 2759 return this; 2760}; 2761 2762function writeStringBuffer(val, buf, pos) { 2763 if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions) 2764 util.utf8.write(val, buf, pos); 2765 else if (buf.utf8Write) 2766 buf.utf8Write(val, pos); 2767 else 2768 buf.write(val, pos); 2769} 2770 2771/** 2772 * @override 2773 */ 2774BufferWriter.prototype.string = function write_string_buffer(value) { 2775 var len = util.Buffer.byteLength(value); 2776 this.uint32(len); 2777 if (len) 2778 this._push(writeStringBuffer, len, value); 2779 return this; 2780}; 2781 2782 2783/** 2784 * Finishes the write operation. 2785 * @name BufferWriter#finish 2786 * @function 2787 * @returns {Buffer} Finished buffer 2788 */ 2789 2790BufferWriter._configure(); 2791 2792},{"14":14,"15":15}]},{},[7]) 2793 2794})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.