protobufjs 8.1.0-experimental → 8.1.2-experimental
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 +89 -18
- 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 +89 -18
- 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 +1 -1
- package/src/namespace.js +68 -12
- package/src/object.js +14 -4
- package/src/root.js +1 -0
- 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 v8.1.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.1.2-experimental (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 08 may 2025 17:02:50 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 v8.1.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.1.2-experimental (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 08 may 2025 17:02:51 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 v8.1.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.1.2-experimental (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 08 may 2025 17:02:50 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -3422,10 +3422,33 @@ function Namespace(name, options) {
|
|
|
3422
3422
|
* @private
|
|
3423
3423
|
*/
|
|
3424
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;
|
|
3425
3441
|
}
|
|
3426
3442
|
|
|
3427
3443
|
function clearCache(namespace) {
|
|
3428
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
|
+
}
|
|
3429
3452
|
return namespace;
|
|
3430
3453
|
}
|
|
3431
3454
|
|
|
@@ -3563,6 +3586,14 @@ Namespace.prototype.add = function add(object) {
|
|
|
3563
3586
|
}
|
|
3564
3587
|
}
|
|
3565
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
|
+
|
|
3566
3597
|
object.onAdd(this);
|
|
3567
3598
|
return clearCache(this);
|
|
3568
3599
|
};
|
|
@@ -3638,6 +3669,9 @@ Namespace.prototype.resolveAll = function resolveAll() {
|
|
|
3638
3669
|
* @override
|
|
3639
3670
|
*/
|
|
3640
3671
|
Namespace.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
3672
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
3673
|
+
this._needsRecursiveFeatureResolution = false;
|
|
3674
|
+
|
|
3641
3675
|
edition = this._edition || edition;
|
|
3642
3676
|
|
|
3643
3677
|
ReflectionObject.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
@@ -3655,7 +3689,6 @@ Namespace.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursi
|
|
|
3655
3689
|
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
3656
3690
|
*/
|
|
3657
3691
|
Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) {
|
|
3658
|
-
|
|
3659
3692
|
/* istanbul ignore next */
|
|
3660
3693
|
if (typeof filterTypes === "boolean") {
|
|
3661
3694
|
parentAlreadyChecked = filterTypes;
|
|
@@ -3674,25 +3707,48 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
3674
3707
|
if (path[0] === "")
|
|
3675
3708
|
return this.root.lookup(path.slice(1), filterTypes);
|
|
3676
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
|
+
|
|
3677
3733
|
// Test if the first part matches any nested object, and if so, traverse if path contains more
|
|
3678
3734
|
var found = this.get(path[0]);
|
|
3735
|
+
var exact = null;
|
|
3679
3736
|
if (found) {
|
|
3680
3737
|
if (path.length === 1) {
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
return found;
|
|
3738
|
+
exact = found;
|
|
3739
|
+
} else if (found instanceof Namespace && (found = found._lookupImpl(path.slice(1))))
|
|
3740
|
+
exact = found;
|
|
3685
3741
|
|
|
3686
3742
|
// Otherwise try each nested namespace
|
|
3687
|
-
} else
|
|
3743
|
+
} else {
|
|
3688
3744
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
3689
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].
|
|
3690
|
-
|
|
3745
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path)))
|
|
3746
|
+
exact = found;
|
|
3747
|
+
}
|
|
3691
3748
|
|
|
3692
|
-
//
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
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;
|
|
3696
3752
|
};
|
|
3697
3753
|
|
|
3698
3754
|
/**
|
|
@@ -3839,6 +3895,12 @@ function ReflectionObject(name, options) {
|
|
|
3839
3895
|
*/
|
|
3840
3896
|
this._features = {};
|
|
3841
3897
|
|
|
3898
|
+
/**
|
|
3899
|
+
* Whether or not features have been resolved.
|
|
3900
|
+
* @type {boolean}
|
|
3901
|
+
*/
|
|
3902
|
+
this._featuresResolved = false;
|
|
3903
|
+
|
|
3842
3904
|
/**
|
|
3843
3905
|
* Parent namespace.
|
|
3844
3906
|
* @type {Namespace|null}
|
|
@@ -3944,10 +4006,8 @@ ReflectionObject.prototype.onRemove = function onRemove(parent) {
|
|
|
3944
4006
|
ReflectionObject.prototype.resolve = function resolve() {
|
|
3945
4007
|
if (this.resolved)
|
|
3946
4008
|
return this;
|
|
3947
|
-
if (this instanceof Root)
|
|
3948
|
-
this.
|
|
3949
|
-
this.resolved = true;
|
|
3950
|
-
}
|
|
4009
|
+
if (this.root instanceof Root)
|
|
4010
|
+
this.resolved = true; // only if part of a root
|
|
3951
4011
|
return this;
|
|
3952
4012
|
};
|
|
3953
4013
|
|
|
@@ -3966,6 +4026,10 @@ ReflectionObject.prototype._resolveFeaturesRecursive = function _resolveFeatures
|
|
|
3966
4026
|
* @returns {undefined}
|
|
3967
4027
|
*/
|
|
3968
4028
|
ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
4029
|
+
if (this._featuresResolved) {
|
|
4030
|
+
return;
|
|
4031
|
+
}
|
|
4032
|
+
|
|
3969
4033
|
var defaults = {};
|
|
3970
4034
|
|
|
3971
4035
|
/* istanbul ignore if */
|
|
@@ -3989,6 +4053,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
3989
4053
|
throw new Error("Unknown edition: " + edition);
|
|
3990
4054
|
}
|
|
3991
4055
|
this._features = Object.assign(defaults, protoFeatures || {});
|
|
4056
|
+
this._featuresResolved = true;
|
|
3992
4057
|
return;
|
|
3993
4058
|
}
|
|
3994
4059
|
|
|
@@ -4010,6 +4075,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
4010
4075
|
// Sister fields should have the same features as their extensions.
|
|
4011
4076
|
this.extensionField._features = this._features;
|
|
4012
4077
|
}
|
|
4078
|
+
this._featuresResolved = true;
|
|
4013
4079
|
};
|
|
4014
4080
|
|
|
4015
4081
|
/**
|
|
@@ -6072,6 +6138,7 @@ Root.prototype.resolveAll = function resolveAll() {
|
|
|
6072
6138
|
throw Error("unresolvable extensions: " + this.deferred.map(function(field) {
|
|
6073
6139
|
return "'extend " + field.extend + "' in " + field.parent.fullName;
|
|
6074
6140
|
}).join(", "));
|
|
6141
|
+
this._resolveFeaturesRecursive(this._edition);
|
|
6075
6142
|
return Namespace.prototype.resolveAll.call(this);
|
|
6076
6143
|
};
|
|
6077
6144
|
|
|
@@ -6509,6 +6576,8 @@ Service.prototype.resolveAll = function resolveAll() {
|
|
|
6509
6576
|
* @override
|
|
6510
6577
|
*/
|
|
6511
6578
|
Service.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
6579
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
6580
|
+
|
|
6512
6581
|
edition = this._edition || edition;
|
|
6513
6582
|
|
|
6514
6583
|
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
@@ -7310,6 +7379,8 @@ Type.prototype.resolveAll = function resolveAll() {
|
|
|
7310
7379
|
* @override
|
|
7311
7380
|
*/
|
|
7312
7381
|
Type.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
7382
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
7383
|
+
|
|
7313
7384
|
edition = this._edition || edition;
|
|
7314
7385
|
|
|
7315
7386
|
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|