protobufjs 8.4.2 → 8.5.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 +21 -3
- package/dist/light/protobuf.js +53 -17
- 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 +25 -7
- 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 +53 -17
- 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 +22 -9
- package/package.json +3 -2
- package/src/converter.js +4 -2
- package/src/decoder.js +4 -2
- package/src/method.js +16 -2
- package/src/namespace.js +4 -4
- package/src/reader.js +12 -0
- package/src/roots.js +1 -1
- package/src/rpc/service.js +10 -4
package/dist/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.
|
|
3
|
-
* compiled fri,
|
|
2
|
+
* protobuf.js v8.5.0 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled fri, 29 may 2026 22:57:25 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -485,7 +485,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
|
485
485
|
} gen
|
|
486
486
|
("}");
|
|
487
487
|
} else gen
|
|
488
|
-
("if(
|
|
488
|
+
("if(!util.isObject(d%s))", prop)
|
|
489
489
|
("throw TypeError(%j)", field.fullName + ": object expected")
|
|
490
490
|
("m%s=types[%i].fromObject(d%s,q+1)", prop, fieldIndex, prop);
|
|
491
491
|
} else {
|
|
@@ -552,6 +552,8 @@ converter.fromObject = function fromObject(mtype) {
|
|
|
552
552
|
var gen = util.codegen(["d", "q"], mtype.name + "$fromObject")
|
|
553
553
|
("if(d instanceof C)")
|
|
554
554
|
("return d")
|
|
555
|
+
("if(!util.isObject(d))")
|
|
556
|
+
("throw TypeError(%j)", mtype.fullName + ": object expected")
|
|
555
557
|
("if(q===undefined)q=0")
|
|
556
558
|
("if(q>util.recursionLimit)")
|
|
557
559
|
("throw Error(\"max depth exceeded\")");
|
|
@@ -568,7 +570,7 @@ converter.fromObject = function fromObject(mtype) {
|
|
|
568
570
|
// Map fields
|
|
569
571
|
if (field.map) { gen
|
|
570
572
|
("if(d%s){", prop)
|
|
571
|
-
("if(
|
|
573
|
+
("if(!util.isObject(d%s))", prop)
|
|
572
574
|
("throw TypeError(%j)", field.fullName + ": object expected")
|
|
573
575
|
("m%s={}", prop)
|
|
574
576
|
("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){", prop);
|
|
@@ -973,8 +975,10 @@ function decoder(mtype) {
|
|
|
973
975
|
// Unknown fields
|
|
974
976
|
gen
|
|
975
977
|
("r.skipType(%s,q,t)", i ? "u" : "t&7")
|
|
976
|
-
("
|
|
977
|
-
|
|
978
|
+
("if(!r.discardUnknown){")
|
|
979
|
+
("util.makeProp(m,\"$unknowns\",false);")
|
|
980
|
+
("(m.$unknowns||(m.$unknowns=[])).push(r.raw(s,r.pos))")
|
|
981
|
+
("}")
|
|
978
982
|
("}")
|
|
979
983
|
("if(z!==undefined)")
|
|
980
984
|
("throw Error(\"missing end group\")");
|
|
@@ -2285,7 +2289,7 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
|
|
|
2285
2289
|
|
|
2286
2290
|
/**
|
|
2287
2291
|
* Whether requests are streamed or not.
|
|
2288
|
-
* @type {
|
|
2292
|
+
* @type {true|undefined}
|
|
2289
2293
|
*/
|
|
2290
2294
|
this.requestStream = requestStream ? true : undefined; // toJSON
|
|
2291
2295
|
|
|
@@ -2297,10 +2301,16 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
|
|
|
2297
2301
|
|
|
2298
2302
|
/**
|
|
2299
2303
|
* Whether responses are streamed or not.
|
|
2300
|
-
* @type {
|
|
2304
|
+
* @type {true|undefined}
|
|
2301
2305
|
*/
|
|
2302
2306
|
this.responseStream = responseStream ? true : undefined; // toJSON
|
|
2303
2307
|
|
|
2308
|
+
/**
|
|
2309
|
+
* gRPC-style method path.
|
|
2310
|
+
* @type {string}
|
|
2311
|
+
*/
|
|
2312
|
+
this.path = "/" + this.name;
|
|
2313
|
+
|
|
2304
2314
|
/**
|
|
2305
2315
|
* Resolved request type.
|
|
2306
2316
|
* @type {Type|null}
|
|
@@ -2378,6 +2388,14 @@ Method.prototype.resolve = function resolve() {
|
|
|
2378
2388
|
if (this.resolved)
|
|
2379
2389
|
return this;
|
|
2380
2390
|
|
|
2391
|
+
if (this.parent) {
|
|
2392
|
+
var serviceName = this.parent.fullName;
|
|
2393
|
+
if (serviceName.charAt(0) === ".")
|
|
2394
|
+
serviceName = serviceName.substring(1);
|
|
2395
|
+
this.path = "/" + serviceName + "/" + this.name;
|
|
2396
|
+
} else
|
|
2397
|
+
this.path = "/" + this.name;
|
|
2398
|
+
|
|
2381
2399
|
this.resolvedRequestType = this.parent.lookupType(this.requestType);
|
|
2382
2400
|
this.resolvedResponseType = this.parent.lookupType(this.responseType);
|
|
2383
2401
|
|
|
@@ -2813,14 +2831,14 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
2813
2831
|
if (path[0] === "")
|
|
2814
2832
|
return this.root.lookup(path.slice(1), filterTypes);
|
|
2815
2833
|
|
|
2816
|
-
//
|
|
2817
|
-
var found = this.
|
|
2834
|
+
// Lookup at this namespace and below
|
|
2835
|
+
var found = this._lookupImpl(path, flatPath);
|
|
2818
2836
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
2819
2837
|
return found;
|
|
2820
2838
|
}
|
|
2821
2839
|
|
|
2822
|
-
//
|
|
2823
|
-
found = this.
|
|
2840
|
+
// Fall back to respective absolute path once relative scope has been checked (non-standard)
|
|
2841
|
+
found = this.root._fullyQualifiedObjects && this.root._fullyQualifiedObjects["." + flatPath];
|
|
2824
2842
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
2825
2843
|
return found;
|
|
2826
2844
|
}
|
|
@@ -4659,6 +4677,12 @@ function Reader(buffer) {
|
|
|
4659
4677
|
* @type {number}
|
|
4660
4678
|
*/
|
|
4661
4679
|
this.len = buffer.length;
|
|
4680
|
+
|
|
4681
|
+
/**
|
|
4682
|
+
* Whether to discard unknown fields while decoding.
|
|
4683
|
+
* @type {boolean}
|
|
4684
|
+
*/
|
|
4685
|
+
this.discardUnknown = Reader.discardUnknown;
|
|
4662
4686
|
}
|
|
4663
4687
|
|
|
4664
4688
|
var create_array = typeof Uint8Array !== "undefined"
|
|
@@ -5071,6 +5095,12 @@ Reader.prototype.skip = function skip(length) {
|
|
|
5071
5095
|
*/
|
|
5072
5096
|
Reader.recursionLimit = util.recursionLimit;
|
|
5073
5097
|
|
|
5098
|
+
/**
|
|
5099
|
+
* Whether readers discard unknown fields while decoding.
|
|
5100
|
+
* @type {boolean}
|
|
5101
|
+
*/
|
|
5102
|
+
Reader.discardUnknown = false;
|
|
5103
|
+
|
|
5074
5104
|
/**
|
|
5075
5105
|
* Skips the next element of the specified wire type.
|
|
5076
5106
|
* @param {number} wireType Wire type received
|
|
@@ -5645,7 +5675,7 @@ Root._configure = function(Type_, parse_, common_) {
|
|
|
5645
5675
|
|
|
5646
5676
|
},{"14":14,"16":16,"28":28,"6":6,"7":7}],21:[function(require,module,exports){
|
|
5647
5677
|
"use strict";
|
|
5648
|
-
module.exports =
|
|
5678
|
+
module.exports = Object.create(null);
|
|
5649
5679
|
|
|
5650
5680
|
/**
|
|
5651
5681
|
* Named roots.
|
|
@@ -5727,10 +5757,16 @@ var util = require(38);
|
|
|
5727
5757
|
* @typedef rpc.ServiceMethod
|
|
5728
5758
|
* @template TReq extends Message<TReq>
|
|
5729
5759
|
* @template TRes extends Message<TRes>
|
|
5730
|
-
* @type {
|
|
5731
|
-
*
|
|
5732
|
-
*
|
|
5733
|
-
*
|
|
5760
|
+
* @type {{
|
|
5761
|
+
* (request: TReq|Properties<TReq>, callback: rpc.ServiceMethodCallback<TRes>): void;
|
|
5762
|
+
* (request: TReq|Properties<TReq>): Promise<TRes>;
|
|
5763
|
+
* readonly name: string;
|
|
5764
|
+
* readonly path: string;
|
|
5765
|
+
* readonly requestType: string;
|
|
5766
|
+
* readonly responseType: string;
|
|
5767
|
+
* readonly requestStream: true|undefined;
|
|
5768
|
+
* readonly responseStream: true|undefined;
|
|
5769
|
+
* }}
|
|
5734
5770
|
*/
|
|
5735
5771
|
|
|
5736
5772
|
/**
|