protobufjs 8.8.0 → 8.8.1

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.8.0 (c) 2016, daniel wirtz
3
- * compiled thu, 27 aug 2026 00:01:05 utc
2
+ * protobuf.js v8.8.1 (c) 2016, daniel wirtz
3
+ * compiled sun, 11 oct 2026 17:08:01 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -483,7 +483,7 @@ function decoder(mtype) {
483
483
  ("if(%s===util.emptyObject)", ref)
484
484
  ("%s={}", ref);
485
485
  gen
486
- ("var c2=r.uint32()+r.pos")
486
+ ("var c2=r.size()+r.pos")
487
487
  ("if(c2>r.len)")
488
488
  ("throw RangeError(\"index out of range\")")
489
489
  ("r.len=c2");
@@ -515,7 +515,7 @@ function decoder(mtype) {
515
515
  ("break");
516
516
 
517
517
  if (types.basic[type] === undefined) gen
518
- ("v=types[%i].decode(r,r.uint32(),undefined,q+1,v)", i); // can't be groups
518
+ ("v=types[%i].decode(r,r.size(),undefined,q+1,v)", i); // can't be groups
519
519
  else gen
520
520
  ("v=r.%s()", type === "string" ? stringMethod(field) : type);
521
521
 
@@ -560,7 +560,7 @@ function decoder(mtype) {
560
560
  ("if(u===2){");
561
561
  if (closed) {
562
562
  gen
563
- ("var c2=r.uint32()+r.pos")
563
+ ("var c2=r.size()+r.pos")
564
564
  ("if(c2>r.len)")
565
565
  ("throw RangeError(\"index out of range\")")
566
566
  ("r.len=c2")
@@ -598,7 +598,7 @@ function decoder(mtype) {
598
598
  if (field.delimited) gen
599
599
  ("%s.push(types[%i].decode(r,undefined,%i,q+1))", ref, i, field.id * 8 + 4);
600
600
  else gen
601
- ("%s.push(types[%i].decode(r,r.uint32(),undefined,q+1))", ref, i);
601
+ ("%s.push(types[%i].decode(r,r.size(),undefined,q+1))", ref, i);
602
602
  } else if (closed) { gen
603
603
  ("v=r.%s()", type)
604
604
  ("if(types[%i].valuesById[v]!==undefined){", i)
@@ -619,7 +619,7 @@ function decoder(mtype) {
619
619
  if (field.delimited) gen
620
620
  ("%s=types[%i].decode(r,undefined,%i,q+1,%s)", ref, i, field.id * 8 + 4, ref);
621
621
  else gen
622
- ("%s=types[%i].decode(r,r.uint32(),undefined,q+1,%s)", ref, i, ref);
622
+ ("%s=types[%i].decode(r,r.size(),undefined,q+1,%s)", ref, i, ref);
623
623
  }
624
624
  else if (field.hasPresence) {
625
625
  gen
@@ -3630,6 +3630,45 @@ Reader.prototype.tag = function read_tag() {
3630
3630
  throw Error("invalid tag encoding");
3631
3631
  };
3632
3632
 
3633
+ /**
3634
+ * Reads a varint length prefix within signed 32 bit range.
3635
+ * @returns {number} Length read
3636
+ */
3637
+ Reader.prototype.size = function read_size() {
3638
+ if (this.len - this.pos < 5) {
3639
+ if (this.pos >= this.len)
3640
+ throw indexOutOfRange(this);
3641
+ if (this.buf[this.pos] >= 128)
3642
+ return readVarint32NearEnd(this);
3643
+ }
3644
+ var buf = this.buf,
3645
+ pos = this.pos,
3646
+ value = (buf[pos] & 127) >>> 0;
3647
+ if (buf[pos++] < 128) {
3648
+ this.pos = pos;
3649
+ return value;
3650
+ }
3651
+ value = (value | (buf[pos] & 127) << 7) >>> 0;
3652
+ if (buf[pos++] < 128) {
3653
+ this.pos = pos;
3654
+ return value;
3655
+ }
3656
+ value = (value | (buf[pos] & 127) << 14) >>> 0;
3657
+ if (buf[pos++] < 128) {
3658
+ this.pos = pos;
3659
+ return value;
3660
+ }
3661
+ value = (value | (buf[pos] & 127) << 21) >>> 0;
3662
+ if (buf[pos++] < 128) {
3663
+ this.pos = pos;
3664
+ return value;
3665
+ }
3666
+ this.pos = pos + 1;
3667
+ if (buf[pos] > 7)
3668
+ throw Error("invalid length encoding");
3669
+ return (value | buf[pos] << 28) >>> 0;
3670
+ };
3671
+
3633
3672
  /**
3634
3673
  * Reads a varint as a signed 32 bit value.
3635
3674
  * @returns {number} Value read
@@ -3843,7 +3882,7 @@ Reader.prototype.double = function read_double() {
3843
3882
  */
3844
3883
  Reader.prototype.uint32s = function read_uint32s(array) {
3845
3884
  if (array === undefined) array = [];
3846
- var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
3885
+ var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
3847
3886
  if (end > len) throw indexOutOfRange(this, end - this.pos);
3848
3887
  this.len = end;
3849
3888
  while (pos < end) {
@@ -3869,7 +3908,7 @@ Reader.prototype.uint32s = function read_uint32s(array) {
3869
3908
  */
3870
3909
  Reader.prototype.int32s = function read_int32s(array) {
3871
3910
  if (array === undefined) array = [];
3872
- var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
3911
+ var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
3873
3912
  if (end > len) throw indexOutOfRange(this, end - this.pos);
3874
3913
  this.len = end;
3875
3914
  while (pos < end) {
@@ -3895,7 +3934,7 @@ Reader.prototype.int32s = function read_int32s(array) {
3895
3934
  */
3896
3935
  Reader.prototype.sint32s = function read_sint32s(array) {
3897
3936
  if (array === undefined) array = [];
3898
- var end = this.uint32() + this.pos, len = this.len;
3937
+ var end = this.size() + this.pos, len = this.len;
3899
3938
  if (end > len) throw indexOutOfRange(this, end - this.pos);
3900
3939
  this.len = end;
3901
3940
  while (this.pos < end)
@@ -3912,7 +3951,7 @@ Reader.prototype.sint32s = function read_sint32s(array) {
3912
3951
  */
3913
3952
  Reader.prototype.bools = function read_bools(array) {
3914
3953
  if (array === undefined) array = [];
3915
- var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
3954
+ var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
3916
3955
  if (end > len) throw indexOutOfRange(this, end - this.pos);
3917
3956
  this.len = end;
3918
3957
  while (pos < end) {
@@ -3950,7 +3989,7 @@ function getLazyView(reader, count, threshold) {
3950
3989
  */
3951
3990
  Reader.prototype.fixed32s = function read_fixed32s(array) {
3952
3991
  if (array === undefined) array = [];
3953
- var len = this.uint32(), end = this.pos + len;
3992
+ var len = this.size(), end = this.pos + len;
3954
3993
  /* istanbul ignore if */
3955
3994
  if (end > this.len) throw indexOutOfRange(this, len);
3956
3995
  var count = len >>> 2, i = array.length, pos = this.pos;
@@ -3974,7 +4013,7 @@ Reader.prototype.fixed32s = function read_fixed32s(array) {
3974
4013
  */
3975
4014
  Reader.prototype.sfixed32s = function read_sfixed32s(array) {
3976
4015
  if (array === undefined) array = [];
3977
- var len = this.uint32(), end = this.pos + len;
4016
+ var len = this.size(), end = this.pos + len;
3978
4017
  /* istanbul ignore if */
3979
4018
  if (end > this.len) throw indexOutOfRange(this, len);
3980
4019
  var count = len >>> 2, i = array.length, pos = this.pos;
@@ -3998,7 +4037,7 @@ Reader.prototype.sfixed32s = function read_sfixed32s(array) {
3998
4037
  */
3999
4038
  Reader.prototype.floats = function read_floats(array) {
4000
4039
  if (array === undefined) array = [];
4001
- var len = this.uint32(), end = this.pos + len;
4040
+ var len = this.size(), end = this.pos + len;
4002
4041
  /* istanbul ignore if */
4003
4042
  if (end > this.len) throw indexOutOfRange(this, len);
4004
4043
  var count = len >>> 2, i = array.length, pos = this.pos;
@@ -4022,7 +4061,7 @@ Reader.prototype.floats = function read_floats(array) {
4022
4061
  */
4023
4062
  Reader.prototype.doubles = function read_doubles(array) {
4024
4063
  if (array === undefined) array = [];
4025
- var len = this.uint32(), end = this.pos + len;
4064
+ var len = this.size(), end = this.pos + len;
4026
4065
  /* istanbul ignore if */
4027
4066
  if (end > this.len) throw indexOutOfRange(this, len);
4028
4067
  var count = len >>> 3, i = array.length, pos = this.pos;
@@ -4046,7 +4085,7 @@ Reader.prototype.doubles = function read_doubles(array) {
4046
4085
  */
4047
4086
  Reader.prototype.uint64s = function read_uint64s(array) {
4048
4087
  if (array === undefined) array = [];
4049
- var end = this.uint32() + this.pos, len = this.len;
4088
+ var end = this.size() + this.pos, len = this.len;
4050
4089
  if (end > len) throw indexOutOfRange(this, end - this.pos);
4051
4090
  this.len = end;
4052
4091
  while (this.pos < end)
@@ -4063,7 +4102,7 @@ Reader.prototype.uint64s = function read_uint64s(array) {
4063
4102
  */
4064
4103
  Reader.prototype.int64s = function read_int64s(array) {
4065
4104
  if (array === undefined) array = [];
4066
- var end = this.uint32() + this.pos, len = this.len;
4105
+ var end = this.size() + this.pos, len = this.len;
4067
4106
  if (end > len) throw indexOutOfRange(this, end - this.pos);
4068
4107
  this.len = end;
4069
4108
  while (this.pos < end)
@@ -4080,7 +4119,7 @@ Reader.prototype.int64s = function read_int64s(array) {
4080
4119
  */
4081
4120
  Reader.prototype.sint64s = function read_sint64s(array) {
4082
4121
  if (array === undefined) array = [];
4083
- var end = this.uint32() + this.pos, len = this.len;
4122
+ var end = this.size() + this.pos, len = this.len;
4084
4123
  if (end > len) throw indexOutOfRange(this, end - this.pos);
4085
4124
  this.len = end;
4086
4125
  while (this.pos < end)
@@ -4097,7 +4136,7 @@ Reader.prototype.sint64s = function read_sint64s(array) {
4097
4136
  */
4098
4137
  Reader.prototype.fixed64s = function read_fixed64s(array) {
4099
4138
  if (array === undefined) array = [];
4100
- var len = this.uint32(), end = this.pos + len, i = array.length;
4139
+ var len = this.size(), end = this.pos + len, i = array.length;
4101
4140
  /* istanbul ignore if */
4102
4141
  if (end > this.len) throw indexOutOfRange(this, len);
4103
4142
  var count = len >>> 3;
@@ -4115,7 +4154,7 @@ Reader.prototype.fixed64s = function read_fixed64s(array) {
4115
4154
  */
4116
4155
  Reader.prototype.sfixed64s = function read_sfixed64s(array) {
4117
4156
  if (array === undefined) array = [];
4118
- var len = this.uint32(), end = this.pos + len, i = array.length;
4157
+ var len = this.size(), end = this.pos + len, i = array.length;
4119
4158
  /* istanbul ignore if */
4120
4159
  if (end > this.len) throw indexOutOfRange(this, len);
4121
4160
  var count = len >>> 3;
@@ -4131,7 +4170,7 @@ Reader.prototype.sfixed64s = function read_sfixed64s(array) {
4131
4170
  * @returns {Uint8Array} Value read
4132
4171
  */
4133
4172
  Reader.prototype.bytes = function read_bytes() {
4134
- var length = this.uint32(),
4173
+ var length = this.size(),
4135
4174
  start = this.pos,
4136
4175
  end = this.pos + length;
4137
4176
 
@@ -4148,7 +4187,7 @@ Reader.prototype.bytes = function read_bytes() {
4148
4187
  * @returns {string} Value read
4149
4188
  */
4150
4189
  Reader.prototype.string = function read_string() {
4151
- var length = this.uint32(),
4190
+ var length = this.size(),
4152
4191
  start = this.pos,
4153
4192
  end = this.pos + length;
4154
4193
 
@@ -4165,7 +4204,7 @@ Reader.prototype.string = function read_string() {
4165
4204
  * @returns {string} Value read
4166
4205
  */
4167
4206
  Reader.prototype.stringVerify = function read_string_verify() {
4168
- var length = this.uint32(),
4207
+ var length = this.size(),
4169
4208
  start = this.pos,
4170
4209
  end = this.pos + length;
4171
4210
 
@@ -4231,7 +4270,7 @@ Reader.prototype.skipType = function(wireType, depth, fieldNumber) {
4231
4270
  this.skip(8);
4232
4271
  break;
4233
4272
  case 2:
4234
- this.skip(this.uint32());
4273
+ this.skip(this.size());
4235
4274
  break;
4236
4275
  case 3:
4237
4276
  while (true) {
@@ -4346,7 +4385,7 @@ BufferReader.prototype.raw = function read_raw_buffer(start, end) {
4346
4385
  * @override
4347
4386
  */
4348
4387
  BufferReader.prototype.string = function read_string_buffer() {
4349
- var len = this.uint32(), // modifies pos
4388
+ var len = this.size(), // modifies pos
4350
4389
  start = this.pos,
4351
4390
  end = this.pos + len;
4352
4391
 
@@ -5821,7 +5860,7 @@ Type.prototype.decode = function decode_setup(reader, length) { // eslint-disabl
5821
5860
  Type.prototype.decodeDelimited = function decodeDelimited(reader) {
5822
5861
  if (!(reader instanceof Reader))
5823
5862
  reader = Reader.create(reader);
5824
- return this.decode(reader, reader.uint32());
5863
+ return this.decode(reader, reader.size());
5825
5864
  };
5826
5865
 
5827
5866
  /**