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/light/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
|
*/
|
|
@@ -104,14 +104,14 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
|
104
104
|
("m%s=d%s|0", prop, prop);
|
|
105
105
|
break;
|
|
106
106
|
case "uint64":
|
|
107
|
+
case "fixed64":
|
|
107
108
|
isUnsigned = true;
|
|
108
109
|
// eslint-disable-next-line no-fallthrough
|
|
109
110
|
case "int64":
|
|
110
111
|
case "sint64":
|
|
111
|
-
case "fixed64":
|
|
112
112
|
case "sfixed64": gen
|
|
113
113
|
("if(util.Long)")
|
|
114
|
-
("
|
|
114
|
+
("m%s=util.Long.fromValue(d%s,%j)", prop, prop, isUnsigned)
|
|
115
115
|
("else if(typeof d%s===\"string\")", prop)
|
|
116
116
|
("m%s=parseInt(d%s,10)", prop, prop)
|
|
117
117
|
("else if(typeof d%s===\"number\")", prop)
|
|
@@ -236,7 +236,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, dstProp, srcProp) {
|
|
|
236
236
|
if (field.resolvedType instanceof Enum) gen
|
|
237
237
|
("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);
|
|
238
238
|
else gen
|
|
239
|
-
("d%s=types[%i].toObject(m%s,o)", dstProp, fieldIndex, srcProp);
|
|
239
|
+
("d%s=types[%i].toObject(m%s,o,q+1)", dstProp, fieldIndex, srcProp);
|
|
240
240
|
} else {
|
|
241
241
|
var isUnsigned = false;
|
|
242
242
|
switch (field.type) {
|
|
@@ -245,13 +245,15 @@ function genValuePartial_toObject(gen, field, fieldIndex, dstProp, srcProp) {
|
|
|
245
245
|
("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s", dstProp, srcProp, srcProp, srcProp);
|
|
246
246
|
break;
|
|
247
247
|
case "uint64":
|
|
248
|
+
case "fixed64":
|
|
248
249
|
isUnsigned = true;
|
|
249
250
|
// eslint-disable-next-line no-fallthrough
|
|
250
251
|
case "int64":
|
|
251
252
|
case "sint64":
|
|
252
|
-
case "fixed64":
|
|
253
253
|
case "sfixed64": gen
|
|
254
|
-
("if(typeof
|
|
254
|
+
("if(typeof BigInt!==\"undefined\"&&o.longs===BigInt)")
|
|
255
|
+
("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)
|
|
256
|
+
("else if(typeof m%s===\"number\")", srcProp)
|
|
255
257
|
("d%s=o.longs===String?String(m%s):m%s", dstProp, srcProp, srcProp)
|
|
256
258
|
("else") // Long-like
|
|
257
259
|
("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);
|
|
@@ -278,9 +280,12 @@ converter.toObject = function toObject(mtype) {
|
|
|
278
280
|
var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);
|
|
279
281
|
if (!fields.length)
|
|
280
282
|
return util.codegen()("return {}");
|
|
281
|
-
var gen = util.codegen(["m", "o"], mtype.name + "$toObject")
|
|
283
|
+
var gen = util.codegen(["m", "o", "q"], mtype.name + "$toObject")
|
|
282
284
|
("if(!o)")
|
|
283
285
|
("o={}")
|
|
286
|
+
("if(q===undefined)q=0")
|
|
287
|
+
("if(q>util.recursionLimit)")
|
|
288
|
+
("throw Error(\"max depth exceeded\")")
|
|
284
289
|
("var d={}");
|
|
285
290
|
|
|
286
291
|
var repeatedFields = [],
|
|
@@ -319,9 +324,9 @@ converter.toObject = function toObject(mtype) {
|
|
|
319
324
|
else if (field.long) gen
|
|
320
325
|
("if(util.Long){")
|
|
321
326
|
("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)
|
|
322
|
-
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
|
|
327
|
+
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():typeof BigInt!==\"undefined\"&&o.longs===BigInt?n.toBigInt():n", prop)
|
|
323
328
|
("}else")
|
|
324
|
-
("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
|
|
329
|
+
("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());
|
|
325
330
|
else if (field.bytes) {
|
|
326
331
|
var arrayDefault = Array.prototype.slice.call(field.typeDefault);
|
|
327
332
|
gen
|
|
@@ -366,7 +371,7 @@ converter.toObject = function toObject(mtype) {
|
|
|
366
371
|
} else { gen
|
|
367
372
|
("if(m%s!=null&&m.hasOwnProperty(%j)){", prop, field.name); // !== undefined && !== null
|
|
368
373
|
genValuePartial_toObject(gen, field, /* sorted */ index, prop);
|
|
369
|
-
if (field.partOf) gen
|
|
374
|
+
if (field.partOf && !field.partOf.isProto3Optional) gen
|
|
370
375
|
("if(o.oneofs)")
|
|
371
376
|
("d%s=%j", util.safeProp(field.partOf.name), field.name);
|
|
372
377
|
}
|
|
@@ -444,7 +449,9 @@ function decoder(mtype) {
|
|
|
444
449
|
else gen
|
|
445
450
|
("k=null");
|
|
446
451
|
|
|
447
|
-
if (types.
|
|
452
|
+
if (types.long[type] !== undefined) gen
|
|
453
|
+
("v=util.Long?util.Long.fromNumber(0,%j):0", type === "uint64" || type === "fixed64");
|
|
454
|
+
else if (types.defaults[type] !== undefined) gen
|
|
448
455
|
("v=%j", types.defaults[type]);
|
|
449
456
|
else gen
|
|
450
457
|
("v=null");
|
|
@@ -603,8 +610,8 @@ var Enum = require(5),
|
|
|
603
610
|
*/
|
|
604
611
|
function genTypePartial(gen, field, fieldIndex, ref) {
|
|
605
612
|
return field.delimited
|
|
606
|
-
? gen("types[%i].encode(%s,w.uint32(%i)).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
|
|
607
|
-
: gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
|
|
613
|
+
? gen("types[%i].encode(%s,w.uint32(%i),q+1).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
|
|
614
|
+
: gen("types[%i].encode(%s,w.uint32(%i).fork(),q+1).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
|
|
608
615
|
}
|
|
609
616
|
|
|
610
617
|
/**
|
|
@@ -614,9 +621,12 @@ function genTypePartial(gen, field, fieldIndex, ref) {
|
|
|
614
621
|
*/
|
|
615
622
|
function encoder(mtype) {
|
|
616
623
|
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
|
|
617
|
-
var gen = util.codegen(["m", "w"], mtype.name + "$encode")
|
|
624
|
+
var gen = util.codegen(["m", "w", "q"], mtype.name + "$encode")
|
|
618
625
|
("if(!w)")
|
|
619
|
-
("w=Writer.create()")
|
|
626
|
+
("w=Writer.create()")
|
|
627
|
+
("if(q===undefined)q=0")
|
|
628
|
+
("if(q>util.recursionLimit)")
|
|
629
|
+
("throw Error(\"max depth exceeded\")");
|
|
620
630
|
|
|
621
631
|
var i, ref;
|
|
622
632
|
|
|
@@ -642,7 +652,7 @@ function encoder(mtype) {
|
|
|
642
652
|
else gen
|
|
643
653
|
("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
|
|
644
654
|
if (wireType === undefined) gen
|
|
645
|
-
("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups
|
|
655
|
+
("types[%i].encode(%s[ks[i]],w.uint32(18).fork(),q+1).ldelim().ldelim()", index, ref); // can't be groups
|
|
646
656
|
else gen
|
|
647
657
|
(".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
|
|
648
658
|
gen
|
|
@@ -783,8 +793,8 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
|
783
793
|
ReflectionObject.prototype._resolveFeatures.call(this, edition);
|
|
784
794
|
|
|
785
795
|
Object.keys(this.values).forEach(key => {
|
|
786
|
-
var parentFeaturesCopy =
|
|
787
|
-
this._valuesFeatures[key] =
|
|
796
|
+
var parentFeaturesCopy = util.merge({}, this._features);
|
|
797
|
+
this._valuesFeatures[key] = util.merge(parentFeaturesCopy, this.valuesOptions && this.valuesOptions[key] && this.valuesOptions[key].features || {});
|
|
788
798
|
});
|
|
789
799
|
|
|
790
800
|
return this;
|
|
@@ -941,7 +951,7 @@ var Enum = require(5),
|
|
|
941
951
|
|
|
942
952
|
var Type; // cyclic
|
|
943
953
|
|
|
944
|
-
var ruleRe = /^required|optional|repeated$/;
|
|
954
|
+
var ruleRe = /^(?:required|optional|repeated)$/;
|
|
945
955
|
|
|
946
956
|
/**
|
|
947
957
|
* Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.
|
|
@@ -1016,9 +1026,6 @@ function Field(name, id, type, rule, extend, options, comment) {
|
|
|
1016
1026
|
* Field rule, if any.
|
|
1017
1027
|
* @type {string|undefined}
|
|
1018
1028
|
*/
|
|
1019
|
-
if (rule === "proto3_optional") {
|
|
1020
|
-
rule = "optional";
|
|
1021
|
-
}
|
|
1022
1029
|
this.rule = rule && rule !== "optional" ? rule : undefined; // toJSON
|
|
1023
1030
|
|
|
1024
1031
|
/**
|
|
@@ -1260,7 +1267,7 @@ Field.prototype.resolve = function resolve() {
|
|
|
1260
1267
|
|
|
1261
1268
|
// convert to internal data type if necesssary
|
|
1262
1269
|
if (this.long) {
|
|
1263
|
-
this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.
|
|
1270
|
+
this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type === "uint64" || this.type === "fixed64");
|
|
1264
1271
|
|
|
1265
1272
|
/* istanbul ignore else */
|
|
1266
1273
|
if (Object.freeze)
|
|
@@ -1490,7 +1497,7 @@ protobuf.util = require(24);
|
|
|
1490
1497
|
// Set up possibly cyclic reflection dependencies
|
|
1491
1498
|
protobuf.ReflectionObject._configure(protobuf.Root);
|
|
1492
1499
|
protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);
|
|
1493
|
-
protobuf.Root._configure(protobuf.Type);
|
|
1500
|
+
protobuf.Root._configure(protobuf.Type, undefined, {});
|
|
1494
1501
|
protobuf.Field._configure(protobuf.Type);
|
|
1495
1502
|
|
|
1496
1503
|
},{"10":10,"11":11,"12":12,"13":13,"14":14,"17":17,"2":2,"21":21,"22":22,"23":23,"24":24,"3":3,"39":39,"4":4,"40":40,"5":5,"6":6,"8":8,"9":9}],8:[function(require,module,exports){
|
|
@@ -1699,7 +1706,7 @@ function Message(properties) {
|
|
|
1699
1706
|
/**
|
|
1700
1707
|
* Creates a new message of this type using the specified properties.
|
|
1701
1708
|
* @param {Object.<string,*>} [properties] Properties to set
|
|
1702
|
-
* @returns {
|
|
1709
|
+
* @returns {T} Message instance
|
|
1703
1710
|
* @template T extends Message<T>
|
|
1704
1711
|
* @this Constructor<T>
|
|
1705
1712
|
*/
|
|
@@ -2745,7 +2752,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
2745
2752
|
throw new Error("Unknown edition for " + this.fullName);
|
|
2746
2753
|
}
|
|
2747
2754
|
|
|
2748
|
-
var protoFeatures =
|
|
2755
|
+
var protoFeatures = util.merge({}, this.options && this.options.features,
|
|
2749
2756
|
this._inferLegacyProtoFeatures(edition));
|
|
2750
2757
|
|
|
2751
2758
|
if (this._edition) {
|
|
@@ -2762,19 +2769,19 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
2762
2769
|
} else {
|
|
2763
2770
|
throw new Error("Unknown edition: " + edition);
|
|
2764
2771
|
}
|
|
2765
|
-
this._features =
|
|
2772
|
+
this._features = util.merge(defaults, protoFeatures);
|
|
2766
2773
|
} else {
|
|
2767
2774
|
// fields in Oneofs aren't actually children of them, so we have to
|
|
2768
2775
|
// special-case it
|
|
2769
2776
|
/* istanbul ignore else */
|
|
2770
2777
|
if (this.partOf instanceof OneOf) {
|
|
2771
|
-
var lexicalParentFeaturesCopy =
|
|
2772
|
-
this._features =
|
|
2778
|
+
var lexicalParentFeaturesCopy = util.merge({}, this.partOf._features);
|
|
2779
|
+
this._features = util.merge(lexicalParentFeaturesCopy, protoFeatures);
|
|
2773
2780
|
} else if (this.declaringField) {
|
|
2774
2781
|
// Skip feature resolution of sister fields.
|
|
2775
2782
|
} else if (this.parent) {
|
|
2776
|
-
var parentFeaturesCopy =
|
|
2777
|
-
this._features =
|
|
2783
|
+
var parentFeaturesCopy = util.merge({}, this.parent._features);
|
|
2784
|
+
this._features = util.merge(parentFeaturesCopy, protoFeatures);
|
|
2778
2785
|
} else {
|
|
2779
2786
|
throw new Error("Unable to find a parent for " + this.fullName);
|
|
2780
2787
|
}
|
|
@@ -3892,8 +3899,12 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
3892
3899
|
}
|
|
3893
3900
|
|
|
3894
3901
|
// Processes a single file
|
|
3895
|
-
function process(filename, source) {
|
|
3902
|
+
function process(filename, source, depth) {
|
|
3903
|
+
if (depth === undefined)
|
|
3904
|
+
depth = 0;
|
|
3896
3905
|
try {
|
|
3906
|
+
if (depth > util.recursionLimit)
|
|
3907
|
+
throw Error("max depth exceeded");
|
|
3897
3908
|
if (util.isString(source) && source.charAt(0) === "{")
|
|
3898
3909
|
source = JSON.parse(source);
|
|
3899
3910
|
if (!util.isString(source))
|
|
@@ -3906,11 +3917,11 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
3906
3917
|
if (parsed.imports)
|
|
3907
3918
|
for (; i < parsed.imports.length; ++i)
|
|
3908
3919
|
if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))
|
|
3909
|
-
fetch(resolved);
|
|
3920
|
+
fetch(resolved, false, depth + 1);
|
|
3910
3921
|
if (parsed.weakImports)
|
|
3911
3922
|
for (i = 0; i < parsed.weakImports.length; ++i)
|
|
3912
3923
|
if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))
|
|
3913
|
-
fetch(resolved, true);
|
|
3924
|
+
fetch(resolved, true, depth + 1);
|
|
3914
3925
|
}
|
|
3915
3926
|
} catch (err) {
|
|
3916
3927
|
finish(err);
|
|
@@ -3921,7 +3932,9 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
3921
3932
|
}
|
|
3922
3933
|
|
|
3923
3934
|
// Fetches a single file
|
|
3924
|
-
function fetch(filename, weak) {
|
|
3935
|
+
function fetch(filename, weak, depth) {
|
|
3936
|
+
if (depth === undefined)
|
|
3937
|
+
depth = 0;
|
|
3925
3938
|
filename = getBundledFileName(filename) || filename;
|
|
3926
3939
|
|
|
3927
3940
|
// Skip if already loaded / attempted
|
|
@@ -3933,12 +3946,12 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
3933
3946
|
// Shortcut bundled definitions
|
|
3934
3947
|
if (Object.prototype.hasOwnProperty.call(common, filename)) {
|
|
3935
3948
|
if (sync) {
|
|
3936
|
-
process(filename, common[filename]);
|
|
3949
|
+
process(filename, common[filename], depth);
|
|
3937
3950
|
} else {
|
|
3938
3951
|
++queued;
|
|
3939
3952
|
setTimeout(function() {
|
|
3940
3953
|
--queued;
|
|
3941
|
-
process(filename, common[filename]);
|
|
3954
|
+
process(filename, common[filename], depth);
|
|
3942
3955
|
});
|
|
3943
3956
|
}
|
|
3944
3957
|
return;
|
|
@@ -3954,7 +3967,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
3954
3967
|
finish(err);
|
|
3955
3968
|
return;
|
|
3956
3969
|
}
|
|
3957
|
-
process(filename, source);
|
|
3970
|
+
process(filename, source, depth);
|
|
3958
3971
|
} else {
|
|
3959
3972
|
++queued;
|
|
3960
3973
|
self.fetch(filename, function(err, source) {
|
|
@@ -3971,7 +3984,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
3971
3984
|
finish(null, self);
|
|
3972
3985
|
return;
|
|
3973
3986
|
}
|
|
3974
|
-
process(filename, source);
|
|
3987
|
+
process(filename, source, depth);
|
|
3975
3988
|
});
|
|
3976
3989
|
}
|
|
3977
3990
|
}
|
|
@@ -5024,7 +5037,7 @@ Type.prototype.isReservedName = function isReservedName(name) {
|
|
|
5024
5037
|
/**
|
|
5025
5038
|
* Creates a new message of this type using the specified properties.
|
|
5026
5039
|
* @param {Object.<string,*>} [properties] Properties to set
|
|
5027
|
-
* @returns {
|
|
5040
|
+
* @returns {ReflectedMessage} Message instance
|
|
5028
5041
|
*/
|
|
5029
5042
|
Type.prototype.create = function create(properties) {
|
|
5030
5043
|
return new this.ctor(properties);
|
|
@@ -5090,8 +5103,8 @@ Type.prototype.setup = function setup() {
|
|
|
5090
5103
|
* @param {Writer} [writer] Writer to encode to
|
|
5091
5104
|
* @returns {Writer} writer
|
|
5092
5105
|
*/
|
|
5093
|
-
Type.prototype.encode = function encode_setup(message, writer) {
|
|
5094
|
-
return this.setup().encode(
|
|
5106
|
+
Type.prototype.encode = function encode_setup(message, writer) { // eslint-disable-line no-unused-vars
|
|
5107
|
+
return this.setup().encode.apply(this, arguments); // overrides this method
|
|
5095
5108
|
};
|
|
5096
5109
|
|
|
5097
5110
|
/**
|
|
@@ -5108,7 +5121,7 @@ Type.prototype.encodeDelimited = function encodeDelimited(message, writer) {
|
|
|
5108
5121
|
* Decodes a message of this type.
|
|
5109
5122
|
* @param {Reader|Uint8Array} reader Reader or buffer to decode from
|
|
5110
5123
|
* @param {number} [length] Length of the message, if known beforehand
|
|
5111
|
-
* @returns {
|
|
5124
|
+
* @returns {ReflectedMessage} Decoded message
|
|
5112
5125
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
5113
5126
|
* @throws {util.ProtocolError<{}>} If required fields are missing
|
|
5114
5127
|
*/
|
|
@@ -5119,7 +5132,7 @@ Type.prototype.decode = function decode_setup(reader, length) { // eslint-disabl
|
|
|
5119
5132
|
/**
|
|
5120
5133
|
* Decodes a message of this type preceeded by its byte length as a varint.
|
|
5121
5134
|
* @param {Reader|Uint8Array} reader Reader or buffer to decode from
|
|
5122
|
-
* @returns {
|
|
5135
|
+
* @returns {ReflectedMessage} Decoded message
|
|
5123
5136
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
5124
5137
|
* @throws {util.ProtocolError} If required fields are missing
|
|
5125
5138
|
*/
|
|
@@ -5141,7 +5154,7 @@ Type.prototype.verify = function verify_setup(message) { // eslint-disable-line
|
|
|
5141
5154
|
/**
|
|
5142
5155
|
* Creates a new message of this type from a plain object. Also converts values to their respective internal types.
|
|
5143
5156
|
* @param {Object.<string,*>} object Plain object to convert
|
|
5144
|
-
* @returns {
|
|
5157
|
+
* @returns {ReflectedMessage} Message instance
|
|
5145
5158
|
*/
|
|
5146
5159
|
Type.prototype.fromObject = function fromObject(object) { // eslint-disable-line no-unused-vars
|
|
5147
5160
|
return this.setup().fromObject.apply(this, arguments);
|
|
@@ -5151,7 +5164,7 @@ Type.prototype.fromObject = function fromObject(object) { // eslint-disable-line
|
|
|
5151
5164
|
* Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.
|
|
5152
5165
|
* @interface IConversionOptions
|
|
5153
5166
|
* @property {Function} [longs] Long conversion type.
|
|
5154
|
-
* Valid values are `String` and `Number` (the global types).
|
|
5167
|
+
* Valid values are `BigInt`, `String` and `Number` (the global types).
|
|
5155
5168
|
* Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
|
|
5156
5169
|
* @property {Function} [enums] Enum value conversion type.
|
|
5157
5170
|
* Only valid value is `String` (the global type).
|
|
@@ -5172,8 +5185,8 @@ Type.prototype.fromObject = function fromObject(object) { // eslint-disable-line
|
|
|
5172
5185
|
* @param {IConversionOptions} [options] Conversion options
|
|
5173
5186
|
* @returns {Object.<string,*>} Plain object
|
|
5174
5187
|
*/
|
|
5175
|
-
Type.prototype.toObject = function toObject(message, options) {
|
|
5176
|
-
return this.setup().toObject(
|
|
5188
|
+
Type.prototype.toObject = function toObject(message, options) { // eslint-disable-line no-unused-vars
|
|
5189
|
+
return this.setup().toObject.apply(this, arguments);
|
|
5177
5190
|
};
|
|
5178
5191
|
|
|
5179
5192
|
/**
|
|
@@ -5428,8 +5441,7 @@ util.fetch = require(29);
|
|
|
5428
5441
|
util.path = require(35);
|
|
5429
5442
|
util.patterns = require(36);
|
|
5430
5443
|
|
|
5431
|
-
var reservedRe = util.patterns.reservedRe
|
|
5432
|
-
unsafePropertyRe = util.patterns.unsafePropertyRe;
|
|
5444
|
+
var reservedRe = util.patterns.reservedRe;
|
|
5433
5445
|
|
|
5434
5446
|
/**
|
|
5435
5447
|
* Node's fs module if available.
|
|
@@ -5592,7 +5604,7 @@ util.decorateEnum = function decorateEnum(object) {
|
|
|
5592
5604
|
util.setProperty = function setProperty(dst, path, value, ifNotSet) {
|
|
5593
5605
|
function setProp(dst, path, value) {
|
|
5594
5606
|
var part = path.shift();
|
|
5595
|
-
if (
|
|
5607
|
+
if (util.isUnsafeProperty(part))
|
|
5596
5608
|
return dst;
|
|
5597
5609
|
if (path.length > 0) {
|
|
5598
5610
|
dst[part] = setProp(dst[part] || {}, path, value);
|
|
@@ -5965,7 +5977,7 @@ function EventEmitter() {
|
|
|
5965
5977
|
* @type {Object.<string,*>}
|
|
5966
5978
|
* @private
|
|
5967
5979
|
*/
|
|
5968
|
-
this._listeners =
|
|
5980
|
+
this._listeners = Object.create(null);
|
|
5969
5981
|
}
|
|
5970
5982
|
|
|
5971
5983
|
/**
|
|
@@ -5999,12 +6011,14 @@ EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
|
5999
6011
|
*/
|
|
6000
6012
|
EventEmitter.prototype.off = function off(evt, fn) {
|
|
6001
6013
|
if (evt === undefined)
|
|
6002
|
-
this._listeners =
|
|
6014
|
+
this._listeners = Object.create(null);
|
|
6003
6015
|
else {
|
|
6004
6016
|
if (fn === undefined)
|
|
6005
6017
|
this._listeners[evt] = [];
|
|
6006
6018
|
else {
|
|
6007
6019
|
var listeners = this._listeners[evt];
|
|
6020
|
+
if (!listeners)
|
|
6021
|
+
return this;
|
|
6008
6022
|
for (var i = 0; i < listeners.length;)
|
|
6009
6023
|
if (listeners[i].fn === fn)
|
|
6010
6024
|
listeners.splice(i, 1);
|
|
@@ -6768,6 +6782,18 @@ util.pool = require(37);
|
|
|
6768
6782
|
// utility to work with the low and high bits of a 64 bit value
|
|
6769
6783
|
util.LongBits = require(33);
|
|
6770
6784
|
|
|
6785
|
+
/**
|
|
6786
|
+
* Tests if the specified key can affect object prototypes.
|
|
6787
|
+
* @memberof util
|
|
6788
|
+
* @param {string} key Key to test
|
|
6789
|
+
* @returns {boolean} `true` if the key is unsafe
|
|
6790
|
+
*/
|
|
6791
|
+
function isUnsafeProperty(key) {
|
|
6792
|
+
return key === "__proto__" || key === "prototype" || key === "constructor";
|
|
6793
|
+
}
|
|
6794
|
+
|
|
6795
|
+
util.isUnsafeProperty = isUnsafeProperty;
|
|
6796
|
+
|
|
6771
6797
|
/**
|
|
6772
6798
|
* Whether running within node or not.
|
|
6773
6799
|
* @memberof util
|
|
@@ -7002,15 +7028,21 @@ util.boolFromKey = function boolFromKey(key) {
|
|
|
7002
7028
|
* Merges the properties of the source object into the destination object.
|
|
7003
7029
|
* @memberof util
|
|
7004
7030
|
* @param {Object.<string,*>} dst Destination object
|
|
7005
|
-
* @param {Object.<string
|
|
7006
|
-
* @param {boolean} [ifNotSet=false] Merges only if the key is not already set
|
|
7031
|
+
* @param {...(Object.<string,*>|boolean)} src Source objects, optionally followed by an `ifNotSet` flag
|
|
7007
7032
|
* @returns {Object.<string,*>} Destination object
|
|
7008
7033
|
*/
|
|
7009
|
-
function merge(dst
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7034
|
+
function merge(dst) { // used by converters
|
|
7035
|
+
var ifNotSet = typeof arguments[arguments.length - 1] === "boolean",
|
|
7036
|
+
limit = ifNotSet ? arguments.length - 1 : arguments.length;
|
|
7037
|
+
ifNotSet = ifNotSet && arguments[arguments.length - 1];
|
|
7038
|
+
for (var a = 1; a < limit; ++a) {
|
|
7039
|
+
var src = arguments[a];
|
|
7040
|
+
if (!src)
|
|
7041
|
+
continue;
|
|
7042
|
+
for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
|
|
7043
|
+
if (!isUnsafeProperty(keys[i]) && (dst[keys[i]] === undefined || !ifNotSet))
|
|
7013
7044
|
dst[keys[i]] = src[keys[i]];
|
|
7045
|
+
}
|
|
7014
7046
|
return dst;
|
|
7015
7047
|
}
|
|
7016
7048
|
|
|
@@ -7324,7 +7356,6 @@ var patterns = exports;
|
|
|
7324
7356
|
patterns.numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;
|
|
7325
7357
|
patterns.typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
|
|
7326
7358
|
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)$/;
|
|
7327
|
-
patterns.unsafePropertyRe = /^(?:__proto__|prototype|constructor)$/;
|
|
7328
7359
|
|
|
7329
7360
|
},{}],37:[function(require,module,exports){
|
|
7330
7361
|
"use strict";
|
|
@@ -7345,7 +7376,7 @@ module.exports = pool;
|
|
|
7345
7376
|
* @param {number} start Start offset
|
|
7346
7377
|
* @param {number} end End offset
|
|
7347
7378
|
* @returns {Uint8Array} Buffer slice
|
|
7348
|
-
* @this
|
|
7379
|
+
* @this Uint8Array
|
|
7349
7380
|
*/
|
|
7350
7381
|
|
|
7351
7382
|
/**
|
|
@@ -7700,7 +7731,8 @@ function verifier(mtype) {
|
|
|
7700
7731
|
*/
|
|
7701
7732
|
var wrappers = exports;
|
|
7702
7733
|
|
|
7703
|
-
var Message = require(10)
|
|
7734
|
+
var Message = require(10),
|
|
7735
|
+
util = require(34);
|
|
7704
7736
|
|
|
7705
7737
|
/**
|
|
7706
7738
|
* From object converter part of an {@link IWrapper}.
|
|
@@ -7747,10 +7779,9 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
7747
7779
|
if (type_url.indexOf("/") === -1) {
|
|
7748
7780
|
type_url = "/" + type_url;
|
|
7749
7781
|
}
|
|
7750
|
-
var nextDepth = depth === undefined ? 1 : depth + 1;
|
|
7751
7782
|
return this.create({
|
|
7752
7783
|
type_url: type_url,
|
|
7753
|
-
value: type.encode(type.fromObject(object,
|
|
7784
|
+
value: type.encode(type.fromObject(object, depth === undefined ? 1 : depth + 1)).finish()
|
|
7754
7785
|
});
|
|
7755
7786
|
}
|
|
7756
7787
|
}
|
|
@@ -7758,13 +7789,16 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
7758
7789
|
return this.fromObject(object, depth);
|
|
7759
7790
|
},
|
|
7760
7791
|
|
|
7761
|
-
toObject: function(message, options) {
|
|
7792
|
+
toObject: function(message, options, depth) {
|
|
7793
|
+
if (depth === undefined)
|
|
7794
|
+
depth = 0;
|
|
7795
|
+
if (depth > util.recursionLimit)
|
|
7796
|
+
throw Error("max depth exceeded");
|
|
7762
7797
|
|
|
7763
7798
|
// Default prefix
|
|
7764
7799
|
var googleApi = "type.googleapis.com/";
|
|
7765
7800
|
var prefix = "";
|
|
7766
7801
|
var name = "";
|
|
7767
|
-
|
|
7768
7802
|
// decode value if requested and unmapped
|
|
7769
7803
|
if (options && options.json && message.type_url && message.value) {
|
|
7770
7804
|
// Only use fully qualified type name after the last '/'
|
|
@@ -7774,12 +7808,12 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
7774
7808
|
var type = this.lookup(name);
|
|
7775
7809
|
/* istanbul ignore else */
|
|
7776
7810
|
if (type)
|
|
7777
|
-
message = type.decode(message.value);
|
|
7811
|
+
message = type.decode(message.value, undefined, undefined, depth + 1);
|
|
7778
7812
|
}
|
|
7779
7813
|
|
|
7780
7814
|
// wrap value if unmapped
|
|
7781
7815
|
if (!(message instanceof this.ctor) && message instanceof Message) {
|
|
7782
|
-
var object = message.$type.toObject(message, options);
|
|
7816
|
+
var object = message.$type.toObject(message, options, depth + 1);
|
|
7783
7817
|
var messageName = message.$type.fullName[0] === "." ?
|
|
7784
7818
|
message.$type.fullName.slice(1) : message.$type.fullName;
|
|
7785
7819
|
// Default to type.googleapis.com prefix if no prefix is used
|
|
@@ -7791,11 +7825,11 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
7791
7825
|
return object;
|
|
7792
7826
|
}
|
|
7793
7827
|
|
|
7794
|
-
return this.toObject(message, options);
|
|
7828
|
+
return this.toObject(message, options, depth);
|
|
7795
7829
|
}
|
|
7796
7830
|
};
|
|
7797
7831
|
|
|
7798
|
-
},{"10":10}],41:[function(require,module,exports){
|
|
7832
|
+
},{"10":10,"34":34}],41:[function(require,module,exports){
|
|
7799
7833
|
"use strict";
|
|
7800
7834
|
module.exports = Writer;
|
|
7801
7835
|
|