protobufjs 7.5.1 → 7.5.2
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 +75 -15
- 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 +75 -15
- 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 +3 -15
- package/package.json +1 -1
- package/src/namespace.js +41 -9
- package/src/object.js +4 -0
- package/src/root.js +24 -4
- 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.2 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled wed, 14 may 2025 19:25:30 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.2 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled wed, 14 may 2025 19:25:30 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.2 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled wed, 14 may 2025 19:25:30 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -3438,6 +3438,13 @@ function Namespace(name, options) {
|
|
|
3438
3438
|
* @protected
|
|
3439
3439
|
*/
|
|
3440
3440
|
this._needsRecursiveFeatureResolution = true;
|
|
3441
|
+
|
|
3442
|
+
/**
|
|
3443
|
+
* Whether or not objects contained in this namespace need a resolve.
|
|
3444
|
+
* @type {boolean}
|
|
3445
|
+
* @protected
|
|
3446
|
+
*/
|
|
3447
|
+
this._needsRecursiveResolve = true;
|
|
3441
3448
|
}
|
|
3442
3449
|
|
|
3443
3450
|
function clearCache(namespace) {
|
|
@@ -3587,11 +3594,13 @@ Namespace.prototype.add = function add(object) {
|
|
|
3587
3594
|
}
|
|
3588
3595
|
|
|
3589
3596
|
this._needsRecursiveFeatureResolution = true;
|
|
3597
|
+
this._needsRecursiveResolve = true;
|
|
3590
3598
|
|
|
3591
3599
|
// Also clear parent caches, since they need to recurse down.
|
|
3592
3600
|
var parent = this;
|
|
3593
3601
|
while(parent = parent.parent) {
|
|
3594
3602
|
parent._needsRecursiveFeatureResolution = true;
|
|
3603
|
+
parent._needsRecursiveResolve = true;
|
|
3595
3604
|
}
|
|
3596
3605
|
|
|
3597
3606
|
object.onAdd(this);
|
|
@@ -3655,6 +3664,8 @@ Namespace.prototype.define = function define(path, json) {
|
|
|
3655
3664
|
* @returns {Namespace} `this`
|
|
3656
3665
|
*/
|
|
3657
3666
|
Namespace.prototype.resolveAll = function resolveAll() {
|
|
3667
|
+
if (!this._needsRecursiveResolve) return this;
|
|
3668
|
+
|
|
3658
3669
|
var nested = this.nestedArray, i = 0;
|
|
3659
3670
|
this.resolve();
|
|
3660
3671
|
while (i < nested.length)
|
|
@@ -3662,6 +3673,7 @@ Namespace.prototype.resolveAll = function resolveAll() {
|
|
|
3662
3673
|
nested[i++].resolveAll();
|
|
3663
3674
|
else
|
|
3664
3675
|
nested[i++].resolve();
|
|
3676
|
+
this._needsRecursiveResolve = false;
|
|
3665
3677
|
return this;
|
|
3666
3678
|
};
|
|
3667
3679
|
|
|
@@ -3703,29 +3715,47 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
3703
3715
|
} else if (!path.length)
|
|
3704
3716
|
return this;
|
|
3705
3717
|
|
|
3718
|
+
var flatPath = path.join(".");
|
|
3719
|
+
|
|
3706
3720
|
// Start at root if path is absolute
|
|
3707
3721
|
if (path[0] === "")
|
|
3708
3722
|
return this.root.lookup(path.slice(1), filterTypes);
|
|
3709
3723
|
|
|
3710
|
-
|
|
3724
|
+
// Early bailout for objects with matching absolute paths
|
|
3725
|
+
var found = this.root._fullyQualifiedObjects["." + flatPath];
|
|
3726
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3727
|
+
return found;
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
// Do a regular lookup at this namespace and below
|
|
3731
|
+
found = this._lookupImpl(path, flatPath);
|
|
3711
3732
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3712
3733
|
return found;
|
|
3713
3734
|
}
|
|
3714
3735
|
|
|
3715
|
-
|
|
3716
|
-
if (this.parent === null || parentAlreadyChecked)
|
|
3736
|
+
if (parentAlreadyChecked)
|
|
3717
3737
|
return null;
|
|
3718
|
-
|
|
3738
|
+
|
|
3739
|
+
// If there hasn't been a match, walk up the tree and look more broadly
|
|
3740
|
+
var current = this;
|
|
3741
|
+
while (current.parent) {
|
|
3742
|
+
found = current.parent._lookupImpl(path, flatPath);
|
|
3743
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3744
|
+
return found;
|
|
3745
|
+
}
|
|
3746
|
+
current = current.parent;
|
|
3747
|
+
}
|
|
3748
|
+
return null;
|
|
3719
3749
|
};
|
|
3720
3750
|
|
|
3721
3751
|
/**
|
|
3722
3752
|
* Internal helper for lookup that handles searching just at this namespace and below along with caching.
|
|
3723
3753
|
* @param {string[]} path Path to look up
|
|
3754
|
+
* @param {string} flatPath Flattened version of the path to use as a cache key
|
|
3724
3755
|
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
3725
3756
|
* @private
|
|
3726
3757
|
*/
|
|
3727
|
-
Namespace.prototype._lookupImpl = function lookup(path) {
|
|
3728
|
-
var flatPath = path.join(".");
|
|
3758
|
+
Namespace.prototype._lookupImpl = function lookup(path, flatPath) {
|
|
3729
3759
|
if(Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) {
|
|
3730
3760
|
return this._lookupCache[flatPath];
|
|
3731
3761
|
}
|
|
@@ -3736,13 +3766,15 @@ Namespace.prototype._lookupImpl = function lookup(path) {
|
|
|
3736
3766
|
if (found) {
|
|
3737
3767
|
if (path.length === 1) {
|
|
3738
3768
|
exact = found;
|
|
3739
|
-
} else if (found instanceof Namespace
|
|
3740
|
-
|
|
3769
|
+
} else if (found instanceof Namespace) {
|
|
3770
|
+
path = path.slice(1);
|
|
3771
|
+
exact = found._lookupImpl(path, path.join("."));
|
|
3772
|
+
}
|
|
3741
3773
|
|
|
3742
3774
|
// Otherwise try each nested namespace
|
|
3743
3775
|
} else {
|
|
3744
3776
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
3745
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path)))
|
|
3777
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath)))
|
|
3746
3778
|
exact = found;
|
|
3747
3779
|
}
|
|
3748
3780
|
|
|
@@ -3879,6 +3911,7 @@ function ReflectionObject(name, options) {
|
|
|
3879
3911
|
/**
|
|
3880
3912
|
* The edition specified for this object. Only relevant for top-level objects.
|
|
3881
3913
|
* @type {string}
|
|
3914
|
+
* @private
|
|
3882
3915
|
*/
|
|
3883
3916
|
this._edition = null;
|
|
3884
3917
|
|
|
@@ -3886,18 +3919,21 @@ function ReflectionObject(name, options) {
|
|
|
3886
3919
|
* The default edition to use for this object if none is specified. For legacy reasons,
|
|
3887
3920
|
* this is proto2 except in the JSON parsing case where it was proto3.
|
|
3888
3921
|
* @type {string}
|
|
3922
|
+
* @private
|
|
3889
3923
|
*/
|
|
3890
3924
|
this._defaultEdition = "proto2";
|
|
3891
3925
|
|
|
3892
3926
|
/**
|
|
3893
3927
|
* Resolved Features.
|
|
3894
3928
|
* @type {object}
|
|
3929
|
+
* @private
|
|
3895
3930
|
*/
|
|
3896
3931
|
this._features = {};
|
|
3897
3932
|
|
|
3898
3933
|
/**
|
|
3899
3934
|
* Whether or not features have been resolved.
|
|
3900
3935
|
* @type {boolean}
|
|
3936
|
+
* @private
|
|
3901
3937
|
*/
|
|
3902
3938
|
this._featuresResolved = false;
|
|
3903
3939
|
|
|
@@ -5906,8 +5942,19 @@ function Root(options) {
|
|
|
5906
5942
|
*/
|
|
5907
5943
|
this.files = [];
|
|
5908
5944
|
|
|
5909
|
-
|
|
5945
|
+
/**
|
|
5946
|
+
* Edition, defaults to proto2 if unspecified.
|
|
5947
|
+
* @type {string}
|
|
5948
|
+
* @private
|
|
5949
|
+
*/
|
|
5910
5950
|
this._edition = "proto2";
|
|
5951
|
+
|
|
5952
|
+
/**
|
|
5953
|
+
* Global lookup cache of fully qualified names.
|
|
5954
|
+
* @type {Object.<string,ReflectionObject>}
|
|
5955
|
+
* @private
|
|
5956
|
+
*/
|
|
5957
|
+
this._fullyQualifiedObjects = {};
|
|
5911
5958
|
}
|
|
5912
5959
|
|
|
5913
5960
|
/**
|
|
@@ -5921,7 +5968,7 @@ Root.fromJSON = function fromJSON(json, root) {
|
|
|
5921
5968
|
root = new Root();
|
|
5922
5969
|
if (json.options)
|
|
5923
5970
|
root.setOptions(json.options);
|
|
5924
|
-
return root.addJSON(json.nested).
|
|
5971
|
+
return root.addJSON(json.nested).resolveAll();
|
|
5925
5972
|
};
|
|
5926
5973
|
|
|
5927
5974
|
/**
|
|
@@ -5970,7 +6017,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
5970
6017
|
// Finishes loading by calling the callback (exactly once)
|
|
5971
6018
|
function finish(err, root) {
|
|
5972
6019
|
if (root) {
|
|
5973
|
-
root.
|
|
6020
|
+
root.resolveAll();
|
|
5974
6021
|
}
|
|
5975
6022
|
/* istanbul ignore if */
|
|
5976
6023
|
if (!callback) {
|
|
@@ -6089,7 +6136,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6089
6136
|
if (resolved = self.resolvePath("", filename[i]))
|
|
6090
6137
|
fetch(resolved);
|
|
6091
6138
|
if (sync) {
|
|
6092
|
-
self.
|
|
6139
|
+
self.resolveAll();
|
|
6093
6140
|
return self;
|
|
6094
6141
|
}
|
|
6095
6142
|
if (!queued) {
|
|
@@ -6138,6 +6185,8 @@ Root.prototype.loadSync = function loadSync(filename, options) {
|
|
|
6138
6185
|
* @override
|
|
6139
6186
|
*/
|
|
6140
6187
|
Root.prototype.resolveAll = function resolveAll() {
|
|
6188
|
+
if (!this._needsRecursiveResolve) return this;
|
|
6189
|
+
|
|
6141
6190
|
if (this.deferred.length)
|
|
6142
6191
|
throw Error("unresolvable extensions: " + this.deferred.map(function(field) {
|
|
6143
6192
|
return "'extend " + field.extend + "' in " + field.parent.fullName;
|
|
@@ -6205,6 +6254,11 @@ Root.prototype._handleAdd = function _handleAdd(object) {
|
|
|
6205
6254
|
object.parent[object.name] = object; // expose namespace as property of its parent
|
|
6206
6255
|
}
|
|
6207
6256
|
|
|
6257
|
+
if (object instanceof Type || object instanceof Enum || object instanceof Field) {
|
|
6258
|
+
// Only store types and enums for quick lookup during resolve.
|
|
6259
|
+
this._fullyQualifiedObjects[object.fullName] = object;
|
|
6260
|
+
}
|
|
6261
|
+
|
|
6208
6262
|
// The above also adds uppercased (and thus conflict-free) nested types, services and enums as
|
|
6209
6263
|
// properties of namespaces just like static code does. This allows using a .d.ts generated for
|
|
6210
6264
|
// a static module with reflection-based solutions where the condition is met.
|
|
@@ -6245,6 +6299,8 @@ Root.prototype._handleRemove = function _handleRemove(object) {
|
|
|
6245
6299
|
delete object.parent[object.name]; // unexpose namespaces
|
|
6246
6300
|
|
|
6247
6301
|
}
|
|
6302
|
+
|
|
6303
|
+
delete this._fullyQualifiedObjects[object.fullName];
|
|
6248
6304
|
};
|
|
6249
6305
|
|
|
6250
6306
|
// Sets up cyclic dependencies (called in index-light)
|
|
@@ -6569,6 +6625,8 @@ Service.prototype.get = function get(name) {
|
|
|
6569
6625
|
* @override
|
|
6570
6626
|
*/
|
|
6571
6627
|
Service.prototype.resolveAll = function resolveAll() {
|
|
6628
|
+
if (!this._needsRecursiveResolve) return this;
|
|
6629
|
+
|
|
6572
6630
|
Namespace.prototype.resolve.call(this);
|
|
6573
6631
|
var methods = this.methodsArray;
|
|
6574
6632
|
for (var i = 0; i < methods.length; ++i)
|
|
@@ -7369,6 +7427,8 @@ Type.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
7369
7427
|
* @override
|
|
7370
7428
|
*/
|
|
7371
7429
|
Type.prototype.resolveAll = function resolveAll() {
|
|
7430
|
+
if (!this._needsRecursiveResolve) return this;
|
|
7431
|
+
|
|
7372
7432
|
Namespace.prototype.resolveAll.call(this);
|
|
7373
7433
|
var oneofs = this.oneofsArray; i = 0;
|
|
7374
7434
|
while (i < oneofs.length)
|