protobufjs 8.7.2 → 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/README.md +24 -17
- package/dist/light/protobuf.js +179 -30
- 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 +113 -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 +202 -37
- 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.generated.d.ts +7 -0
- package/ext/descriptor.js +33 -0
- package/ext/protojson.js +29 -8
- package/ext/textformat.js +8 -4
- package/google/protobuf/descriptor.json +24 -1
- package/google/protobuf/descriptor.proto +15 -1
- package/google/protobuf/json_enumvalue_options.json +56 -0
- package/google/protobuf/json_enumvalue_options.proto +31 -0
- package/index.d.ts +18 -0
- package/package.json +1 -1
- package/src/decoder.js +35 -6
- package/src/enum.js +10 -0
- package/src/object.js +5 -2
- package/src/parse.js +9 -4
- package/src/reader.js +110 -17
- package/src/reader_buffer.js +1 -1
- package/src/tokenize.js +14 -3
- package/src/type.js +11 -1
- package/src/wrappers.js +5 -1
package/dist/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.
|
|
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
|
*/
|
|
@@ -853,7 +853,17 @@ function decoder(mtype) {
|
|
|
853
853
|
("if(q===undefined)q=0")
|
|
854
854
|
("if(q>Reader.recursionLimit)")
|
|
855
855
|
("throw Error(\"max depth exceeded\")")
|
|
856
|
-
("var c
|
|
856
|
+
("var c,m" + (hasMapField ? ",k,v" : needsValueVar ? ",v" : ""))
|
|
857
|
+
("if(l===undefined)")
|
|
858
|
+
("c=r.len")
|
|
859
|
+
("else{")
|
|
860
|
+
("c=r.pos+l")
|
|
861
|
+
("if(c>r.len)")
|
|
862
|
+
("throw RangeError(\"index out of range\")")
|
|
863
|
+
("l=r.len")
|
|
864
|
+
("r.len=c")
|
|
865
|
+
("}")
|
|
866
|
+
("m=g||new C")
|
|
857
867
|
("while(r.pos<c){")
|
|
858
868
|
("var s=r.pos")
|
|
859
869
|
("var t=r.tag()")
|
|
@@ -880,7 +890,10 @@ function decoder(mtype) {
|
|
|
880
890
|
("if(%s===util.emptyObject)", ref)
|
|
881
891
|
("%s={}", ref);
|
|
882
892
|
gen
|
|
883
|
-
("var c2=r.
|
|
893
|
+
("var c2=r.size()+r.pos")
|
|
894
|
+
("if(c2>r.len)")
|
|
895
|
+
("throw RangeError(\"index out of range\")")
|
|
896
|
+
("r.len=c2");
|
|
884
897
|
|
|
885
898
|
if (types.defaults[field.keyType] !== undefined) gen
|
|
886
899
|
("k=%j", types.defaults[field.keyType]);
|
|
@@ -909,7 +922,7 @@ function decoder(mtype) {
|
|
|
909
922
|
("break");
|
|
910
923
|
|
|
911
924
|
if (types.basic[type] === undefined) gen
|
|
912
|
-
("v=types[%i].decode(r,r.
|
|
925
|
+
("v=types[%i].decode(r,r.size(),undefined,q+1,v)", i); // can't be groups
|
|
913
926
|
else gen
|
|
914
927
|
("v=r.%s()", type === "string" ? stringMethod(field) : type);
|
|
915
928
|
|
|
@@ -918,6 +931,10 @@ function decoder(mtype) {
|
|
|
918
931
|
("}")
|
|
919
932
|
("r.skipType(u,q,t2)")
|
|
920
933
|
("}");
|
|
934
|
+
gen
|
|
935
|
+
("if(r.pos!==c2)")
|
|
936
|
+
("throw RangeError(\"index out of range\")")
|
|
937
|
+
("r.len=c");
|
|
921
938
|
|
|
922
939
|
if (closed) { gen
|
|
923
940
|
("if(types[%i].valuesById[v]===undefined){", i);
|
|
@@ -950,7 +967,10 @@ function decoder(mtype) {
|
|
|
950
967
|
("if(u===2){");
|
|
951
968
|
if (closed) {
|
|
952
969
|
gen
|
|
953
|
-
("var c2=r.
|
|
970
|
+
("var c2=r.size()+r.pos")
|
|
971
|
+
("if(c2>r.len)")
|
|
972
|
+
("throw RangeError(\"index out of range\")")
|
|
973
|
+
("r.len=c2")
|
|
954
974
|
("while(r.pos<c2){")
|
|
955
975
|
("s=r.pos")
|
|
956
976
|
("v=r.%s()", type)
|
|
@@ -961,6 +981,10 @@ function decoder(mtype) {
|
|
|
961
981
|
("}else");
|
|
962
982
|
genPreserveUnknown(gen, "util.rawField(" + field.id + ",0,r.raw(s,r.pos))")
|
|
963
983
|
("}");
|
|
984
|
+
gen
|
|
985
|
+
("if(r.pos!==c2)")
|
|
986
|
+
("throw RangeError(\"index out of range\")")
|
|
987
|
+
("r.len=c");
|
|
964
988
|
} else gen
|
|
965
989
|
("if(!(%s&&%s.length))", ref, ref)
|
|
966
990
|
("%s=[]", ref)
|
|
@@ -981,7 +1005,7 @@ function decoder(mtype) {
|
|
|
981
1005
|
if (field.delimited) gen
|
|
982
1006
|
("%s.push(types[%i].decode(r,undefined,%i,q+1))", ref, i, field.id * 8 + 4);
|
|
983
1007
|
else gen
|
|
984
|
-
("%s.push(types[%i].decode(r,r.
|
|
1008
|
+
("%s.push(types[%i].decode(r,r.size(),undefined,q+1))", ref, i);
|
|
985
1009
|
} else if (closed) { gen
|
|
986
1010
|
("v=r.%s()", type)
|
|
987
1011
|
("if(types[%i].valuesById[v]!==undefined){", i)
|
|
@@ -1002,7 +1026,7 @@ function decoder(mtype) {
|
|
|
1002
1026
|
if (field.delimited) gen
|
|
1003
1027
|
("%s=types[%i].decode(r,undefined,%i,q+1,%s)", ref, i, field.id * 8 + 4, ref);
|
|
1004
1028
|
else gen
|
|
1005
|
-
("%s=types[%i].decode(r,r.
|
|
1029
|
+
("%s=types[%i].decode(r,r.size(),undefined,q+1,%s)", ref, i, ref);
|
|
1006
1030
|
}
|
|
1007
1031
|
else if (field.hasPresence) {
|
|
1008
1032
|
gen
|
|
@@ -1069,6 +1093,11 @@ function decoder(mtype) {
|
|
|
1069
1093
|
("r.skipType(%s,q,t)", i ? "u" : "t&7");
|
|
1070
1094
|
genPreserveUnknown(gen, "r.raw(s,r.pos)")
|
|
1071
1095
|
("}")
|
|
1096
|
+
("if(l!==undefined){")
|
|
1097
|
+
("if(r.pos!==c)")
|
|
1098
|
+
("throw RangeError(\"index out of range\")")
|
|
1099
|
+
("r.len=l")
|
|
1100
|
+
("}")
|
|
1072
1101
|
("if(z!==undefined)")
|
|
1073
1102
|
("throw Error(\"missing end group\")");
|
|
1074
1103
|
|
|
@@ -1289,6 +1318,12 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
|
|
|
1289
1318
|
*/
|
|
1290
1319
|
this.reserved = undefined; // toJSON
|
|
1291
1320
|
|
|
1321
|
+
/**
|
|
1322
|
+
* Declared symbol visibility, if any.
|
|
1323
|
+
* @type {"local"|"export"|undefined}
|
|
1324
|
+
*/
|
|
1325
|
+
this.visibility = undefined; // toJSON
|
|
1326
|
+
|
|
1292
1327
|
// Note that values inherit valuesById on their prototype which makes them a TypeScript-
|
|
1293
1328
|
// compatible enum. This is used by pbts to write actual enum definitions that work for
|
|
1294
1329
|
// static and reflection code alike instead of emitting generic object definitions.
|
|
@@ -1325,6 +1360,7 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
|
1325
1360
|
* @property {Object.<string,*>} [options] Enum options
|
|
1326
1361
|
* @property {Object.<string,Object.<string,*>>} [valuesOptions] Enum value options
|
|
1327
1362
|
* @property {Array.<number[]|string>} [reserved] Reserved ranges
|
|
1363
|
+
* @property {"local"|"export"} [visibility] Declared symbol visibility
|
|
1328
1364
|
* @property {string|null} [comment] Enum comment
|
|
1329
1365
|
* @property {Object.<string,string|null>} [comments] Value comments
|
|
1330
1366
|
*/
|
|
@@ -1339,6 +1375,8 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
|
1339
1375
|
Enum.fromJSON = function fromJSON(name, json) {
|
|
1340
1376
|
var enm = new Enum(name, json.values, json.options, json.comment, json.comments, json.valuesOptions);
|
|
1341
1377
|
enm.reserved = json.reserved;
|
|
1378
|
+
if (json.visibility)
|
|
1379
|
+
enm.visibility = json.visibility;
|
|
1342
1380
|
if (json.edition)
|
|
1343
1381
|
enm._edition = json.edition;
|
|
1344
1382
|
enm._defaultEdition = "proto3"; // For backwards-compatibility.
|
|
@@ -1358,6 +1396,7 @@ Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
1358
1396
|
"valuesOptions" , this.valuesOptions,
|
|
1359
1397
|
"values" , this.values,
|
|
1360
1398
|
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
1399
|
+
"visibility" , this.visibility,
|
|
1361
1400
|
"comment" , keepComments ? this.comment : undefined,
|
|
1362
1401
|
"comments" , keepComments ? this.comments : undefined
|
|
1363
1402
|
]);
|
|
@@ -3182,10 +3221,11 @@ var Root; // cyclic
|
|
|
3182
3221
|
|
|
3183
3222
|
/* eslint-disable no-warning-comments */
|
|
3184
3223
|
// TODO: Replace with embedded proto.
|
|
3185
|
-
var editions2024Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE2024", default_symbol_visibility: "EXPORT_TOP_LEVEL" };
|
|
3186
|
-
var editions2023Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE_LEGACY", default_symbol_visibility: "EXPORT_ALL" };
|
|
3187
3224
|
var proto2Defaults = {enum_type: "CLOSED", field_presence: "EXPLICIT", json_format: "LEGACY_BEST_EFFORT", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "EXPANDED", utf8_validation: "NONE", enforce_naming_style: "STYLE_LEGACY", default_symbol_visibility: "EXPORT_ALL" };
|
|
3188
3225
|
var proto3Defaults = {enum_type: "OPEN", field_presence: "IMPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE_LEGACY", default_symbol_visibility: "EXPORT_ALL" };
|
|
3226
|
+
var editions2023Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE_LEGACY", default_symbol_visibility: "EXPORT_ALL" };
|
|
3227
|
+
var editions2024Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE2024", default_symbol_visibility: "EXPORT_TOP_LEVEL" };
|
|
3228
|
+
var editions2026Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE2026", default_symbol_visibility: "STRICT", enforce_proto_limits: "PROTO_LIMITS2026" };
|
|
3189
3229
|
|
|
3190
3230
|
/**
|
|
3191
3231
|
* Constructs a new reflection object instance.
|
|
@@ -3399,6 +3439,8 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
3399
3439
|
defaults = Object.assign({}, editions2023Defaults);
|
|
3400
3440
|
} else if (edition === "2024") {
|
|
3401
3441
|
defaults = Object.assign({}, editions2024Defaults);
|
|
3442
|
+
} else if (edition === "2026") {
|
|
3443
|
+
defaults = Object.assign({}, editions2026Defaults);
|
|
3402
3444
|
} else {
|
|
3403
3445
|
throw new Error("Unknown edition: " + edition);
|
|
3404
3446
|
}
|
|
@@ -4109,7 +4151,7 @@ function parse(source, root, options) {
|
|
|
4109
4151
|
function parseEdition() {
|
|
4110
4152
|
skip("=");
|
|
4111
4153
|
edition = readString();
|
|
4112
|
-
const supportedEditions = ["2023", "2024"];
|
|
4154
|
+
const supportedEditions = ["2023", "2024", "2026"];
|
|
4113
4155
|
|
|
4114
4156
|
/* istanbul ignore if */
|
|
4115
4157
|
if (!supportedEditions.includes(edition))
|
|
@@ -4143,6 +4185,7 @@ function parse(source, root, options) {
|
|
|
4143
4185
|
if (edition < "2024") {
|
|
4144
4186
|
return false;
|
|
4145
4187
|
}
|
|
4188
|
+
var visibility = token;
|
|
4146
4189
|
token = next();
|
|
4147
4190
|
if (token === "export" || token === "local") {
|
|
4148
4191
|
return false;
|
|
@@ -4150,9 +4193,11 @@ function parse(source, root, options) {
|
|
|
4150
4193
|
if (token !== "message" && token !== "enum") {
|
|
4151
4194
|
return false;
|
|
4152
4195
|
}
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4196
|
+
(token === "message"
|
|
4197
|
+
? parseType(parent, token, depth + 1)
|
|
4198
|
+
: parseEnum(parent, token)
|
|
4199
|
+
).visibility = visibility;
|
|
4200
|
+
return true;
|
|
4156
4201
|
|
|
4157
4202
|
case "service":
|
|
4158
4203
|
parseService(parent, token, depth + 1);
|
|
@@ -4257,6 +4302,7 @@ function parse(source, root, options) {
|
|
|
4257
4302
|
if (parent === ptr) {
|
|
4258
4303
|
topLevelObjects.push(type);
|
|
4259
4304
|
}
|
|
4305
|
+
return type;
|
|
4260
4306
|
}
|
|
4261
4307
|
|
|
4262
4308
|
function parseField(parent, rule, extend, depth) {
|
|
@@ -4521,6 +4567,7 @@ function parse(source, root, options) {
|
|
|
4521
4567
|
if (parent === ptr) {
|
|
4522
4568
|
topLevelObjects.push(enm);
|
|
4523
4569
|
}
|
|
4570
|
+
return enm;
|
|
4524
4571
|
}
|
|
4525
4572
|
|
|
4526
4573
|
function parseEnumValue(token) {
|
|
@@ -5011,12 +5058,32 @@ Reader.prototype.raw = function read_raw(start, end) {
|
|
|
5011
5058
|
return this.buf.subarray(start, end);
|
|
5012
5059
|
};
|
|
5013
5060
|
|
|
5061
|
+
function readVarint32NearEnd(reader) {
|
|
5062
|
+
// Safely read up to four bytes of a varint32 near the reader limit
|
|
5063
|
+
var value = 0;
|
|
5064
|
+
for (var i = 0; i < 4; ++i) {
|
|
5065
|
+
if (reader.pos >= reader.len)
|
|
5066
|
+
throw indexOutOfRange(reader);
|
|
5067
|
+
var b = reader.buf[reader.pos++];
|
|
5068
|
+
value = (value | (b & 127) << i * 7) >>> 0;
|
|
5069
|
+
if (b < 128)
|
|
5070
|
+
return value;
|
|
5071
|
+
}
|
|
5072
|
+
throw indexOutOfRange(reader);
|
|
5073
|
+
}
|
|
5074
|
+
|
|
5014
5075
|
/**
|
|
5015
5076
|
* Reads a varint as an unsigned 32 bit value.
|
|
5016
5077
|
* @function
|
|
5017
5078
|
* @returns {number} Value read
|
|
5018
5079
|
*/
|
|
5019
5080
|
Reader.prototype.uint32 = function read_uint32() {
|
|
5081
|
+
if (this.len - this.pos < 5) {
|
|
5082
|
+
if (this.pos >= this.len)
|
|
5083
|
+
throw indexOutOfRange(this);
|
|
5084
|
+
if (this.buf[this.pos] >= 128)
|
|
5085
|
+
return readVarint32NearEnd(this);
|
|
5086
|
+
}
|
|
5020
5087
|
var buf = this.buf,
|
|
5021
5088
|
pos = this.pos,
|
|
5022
5089
|
value = (buf[pos] & 127) >>> 0;
|
|
@@ -5067,6 +5134,12 @@ Reader.prototype.uint32 = function read_uint32() {
|
|
|
5067
5134
|
* @returns {number} Tag read
|
|
5068
5135
|
*/
|
|
5069
5136
|
Reader.prototype.tag = function read_tag() {
|
|
5137
|
+
if (this.len - this.pos < 5) {
|
|
5138
|
+
if (this.pos >= this.len)
|
|
5139
|
+
throw indexOutOfRange(this);
|
|
5140
|
+
if (this.buf[this.pos] >= 128)
|
|
5141
|
+
return readVarint32NearEnd(this);
|
|
5142
|
+
}
|
|
5070
5143
|
var buf = this.buf,
|
|
5071
5144
|
pos = this.pos,
|
|
5072
5145
|
value = (buf[pos] & 127) >>> 0;
|
|
@@ -5099,6 +5172,45 @@ Reader.prototype.tag = function read_tag() {
|
|
|
5099
5172
|
throw Error("invalid tag encoding");
|
|
5100
5173
|
};
|
|
5101
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
|
+
|
|
5102
5214
|
/**
|
|
5103
5215
|
* Reads a varint as a signed 32 bit value.
|
|
5104
5216
|
* @returns {number} Value read
|
|
@@ -5312,7 +5424,9 @@ Reader.prototype.double = function read_double() {
|
|
|
5312
5424
|
*/
|
|
5313
5425
|
Reader.prototype.uint32s = function read_uint32s(array) {
|
|
5314
5426
|
if (array === undefined) array = [];
|
|
5315
|
-
var end = this.
|
|
5427
|
+
var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
5428
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5429
|
+
this.len = end;
|
|
5316
5430
|
while (pos < end) {
|
|
5317
5431
|
value = buf[pos++];
|
|
5318
5432
|
if (value < 128)
|
|
@@ -5324,6 +5438,8 @@ Reader.prototype.uint32s = function read_uint32s(array) {
|
|
|
5324
5438
|
}
|
|
5325
5439
|
}
|
|
5326
5440
|
this.pos = pos;
|
|
5441
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
5442
|
+
this.len = len;
|
|
5327
5443
|
return array;
|
|
5328
5444
|
};
|
|
5329
5445
|
|
|
@@ -5334,7 +5450,9 @@ Reader.prototype.uint32s = function read_uint32s(array) {
|
|
|
5334
5450
|
*/
|
|
5335
5451
|
Reader.prototype.int32s = function read_int32s(array) {
|
|
5336
5452
|
if (array === undefined) array = [];
|
|
5337
|
-
var end = this.
|
|
5453
|
+
var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
5454
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5455
|
+
this.len = end;
|
|
5338
5456
|
while (pos < end) {
|
|
5339
5457
|
value = buf[pos++];
|
|
5340
5458
|
if (value < 128)
|
|
@@ -5346,6 +5464,8 @@ Reader.prototype.int32s = function read_int32s(array) {
|
|
|
5346
5464
|
}
|
|
5347
5465
|
}
|
|
5348
5466
|
this.pos = pos;
|
|
5467
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
5468
|
+
this.len = len;
|
|
5349
5469
|
return array;
|
|
5350
5470
|
};
|
|
5351
5471
|
|
|
@@ -5356,9 +5476,13 @@ Reader.prototype.int32s = function read_int32s(array) {
|
|
|
5356
5476
|
*/
|
|
5357
5477
|
Reader.prototype.sint32s = function read_sint32s(array) {
|
|
5358
5478
|
if (array === undefined) array = [];
|
|
5359
|
-
var end = this.
|
|
5479
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5480
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5481
|
+
this.len = end;
|
|
5360
5482
|
while (this.pos < end)
|
|
5361
5483
|
array.push(this.sint32());
|
|
5484
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
5485
|
+
this.len = len;
|
|
5362
5486
|
return array;
|
|
5363
5487
|
};
|
|
5364
5488
|
|
|
@@ -5369,7 +5493,9 @@ Reader.prototype.sint32s = function read_sint32s(array) {
|
|
|
5369
5493
|
*/
|
|
5370
5494
|
Reader.prototype.bools = function read_bools(array) {
|
|
5371
5495
|
if (array === undefined) array = [];
|
|
5372
|
-
var end = this.
|
|
5496
|
+
var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
5497
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5498
|
+
this.len = end;
|
|
5373
5499
|
while (pos < end) {
|
|
5374
5500
|
value = buf[pos++];
|
|
5375
5501
|
if (value < 128)
|
|
@@ -5381,6 +5507,8 @@ Reader.prototype.bools = function read_bools(array) {
|
|
|
5381
5507
|
}
|
|
5382
5508
|
}
|
|
5383
5509
|
this.pos = pos;
|
|
5510
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
5511
|
+
this.len = len;
|
|
5384
5512
|
return array;
|
|
5385
5513
|
};
|
|
5386
5514
|
|
|
@@ -5403,7 +5531,7 @@ function getLazyView(reader, count, threshold) {
|
|
|
5403
5531
|
*/
|
|
5404
5532
|
Reader.prototype.fixed32s = function read_fixed32s(array) {
|
|
5405
5533
|
if (array === undefined) array = [];
|
|
5406
|
-
var len = this.
|
|
5534
|
+
var len = this.size(), end = this.pos + len;
|
|
5407
5535
|
/* istanbul ignore if */
|
|
5408
5536
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5409
5537
|
var count = len >>> 2, i = array.length, pos = this.pos;
|
|
@@ -5427,7 +5555,7 @@ Reader.prototype.fixed32s = function read_fixed32s(array) {
|
|
|
5427
5555
|
*/
|
|
5428
5556
|
Reader.prototype.sfixed32s = function read_sfixed32s(array) {
|
|
5429
5557
|
if (array === undefined) array = [];
|
|
5430
|
-
var len = this.
|
|
5558
|
+
var len = this.size(), end = this.pos + len;
|
|
5431
5559
|
/* istanbul ignore if */
|
|
5432
5560
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5433
5561
|
var count = len >>> 2, i = array.length, pos = this.pos;
|
|
@@ -5451,7 +5579,7 @@ Reader.prototype.sfixed32s = function read_sfixed32s(array) {
|
|
|
5451
5579
|
*/
|
|
5452
5580
|
Reader.prototype.floats = function read_floats(array) {
|
|
5453
5581
|
if (array === undefined) array = [];
|
|
5454
|
-
var len = this.
|
|
5582
|
+
var len = this.size(), end = this.pos + len;
|
|
5455
5583
|
/* istanbul ignore if */
|
|
5456
5584
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5457
5585
|
var count = len >>> 2, i = array.length, pos = this.pos;
|
|
@@ -5475,7 +5603,7 @@ Reader.prototype.floats = function read_floats(array) {
|
|
|
5475
5603
|
*/
|
|
5476
5604
|
Reader.prototype.doubles = function read_doubles(array) {
|
|
5477
5605
|
if (array === undefined) array = [];
|
|
5478
|
-
var len = this.
|
|
5606
|
+
var len = this.size(), end = this.pos + len;
|
|
5479
5607
|
/* istanbul ignore if */
|
|
5480
5608
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5481
5609
|
var count = len >>> 3, i = array.length, pos = this.pos;
|
|
@@ -5499,9 +5627,13 @@ Reader.prototype.doubles = function read_doubles(array) {
|
|
|
5499
5627
|
*/
|
|
5500
5628
|
Reader.prototype.uint64s = function read_uint64s(array) {
|
|
5501
5629
|
if (array === undefined) array = [];
|
|
5502
|
-
var end = this.
|
|
5630
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5631
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5632
|
+
this.len = end;
|
|
5503
5633
|
while (this.pos < end)
|
|
5504
5634
|
array.push(this.uint64());
|
|
5635
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
5636
|
+
this.len = len;
|
|
5505
5637
|
return array;
|
|
5506
5638
|
};
|
|
5507
5639
|
|
|
@@ -5512,9 +5644,13 @@ Reader.prototype.uint64s = function read_uint64s(array) {
|
|
|
5512
5644
|
*/
|
|
5513
5645
|
Reader.prototype.int64s = function read_int64s(array) {
|
|
5514
5646
|
if (array === undefined) array = [];
|
|
5515
|
-
var end = this.
|
|
5647
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5648
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5649
|
+
this.len = end;
|
|
5516
5650
|
while (this.pos < end)
|
|
5517
5651
|
array.push(this.int64());
|
|
5652
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
5653
|
+
this.len = len;
|
|
5518
5654
|
return array;
|
|
5519
5655
|
};
|
|
5520
5656
|
|
|
@@ -5525,9 +5661,13 @@ Reader.prototype.int64s = function read_int64s(array) {
|
|
|
5525
5661
|
*/
|
|
5526
5662
|
Reader.prototype.sint64s = function read_sint64s(array) {
|
|
5527
5663
|
if (array === undefined) array = [];
|
|
5528
|
-
var end = this.
|
|
5664
|
+
var end = this.size() + this.pos, len = this.len;
|
|
5665
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
5666
|
+
this.len = end;
|
|
5529
5667
|
while (this.pos < end)
|
|
5530
5668
|
array.push(this.sint64());
|
|
5669
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
5670
|
+
this.len = len;
|
|
5531
5671
|
return array;
|
|
5532
5672
|
};
|
|
5533
5673
|
|
|
@@ -5538,7 +5678,7 @@ Reader.prototype.sint64s = function read_sint64s(array) {
|
|
|
5538
5678
|
*/
|
|
5539
5679
|
Reader.prototype.fixed64s = function read_fixed64s(array) {
|
|
5540
5680
|
if (array === undefined) array = [];
|
|
5541
|
-
var len = this.
|
|
5681
|
+
var len = this.size(), end = this.pos + len, i = array.length;
|
|
5542
5682
|
/* istanbul ignore if */
|
|
5543
5683
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5544
5684
|
var count = len >>> 3;
|
|
@@ -5556,7 +5696,7 @@ Reader.prototype.fixed64s = function read_fixed64s(array) {
|
|
|
5556
5696
|
*/
|
|
5557
5697
|
Reader.prototype.sfixed64s = function read_sfixed64s(array) {
|
|
5558
5698
|
if (array === undefined) array = [];
|
|
5559
|
-
var len = this.
|
|
5699
|
+
var len = this.size(), end = this.pos + len, i = array.length;
|
|
5560
5700
|
/* istanbul ignore if */
|
|
5561
5701
|
if (end > this.len) throw indexOutOfRange(this, len);
|
|
5562
5702
|
var count = len >>> 3;
|
|
@@ -5572,7 +5712,7 @@ Reader.prototype.sfixed64s = function read_sfixed64s(array) {
|
|
|
5572
5712
|
* @returns {Uint8Array} Value read
|
|
5573
5713
|
*/
|
|
5574
5714
|
Reader.prototype.bytes = function read_bytes() {
|
|
5575
|
-
var length = this.
|
|
5715
|
+
var length = this.size(),
|
|
5576
5716
|
start = this.pos,
|
|
5577
5717
|
end = this.pos + length;
|
|
5578
5718
|
|
|
@@ -5589,7 +5729,7 @@ Reader.prototype.bytes = function read_bytes() {
|
|
|
5589
5729
|
* @returns {string} Value read
|
|
5590
5730
|
*/
|
|
5591
5731
|
Reader.prototype.string = function read_string() {
|
|
5592
|
-
var length = this.
|
|
5732
|
+
var length = this.size(),
|
|
5593
5733
|
start = this.pos,
|
|
5594
5734
|
end = this.pos + length;
|
|
5595
5735
|
|
|
@@ -5606,7 +5746,7 @@ Reader.prototype.string = function read_string() {
|
|
|
5606
5746
|
* @returns {string} Value read
|
|
5607
5747
|
*/
|
|
5608
5748
|
Reader.prototype.stringVerify = function read_string_verify() {
|
|
5609
|
-
var length = this.
|
|
5749
|
+
var length = this.size(),
|
|
5610
5750
|
start = this.pos,
|
|
5611
5751
|
end = this.pos + length;
|
|
5612
5752
|
|
|
@@ -5672,7 +5812,7 @@ Reader.prototype.skipType = function(wireType, depth, fieldNumber) {
|
|
|
5672
5812
|
this.skip(8);
|
|
5673
5813
|
break;
|
|
5674
5814
|
case 2:
|
|
5675
|
-
this.skip(this.
|
|
5815
|
+
this.skip(this.size());
|
|
5676
5816
|
break;
|
|
5677
5817
|
case 3:
|
|
5678
5818
|
while (true) {
|
|
@@ -5787,7 +5927,7 @@ BufferReader.prototype.raw = function read_raw_buffer(start, end) {
|
|
|
5787
5927
|
* @override
|
|
5788
5928
|
*/
|
|
5789
5929
|
BufferReader.prototype.string = function read_string_buffer() {
|
|
5790
|
-
var len = this.
|
|
5930
|
+
var len = this.size(), // modifies pos
|
|
5791
5931
|
start = this.pos,
|
|
5792
5932
|
end = this.pos + len;
|
|
5793
5933
|
|
|
@@ -6671,13 +6811,19 @@ var setCommentRe = /^ *[*/]+ */,
|
|
|
6671
6811
|
setCommentAltRe = /^\s*\*?\/*/,
|
|
6672
6812
|
setCommentSplitRe = /\n/g,
|
|
6673
6813
|
whitespaceRe = /\s/,
|
|
6674
|
-
unescapeRe = /\\(
|
|
6814
|
+
unescapeRe = /\\([0-7]{1,3}|[xX][0-9a-fA-F]{1,2}|.?)/g;
|
|
6675
6815
|
|
|
6676
6816
|
var unescapeMap = {
|
|
6677
|
-
"
|
|
6817
|
+
"a": "\x07",
|
|
6818
|
+
"b": "\b",
|
|
6819
|
+
"f": "\f",
|
|
6678
6820
|
"r": "\r",
|
|
6679
6821
|
"n": "\n",
|
|
6680
|
-
"t": "\t"
|
|
6822
|
+
"t": "\t",
|
|
6823
|
+
"v": "\v",
|
|
6824
|
+
"?": "?",
|
|
6825
|
+
"'": "'",
|
|
6826
|
+
"\"": "\""
|
|
6681
6827
|
};
|
|
6682
6828
|
|
|
6683
6829
|
/**
|
|
@@ -6689,6 +6835,11 @@ var unescapeMap = {
|
|
|
6689
6835
|
*/
|
|
6690
6836
|
function unescape(str) {
|
|
6691
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));
|
|
6692
6843
|
switch ($1) {
|
|
6693
6844
|
case "\\":
|
|
6694
6845
|
case "":
|
|
@@ -7155,6 +7306,12 @@ function Type(name, options) {
|
|
|
7155
7306
|
*/
|
|
7156
7307
|
this.group = undefined; // toJSON
|
|
7157
7308
|
|
|
7309
|
+
/**
|
|
7310
|
+
* Declared symbol visibility, if any.
|
|
7311
|
+
* @type {"local"|"export"|undefined}
|
|
7312
|
+
*/
|
|
7313
|
+
this.visibility = undefined; // toJSON
|
|
7314
|
+
|
|
7158
7315
|
/**
|
|
7159
7316
|
* Cached fields by id.
|
|
7160
7317
|
* @type {Object.<number,Field>|null}
|
|
@@ -7339,6 +7496,7 @@ function clearCache(type) {
|
|
|
7339
7496
|
* @property {number[][]} [extensions] Extension ranges
|
|
7340
7497
|
* @property {Array.<number[]|string>} [reserved] Reserved ranges
|
|
7341
7498
|
* @property {boolean} [group=false] Whether a legacy group or not
|
|
7499
|
+
* @property {"local"|"export"} [visibility] Declared symbol visibility
|
|
7342
7500
|
* @property {string|null} [comment] Message type comment
|
|
7343
7501
|
*/
|
|
7344
7502
|
|
|
@@ -7389,6 +7547,8 @@ Type.fromJSON = function fromJSON(name, json, depth) {
|
|
|
7389
7547
|
type.reserved = json.reserved;
|
|
7390
7548
|
if (json.group)
|
|
7391
7549
|
type.group = true;
|
|
7550
|
+
if (json.visibility)
|
|
7551
|
+
type.visibility = json.visibility;
|
|
7392
7552
|
if (json.comment)
|
|
7393
7553
|
type.comment = json.comment;
|
|
7394
7554
|
if (json.edition)
|
|
@@ -7413,6 +7573,7 @@ Type.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
7413
7573
|
"extensions" , this.extensions && this.extensions.length ? this.extensions : undefined,
|
|
7414
7574
|
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
7415
7575
|
"group" , this.group || undefined,
|
|
7576
|
+
"visibility" , this.visibility,
|
|
7416
7577
|
"nested" , inherited && inherited.nested || undefined,
|
|
7417
7578
|
"comment" , keepComments ? this.comment : undefined
|
|
7418
7579
|
]);
|
|
@@ -7675,7 +7836,7 @@ Type.prototype.decode = function decode_setup(reader, length) { // eslint-disabl
|
|
|
7675
7836
|
Type.prototype.decodeDelimited = function decodeDelimited(reader) {
|
|
7676
7837
|
if (!(reader instanceof Reader))
|
|
7677
7838
|
reader = Reader.create(reader);
|
|
7678
|
-
return this.decode(reader, reader.
|
|
7839
|
+
return this.decode(reader, reader.size());
|
|
7679
7840
|
};
|
|
7680
7841
|
|
|
7681
7842
|
/**
|
|
@@ -10376,6 +10537,10 @@ var Message = require(12),
|
|
|
10376
10537
|
wrappers[".google.protobuf.Any"] = {
|
|
10377
10538
|
|
|
10378
10539
|
fromObject: function(object, depth) {
|
|
10540
|
+
if (depth === undefined)
|
|
10541
|
+
depth = 0;
|
|
10542
|
+
if (depth > util.recursionLimit)
|
|
10543
|
+
throw Error("max depth exceeded");
|
|
10379
10544
|
|
|
10380
10545
|
// unwrap value type if mapped
|
|
10381
10546
|
if (object && object["@type"]) {
|
|
@@ -10393,7 +10558,7 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
10393
10558
|
}
|
|
10394
10559
|
return this.create({
|
|
10395
10560
|
type_url: type_url,
|
|
10396
|
-
value: type.encode(type.fromObject(object, depth
|
|
10561
|
+
value: type.encode(type.fromObject(object, depth + 1)).finish()
|
|
10397
10562
|
});
|
|
10398
10563
|
}
|
|
10399
10564
|
}
|