protobufjs 7.5.0 → 7.5.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/dist/light/protobuf.js +103 -26
- 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 +107 -26
- 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 +6 -0
- package/package.json +4 -2
- package/src/field.js +9 -3
- package/src/namespace.js +68 -12
- package/src/object.js +14 -4
- package/src/parse.js +4 -0
- package/src/root.js +6 -5
- package/src/service.js +2 -0
- package/src/type.js +2 -0
package/dist/minimal/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v7.5.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v7.5.1 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 08 may 2025 17:34:56 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v7.5.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v7.5.1 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 08 may 2025 17:34:56 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
package/dist/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v7.5.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v7.5.1 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 08 may 2025 17:34:56 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -2641,12 +2641,18 @@ Field.prototype._inferLegacyProtoFeatures = function _inferLegacyProtoFeatures(e
|
|
|
2641
2641
|
}
|
|
2642
2642
|
|
|
2643
2643
|
var features = {};
|
|
2644
|
-
|
|
2644
|
+
|
|
2645
2645
|
if (this.rule === "required") {
|
|
2646
2646
|
features.field_presence = "LEGACY_REQUIRED";
|
|
2647
2647
|
}
|
|
2648
|
-
if (this.
|
|
2649
|
-
|
|
2648
|
+
if (this.parent && types.defaults[this.type] === undefined) {
|
|
2649
|
+
// We can't use resolvedType because types may not have been resolved yet. However,
|
|
2650
|
+
// legacy groups are always in the same scope as the field so we don't have to do a
|
|
2651
|
+
// full scan of the tree.
|
|
2652
|
+
var type = this.parent.get(this.type.split(".").pop());
|
|
2653
|
+
if (type && type instanceof Type && type.group) {
|
|
2654
|
+
features.message_encoding = "DELIMITED";
|
|
2655
|
+
}
|
|
2650
2656
|
}
|
|
2651
2657
|
if (this.getOption("packed") === true) {
|
|
2652
2658
|
features.repeated_field_encoding = "PACKED";
|
|
@@ -3416,10 +3422,33 @@ function Namespace(name, options) {
|
|
|
3416
3422
|
* @private
|
|
3417
3423
|
*/
|
|
3418
3424
|
this._nestedArray = null;
|
|
3425
|
+
|
|
3426
|
+
/**
|
|
3427
|
+
* Cache lookup calls for any objects contains anywhere under this namespace.
|
|
3428
|
+
* This drastically speeds up resolve for large cross-linked protos where the same
|
|
3429
|
+
* types are looked up repeatedly.
|
|
3430
|
+
* @type {Object.<string,ReflectionObject|null>}
|
|
3431
|
+
* @private
|
|
3432
|
+
*/
|
|
3433
|
+
this._lookupCache = {};
|
|
3434
|
+
|
|
3435
|
+
/**
|
|
3436
|
+
* Whether or not objects contained in this namespace need feature resolution.
|
|
3437
|
+
* @type {boolean}
|
|
3438
|
+
* @protected
|
|
3439
|
+
*/
|
|
3440
|
+
this._needsRecursiveFeatureResolution = true;
|
|
3419
3441
|
}
|
|
3420
3442
|
|
|
3421
3443
|
function clearCache(namespace) {
|
|
3422
3444
|
namespace._nestedArray = null;
|
|
3445
|
+
namespace._lookupCache = {};
|
|
3446
|
+
|
|
3447
|
+
// Also clear parent caches, since they include nested lookups.
|
|
3448
|
+
var parent = namespace;
|
|
3449
|
+
while(parent = parent.parent) {
|
|
3450
|
+
parent._lookupCache = {};
|
|
3451
|
+
}
|
|
3423
3452
|
return namespace;
|
|
3424
3453
|
}
|
|
3425
3454
|
|
|
@@ -3557,6 +3586,14 @@ Namespace.prototype.add = function add(object) {
|
|
|
3557
3586
|
}
|
|
3558
3587
|
}
|
|
3559
3588
|
|
|
3589
|
+
this._needsRecursiveFeatureResolution = true;
|
|
3590
|
+
|
|
3591
|
+
// Also clear parent caches, since they need to recurse down.
|
|
3592
|
+
var parent = this;
|
|
3593
|
+
while(parent = parent.parent) {
|
|
3594
|
+
parent._needsRecursiveFeatureResolution = true;
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3560
3597
|
object.onAdd(this);
|
|
3561
3598
|
return clearCache(this);
|
|
3562
3599
|
};
|
|
@@ -3632,6 +3669,9 @@ Namespace.prototype.resolveAll = function resolveAll() {
|
|
|
3632
3669
|
* @override
|
|
3633
3670
|
*/
|
|
3634
3671
|
Namespace.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
3672
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
3673
|
+
this._needsRecursiveFeatureResolution = false;
|
|
3674
|
+
|
|
3635
3675
|
edition = this._edition || edition;
|
|
3636
3676
|
|
|
3637
3677
|
ReflectionObject.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
@@ -3649,7 +3689,6 @@ Namespace.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursi
|
|
|
3649
3689
|
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
3650
3690
|
*/
|
|
3651
3691
|
Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) {
|
|
3652
|
-
|
|
3653
3692
|
/* istanbul ignore next */
|
|
3654
3693
|
if (typeof filterTypes === "boolean") {
|
|
3655
3694
|
parentAlreadyChecked = filterTypes;
|
|
@@ -3668,25 +3707,48 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
3668
3707
|
if (path[0] === "")
|
|
3669
3708
|
return this.root.lookup(path.slice(1), filterTypes);
|
|
3670
3709
|
|
|
3710
|
+
var found = this._lookupImpl(path);
|
|
3711
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3712
|
+
return found;
|
|
3713
|
+
}
|
|
3714
|
+
|
|
3715
|
+
// If there hasn't been a match, try again at the parent
|
|
3716
|
+
if (this.parent === null || parentAlreadyChecked)
|
|
3717
|
+
return null;
|
|
3718
|
+
return this.parent.lookup(path, filterTypes);
|
|
3719
|
+
};
|
|
3720
|
+
|
|
3721
|
+
/**
|
|
3722
|
+
* Internal helper for lookup that handles searching just at this namespace and below along with caching.
|
|
3723
|
+
* @param {string[]} path Path to look up
|
|
3724
|
+
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
3725
|
+
* @private
|
|
3726
|
+
*/
|
|
3727
|
+
Namespace.prototype._lookupImpl = function lookup(path) {
|
|
3728
|
+
var flatPath = path.join(".");
|
|
3729
|
+
if(Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) {
|
|
3730
|
+
return this._lookupCache[flatPath];
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3671
3733
|
// Test if the first part matches any nested object, and if so, traverse if path contains more
|
|
3672
3734
|
var found = this.get(path[0]);
|
|
3735
|
+
var exact = null;
|
|
3673
3736
|
if (found) {
|
|
3674
3737
|
if (path.length === 1) {
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
return found;
|
|
3738
|
+
exact = found;
|
|
3739
|
+
} else if (found instanceof Namespace && (found = found._lookupImpl(path.slice(1))))
|
|
3740
|
+
exact = found;
|
|
3679
3741
|
|
|
3680
3742
|
// Otherwise try each nested namespace
|
|
3681
|
-
} else
|
|
3743
|
+
} else {
|
|
3682
3744
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
3683
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].
|
|
3684
|
-
|
|
3745
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path)))
|
|
3746
|
+
exact = found;
|
|
3747
|
+
}
|
|
3685
3748
|
|
|
3686
|
-
//
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
return this.parent.lookup(path, filterTypes);
|
|
3749
|
+
// Set this even when null, so that when we walk up the tree we can quickly bail on repeated checks back down.
|
|
3750
|
+
this._lookupCache[flatPath] = exact;
|
|
3751
|
+
return exact;
|
|
3690
3752
|
};
|
|
3691
3753
|
|
|
3692
3754
|
/**
|
|
@@ -3833,6 +3895,12 @@ function ReflectionObject(name, options) {
|
|
|
3833
3895
|
*/
|
|
3834
3896
|
this._features = {};
|
|
3835
3897
|
|
|
3898
|
+
/**
|
|
3899
|
+
* Whether or not features have been resolved.
|
|
3900
|
+
* @type {boolean}
|
|
3901
|
+
*/
|
|
3902
|
+
this._featuresResolved = false;
|
|
3903
|
+
|
|
3836
3904
|
/**
|
|
3837
3905
|
* Parent namespace.
|
|
3838
3906
|
* @type {Namespace|null}
|
|
@@ -3938,10 +4006,8 @@ ReflectionObject.prototype.onRemove = function onRemove(parent) {
|
|
|
3938
4006
|
ReflectionObject.prototype.resolve = function resolve() {
|
|
3939
4007
|
if (this.resolved)
|
|
3940
4008
|
return this;
|
|
3941
|
-
if (this instanceof Root)
|
|
3942
|
-
this.
|
|
3943
|
-
this.resolved = true;
|
|
3944
|
-
}
|
|
4009
|
+
if (this.root instanceof Root)
|
|
4010
|
+
this.resolved = true; // only if part of a root
|
|
3945
4011
|
return this;
|
|
3946
4012
|
};
|
|
3947
4013
|
|
|
@@ -3960,6 +4026,10 @@ ReflectionObject.prototype._resolveFeaturesRecursive = function _resolveFeatures
|
|
|
3960
4026
|
* @returns {undefined}
|
|
3961
4027
|
*/
|
|
3962
4028
|
ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
4029
|
+
if (this._featuresResolved) {
|
|
4030
|
+
return;
|
|
4031
|
+
}
|
|
4032
|
+
|
|
3963
4033
|
var defaults = {};
|
|
3964
4034
|
|
|
3965
4035
|
/* istanbul ignore if */
|
|
@@ -3983,6 +4053,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
3983
4053
|
throw new Error("Unknown edition: " + edition);
|
|
3984
4054
|
}
|
|
3985
4055
|
this._features = Object.assign(defaults, protoFeatures || {});
|
|
4056
|
+
this._featuresResolved = true;
|
|
3986
4057
|
return;
|
|
3987
4058
|
}
|
|
3988
4059
|
|
|
@@ -4004,6 +4075,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
4004
4075
|
// Sister fields should have the same features as their extensions.
|
|
4005
4076
|
this.extensionField._features = this._features;
|
|
4006
4077
|
}
|
|
4078
|
+
this._featuresResolved = true;
|
|
4007
4079
|
};
|
|
4008
4080
|
|
|
4009
4081
|
/**
|
|
@@ -4879,6 +4951,10 @@ function parse(source, root, options) {
|
|
|
4879
4951
|
parseEnum(type, token);
|
|
4880
4952
|
break;
|
|
4881
4953
|
|
|
4954
|
+
case "reserved":
|
|
4955
|
+
readRanges(type.reserved || (type.reserved = []), true);
|
|
4956
|
+
break;
|
|
4957
|
+
|
|
4882
4958
|
/* istanbul ignore next */
|
|
4883
4959
|
default:
|
|
4884
4960
|
throw illegal(token); // there are no groups with proto3 semantics
|
|
@@ -5845,7 +5921,7 @@ Root.fromJSON = function fromJSON(json, root) {
|
|
|
5845
5921
|
root = new Root();
|
|
5846
5922
|
if (json.options)
|
|
5847
5923
|
root.setOptions(json.options);
|
|
5848
|
-
return root.addJSON(json.nested).
|
|
5924
|
+
return root.addJSON(json.nested)._resolveFeaturesRecursive();
|
|
5849
5925
|
};
|
|
5850
5926
|
|
|
5851
5927
|
/**
|
|
@@ -5893,6 +5969,9 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5893
5969
|
|
|
5894
5970
|
// Finishes loading by calling the callback (exactly once)
|
|
5895
5971
|
function finish(err, root) {
|
|
5972
|
+
if (root) {
|
|
5973
|
+
root._resolveFeaturesRecursive();
|
|
5974
|
+
}
|
|
5896
5975
|
/* istanbul ignore if */
|
|
5897
5976
|
if (!callback) {
|
|
5898
5977
|
return;
|
|
@@ -5902,9 +5981,6 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5902
5981
|
}
|
|
5903
5982
|
var cb = callback;
|
|
5904
5983
|
callback = null;
|
|
5905
|
-
if (root) {
|
|
5906
|
-
root.resolveAll();
|
|
5907
|
-
}
|
|
5908
5984
|
cb(err, root);
|
|
5909
5985
|
}
|
|
5910
5986
|
|
|
@@ -6012,8 +6088,8 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6012
6088
|
for (var i = 0, resolved; i < filename.length; ++i)
|
|
6013
6089
|
if (resolved = self.resolvePath("", filename[i]))
|
|
6014
6090
|
fetch(resolved);
|
|
6015
|
-
self.resolveAll();
|
|
6016
6091
|
if (sync) {
|
|
6092
|
+
self._resolveFeaturesRecursive();
|
|
6017
6093
|
return self;
|
|
6018
6094
|
}
|
|
6019
6095
|
if (!queued) {
|
|
@@ -6066,6 +6142,7 @@ Root.prototype.resolveAll = function resolveAll() {
|
|
|
6066
6142
|
throw Error("unresolvable extensions: " + this.deferred.map(function(field) {
|
|
6067
6143
|
return "'extend " + field.extend + "' in " + field.parent.fullName;
|
|
6068
6144
|
}).join(", "));
|
|
6145
|
+
this._resolveFeaturesRecursive(this._edition);
|
|
6069
6146
|
return Namespace.prototype.resolveAll.call(this);
|
|
6070
6147
|
};
|
|
6071
6148
|
|
|
@@ -6503,6 +6580,8 @@ Service.prototype.resolveAll = function resolveAll() {
|
|
|
6503
6580
|
* @override
|
|
6504
6581
|
*/
|
|
6505
6582
|
Service.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
6583
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
6584
|
+
|
|
6506
6585
|
edition = this._edition || edition;
|
|
6507
6586
|
|
|
6508
6587
|
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
@@ -7304,6 +7383,8 @@ Type.prototype.resolveAll = function resolveAll() {
|
|
|
7304
7383
|
* @override
|
|
7305
7384
|
*/
|
|
7306
7385
|
Type.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
7386
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
7387
|
+
|
|
7307
7388
|
edition = this._edition || edition;
|
|
7308
7389
|
|
|
7309
7390
|
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|