protobufjs 8.7.0 → 8.7.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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v8.7.0 (c) 2016, daniel wirtz
3
- * compiled mon, 06 jul 2026 13:50:00 utc
2
+ * protobuf.js v8.7.2 (c) 2016, daniel wirtz
3
+ * compiled sat, 08 aug 2026 13:15:56 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -66,6 +66,7 @@ exports.configure = configure;
66
66
  * @returns {undefined}
67
67
  */
68
68
  function configure() {
69
+ exports.util.LongBits._configure(exports.util.Long);
69
70
  exports.Writer._configure(exports.BufferWriter);
70
71
  exports.Reader._configure(exports.BufferReader);
71
72
  }
@@ -471,9 +472,18 @@ Reader.prototype.double = function read_double() {
471
472
  */
472
473
  Reader.prototype.uint32s = function read_uint32s(array) {
473
474
  if (array === undefined) array = [];
474
- var end = this.uint32() + this.pos;
475
- while (this.pos < end)
476
- array.push(this.uint32());
475
+ var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
476
+ while (pos < end) {
477
+ value = buf[pos++];
478
+ if (value < 128)
479
+ array.push(value);
480
+ else {
481
+ this.pos = pos - 1;
482
+ array.push(this.uint32());
483
+ pos = this.pos;
484
+ }
485
+ }
486
+ this.pos = pos;
477
487
  return array;
478
488
  };
479
489
 
@@ -484,9 +494,18 @@ Reader.prototype.uint32s = function read_uint32s(array) {
484
494
  */
485
495
  Reader.prototype.int32s = function read_int32s(array) {
486
496
  if (array === undefined) array = [];
487
- var end = this.uint32() + this.pos;
488
- while (this.pos < end)
489
- array.push(this.int32());
497
+ var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
498
+ while (pos < end) {
499
+ value = buf[pos++];
500
+ if (value < 128)
501
+ array.push(value);
502
+ else {
503
+ this.pos = pos - 1;
504
+ array.push(this.int32());
505
+ pos = this.pos;
506
+ }
507
+ }
508
+ this.pos = pos;
490
509
  return array;
491
510
  };
492
511
 
@@ -510,9 +529,18 @@ Reader.prototype.sint32s = function read_sint32s(array) {
510
529
  */
511
530
  Reader.prototype.bools = function read_bools(array) {
512
531
  if (array === undefined) array = [];
513
- var end = this.uint32() + this.pos;
514
- while (this.pos < end)
515
- array.push(this.bool());
532
+ var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
533
+ while (pos < end) {
534
+ value = buf[pos++];
535
+ if (value < 128)
536
+ array.push(value !== 0);
537
+ else {
538
+ this.pos = pos - 1;
539
+ array.push(this.bool());
540
+ pos = this.pos;
541
+ }
542
+ }
543
+ this.pos = pos;
516
544
  return array;
517
545
  };
518
546
 
@@ -1788,7 +1816,7 @@ function readUintBE(buf, pos) {
1788
1816
  "use strict";
1789
1817
  module.exports = LongBits;
1790
1818
 
1791
- var util = require(12);
1819
+ var Long;
1792
1820
 
1793
1821
  /**
1794
1822
  * Constructs new long bits.
@@ -1867,10 +1895,10 @@ LongBits.fromNumber = function fromNumber(value) {
1867
1895
  LongBits.from = function from(value) {
1868
1896
  if (typeof value === "number")
1869
1897
  return LongBits.fromNumber(value);
1870
- if (util.isString(value)) {
1898
+ if (typeof value === "string" || value instanceof String) {
1871
1899
  /* istanbul ignore else */
1872
- if (util.Long)
1873
- value = util.Long.fromString(value);
1900
+ if (Long)
1901
+ value = Long.fromString(value);
1874
1902
  else
1875
1903
  return LongBits.fromNumber(parseInt(value, 10));
1876
1904
  }
@@ -1899,8 +1927,8 @@ LongBits.prototype.toNumber = function toNumber(unsigned) {
1899
1927
  * @returns {Long} Long
1900
1928
  */
1901
1929
  LongBits.prototype.toLong = function toLong(unsigned) {
1902
- return util.Long
1903
- ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
1930
+ return Long
1931
+ ? new Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
1904
1932
  /* istanbul ignore next */
1905
1933
  : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
1906
1934
  };
@@ -1986,7 +2014,11 @@ LongBits.prototype.length = function length() {
1986
2014
  : part2 < 128 ? 9 : 10;
1987
2015
  };
1988
2016
 
1989
- },{"12":12}],12:[function(require,module,exports){
2017
+ LongBits._configure = function(Long_) {
2018
+ Long = Long_;
2019
+ };
2020
+
2021
+ },{}],12:[function(require,module,exports){
1990
2022
  "use strict";
1991
2023
  /* global globalThis */
1992
2024
  var util = exports;
@@ -2558,7 +2590,6 @@ function pool(alloc, slice, size) {
2558
2590
  * @namespace
2559
2591
  */
2560
2592
  var utf8 = exports,
2561
- replacementChar = "\ufffd",
2562
2593
  looseDecoder = new TextDecoder("utf-8", { ignoreBOM: true }),
2563
2594
  strictDecoder;
2564
2595
  var TEXT_DECODER_MIN_LENGTH = 64;
@@ -2593,31 +2624,6 @@ utf8.length = function utf8_length(string) {
2593
2624
  return len;
2594
2625
  };
2595
2626
 
2596
- function utf8_read_js(buffer, start, end, str) {
2597
- for (var i = start; i < end;) {
2598
- var t = buffer[i++];
2599
- if (t <= 0x7F) {
2600
- str += String.fromCharCode(t);
2601
- } else if (t >= 0xC0 && t < 0xE0) {
2602
- var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F;
2603
- str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar;
2604
- } else if (t >= 0xE0 && t < 0xF0) {
2605
- var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
2606
- str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
2607
- } else if (t >= 0xF0) {
2608
- var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
2609
- if (t2 < 0x10000 || t2 > 0x10FFFF)
2610
- str += replacementChar;
2611
- else {
2612
- t2 -= 0x10000;
2613
- str += String.fromCharCode(0xD800 + (t2 >> 10));
2614
- str += String.fromCharCode(0xDC00 + (t2 & 0x3FF));
2615
- }
2616
- }
2617
- }
2618
- return str;
2619
- }
2620
-
2621
2627
  function utf8_read_decoder(decoder, buffer, start, end) {
2622
2628
  var source = start === 0 && end === buffer.length
2623
2629
  ? buffer
@@ -2652,14 +2658,14 @@ utf8.read = function utf8_read_loose(buffer, start, end) {
2652
2658
  c7 = buffer[i + 6];
2653
2659
  c8 = buffer[i + 7];
2654
2660
  if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
2655
- return utf8_read_js(buffer, i, end, str);
2661
+ return str + utf8_read_decoder(looseDecoder, buffer, i, end);
2656
2662
  str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
2657
2663
  }
2658
2664
 
2659
2665
  for (; i < end; ++i) {
2660
2666
  c1 = buffer[i];
2661
2667
  if (c1 & 0x80)
2662
- return utf8_read_js(buffer, i, end, str);
2668
+ return str + utf8_read_decoder(looseDecoder, buffer, i, end);
2663
2669
  str += String.fromCharCode(c1);
2664
2670
  }
2665
2671
 
@@ -2770,7 +2776,7 @@ function Writer() {
2770
2776
  * Backing buffer.
2771
2777
  * @type {Uint8Array}
2772
2778
  */
2773
- this.buf = this.constructor.alloc(64);
2779
+ this.buf = this.constructor.alloc(Writer.initialBufferSize);
2774
2780
 
2775
2781
  /**
2776
2782
  * Cached DataView over {@link Writer#buf}.
@@ -2785,6 +2791,12 @@ function Writer() {
2785
2791
  this.states = null;
2786
2792
  }
2787
2793
 
2794
+ /**
2795
+ * Initial backing buffer size in bytes. Defaults to 128.
2796
+ * @type {number}
2797
+ */
2798
+ Writer.initialBufferSize = 128;
2799
+
2788
2800
  /**
2789
2801
  * Current write position.
2790
2802
  * @name Writer#len