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.
- package/dist/light/protobuf.js +65 -26
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +59 -20
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +79 -29
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/descriptor.js +9 -0
- package/ext/protojson.js +15 -4
- package/google/protobuf/descriptor.json +4 -0
- package/google/protobuf/descriptor.proto +1 -0
- package/google/protobuf/json_enumvalue_options.json +56 -0
- package/google/protobuf/json_enumvalue_options.proto +31 -0
- package/index.d.ts +6 -0
- package/package.json +1 -1
- package/src/decoder.js +5 -5
- package/src/reader.js +56 -17
- package/src/reader_buffer.js +1 -1
- package/src/tokenize.js +14 -3
- package/src/type.js +1 -1
package/dist/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.8.
|
|
3
|
-
* compiled
|
|
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
|
*/
|
|
@@ -890,7 +890,7 @@ function decoder(mtype) {
|
|
|
890
890
|
("if(%s===util.emptyObject)", ref)
|
|
891
891
|
("%s={}", ref);
|
|
892
892
|
gen
|
|
893
|
-
("var c2=r.
|
|
893
|
+
("var c2=r.size()+r.pos")
|
|
894
894
|
("if(c2>r.len)")
|
|
895
895
|
("throw RangeError(\"index out of range\")")
|
|
896
896
|
("r.len=c2");
|
|
@@ -922,7 +922,7 @@ function decoder(mtype) {
|
|
|
922
922
|
("break");
|
|
923
923
|
|
|
924
924
|
if (types.basic[type] === undefined) gen
|
|
925
|
-
("v=types[%i].decode(r,r.
|
|
925
|
+
("v=types[%i].decode(r,r.size(),undefined,q+1,v)", i); // can't be groups
|
|
926
926
|
else gen
|
|
927
927
|
("v=r.%s()", type === "string" ? stringMethod(field) : type);
|
|
928
928
|
|
|
@@ -967,7 +967,7 @@ function decoder(mtype) {
|
|
|
967
967
|
("if(u===2){");
|
|
968
968
|
if (closed) {
|
|
969
969
|
gen
|
|
970
|
-
("var c2=r.
|
|
970
|
+
("var c2=r.size()+r.pos")
|
|
971
971
|
("if(c2>r.len)")
|
|
972
972
|
("throw RangeError(\"index out of range\")")
|
|
973
973
|
("r.len=c2")
|
|
@@ -1005,7 +1005,7 @@ function decoder(mtype) {
|
|
|
1005
1005
|
if (field.delimited) gen
|
|
1006
1006
|
("%s.push(types[%i].decode(r,undefined,%i,q+1))", ref, i, field.id * 8 + 4);
|
|
1007
1007
|
else gen
|
|
1008
|
-
("%s.push(types[%i].decode(r,r.
|
|
1008
|
+
("%s.push(types[%i].decode(r,r.size(),undefined,q+1))", ref, i);
|
|
1009
1009
|
} else if (closed) { gen
|
|
1010
1010
|
("v=r.%s()", type)
|
|
1011
1011
|
("if(types[%i].valuesById[v]!==undefined){", i)
|
|
@@ -1026,7 +1026,7 @@ function decoder(mtype) {
|
|
|
1026
1026
|
if (field.delimited) gen
|
|
1027
1027
|
("%s=types[%i].decode(r,undefined,%i,q+1,%s)", ref, i, field.id * 8 + 4, ref);
|
|
1028
1028
|
else gen
|
|
1029
|
-
("%s=types[%i].decode(r,r.
|
|
1029
|
+
("%s=types[%i].decode(r,r.size(),undefined,q+1,%s)", ref, i, ref);
|
|
1030
1030
|
}
|
|
1031
1031
|
else if (field.hasPresence) {
|
|
1032
1032
|
gen
|
|
@@ -5172,6 +5172,45 @@ Reader.prototype.tag = function read_tag() {
|
|
|
5172
5172
|
throw Error("invalid tag encoding");
|
|
5173
5173
|
};
|
|
5174
5174
|
|
|
5175
|
+
/**
|
|
5176
|
+
* Reads a varint length prefix within signed 32 bit range.
|
|
5177
|
+
* @returns {number} Length read
|
|
5178
|
+
*/
|
|
5179
|
+
Reader.prototype.size = function read_size() {
|
|
5180
|
+
if (this.len - this.pos < 5) {
|
|
5181
|
+
if (this.pos >= this.len)
|
|
5182
|
+
throw indexOutOfRange(this);
|
|
5183
|
+
if (this.buf[this.pos] >= 128)
|
|
5184
|
+
return readVarint32NearEnd(this);
|
|
5185
|
+
}
|
|
5186
|
+
var buf = this.buf,
|
|
5187
|
+
pos = this.pos,
|
|
5188
|
+
value = (buf[pos] & 127) >>> 0;
|
|
5189
|
+
if (buf[pos++] < 128) {
|
|
5190
|
+
this.pos = pos;
|
|
5191
|
+
return value;
|
|
5192
|
+
}
|
|
5193
|
+
value = (value | (buf[pos] & 127) << 7) >>> 0;
|
|
5194
|
+
if (buf[pos++] < 128) {
|
|
5195
|
+
this.pos = pos;
|
|
5196
|
+
return value;
|
|
5197
|
+
}
|
|
5198
|
+
value = (value | (buf[pos] & 127) << 14) >>> 0;
|
|
5199
|
+
if (buf[pos++] < 128) {
|
|
5200
|
+
this.pos = pos;
|
|
5201
|
+
return value;
|
|
5202
|
+
}
|
|
5203
|
+
value = (value | (buf[pos] & 127) << 21) >>> 0;
|
|
5204
|
+
if (buf[pos++] < 128) {
|
|
5205
|
+
this.pos = pos;
|
|
5206
|
+
return value;
|
|
5207
|
+
}
|
|
5208
|
+
this.pos = pos + 1;
|
|
5209
|
+
if (buf[pos] > 7)
|
|
5210
|
+
throw Error("invalid length encoding");
|
|
5211
|
+
return (value | buf[pos] << 28) >>> 0;
|
|
5212
|
+
};
|
|
5213
|
+
|
|
5175
5214
|
/**
|
|
5176
5215
|
* Reads a varint as a signed 32 bit value.
|
|
5177
5216
|
* @returns {number} Value read
|
|
@@ -5385,7 +5424,7 @@ Reader.prototype.double = function read_double() {
|
|
|
5385
5424
|
*/
|
|
5386
5425
|
Reader.prototype.uint32s = function read_uint32s(array) {
|
|
5387
5426
|
if (array === undefined) array = [];
|
|
5388
|
-
var end = this.
|
|
5427
|
+
var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
5389
5428
|
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5390
5429
|
this.len = end;
|
|
5391
5430
|
while (pos < end) {
|
|
@@ -5411,7 +5450,7 @@ Reader.prototype.uint32s = function read_uint32s(array) {
|
|
|
5411
5450
|
*/
|
|
5412
5451
|
Reader.prototype.int32s = function read_int32s(array) {
|
|
5413
5452
|
if (array === undefined) array = [];
|
|
5414
|
-
var end = this.
|
|
5453
|
+
var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
5415
5454
|
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5416
5455
|
this.len = end;
|
|
5417
5456
|
while (pos < end) {
|
|
@@ -5437,7 +5476,7 @@ Reader.prototype.int32s = function read_int32s(array) {
|
|
|
5437
5476
|
*/
|
|
5438
5477
|
Reader.prototype.sint32s = function read_sint32s(array) {
|
|
5439
5478
|
if (array === undefined) array = [];
|
|
5440
|
-
var end = this.
|
|
5479
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5441
5480
|
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5442
5481
|
this.len = end;
|
|
5443
5482
|
while (this.pos < end)
|
|
@@ -5454,7 +5493,7 @@ Reader.prototype.sint32s = function read_sint32s(array) {
|
|
|
5454
5493
|
*/
|
|
5455
5494
|
Reader.prototype.bools = function read_bools(array) {
|
|
5456
5495
|
if (array === undefined) array = [];
|
|
5457
|
-
var end = this.
|
|
5496
|
+
var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
5458
5497
|
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5459
5498
|
this.len = end;
|
|
5460
5499
|
while (pos < end) {
|
|
@@ -5492,7 +5531,7 @@ function getLazyView(reader, count, threshold) {
|
|
|
5492
5531
|
*/
|
|
5493
5532
|
Reader.prototype.fixed32s = function read_fixed32s(array) {
|
|
5494
5533
|
if (array === undefined) array = [];
|
|
5495
|
-
var len = this.
|
|
5534
|
+
var len = this.size(), end = this.pos + len;
|
|
5496
5535
|
/* istanbul ignore if */
|
|
5497
5536
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5498
5537
|
var count = len >>> 2, i = array.length, pos = this.pos;
|
|
@@ -5516,7 +5555,7 @@ Reader.prototype.fixed32s = function read_fixed32s(array) {
|
|
|
5516
5555
|
*/
|
|
5517
5556
|
Reader.prototype.sfixed32s = function read_sfixed32s(array) {
|
|
5518
5557
|
if (array === undefined) array = [];
|
|
5519
|
-
var len = this.
|
|
5558
|
+
var len = this.size(), end = this.pos + len;
|
|
5520
5559
|
/* istanbul ignore if */
|
|
5521
5560
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5522
5561
|
var count = len >>> 2, i = array.length, pos = this.pos;
|
|
@@ -5540,7 +5579,7 @@ Reader.prototype.sfixed32s = function read_sfixed32s(array) {
|
|
|
5540
5579
|
*/
|
|
5541
5580
|
Reader.prototype.floats = function read_floats(array) {
|
|
5542
5581
|
if (array === undefined) array = [];
|
|
5543
|
-
var len = this.
|
|
5582
|
+
var len = this.size(), end = this.pos + len;
|
|
5544
5583
|
/* istanbul ignore if */
|
|
5545
5584
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5546
5585
|
var count = len >>> 2, i = array.length, pos = this.pos;
|
|
@@ -5564,7 +5603,7 @@ Reader.prototype.floats = function read_floats(array) {
|
|
|
5564
5603
|
*/
|
|
5565
5604
|
Reader.prototype.doubles = function read_doubles(array) {
|
|
5566
5605
|
if (array === undefined) array = [];
|
|
5567
|
-
var len = this.
|
|
5606
|
+
var len = this.size(), end = this.pos + len;
|
|
5568
5607
|
/* istanbul ignore if */
|
|
5569
5608
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5570
5609
|
var count = len >>> 3, i = array.length, pos = this.pos;
|
|
@@ -5588,7 +5627,7 @@ Reader.prototype.doubles = function read_doubles(array) {
|
|
|
5588
5627
|
*/
|
|
5589
5628
|
Reader.prototype.uint64s = function read_uint64s(array) {
|
|
5590
5629
|
if (array === undefined) array = [];
|
|
5591
|
-
var end = this.
|
|
5630
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5592
5631
|
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5593
5632
|
this.len = end;
|
|
5594
5633
|
while (this.pos < end)
|
|
@@ -5605,7 +5644,7 @@ Reader.prototype.uint64s = function read_uint64s(array) {
|
|
|
5605
5644
|
*/
|
|
5606
5645
|
Reader.prototype.int64s = function read_int64s(array) {
|
|
5607
5646
|
if (array === undefined) array = [];
|
|
5608
|
-
var end = this.
|
|
5647
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5609
5648
|
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5610
5649
|
this.len = end;
|
|
5611
5650
|
while (this.pos < end)
|
|
@@ -5622,7 +5661,7 @@ Reader.prototype.int64s = function read_int64s(array) {
|
|
|
5622
5661
|
*/
|
|
5623
5662
|
Reader.prototype.sint64s = function read_sint64s(array) {
|
|
5624
5663
|
if (array === undefined) array = [];
|
|
5625
|
-
var end = this.
|
|
5664
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5626
5665
|
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5627
5666
|
this.len = end;
|
|
5628
5667
|
while (this.pos < end)
|
|
@@ -5639,7 +5678,7 @@ Reader.prototype.sint64s = function read_sint64s(array) {
|
|
|
5639
5678
|
*/
|
|
5640
5679
|
Reader.prototype.fixed64s = function read_fixed64s(array) {
|
|
5641
5680
|
if (array === undefined) array = [];
|
|
5642
|
-
var len = this.
|
|
5681
|
+
var len = this.size(), end = this.pos + len, i = array.length;
|
|
5643
5682
|
/* istanbul ignore if */
|
|
5644
5683
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5645
5684
|
var count = len >>> 3;
|
|
@@ -5657,7 +5696,7 @@ Reader.prototype.fixed64s = function read_fixed64s(array) {
|
|
|
5657
5696
|
*/
|
|
5658
5697
|
Reader.prototype.sfixed64s = function read_sfixed64s(array) {
|
|
5659
5698
|
if (array === undefined) array = [];
|
|
5660
|
-
var len = this.
|
|
5699
|
+
var len = this.size(), end = this.pos + len, i = array.length;
|
|
5661
5700
|
/* istanbul ignore if */
|
|
5662
5701
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5663
5702
|
var count = len >>> 3;
|
|
@@ -5673,7 +5712,7 @@ Reader.prototype.sfixed64s = function read_sfixed64s(array) {
|
|
|
5673
5712
|
* @returns {Uint8Array} Value read
|
|
5674
5713
|
*/
|
|
5675
5714
|
Reader.prototype.bytes = function read_bytes() {
|
|
5676
|
-
var length = this.
|
|
5715
|
+
var length = this.size(),
|
|
5677
5716
|
start = this.pos,
|
|
5678
5717
|
end = this.pos + length;
|
|
5679
5718
|
|
|
@@ -5690,7 +5729,7 @@ Reader.prototype.bytes = function read_bytes() {
|
|
|
5690
5729
|
* @returns {string} Value read
|
|
5691
5730
|
*/
|
|
5692
5731
|
Reader.prototype.string = function read_string() {
|
|
5693
|
-
var length = this.
|
|
5732
|
+
var length = this.size(),
|
|
5694
5733
|
start = this.pos,
|
|
5695
5734
|
end = this.pos + length;
|
|
5696
5735
|
|
|
@@ -5707,7 +5746,7 @@ Reader.prototype.string = function read_string() {
|
|
|
5707
5746
|
* @returns {string} Value read
|
|
5708
5747
|
*/
|
|
5709
5748
|
Reader.prototype.stringVerify = function read_string_verify() {
|
|
5710
|
-
var length = this.
|
|
5749
|
+
var length = this.size(),
|
|
5711
5750
|
start = this.pos,
|
|
5712
5751
|
end = this.pos + length;
|
|
5713
5752
|
|
|
@@ -5773,7 +5812,7 @@ Reader.prototype.skipType = function(wireType, depth, fieldNumber) {
|
|
|
5773
5812
|
this.skip(8);
|
|
5774
5813
|
break;
|
|
5775
5814
|
case 2:
|
|
5776
|
-
this.skip(this.
|
|
5815
|
+
this.skip(this.size());
|
|
5777
5816
|
break;
|
|
5778
5817
|
case 3:
|
|
5779
5818
|
while (true) {
|
|
@@ -5888,7 +5927,7 @@ BufferReader.prototype.raw = function read_raw_buffer(start, end) {
|
|
|
5888
5927
|
* @override
|
|
5889
5928
|
*/
|
|
5890
5929
|
BufferReader.prototype.string = function read_string_buffer() {
|
|
5891
|
-
var len = this.
|
|
5930
|
+
var len = this.size(), // modifies pos
|
|
5892
5931
|
start = this.pos,
|
|
5893
5932
|
end = this.pos + len;
|
|
5894
5933
|
|
|
@@ -6772,13 +6811,19 @@ var setCommentRe = /^ *[*/]+ */,
|
|
|
6772
6811
|
setCommentAltRe = /^\s*\*?\/*/,
|
|
6773
6812
|
setCommentSplitRe = /\n/g,
|
|
6774
6813
|
whitespaceRe = /\s/,
|
|
6775
|
-
unescapeRe = /\\(
|
|
6814
|
+
unescapeRe = /\\([0-7]{1,3}|[xX][0-9a-fA-F]{1,2}|.?)/g;
|
|
6776
6815
|
|
|
6777
6816
|
var unescapeMap = {
|
|
6778
|
-
"
|
|
6817
|
+
"a": "\x07",
|
|
6818
|
+
"b": "\b",
|
|
6819
|
+
"f": "\f",
|
|
6779
6820
|
"r": "\r",
|
|
6780
6821
|
"n": "\n",
|
|
6781
|
-
"t": "\t"
|
|
6822
|
+
"t": "\t",
|
|
6823
|
+
"v": "\v",
|
|
6824
|
+
"?": "?",
|
|
6825
|
+
"'": "'",
|
|
6826
|
+
"\"": "\""
|
|
6782
6827
|
};
|
|
6783
6828
|
|
|
6784
6829
|
/**
|
|
@@ -6790,6 +6835,11 @@ var unescapeMap = {
|
|
|
6790
6835
|
*/
|
|
6791
6836
|
function unescape(str) {
|
|
6792
6837
|
return str.replace(unescapeRe, function($0, $1) {
|
|
6838
|
+
var first = $1.charAt(0);
|
|
6839
|
+
if (first >= "0" && first <= "7")
|
|
6840
|
+
return String.fromCharCode(parseInt($1, 8) & 255);
|
|
6841
|
+
if (first === "x" || first === "X")
|
|
6842
|
+
return String.fromCharCode(parseInt($1.substring(1), 16));
|
|
6793
6843
|
switch ($1) {
|
|
6794
6844
|
case "\\":
|
|
6795
6845
|
case "":
|
|
@@ -7786,7 +7836,7 @@ Type.prototype.decode = function decode_setup(reader, length) { // eslint-disabl
|
|
|
7786
7836
|
Type.prototype.decodeDelimited = function decodeDelimited(reader) {
|
|
7787
7837
|
if (!(reader instanceof Reader))
|
|
7788
7838
|
reader = Reader.create(reader);
|
|
7789
|
-
return this.decode(reader, reader.
|
|
7839
|
+
return this.decode(reader, reader.size());
|
|
7790
7840
|
};
|
|
7791
7841
|
|
|
7792
7842
|
/**
|