protobufjs 8.3.0 → 8.4.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 +46 -31
- package/dist/light/protobuf.js +105 -71
- 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 +31 -11
- 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 +106 -72
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/index.d.ts +21 -9
- package/package.json +2 -2
- package/src/converter.js +14 -9
- package/src/decoder.js +3 -1
- package/src/encoder.js +8 -5
- package/src/enum.js +2 -2
- package/src/field.js +2 -5
- package/src/index-light.js +1 -1
- package/src/message.js +1 -1
- package/src/object.js +6 -6
- package/src/parse.js +1 -1
- package/src/root.js +14 -8
- package/src/type.js +9 -9
- package/src/typescript.js +6 -0
- package/src/util/eventemitter.js +4 -2
- package/src/util/minimal.js +24 -6
- package/src/util/patterns.js +0 -1
- package/src/util/pool.js +1 -1
- package/src/util.js +2 -3
- package/src/wrappers.js +11 -8
package/dist/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.4.1 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 21 may 2026 18:52:08 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -505,14 +505,14 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
|
505
505
|
("m%s=d%s|0", prop, prop);
|
|
506
506
|
break;
|
|
507
507
|
case "uint64":
|
|
508
|
+
case "fixed64":
|
|
508
509
|
isUnsigned = true;
|
|
509
510
|
// eslint-disable-next-line no-fallthrough
|
|
510
511
|
case "int64":
|
|
511
512
|
case "sint64":
|
|
512
|
-
case "fixed64":
|
|
513
513
|
case "sfixed64": gen
|
|
514
514
|
("if(util.Long)")
|
|
515
|
-
("
|
|
515
|
+
("m%s=util.Long.fromValue(d%s,%j)", prop, prop, isUnsigned)
|
|
516
516
|
("else if(typeof d%s===\"string\")", prop)
|
|
517
517
|
("m%s=parseInt(d%s,10)", prop, prop)
|
|
518
518
|
("else if(typeof d%s===\"number\")", prop)
|
|
@@ -637,7 +637,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, dstProp, srcProp) {
|
|
|
637
637
|
if (field.resolvedType instanceof Enum) gen
|
|
638
638
|
("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s", dstProp, fieldIndex, srcProp, srcProp, fieldIndex, srcProp, srcProp);
|
|
639
639
|
else gen
|
|
640
|
-
("d%s=types[%i].toObject(m%s,o)", dstProp, fieldIndex, srcProp);
|
|
640
|
+
("d%s=types[%i].toObject(m%s,o,q+1)", dstProp, fieldIndex, srcProp);
|
|
641
641
|
} else {
|
|
642
642
|
var isUnsigned = false;
|
|
643
643
|
switch (field.type) {
|
|
@@ -646,13 +646,15 @@ function genValuePartial_toObject(gen, field, fieldIndex, dstProp, srcProp) {
|
|
|
646
646
|
("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s", dstProp, srcProp, srcProp, srcProp);
|
|
647
647
|
break;
|
|
648
648
|
case "uint64":
|
|
649
|
+
case "fixed64":
|
|
649
650
|
isUnsigned = true;
|
|
650
651
|
// eslint-disable-next-line no-fallthrough
|
|
651
652
|
case "int64":
|
|
652
653
|
case "sint64":
|
|
653
|
-
case "fixed64":
|
|
654
654
|
case "sfixed64": gen
|
|
655
|
-
("if(typeof
|
|
655
|
+
("if(typeof BigInt!==\"undefined\"&&o.longs===BigInt)")
|
|
656
|
+
("d%s=typeof m%s===\"number\"?BigInt(m%s):util.Long.fromBits(m%s.low>>>0,m%s.high>>>0,%j).toBigInt()", dstProp, srcProp, srcProp, srcProp, srcProp, isUnsigned)
|
|
657
|
+
("else if(typeof m%s===\"number\")", srcProp)
|
|
656
658
|
("d%s=o.longs===String?String(m%s):m%s", dstProp, srcProp, srcProp)
|
|
657
659
|
("else") // Long-like
|
|
658
660
|
("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s", dstProp, srcProp, srcProp, srcProp, isUnsigned ? "true": "", srcProp);
|
|
@@ -679,9 +681,12 @@ converter.toObject = function toObject(mtype) {
|
|
|
679
681
|
var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);
|
|
680
682
|
if (!fields.length)
|
|
681
683
|
return util.codegen()("return {}");
|
|
682
|
-
var gen = util.codegen(["m", "o"], mtype.name + "$toObject")
|
|
684
|
+
var gen = util.codegen(["m", "o", "q"], mtype.name + "$toObject")
|
|
683
685
|
("if(!o)")
|
|
684
686
|
("o={}")
|
|
687
|
+
("if(q===undefined)q=0")
|
|
688
|
+
("if(q>util.recursionLimit)")
|
|
689
|
+
("throw Error(\"max depth exceeded\")")
|
|
685
690
|
("var d={}");
|
|
686
691
|
|
|
687
692
|
var repeatedFields = [],
|
|
@@ -720,9 +725,9 @@ converter.toObject = function toObject(mtype) {
|
|
|
720
725
|
else if (field.long) gen
|
|
721
726
|
("if(util.Long){")
|
|
722
727
|
("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)
|
|
723
|
-
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
|
|
728
|
+
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():typeof BigInt!==\"undefined\"&&o.longs===BigInt?n.toBigInt():n", prop)
|
|
724
729
|
("}else")
|
|
725
|
-
("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
|
|
730
|
+
("d%s=o.longs===String?%j:typeof BigInt!==\"undefined\"&&o.longs===BigInt?BigInt(%j):%i", prop, field.typeDefault.toString(), field.typeDefault.toString(), field.typeDefault.toNumber());
|
|
726
731
|
else if (field.bytes) {
|
|
727
732
|
var arrayDefault = Array.prototype.slice.call(field.typeDefault);
|
|
728
733
|
gen
|
|
@@ -767,7 +772,7 @@ converter.toObject = function toObject(mtype) {
|
|
|
767
772
|
} else { gen
|
|
768
773
|
("if(m%s!=null&&m.hasOwnProperty(%j)){", prop, field.name); // !== undefined && !== null
|
|
769
774
|
genValuePartial_toObject(gen, field, /* sorted */ index, prop);
|
|
770
|
-
if (field.partOf) gen
|
|
775
|
+
if (field.partOf && !field.partOf.isProto3Optional) gen
|
|
771
776
|
("if(o.oneofs)")
|
|
772
777
|
("d%s=%j", util.safeProp(field.partOf.name), field.name);
|
|
773
778
|
}
|
|
@@ -845,7 +850,9 @@ function decoder(mtype) {
|
|
|
845
850
|
else gen
|
|
846
851
|
("k=null");
|
|
847
852
|
|
|
848
|
-
if (types.
|
|
853
|
+
if (types.long[type] !== undefined) gen
|
|
854
|
+
("v=util.Long?util.Long.fromNumber(0,%j):0", type === "uint64" || type === "fixed64");
|
|
855
|
+
else if (types.defaults[type] !== undefined) gen
|
|
849
856
|
("v=%j", types.defaults[type]);
|
|
850
857
|
else gen
|
|
851
858
|
("v=null");
|
|
@@ -1004,8 +1011,8 @@ var Enum = require(6),
|
|
|
1004
1011
|
*/
|
|
1005
1012
|
function genTypePartial(gen, field, fieldIndex, ref) {
|
|
1006
1013
|
return field.delimited
|
|
1007
|
-
? gen("types[%i].encode(%s,w.uint32(%i)).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
|
|
1008
|
-
: gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
|
|
1014
|
+
? gen("types[%i].encode(%s,w.uint32(%i),q+1).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
|
|
1015
|
+
: gen("types[%i].encode(%s,w.uint32(%i).fork(),q+1).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
|
|
1009
1016
|
}
|
|
1010
1017
|
|
|
1011
1018
|
/**
|
|
@@ -1015,9 +1022,12 @@ function genTypePartial(gen, field, fieldIndex, ref) {
|
|
|
1015
1022
|
*/
|
|
1016
1023
|
function encoder(mtype) {
|
|
1017
1024
|
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
|
|
1018
|
-
var gen = util.codegen(["m", "w"], mtype.name + "$encode")
|
|
1025
|
+
var gen = util.codegen(["m", "w", "q"], mtype.name + "$encode")
|
|
1019
1026
|
("if(!w)")
|
|
1020
|
-
("w=Writer.create()")
|
|
1027
|
+
("w=Writer.create()")
|
|
1028
|
+
("if(q===undefined)q=0")
|
|
1029
|
+
("if(q>util.recursionLimit)")
|
|
1030
|
+
("throw Error(\"max depth exceeded\")");
|
|
1021
1031
|
|
|
1022
1032
|
var i, ref;
|
|
1023
1033
|
|
|
@@ -1043,7 +1053,7 @@ function encoder(mtype) {
|
|
|
1043
1053
|
else gen
|
|
1044
1054
|
("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
|
|
1045
1055
|
if (wireType === undefined) gen
|
|
1046
|
-
("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups
|
|
1056
|
+
("types[%i].encode(%s[ks[i]],w.uint32(18).fork(),q+1).ldelim().ldelim()", index, ref); // can't be groups
|
|
1047
1057
|
else gen
|
|
1048
1058
|
(".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
|
|
1049
1059
|
gen
|
|
@@ -1184,8 +1194,8 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
|
1184
1194
|
ReflectionObject.prototype._resolveFeatures.call(this, edition);
|
|
1185
1195
|
|
|
1186
1196
|
Object.keys(this.values).forEach(key => {
|
|
1187
|
-
var parentFeaturesCopy =
|
|
1188
|
-
this._valuesFeatures[key] =
|
|
1197
|
+
var parentFeaturesCopy = util.merge({}, this._features);
|
|
1198
|
+
this._valuesFeatures[key] = util.merge(parentFeaturesCopy, this.valuesOptions && this.valuesOptions[key] && this.valuesOptions[key].features || {});
|
|
1189
1199
|
});
|
|
1190
1200
|
|
|
1191
1201
|
return this;
|
|
@@ -1342,7 +1352,7 @@ var Enum = require(6),
|
|
|
1342
1352
|
|
|
1343
1353
|
var Type; // cyclic
|
|
1344
1354
|
|
|
1345
|
-
var ruleRe = /^required|optional|repeated$/;
|
|
1355
|
+
var ruleRe = /^(?:required|optional|repeated)$/;
|
|
1346
1356
|
|
|
1347
1357
|
/**
|
|
1348
1358
|
* Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.
|
|
@@ -1417,9 +1427,6 @@ function Field(name, id, type, rule, extend, options, comment) {
|
|
|
1417
1427
|
* Field rule, if any.
|
|
1418
1428
|
* @type {string|undefined}
|
|
1419
1429
|
*/
|
|
1420
|
-
if (rule === "proto3_optional") {
|
|
1421
|
-
rule = "optional";
|
|
1422
|
-
}
|
|
1423
1430
|
this.rule = rule && rule !== "optional" ? rule : undefined; // toJSON
|
|
1424
1431
|
|
|
1425
1432
|
/**
|
|
@@ -1661,7 +1668,7 @@ Field.prototype.resolve = function resolve() {
|
|
|
1661
1668
|
|
|
1662
1669
|
// convert to internal data type if necesssary
|
|
1663
1670
|
if (this.long) {
|
|
1664
|
-
this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.
|
|
1671
|
+
this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type === "uint64" || this.type === "fixed64");
|
|
1665
1672
|
|
|
1666
1673
|
/* istanbul ignore else */
|
|
1667
1674
|
if (Object.freeze)
|
|
@@ -1891,7 +1898,7 @@ protobuf.util = require(28);
|
|
|
1891
1898
|
// Set up possibly cyclic reflection dependencies
|
|
1892
1899
|
protobuf.ReflectionObject._configure(protobuf.Root);
|
|
1893
1900
|
protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);
|
|
1894
|
-
protobuf.Root._configure(protobuf.Type);
|
|
1901
|
+
protobuf.Root._configure(protobuf.Type, undefined, {});
|
|
1895
1902
|
protobuf.Field._configure(protobuf.Type);
|
|
1896
1903
|
|
|
1897
1904
|
},{"11":11,"12":12,"13":13,"14":14,"15":15,"16":16,"20":20,"24":24,"26":26,"27":27,"28":28,"3":3,"4":4,"43":43,"44":44,"5":5,"6":6,"7":7,"9":9}],9:[function(require,module,exports){
|
|
@@ -2114,7 +2121,7 @@ function Message(properties) {
|
|
|
2114
2121
|
/**
|
|
2115
2122
|
* Creates a new message of this type using the specified properties.
|
|
2116
2123
|
* @param {Object.<string,*>} [properties] Properties to set
|
|
2117
|
-
* @returns {
|
|
2124
|
+
* @returns {T} Message instance
|
|
2118
2125
|
* @template T extends Message<T>
|
|
2119
2126
|
* @this Constructor<T>
|
|
2120
2127
|
*/
|
|
@@ -3160,7 +3167,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
3160
3167
|
throw new Error("Unknown edition for " + this.fullName);
|
|
3161
3168
|
}
|
|
3162
3169
|
|
|
3163
|
-
var protoFeatures =
|
|
3170
|
+
var protoFeatures = util.merge({}, this.options && this.options.features,
|
|
3164
3171
|
this._inferLegacyProtoFeatures(edition));
|
|
3165
3172
|
|
|
3166
3173
|
if (this._edition) {
|
|
@@ -3177,19 +3184,19 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
3177
3184
|
} else {
|
|
3178
3185
|
throw new Error("Unknown edition: " + edition);
|
|
3179
3186
|
}
|
|
3180
|
-
this._features =
|
|
3187
|
+
this._features = util.merge(defaults, protoFeatures);
|
|
3181
3188
|
} else {
|
|
3182
3189
|
// fields in Oneofs aren't actually children of them, so we have to
|
|
3183
3190
|
// special-case it
|
|
3184
3191
|
/* istanbul ignore else */
|
|
3185
3192
|
if (this.partOf instanceof OneOf) {
|
|
3186
|
-
var lexicalParentFeaturesCopy =
|
|
3187
|
-
this._features =
|
|
3193
|
+
var lexicalParentFeaturesCopy = util.merge({}, this.partOf._features);
|
|
3194
|
+
this._features = util.merge(lexicalParentFeaturesCopy, protoFeatures);
|
|
3188
3195
|
} else if (this.declaringField) {
|
|
3189
3196
|
// Skip feature resolution of sister fields.
|
|
3190
3197
|
} else if (this.parent) {
|
|
3191
|
-
var parentFeaturesCopy =
|
|
3192
|
-
this._features =
|
|
3198
|
+
var parentFeaturesCopy = util.merge({}, this.parent._features);
|
|
3199
|
+
this._features = util.merge(parentFeaturesCopy, protoFeatures);
|
|
3193
3200
|
} else {
|
|
3194
3201
|
throw new Error("Unable to find a parent for " + this.fullName);
|
|
3195
3202
|
}
|
|
@@ -4040,7 +4047,7 @@ function parse(source, root, options) {
|
|
|
4040
4047
|
name = applyCase(name);
|
|
4041
4048
|
skip("=");
|
|
4042
4049
|
|
|
4043
|
-
var field = new Field(name, parseId(next()), type, rule, extend);
|
|
4050
|
+
var field = new Field(name, parseId(next()), type, rule === "proto3_optional" ? "optional" : rule, extend);
|
|
4044
4051
|
|
|
4045
4052
|
ifBlock(field, function parseField_block(token) {
|
|
4046
4053
|
|
|
@@ -5360,8 +5367,12 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5360
5367
|
}
|
|
5361
5368
|
|
|
5362
5369
|
// Processes a single file
|
|
5363
|
-
function process(filename, source) {
|
|
5370
|
+
function process(filename, source, depth) {
|
|
5371
|
+
if (depth === undefined)
|
|
5372
|
+
depth = 0;
|
|
5364
5373
|
try {
|
|
5374
|
+
if (depth > util.recursionLimit)
|
|
5375
|
+
throw Error("max depth exceeded");
|
|
5365
5376
|
if (util.isString(source) && source.charAt(0) === "{")
|
|
5366
5377
|
source = JSON.parse(source);
|
|
5367
5378
|
if (!util.isString(source))
|
|
@@ -5374,11 +5385,11 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5374
5385
|
if (parsed.imports)
|
|
5375
5386
|
for (; i < parsed.imports.length; ++i)
|
|
5376
5387
|
if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))
|
|
5377
|
-
fetch(resolved);
|
|
5388
|
+
fetch(resolved, false, depth + 1);
|
|
5378
5389
|
if (parsed.weakImports)
|
|
5379
5390
|
for (i = 0; i < parsed.weakImports.length; ++i)
|
|
5380
5391
|
if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))
|
|
5381
|
-
fetch(resolved, true);
|
|
5392
|
+
fetch(resolved, true, depth + 1);
|
|
5382
5393
|
}
|
|
5383
5394
|
} catch (err) {
|
|
5384
5395
|
finish(err);
|
|
@@ -5389,7 +5400,9 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5389
5400
|
}
|
|
5390
5401
|
|
|
5391
5402
|
// Fetches a single file
|
|
5392
|
-
function fetch(filename, weak) {
|
|
5403
|
+
function fetch(filename, weak, depth) {
|
|
5404
|
+
if (depth === undefined)
|
|
5405
|
+
depth = 0;
|
|
5393
5406
|
filename = getBundledFileName(filename) || filename;
|
|
5394
5407
|
|
|
5395
5408
|
// Skip if already loaded / attempted
|
|
@@ -5401,12 +5414,12 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5401
5414
|
// Shortcut bundled definitions
|
|
5402
5415
|
if (Object.prototype.hasOwnProperty.call(common, filename)) {
|
|
5403
5416
|
if (sync) {
|
|
5404
|
-
process(filename, common[filename]);
|
|
5417
|
+
process(filename, common[filename], depth);
|
|
5405
5418
|
} else {
|
|
5406
5419
|
++queued;
|
|
5407
5420
|
setTimeout(function() {
|
|
5408
5421
|
--queued;
|
|
5409
|
-
process(filename, common[filename]);
|
|
5422
|
+
process(filename, common[filename], depth);
|
|
5410
5423
|
});
|
|
5411
5424
|
}
|
|
5412
5425
|
return;
|
|
@@ -5422,7 +5435,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5422
5435
|
finish(err);
|
|
5423
5436
|
return;
|
|
5424
5437
|
}
|
|
5425
|
-
process(filename, source);
|
|
5438
|
+
process(filename, source, depth);
|
|
5426
5439
|
} else {
|
|
5427
5440
|
++queued;
|
|
5428
5441
|
self.fetch(filename, function(err, source) {
|
|
@@ -5439,7 +5452,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5439
5452
|
finish(null, self);
|
|
5440
5453
|
return;
|
|
5441
5454
|
}
|
|
5442
|
-
process(filename, source);
|
|
5455
|
+
process(filename, source, depth);
|
|
5443
5456
|
});
|
|
5444
5457
|
}
|
|
5445
5458
|
}
|
|
@@ -6915,7 +6928,7 @@ Type.prototype.isReservedName = function isReservedName(name) {
|
|
|
6915
6928
|
/**
|
|
6916
6929
|
* Creates a new message of this type using the specified properties.
|
|
6917
6930
|
* @param {Object.<string,*>} [properties] Properties to set
|
|
6918
|
-
* @returns {
|
|
6931
|
+
* @returns {ReflectedMessage} Message instance
|
|
6919
6932
|
*/
|
|
6920
6933
|
Type.prototype.create = function create(properties) {
|
|
6921
6934
|
return new this.ctor(properties);
|
|
@@ -6981,8 +6994,8 @@ Type.prototype.setup = function setup() {
|
|
|
6981
6994
|
* @param {Writer} [writer] Writer to encode to
|
|
6982
6995
|
* @returns {Writer} writer
|
|
6983
6996
|
*/
|
|
6984
|
-
Type.prototype.encode = function encode_setup(message, writer) {
|
|
6985
|
-
return this.setup().encode(
|
|
6997
|
+
Type.prototype.encode = function encode_setup(message, writer) { // eslint-disable-line no-unused-vars
|
|
6998
|
+
return this.setup().encode.apply(this, arguments); // overrides this method
|
|
6986
6999
|
};
|
|
6987
7000
|
|
|
6988
7001
|
/**
|
|
@@ -6999,7 +7012,7 @@ Type.prototype.encodeDelimited = function encodeDelimited(message, writer) {
|
|
|
6999
7012
|
* Decodes a message of this type.
|
|
7000
7013
|
* @param {Reader|Uint8Array} reader Reader or buffer to decode from
|
|
7001
7014
|
* @param {number} [length] Length of the message, if known beforehand
|
|
7002
|
-
* @returns {
|
|
7015
|
+
* @returns {ReflectedMessage} Decoded message
|
|
7003
7016
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
7004
7017
|
* @throws {util.ProtocolError<{}>} If required fields are missing
|
|
7005
7018
|
*/
|
|
@@ -7010,7 +7023,7 @@ Type.prototype.decode = function decode_setup(reader, length) { // eslint-disabl
|
|
|
7010
7023
|
/**
|
|
7011
7024
|
* Decodes a message of this type preceeded by its byte length as a varint.
|
|
7012
7025
|
* @param {Reader|Uint8Array} reader Reader or buffer to decode from
|
|
7013
|
-
* @returns {
|
|
7026
|
+
* @returns {ReflectedMessage} Decoded message
|
|
7014
7027
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
7015
7028
|
* @throws {util.ProtocolError} If required fields are missing
|
|
7016
7029
|
*/
|
|
@@ -7032,7 +7045,7 @@ Type.prototype.verify = function verify_setup(message) { // eslint-disable-line
|
|
|
7032
7045
|
/**
|
|
7033
7046
|
* Creates a new message of this type from a plain object. Also converts values to their respective internal types.
|
|
7034
7047
|
* @param {Object.<string,*>} object Plain object to convert
|
|
7035
|
-
* @returns {
|
|
7048
|
+
* @returns {ReflectedMessage} Message instance
|
|
7036
7049
|
*/
|
|
7037
7050
|
Type.prototype.fromObject = function fromObject(object) { // eslint-disable-line no-unused-vars
|
|
7038
7051
|
return this.setup().fromObject.apply(this, arguments);
|
|
@@ -7042,7 +7055,7 @@ Type.prototype.fromObject = function fromObject(object) { // eslint-disable-line
|
|
|
7042
7055
|
* Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.
|
|
7043
7056
|
* @interface IConversionOptions
|
|
7044
7057
|
* @property {Function} [longs] Long conversion type.
|
|
7045
|
-
* Valid values are `String` and `Number` (the global types).
|
|
7058
|
+
* Valid values are `BigInt`, `String` and `Number` (the global types).
|
|
7046
7059
|
* Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
|
|
7047
7060
|
* @property {Function} [enums] Enum value conversion type.
|
|
7048
7061
|
* Only valid value is `String` (the global type).
|
|
@@ -7063,8 +7076,8 @@ Type.prototype.fromObject = function fromObject(object) { // eslint-disable-line
|
|
|
7063
7076
|
* @param {IConversionOptions} [options] Conversion options
|
|
7064
7077
|
* @returns {Object.<string,*>} Plain object
|
|
7065
7078
|
*/
|
|
7066
|
-
Type.prototype.toObject = function toObject(message, options) {
|
|
7067
|
-
return this.setup().toObject(
|
|
7079
|
+
Type.prototype.toObject = function toObject(message, options) { // eslint-disable-line no-unused-vars
|
|
7080
|
+
return this.setup().toObject.apply(this, arguments);
|
|
7068
7081
|
};
|
|
7069
7082
|
|
|
7070
7083
|
/**
|
|
@@ -7319,8 +7332,7 @@ util.fetch = require(33);
|
|
|
7319
7332
|
util.path = require(39);
|
|
7320
7333
|
util.patterns = require(40);
|
|
7321
7334
|
|
|
7322
|
-
var reservedRe = util.patterns.reservedRe
|
|
7323
|
-
unsafePropertyRe = util.patterns.unsafePropertyRe;
|
|
7335
|
+
var reservedRe = util.patterns.reservedRe;
|
|
7324
7336
|
|
|
7325
7337
|
/**
|
|
7326
7338
|
* Node's fs module if available.
|
|
@@ -7483,7 +7495,7 @@ util.decorateEnum = function decorateEnum(object) {
|
|
|
7483
7495
|
util.setProperty = function setProperty(dst, path, value, ifNotSet) {
|
|
7484
7496
|
function setProp(dst, path, value) {
|
|
7485
7497
|
var part = path.shift();
|
|
7486
|
-
if (
|
|
7498
|
+
if (util.isUnsafeProperty(part))
|
|
7487
7499
|
return dst;
|
|
7488
7500
|
if (path.length > 0) {
|
|
7489
7501
|
dst[part] = setProp(dst[part] || {}, path, value);
|
|
@@ -7856,7 +7868,7 @@ function EventEmitter() {
|
|
|
7856
7868
|
* @type {Object.<string,*>}
|
|
7857
7869
|
* @private
|
|
7858
7870
|
*/
|
|
7859
|
-
this._listeners =
|
|
7871
|
+
this._listeners = Object.create(null);
|
|
7860
7872
|
}
|
|
7861
7873
|
|
|
7862
7874
|
/**
|
|
@@ -7890,12 +7902,14 @@ EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
|
7890
7902
|
*/
|
|
7891
7903
|
EventEmitter.prototype.off = function off(evt, fn) {
|
|
7892
7904
|
if (evt === undefined)
|
|
7893
|
-
this._listeners =
|
|
7905
|
+
this._listeners = Object.create(null);
|
|
7894
7906
|
else {
|
|
7895
7907
|
if (fn === undefined)
|
|
7896
7908
|
this._listeners[evt] = [];
|
|
7897
7909
|
else {
|
|
7898
7910
|
var listeners = this._listeners[evt];
|
|
7911
|
+
if (!listeners)
|
|
7912
|
+
return this;
|
|
7899
7913
|
for (var i = 0; i < listeners.length;)
|
|
7900
7914
|
if (listeners[i].fn === fn)
|
|
7901
7915
|
listeners.splice(i, 1);
|
|
@@ -8659,6 +8673,18 @@ util.pool = require(41);
|
|
|
8659
8673
|
// utility to work with the low and high bits of a 64 bit value
|
|
8660
8674
|
util.LongBits = require(37);
|
|
8661
8675
|
|
|
8676
|
+
/**
|
|
8677
|
+
* Tests if the specified key can affect object prototypes.
|
|
8678
|
+
* @memberof util
|
|
8679
|
+
* @param {string} key Key to test
|
|
8680
|
+
* @returns {boolean} `true` if the key is unsafe
|
|
8681
|
+
*/
|
|
8682
|
+
function isUnsafeProperty(key) {
|
|
8683
|
+
return key === "__proto__" || key === "prototype" || key === "constructor";
|
|
8684
|
+
}
|
|
8685
|
+
|
|
8686
|
+
util.isUnsafeProperty = isUnsafeProperty;
|
|
8687
|
+
|
|
8662
8688
|
/**
|
|
8663
8689
|
* Whether running within node or not.
|
|
8664
8690
|
* @memberof util
|
|
@@ -8893,15 +8919,21 @@ util.boolFromKey = function boolFromKey(key) {
|
|
|
8893
8919
|
* Merges the properties of the source object into the destination object.
|
|
8894
8920
|
* @memberof util
|
|
8895
8921
|
* @param {Object.<string,*>} dst Destination object
|
|
8896
|
-
* @param {Object.<string
|
|
8897
|
-
* @param {boolean} [ifNotSet=false] Merges only if the key is not already set
|
|
8922
|
+
* @param {...(Object.<string,*>|boolean)} src Source objects, optionally followed by an `ifNotSet` flag
|
|
8898
8923
|
* @returns {Object.<string,*>} Destination object
|
|
8899
8924
|
*/
|
|
8900
|
-
function merge(dst
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8925
|
+
function merge(dst) { // used by converters
|
|
8926
|
+
var ifNotSet = typeof arguments[arguments.length - 1] === "boolean",
|
|
8927
|
+
limit = ifNotSet ? arguments.length - 1 : arguments.length;
|
|
8928
|
+
ifNotSet = ifNotSet && arguments[arguments.length - 1];
|
|
8929
|
+
for (var a = 1; a < limit; ++a) {
|
|
8930
|
+
var src = arguments[a];
|
|
8931
|
+
if (!src)
|
|
8932
|
+
continue;
|
|
8933
|
+
for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
|
|
8934
|
+
if (!isUnsafeProperty(keys[i]) && (dst[keys[i]] === undefined || !ifNotSet))
|
|
8904
8935
|
dst[keys[i]] = src[keys[i]];
|
|
8936
|
+
}
|
|
8905
8937
|
return dst;
|
|
8906
8938
|
}
|
|
8907
8939
|
|
|
@@ -9215,7 +9247,6 @@ var patterns = exports;
|
|
|
9215
9247
|
patterns.numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;
|
|
9216
9248
|
patterns.typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
|
|
9217
9249
|
patterns.reservedRe = /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/;
|
|
9218
|
-
patterns.unsafePropertyRe = /^(?:__proto__|prototype|constructor)$/;
|
|
9219
9250
|
|
|
9220
9251
|
},{}],41:[function(require,module,exports){
|
|
9221
9252
|
"use strict";
|
|
@@ -9236,7 +9267,7 @@ module.exports = pool;
|
|
|
9236
9267
|
* @param {number} start Start offset
|
|
9237
9268
|
* @param {number} end End offset
|
|
9238
9269
|
* @returns {Uint8Array} Buffer slice
|
|
9239
|
-
* @this
|
|
9270
|
+
* @this Uint8Array
|
|
9240
9271
|
*/
|
|
9241
9272
|
|
|
9242
9273
|
/**
|
|
@@ -9591,7 +9622,8 @@ function verifier(mtype) {
|
|
|
9591
9622
|
*/
|
|
9592
9623
|
var wrappers = exports;
|
|
9593
9624
|
|
|
9594
|
-
var Message = require(12)
|
|
9625
|
+
var Message = require(12),
|
|
9626
|
+
util = require(38);
|
|
9595
9627
|
|
|
9596
9628
|
/**
|
|
9597
9629
|
* From object converter part of an {@link IWrapper}.
|
|
@@ -9638,10 +9670,9 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9638
9670
|
if (type_url.indexOf("/") === -1) {
|
|
9639
9671
|
type_url = "/" + type_url;
|
|
9640
9672
|
}
|
|
9641
|
-
var nextDepth = depth === undefined ? 1 : depth + 1;
|
|
9642
9673
|
return this.create({
|
|
9643
9674
|
type_url: type_url,
|
|
9644
|
-
value: type.encode(type.fromObject(object,
|
|
9675
|
+
value: type.encode(type.fromObject(object, depth === undefined ? 1 : depth + 1)).finish()
|
|
9645
9676
|
});
|
|
9646
9677
|
}
|
|
9647
9678
|
}
|
|
@@ -9649,13 +9680,16 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9649
9680
|
return this.fromObject(object, depth);
|
|
9650
9681
|
},
|
|
9651
9682
|
|
|
9652
|
-
toObject: function(message, options) {
|
|
9683
|
+
toObject: function(message, options, depth) {
|
|
9684
|
+
if (depth === undefined)
|
|
9685
|
+
depth = 0;
|
|
9686
|
+
if (depth > util.recursionLimit)
|
|
9687
|
+
throw Error("max depth exceeded");
|
|
9653
9688
|
|
|
9654
9689
|
// Default prefix
|
|
9655
9690
|
var googleApi = "type.googleapis.com/";
|
|
9656
9691
|
var prefix = "";
|
|
9657
9692
|
var name = "";
|
|
9658
|
-
|
|
9659
9693
|
// decode value if requested and unmapped
|
|
9660
9694
|
if (options && options.json && message.type_url && message.value) {
|
|
9661
9695
|
// Only use fully qualified type name after the last '/'
|
|
@@ -9665,12 +9699,12 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9665
9699
|
var type = this.lookup(name);
|
|
9666
9700
|
/* istanbul ignore else */
|
|
9667
9701
|
if (type)
|
|
9668
|
-
message = type.decode(message.value);
|
|
9702
|
+
message = type.decode(message.value, undefined, undefined, depth + 1);
|
|
9669
9703
|
}
|
|
9670
9704
|
|
|
9671
9705
|
// wrap value if unmapped
|
|
9672
9706
|
if (!(message instanceof this.ctor) && message instanceof Message) {
|
|
9673
|
-
var object = message.$type.toObject(message, options);
|
|
9707
|
+
var object = message.$type.toObject(message, options, depth + 1);
|
|
9674
9708
|
var messageName = message.$type.fullName[0] === "." ?
|
|
9675
9709
|
message.$type.fullName.slice(1) : message.$type.fullName;
|
|
9676
9710
|
// Default to type.googleapis.com prefix if no prefix is used
|
|
@@ -9682,11 +9716,11 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9682
9716
|
return object;
|
|
9683
9717
|
}
|
|
9684
9718
|
|
|
9685
|
-
return this.toObject(message, options);
|
|
9719
|
+
return this.toObject(message, options, depth);
|
|
9686
9720
|
}
|
|
9687
9721
|
};
|
|
9688
9722
|
|
|
9689
|
-
},{"12":12}],45:[function(require,module,exports){
|
|
9723
|
+
},{"12":12,"38":38}],45:[function(require,module,exports){
|
|
9690
9724
|
"use strict";
|
|
9691
9725
|
module.exports = Writer;
|
|
9692
9726
|
|