protobufjs 7.5.6 → 7.5.8
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/dist/light/protobuf.js +39 -13
- 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 +2 -2
- package/dist/minimal/protobuf.min.js +2 -2
- package/dist/protobuf.js +74 -43
- 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 +18 -5
- package/package.json +1 -1
- package/src/namespace.js +11 -5
- package/src/parse.js +35 -30
- package/src/root.js +4 -2
- package/src/service.js +4 -2
- package/src/type.js +4 -2
- package/src/util.js +14 -0
package/dist/light/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v7.5.
|
|
3
|
-
* compiled tue,
|
|
2
|
+
* protobuf.js v7.5.8 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled tue, 12 may 2026 09:39:59 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -2985,11 +2985,13 @@ var Type, // cyclic
|
|
|
2985
2985
|
* @function
|
|
2986
2986
|
* @param {string} name Namespace name
|
|
2987
2987
|
* @param {Object.<string,*>} json JSON object
|
|
2988
|
+
* @param {number} [depth] Current nesting depth, defaults to `0`
|
|
2988
2989
|
* @returns {Namespace} Created namespace
|
|
2989
2990
|
* @throws {TypeError} If arguments are invalid
|
|
2990
2991
|
*/
|
|
2991
|
-
Namespace.fromJSON = function fromJSON(name, json) {
|
|
2992
|
-
|
|
2992
|
+
Namespace.fromJSON = function fromJSON(name, json, depth) {
|
|
2993
|
+
depth = util.checkDepth(depth);
|
|
2994
|
+
return new Namespace(name, json.options).addJSON(json.nested, depth);
|
|
2993
2995
|
};
|
|
2994
2996
|
|
|
2995
2997
|
/**
|
|
@@ -3147,9 +3149,11 @@ Namespace.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
3147
3149
|
/**
|
|
3148
3150
|
* Adds nested objects to this namespace from nested object descriptors.
|
|
3149
3151
|
* @param {Object.<string,AnyNestedObject>} nestedJson Any nested object descriptors
|
|
3152
|
+
* @param {number} [depth] Current nesting depth, defaults to `0`
|
|
3150
3153
|
* @returns {Namespace} `this`
|
|
3151
3154
|
*/
|
|
3152
|
-
Namespace.prototype.addJSON = function addJSON(nestedJson) {
|
|
3155
|
+
Namespace.prototype.addJSON = function addJSON(nestedJson, depth) {
|
|
3156
|
+
depth = util.checkDepth(depth);
|
|
3153
3157
|
var ns = this;
|
|
3154
3158
|
/* istanbul ignore else */
|
|
3155
3159
|
if (nestedJson) {
|
|
@@ -3164,7 +3168,7 @@ Namespace.prototype.addJSON = function addJSON(nestedJson) {
|
|
|
3164
3168
|
? Service.fromJSON
|
|
3165
3169
|
: nested.id !== undefined
|
|
3166
3170
|
? Field.fromJSON
|
|
3167
|
-
: Namespace.fromJSON )(names[i], nested)
|
|
3171
|
+
: Namespace.fromJSON )(names[i], nested, depth + 1)
|
|
3168
3172
|
);
|
|
3169
3173
|
}
|
|
3170
3174
|
}
|
|
@@ -3422,8 +3426,10 @@ Namespace.prototype._lookupImpl = function lookup(path, flatPath) {
|
|
|
3422
3426
|
// Otherwise try each nested namespace
|
|
3423
3427
|
} else {
|
|
3424
3428
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
3425
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath)))
|
|
3429
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath))) {
|
|
3426
3430
|
exact = found;
|
|
3431
|
+
break;
|
|
3432
|
+
}
|
|
3427
3433
|
}
|
|
3428
3434
|
|
|
3429
3435
|
// Set this even when null, so that when we walk up the tree we can quickly bail on repeated checks back down.
|
|
@@ -4652,14 +4658,16 @@ function Root(options) {
|
|
|
4652
4658
|
* Loads a namespace descriptor into a root namespace.
|
|
4653
4659
|
* @param {INamespace} json Namespace descriptor
|
|
4654
4660
|
* @param {Root} [root] Root namespace, defaults to create a new one if omitted
|
|
4661
|
+
* @param {number} [depth] Current nesting depth, defaults to `0`
|
|
4655
4662
|
* @returns {Root} Root namespace
|
|
4656
4663
|
*/
|
|
4657
|
-
Root.fromJSON = function fromJSON(json, root) {
|
|
4664
|
+
Root.fromJSON = function fromJSON(json, root, depth) {
|
|
4665
|
+
depth = util.checkDepth(depth);
|
|
4658
4666
|
if (!root)
|
|
4659
4667
|
root = new Root();
|
|
4660
4668
|
if (json.options)
|
|
4661
4669
|
root.setOptions(json.options);
|
|
4662
|
-
return root.addJSON(json.nested).resolveAll();
|
|
4670
|
+
return root.addJSON(json.nested, depth).resolveAll();
|
|
4663
4671
|
};
|
|
4664
4672
|
|
|
4665
4673
|
/**
|
|
@@ -5253,17 +5261,19 @@ function Service(name, options) {
|
|
|
5253
5261
|
* Constructs a service from a service descriptor.
|
|
5254
5262
|
* @param {string} name Service name
|
|
5255
5263
|
* @param {IService} json Service descriptor
|
|
5264
|
+
* @param {number} [depth] Current nesting depth, defaults to `0`
|
|
5256
5265
|
* @returns {Service} Created service
|
|
5257
5266
|
* @throws {TypeError} If arguments are invalid
|
|
5258
5267
|
*/
|
|
5259
|
-
Service.fromJSON = function fromJSON(name, json) {
|
|
5268
|
+
Service.fromJSON = function fromJSON(name, json, depth) {
|
|
5269
|
+
depth = util.checkDepth(depth);
|
|
5260
5270
|
var service = new Service(name, json.options);
|
|
5261
5271
|
/* istanbul ignore else */
|
|
5262
5272
|
if (json.methods)
|
|
5263
5273
|
for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i)
|
|
5264
5274
|
service.add(Method.fromJSON(names[i], json.methods[names[i]]));
|
|
5265
5275
|
if (json.nested)
|
|
5266
|
-
service.addJSON(json.nested);
|
|
5276
|
+
service.addJSON(json.nested, depth);
|
|
5267
5277
|
if (json.edition)
|
|
5268
5278
|
service._edition = json.edition;
|
|
5269
5279
|
service.comment = json.comment;
|
|
@@ -5633,9 +5643,11 @@ function clearCache(type) {
|
|
|
5633
5643
|
* Creates a message type from a message type descriptor.
|
|
5634
5644
|
* @param {string} name Message name
|
|
5635
5645
|
* @param {IType} json Message type descriptor
|
|
5646
|
+
* @param {number} [depth] Current nesting depth, defaults to `0`
|
|
5636
5647
|
* @returns {Type} Created message type
|
|
5637
5648
|
*/
|
|
5638
|
-
Type.fromJSON = function fromJSON(name, json) {
|
|
5649
|
+
Type.fromJSON = function fromJSON(name, json, depth) {
|
|
5650
|
+
depth = util.checkDepth(depth);
|
|
5639
5651
|
var type = new Type(name, json.options);
|
|
5640
5652
|
type.extensions = json.extensions;
|
|
5641
5653
|
type.reserved = json.reserved;
|
|
@@ -5662,7 +5674,7 @@ Type.fromJSON = function fromJSON(name, json) {
|
|
|
5662
5674
|
? Enum.fromJSON
|
|
5663
5675
|
: nested.methods !== undefined
|
|
5664
5676
|
? Service.fromJSON
|
|
5665
|
-
: Namespace.fromJSON )(names[i], nested)
|
|
5677
|
+
: Namespace.fromJSON )(names[i], nested, depth + 1)
|
|
5666
5678
|
);
|
|
5667
5679
|
}
|
|
5668
5680
|
if (json.extensions && json.extensions.length)
|
|
@@ -6250,6 +6262,20 @@ var reservedRe = util.patterns.reservedRe,
|
|
|
6250
6262
|
*/
|
|
6251
6263
|
util.fs = util.inquire("fs");
|
|
6252
6264
|
|
|
6265
|
+
/**
|
|
6266
|
+
* Checks a recursion depth.
|
|
6267
|
+
* @param {number|undefined} depth Depth of recursion
|
|
6268
|
+
* @returns {number} Depth of recursion
|
|
6269
|
+
* @throws {Error} If depth exceeds util.recursionLimit
|
|
6270
|
+
*/
|
|
6271
|
+
util.checkDepth = function checkDepth(depth) {
|
|
6272
|
+
if (depth === undefined)
|
|
6273
|
+
depth = 0;
|
|
6274
|
+
if (depth > util.recursionLimit)
|
|
6275
|
+
throw Error("max depth exceeded");
|
|
6276
|
+
return depth;
|
|
6277
|
+
};
|
|
6278
|
+
|
|
6253
6279
|
/**
|
|
6254
6280
|
* Converts an object's values to an array.
|
|
6255
6281
|
* @param {Object.<string,*>} object Object to convert
|