protobufjs 8.7.1 → 8.8.0
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 +70 -86
- package/dist/light/protobuf.js +185 -54
- 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 +105 -44
- 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 +220 -81
- 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 +50 -10
- package/ext/protojson.js +14 -4
- package/ext/textformat.js +8 -4
- package/google/protobuf/descriptor.json +20 -1
- package/google/protobuf/descriptor.proto +14 -1
- package/index.d.ts +15 -0
- package/package.json +1 -1
- package/src/converter.js +5 -1
- package/src/decoder.js +31 -2
- package/src/enum.js +15 -2
- package/src/field.js +6 -1
- package/src/object.js +5 -2
- package/src/parse.js +35 -27
- package/src/reader.js +94 -13
- package/src/type.js +10 -0
- package/src/util/codegen.js +3 -1
- package/src/util/utf8.js +2 -28
- package/src/wrappers.js +5 -1
- package/src/writer.js +7 -1
package/dist/light/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.8.0 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 27 aug 2026 00:01:05 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -345,7 +345,11 @@ converter.toObject = function toObject(mtype) {
|
|
|
345
345
|
("d%s=%j", prop, arrayDefault)
|
|
346
346
|
("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop)
|
|
347
347
|
("}");
|
|
348
|
-
} else
|
|
348
|
+
} else if ((field.type === "double" || field.type === "float") && typeof field.typeDefault === "number"
|
|
349
|
+
&& (!isFinite(field.typeDefault) || Object.is(field.typeDefault, -0))) gen
|
|
350
|
+
("d%s=%f", prop, field.typeDefault)
|
|
351
|
+
("if(o.json&&!isFinite(d%s))d%s=String(d%s)", prop, prop, prop);
|
|
352
|
+
else gen
|
|
349
353
|
("d%s=%j", prop, field.typeDefault); // also messages (=null)
|
|
350
354
|
} gen
|
|
351
355
|
("}");
|
|
@@ -442,7 +446,17 @@ function decoder(mtype) {
|
|
|
442
446
|
("if(q===undefined)q=0")
|
|
443
447
|
("if(q>Reader.recursionLimit)")
|
|
444
448
|
("throw Error(\"max depth exceeded\")")
|
|
445
|
-
("var c
|
|
449
|
+
("var c,m" + (hasMapField ? ",k,v" : needsValueVar ? ",v" : ""))
|
|
450
|
+
("if(l===undefined)")
|
|
451
|
+
("c=r.len")
|
|
452
|
+
("else{")
|
|
453
|
+
("c=r.pos+l")
|
|
454
|
+
("if(c>r.len)")
|
|
455
|
+
("throw RangeError(\"index out of range\")")
|
|
456
|
+
("l=r.len")
|
|
457
|
+
("r.len=c")
|
|
458
|
+
("}")
|
|
459
|
+
("m=g||new C")
|
|
446
460
|
("while(r.pos<c){")
|
|
447
461
|
("var s=r.pos")
|
|
448
462
|
("var t=r.tag()")
|
|
@@ -469,7 +483,10 @@ function decoder(mtype) {
|
|
|
469
483
|
("if(%s===util.emptyObject)", ref)
|
|
470
484
|
("%s={}", ref);
|
|
471
485
|
gen
|
|
472
|
-
("var c2=r.uint32()+r.pos")
|
|
486
|
+
("var c2=r.uint32()+r.pos")
|
|
487
|
+
("if(c2>r.len)")
|
|
488
|
+
("throw RangeError(\"index out of range\")")
|
|
489
|
+
("r.len=c2");
|
|
473
490
|
|
|
474
491
|
if (types.defaults[field.keyType] !== undefined) gen
|
|
475
492
|
("k=%j", types.defaults[field.keyType]);
|
|
@@ -507,6 +524,10 @@ function decoder(mtype) {
|
|
|
507
524
|
("}")
|
|
508
525
|
("r.skipType(u,q,t2)")
|
|
509
526
|
("}");
|
|
527
|
+
gen
|
|
528
|
+
("if(r.pos!==c2)")
|
|
529
|
+
("throw RangeError(\"index out of range\")")
|
|
530
|
+
("r.len=c");
|
|
510
531
|
|
|
511
532
|
if (closed) { gen
|
|
512
533
|
("if(types[%i].valuesById[v]===undefined){", i);
|
|
@@ -540,6 +561,9 @@ function decoder(mtype) {
|
|
|
540
561
|
if (closed) {
|
|
541
562
|
gen
|
|
542
563
|
("var c2=r.uint32()+r.pos")
|
|
564
|
+
("if(c2>r.len)")
|
|
565
|
+
("throw RangeError(\"index out of range\")")
|
|
566
|
+
("r.len=c2")
|
|
543
567
|
("while(r.pos<c2){")
|
|
544
568
|
("s=r.pos")
|
|
545
569
|
("v=r.%s()", type)
|
|
@@ -550,6 +574,10 @@ function decoder(mtype) {
|
|
|
550
574
|
("}else");
|
|
551
575
|
genPreserveUnknown(gen, "util.rawField(" + field.id + ",0,r.raw(s,r.pos))")
|
|
552
576
|
("}");
|
|
577
|
+
gen
|
|
578
|
+
("if(r.pos!==c2)")
|
|
579
|
+
("throw RangeError(\"index out of range\")")
|
|
580
|
+
("r.len=c");
|
|
553
581
|
} else gen
|
|
554
582
|
("if(!(%s&&%s.length))", ref, ref)
|
|
555
583
|
("%s=[]", ref)
|
|
@@ -658,6 +686,11 @@ function decoder(mtype) {
|
|
|
658
686
|
("r.skipType(%s,q,t)", i ? "u" : "t&7");
|
|
659
687
|
genPreserveUnknown(gen, "r.raw(s,r.pos)")
|
|
660
688
|
("}")
|
|
689
|
+
("if(l!==undefined){")
|
|
690
|
+
("if(r.pos!==c)")
|
|
691
|
+
("throw RangeError(\"index out of range\")")
|
|
692
|
+
("r.len=l")
|
|
693
|
+
("}")
|
|
661
694
|
("if(z!==undefined)")
|
|
662
695
|
("throw Error(\"missing end group\")");
|
|
663
696
|
|
|
@@ -878,14 +911,23 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
|
|
|
878
911
|
*/
|
|
879
912
|
this.reserved = undefined; // toJSON
|
|
880
913
|
|
|
914
|
+
/**
|
|
915
|
+
* Declared symbol visibility, if any.
|
|
916
|
+
* @type {"local"|"export"|undefined}
|
|
917
|
+
*/
|
|
918
|
+
this.visibility = undefined; // toJSON
|
|
919
|
+
|
|
881
920
|
// Note that values inherit valuesById on their prototype which makes them a TypeScript-
|
|
882
921
|
// compatible enum. This is used by pbts to write actual enum definitions that work for
|
|
883
922
|
// static and reflection code alike instead of emitting generic object definitions.
|
|
884
923
|
|
|
885
924
|
if (values)
|
|
886
925
|
for (var keys = Object.keys(values), i = 0; i < keys.length; ++i)
|
|
887
|
-
if (keys[i] !== "__proto__" && typeof values[keys[i]] === "number") // use forward entries only
|
|
888
|
-
this.
|
|
926
|
+
if (keys[i] !== "__proto__" && typeof values[keys[i]] === "number") { // use forward entries only
|
|
927
|
+
this.values[keys[i]] = values[keys[i]];
|
|
928
|
+
if (this.valuesById[values[keys[i]]] === undefined)
|
|
929
|
+
this.valuesById[values[keys[i]]] = keys[i];
|
|
930
|
+
}
|
|
889
931
|
}
|
|
890
932
|
|
|
891
933
|
/**
|
|
@@ -911,6 +953,7 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
|
911
953
|
* @property {Object.<string,*>} [options] Enum options
|
|
912
954
|
* @property {Object.<string,Object.<string,*>>} [valuesOptions] Enum value options
|
|
913
955
|
* @property {Array.<number[]|string>} [reserved] Reserved ranges
|
|
956
|
+
* @property {"local"|"export"} [visibility] Declared symbol visibility
|
|
914
957
|
* @property {string|null} [comment] Enum comment
|
|
915
958
|
* @property {Object.<string,string|null>} [comments] Value comments
|
|
916
959
|
*/
|
|
@@ -925,6 +968,8 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
|
925
968
|
Enum.fromJSON = function fromJSON(name, json) {
|
|
926
969
|
var enm = new Enum(name, json.values, json.options, json.comment, json.comments, json.valuesOptions);
|
|
927
970
|
enm.reserved = json.reserved;
|
|
971
|
+
if (json.visibility)
|
|
972
|
+
enm.visibility = json.visibility;
|
|
928
973
|
if (json.edition)
|
|
929
974
|
enm._edition = json.edition;
|
|
930
975
|
enm._defaultEdition = "proto3"; // For backwards-compatibility.
|
|
@@ -944,6 +989,7 @@ Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
944
989
|
"valuesOptions" , this.valuesOptions,
|
|
945
990
|
"values" , this.values,
|
|
946
991
|
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
992
|
+
"visibility" , this.visibility,
|
|
947
993
|
"comment" , keepComments ? this.comment : undefined,
|
|
948
994
|
"comments" , keepComments ? this.comments : undefined
|
|
949
995
|
]);
|
|
@@ -1414,12 +1460,17 @@ Field.prototype.resolve = function resolve() {
|
|
|
1414
1460
|
|
|
1415
1461
|
// convert to internal data type if necesssary
|
|
1416
1462
|
if (this.long) {
|
|
1417
|
-
|
|
1463
|
+
var unsigned = this.type === "uint64" || this.type === "fixed64";
|
|
1464
|
+
this.typeDefault = typeof this.typeDefault === "string"
|
|
1465
|
+
? util.Long.fromString(this.typeDefault, unsigned)
|
|
1466
|
+
: util.Long.fromNumber(this.typeDefault, unsigned);
|
|
1418
1467
|
|
|
1419
1468
|
/* istanbul ignore else */
|
|
1420
1469
|
if (Object.freeze)
|
|
1421
1470
|
Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it)
|
|
1422
1471
|
|
|
1472
|
+
} else if (types.long[this.type] !== undefined && typeof this.typeDefault === "string") {
|
|
1473
|
+
this.typeDefault = parseInt(this.typeDefault, 10);
|
|
1423
1474
|
} else if (this.bytes && typeof this.typeDefault === "string") {
|
|
1424
1475
|
var buf;
|
|
1425
1476
|
if (util.base64.test(this.typeDefault))
|
|
@@ -2749,10 +2800,11 @@ var Root; // cyclic
|
|
|
2749
2800
|
|
|
2750
2801
|
/* eslint-disable no-warning-comments */
|
|
2751
2802
|
// TODO: Replace with embedded proto.
|
|
2752
|
-
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" };
|
|
2753
|
-
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" };
|
|
2754
2803
|
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" };
|
|
2755
2804
|
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" };
|
|
2805
|
+
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" };
|
|
2806
|
+
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" };
|
|
2807
|
+
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" };
|
|
2756
2808
|
|
|
2757
2809
|
/**
|
|
2758
2810
|
* Constructs a new reflection object instance.
|
|
@@ -2966,6 +3018,8 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
2966
3018
|
defaults = Object.assign({}, editions2023Defaults);
|
|
2967
3019
|
} else if (edition === "2024") {
|
|
2968
3020
|
defaults = Object.assign({}, editions2024Defaults);
|
|
3021
|
+
} else if (edition === "2026") {
|
|
3022
|
+
defaults = Object.assign({}, editions2026Defaults);
|
|
2969
3023
|
} else {
|
|
2970
3024
|
throw new Error("Unknown edition: " + edition);
|
|
2971
3025
|
}
|
|
@@ -3462,12 +3516,32 @@ Reader.prototype.raw = function read_raw(start, end) {
|
|
|
3462
3516
|
return this.buf.subarray(start, end);
|
|
3463
3517
|
};
|
|
3464
3518
|
|
|
3519
|
+
function readVarint32NearEnd(reader) {
|
|
3520
|
+
// Safely read up to four bytes of a varint32 near the reader limit
|
|
3521
|
+
var value = 0;
|
|
3522
|
+
for (var i = 0; i < 4; ++i) {
|
|
3523
|
+
if (reader.pos >= reader.len)
|
|
3524
|
+
throw indexOutOfRange(reader);
|
|
3525
|
+
var b = reader.buf[reader.pos++];
|
|
3526
|
+
value = (value | (b & 127) << i * 7) >>> 0;
|
|
3527
|
+
if (b < 128)
|
|
3528
|
+
return value;
|
|
3529
|
+
}
|
|
3530
|
+
throw indexOutOfRange(reader);
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3465
3533
|
/**
|
|
3466
3534
|
* Reads a varint as an unsigned 32 bit value.
|
|
3467
3535
|
* @function
|
|
3468
3536
|
* @returns {number} Value read
|
|
3469
3537
|
*/
|
|
3470
3538
|
Reader.prototype.uint32 = function read_uint32() {
|
|
3539
|
+
if (this.len - this.pos < 5) {
|
|
3540
|
+
if (this.pos >= this.len)
|
|
3541
|
+
throw indexOutOfRange(this);
|
|
3542
|
+
if (this.buf[this.pos] >= 128)
|
|
3543
|
+
return readVarint32NearEnd(this);
|
|
3544
|
+
}
|
|
3471
3545
|
var buf = this.buf,
|
|
3472
3546
|
pos = this.pos,
|
|
3473
3547
|
value = (buf[pos] & 127) >>> 0;
|
|
@@ -3518,6 +3592,12 @@ Reader.prototype.uint32 = function read_uint32() {
|
|
|
3518
3592
|
* @returns {number} Tag read
|
|
3519
3593
|
*/
|
|
3520
3594
|
Reader.prototype.tag = function read_tag() {
|
|
3595
|
+
if (this.len - this.pos < 5) {
|
|
3596
|
+
if (this.pos >= this.len)
|
|
3597
|
+
throw indexOutOfRange(this);
|
|
3598
|
+
if (this.buf[this.pos] >= 128)
|
|
3599
|
+
return readVarint32NearEnd(this);
|
|
3600
|
+
}
|
|
3521
3601
|
var buf = this.buf,
|
|
3522
3602
|
pos = this.pos,
|
|
3523
3603
|
value = (buf[pos] & 127) >>> 0;
|
|
@@ -3763,9 +3843,22 @@ Reader.prototype.double = function read_double() {
|
|
|
3763
3843
|
*/
|
|
3764
3844
|
Reader.prototype.uint32s = function read_uint32s(array) {
|
|
3765
3845
|
if (array === undefined) array = [];
|
|
3766
|
-
var end = this.uint32() + this.pos;
|
|
3767
|
-
|
|
3768
|
-
|
|
3846
|
+
var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
3847
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
3848
|
+
this.len = end;
|
|
3849
|
+
while (pos < end) {
|
|
3850
|
+
value = buf[pos++];
|
|
3851
|
+
if (value < 128)
|
|
3852
|
+
array.push(value);
|
|
3853
|
+
else {
|
|
3854
|
+
this.pos = pos - 1;
|
|
3855
|
+
array.push(this.uint32());
|
|
3856
|
+
pos = this.pos;
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
this.pos = pos;
|
|
3860
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
3861
|
+
this.len = len;
|
|
3769
3862
|
return array;
|
|
3770
3863
|
};
|
|
3771
3864
|
|
|
@@ -3776,9 +3869,22 @@ Reader.prototype.uint32s = function read_uint32s(array) {
|
|
|
3776
3869
|
*/
|
|
3777
3870
|
Reader.prototype.int32s = function read_int32s(array) {
|
|
3778
3871
|
if (array === undefined) array = [];
|
|
3779
|
-
var end = this.uint32() + this.pos;
|
|
3780
|
-
|
|
3781
|
-
|
|
3872
|
+
var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
3873
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
3874
|
+
this.len = end;
|
|
3875
|
+
while (pos < end) {
|
|
3876
|
+
value = buf[pos++];
|
|
3877
|
+
if (value < 128)
|
|
3878
|
+
array.push(value);
|
|
3879
|
+
else {
|
|
3880
|
+
this.pos = pos - 1;
|
|
3881
|
+
array.push(this.int32());
|
|
3882
|
+
pos = this.pos;
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
this.pos = pos;
|
|
3886
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
3887
|
+
this.len = len;
|
|
3782
3888
|
return array;
|
|
3783
3889
|
};
|
|
3784
3890
|
|
|
@@ -3789,9 +3895,13 @@ Reader.prototype.int32s = function read_int32s(array) {
|
|
|
3789
3895
|
*/
|
|
3790
3896
|
Reader.prototype.sint32s = function read_sint32s(array) {
|
|
3791
3897
|
if (array === undefined) array = [];
|
|
3792
|
-
var end = this.uint32() + this.pos;
|
|
3898
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
3899
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
3900
|
+
this.len = end;
|
|
3793
3901
|
while (this.pos < end)
|
|
3794
3902
|
array.push(this.sint32());
|
|
3903
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
3904
|
+
this.len = len;
|
|
3795
3905
|
return array;
|
|
3796
3906
|
};
|
|
3797
3907
|
|
|
@@ -3802,9 +3912,22 @@ Reader.prototype.sint32s = function read_sint32s(array) {
|
|
|
3802
3912
|
*/
|
|
3803
3913
|
Reader.prototype.bools = function read_bools(array) {
|
|
3804
3914
|
if (array === undefined) array = [];
|
|
3805
|
-
var end = this.uint32() + this.pos;
|
|
3806
|
-
|
|
3807
|
-
|
|
3915
|
+
var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
3916
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
3917
|
+
this.len = end;
|
|
3918
|
+
while (pos < end) {
|
|
3919
|
+
value = buf[pos++];
|
|
3920
|
+
if (value < 128)
|
|
3921
|
+
array.push(value !== 0);
|
|
3922
|
+
else {
|
|
3923
|
+
this.pos = pos - 1;
|
|
3924
|
+
array.push(this.bool());
|
|
3925
|
+
pos = this.pos;
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
this.pos = pos;
|
|
3929
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
3930
|
+
this.len = len;
|
|
3808
3931
|
return array;
|
|
3809
3932
|
};
|
|
3810
3933
|
|
|
@@ -3923,9 +4046,13 @@ Reader.prototype.doubles = function read_doubles(array) {
|
|
|
3923
4046
|
*/
|
|
3924
4047
|
Reader.prototype.uint64s = function read_uint64s(array) {
|
|
3925
4048
|
if (array === undefined) array = [];
|
|
3926
|
-
var end = this.uint32() + this.pos;
|
|
4049
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
4050
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
4051
|
+
this.len = end;
|
|
3927
4052
|
while (this.pos < end)
|
|
3928
4053
|
array.push(this.uint64());
|
|
4054
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
4055
|
+
this.len = len;
|
|
3929
4056
|
return array;
|
|
3930
4057
|
};
|
|
3931
4058
|
|
|
@@ -3936,9 +4063,13 @@ Reader.prototype.uint64s = function read_uint64s(array) {
|
|
|
3936
4063
|
*/
|
|
3937
4064
|
Reader.prototype.int64s = function read_int64s(array) {
|
|
3938
4065
|
if (array === undefined) array = [];
|
|
3939
|
-
var end = this.uint32() + this.pos;
|
|
4066
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
4067
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
4068
|
+
this.len = end;
|
|
3940
4069
|
while (this.pos < end)
|
|
3941
4070
|
array.push(this.int64());
|
|
4071
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
4072
|
+
this.len = len;
|
|
3942
4073
|
return array;
|
|
3943
4074
|
};
|
|
3944
4075
|
|
|
@@ -3949,9 +4080,13 @@ Reader.prototype.int64s = function read_int64s(array) {
|
|
|
3949
4080
|
*/
|
|
3950
4081
|
Reader.prototype.sint64s = function read_sint64s(array) {
|
|
3951
4082
|
if (array === undefined) array = [];
|
|
3952
|
-
var end = this.uint32() + this.pos;
|
|
4083
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
4084
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
4085
|
+
this.len = end;
|
|
3953
4086
|
while (this.pos < end)
|
|
3954
4087
|
array.push(this.sint64());
|
|
4088
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
4089
|
+
this.len = len;
|
|
3955
4090
|
return array;
|
|
3956
4091
|
};
|
|
3957
4092
|
|
|
@@ -5156,6 +5291,12 @@ function Type(name, options) {
|
|
|
5156
5291
|
*/
|
|
5157
5292
|
this.group = undefined; // toJSON
|
|
5158
5293
|
|
|
5294
|
+
/**
|
|
5295
|
+
* Declared symbol visibility, if any.
|
|
5296
|
+
* @type {"local"|"export"|undefined}
|
|
5297
|
+
*/
|
|
5298
|
+
this.visibility = undefined; // toJSON
|
|
5299
|
+
|
|
5159
5300
|
/**
|
|
5160
5301
|
* Cached fields by id.
|
|
5161
5302
|
* @type {Object.<number,Field>|null}
|
|
@@ -5340,6 +5481,7 @@ function clearCache(type) {
|
|
|
5340
5481
|
* @property {number[][]} [extensions] Extension ranges
|
|
5341
5482
|
* @property {Array.<number[]|string>} [reserved] Reserved ranges
|
|
5342
5483
|
* @property {boolean} [group=false] Whether a legacy group or not
|
|
5484
|
+
* @property {"local"|"export"} [visibility] Declared symbol visibility
|
|
5343
5485
|
* @property {string|null} [comment] Message type comment
|
|
5344
5486
|
*/
|
|
5345
5487
|
|
|
@@ -5390,6 +5532,8 @@ Type.fromJSON = function fromJSON(name, json, depth) {
|
|
|
5390
5532
|
type.reserved = json.reserved;
|
|
5391
5533
|
if (json.group)
|
|
5392
5534
|
type.group = true;
|
|
5535
|
+
if (json.visibility)
|
|
5536
|
+
type.visibility = json.visibility;
|
|
5393
5537
|
if (json.comment)
|
|
5394
5538
|
type.comment = json.comment;
|
|
5395
5539
|
if (json.edition)
|
|
@@ -5414,6 +5558,7 @@ Type.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
5414
5558
|
"extensions" , this.extensions && this.extensions.length ? this.extensions : undefined,
|
|
5415
5559
|
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
5416
5560
|
"group" , this.group || undefined,
|
|
5561
|
+
"visibility" , this.visibility,
|
|
5417
5562
|
"nested" , inherited && inherited.nested || undefined,
|
|
5418
5563
|
"comment" , keepComments ? this.comment : undefined
|
|
5419
5564
|
]);
|
|
@@ -6494,7 +6639,9 @@ function codegen(functionParams, functionName) {
|
|
|
6494
6639
|
formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) {
|
|
6495
6640
|
var value = formatParams[formatOffset++];
|
|
6496
6641
|
switch ($1) {
|
|
6497
|
-
case "d": case "f":
|
|
6642
|
+
case "d": case "f":
|
|
6643
|
+
value = Number(value);
|
|
6644
|
+
return Object.is(value, -0) ? "-0" : String(value);
|
|
6498
6645
|
case "i": return String(Math.floor(value));
|
|
6499
6646
|
case "j": return JSON.stringify(value);
|
|
6500
6647
|
case "s": return String(value);
|
|
@@ -7988,7 +8135,6 @@ function pool(alloc, slice, size) {
|
|
|
7988
8135
|
* @namespace
|
|
7989
8136
|
*/
|
|
7990
8137
|
var utf8 = exports,
|
|
7991
|
-
replacementChar = "\ufffd",
|
|
7992
8138
|
looseDecoder = new TextDecoder("utf-8", { ignoreBOM: true }),
|
|
7993
8139
|
strictDecoder;
|
|
7994
8140
|
var TEXT_DECODER_MIN_LENGTH = 64;
|
|
@@ -8023,31 +8169,6 @@ utf8.length = function utf8_length(string) {
|
|
|
8023
8169
|
return len;
|
|
8024
8170
|
};
|
|
8025
8171
|
|
|
8026
|
-
function utf8_read_js(buffer, start, end, str) {
|
|
8027
|
-
for (var i = start; i < end;) {
|
|
8028
|
-
var t = buffer[i++];
|
|
8029
|
-
if (t <= 0x7F) {
|
|
8030
|
-
str += String.fromCharCode(t);
|
|
8031
|
-
} else if (t >= 0xC0 && t < 0xE0) {
|
|
8032
|
-
var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F;
|
|
8033
|
-
str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar;
|
|
8034
|
-
} else if (t >= 0xE0 && t < 0xF0) {
|
|
8035
|
-
var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
|
|
8036
|
-
str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
|
|
8037
|
-
} else if (t >= 0xF0) {
|
|
8038
|
-
var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
|
|
8039
|
-
if (t2 < 0x10000 || t2 > 0x10FFFF)
|
|
8040
|
-
str += replacementChar;
|
|
8041
|
-
else {
|
|
8042
|
-
t2 -= 0x10000;
|
|
8043
|
-
str += String.fromCharCode(0xD800 + (t2 >> 10));
|
|
8044
|
-
str += String.fromCharCode(0xDC00 + (t2 & 0x3FF));
|
|
8045
|
-
}
|
|
8046
|
-
}
|
|
8047
|
-
}
|
|
8048
|
-
return str;
|
|
8049
|
-
}
|
|
8050
|
-
|
|
8051
8172
|
function utf8_read_decoder(decoder, buffer, start, end) {
|
|
8052
8173
|
var source = start === 0 && end === buffer.length
|
|
8053
8174
|
? buffer
|
|
@@ -8082,14 +8203,14 @@ utf8.read = function utf8_read_loose(buffer, start, end) {
|
|
|
8082
8203
|
c7 = buffer[i + 6];
|
|
8083
8204
|
c8 = buffer[i + 7];
|
|
8084
8205
|
if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
|
|
8085
|
-
return
|
|
8206
|
+
return str + utf8_read_decoder(looseDecoder, buffer, i, end);
|
|
8086
8207
|
str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
|
|
8087
8208
|
}
|
|
8088
8209
|
|
|
8089
8210
|
for (; i < end; ++i) {
|
|
8090
8211
|
c1 = buffer[i];
|
|
8091
8212
|
if (c1 & 0x80)
|
|
8092
|
-
return
|
|
8213
|
+
return str + utf8_read_decoder(looseDecoder, buffer, i, end);
|
|
8093
8214
|
str += String.fromCharCode(c1);
|
|
8094
8215
|
}
|
|
8095
8216
|
|
|
@@ -8401,6 +8522,10 @@ var Message = require(10),
|
|
|
8401
8522
|
wrappers[".google.protobuf.Any"] = {
|
|
8402
8523
|
|
|
8403
8524
|
fromObject: function(object, depth) {
|
|
8525
|
+
if (depth === undefined)
|
|
8526
|
+
depth = 0;
|
|
8527
|
+
if (depth > util.recursionLimit)
|
|
8528
|
+
throw Error("max depth exceeded");
|
|
8404
8529
|
|
|
8405
8530
|
// unwrap value type if mapped
|
|
8406
8531
|
if (object && object["@type"]) {
|
|
@@ -8418,7 +8543,7 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
8418
8543
|
}
|
|
8419
8544
|
return this.create({
|
|
8420
8545
|
type_url: type_url,
|
|
8421
|
-
value: type.encode(type.fromObject(object, depth
|
|
8546
|
+
value: type.encode(type.fromObject(object, depth + 1)).finish()
|
|
8422
8547
|
});
|
|
8423
8548
|
}
|
|
8424
8549
|
}
|
|
@@ -8495,7 +8620,7 @@ function Writer() {
|
|
|
8495
8620
|
* Backing buffer.
|
|
8496
8621
|
* @type {Uint8Array}
|
|
8497
8622
|
*/
|
|
8498
|
-
this.buf = this.constructor.alloc(
|
|
8623
|
+
this.buf = this.constructor.alloc(Writer.initialBufferSize);
|
|
8499
8624
|
|
|
8500
8625
|
/**
|
|
8501
8626
|
* Cached DataView over {@link Writer#buf}.
|
|
@@ -8510,6 +8635,12 @@ function Writer() {
|
|
|
8510
8635
|
this.states = null;
|
|
8511
8636
|
}
|
|
8512
8637
|
|
|
8638
|
+
/**
|
|
8639
|
+
* Initial backing buffer size in bytes. Defaults to 128.
|
|
8640
|
+
* @type {number}
|
|
8641
|
+
*/
|
|
8642
|
+
Writer.initialBufferSize = 128;
|
|
8643
|
+
|
|
8513
8644
|
/**
|
|
8514
8645
|
* Current write position.
|
|
8515
8646
|
* @name Writer#len
|