protobufjs 8.1.1-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 +77 -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 +77 -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 +7 -1
- package/package.json +1 -1
- package/src/namespace.js +68 -12
- package/src/object.js +3 -4
- package/src/service.js +2 -0
- package/src/type.js +2 -0
package/dist/light/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
|
*/
|
|
@@ -3007,10 +3007,33 @@ function Namespace(name, options) {
|
|
|
3007
3007
|
* @private
|
|
3008
3008
|
*/
|
|
3009
3009
|
this._nestedArray = null;
|
|
3010
|
+
|
|
3011
|
+
/**
|
|
3012
|
+
* Cache lookup calls for any objects contains anywhere under this namespace.
|
|
3013
|
+
* This drastically speeds up resolve for large cross-linked protos where the same
|
|
3014
|
+
* types are looked up repeatedly.
|
|
3015
|
+
* @type {Object.<string,ReflectionObject|null>}
|
|
3016
|
+
* @private
|
|
3017
|
+
*/
|
|
3018
|
+
this._lookupCache = {};
|
|
3019
|
+
|
|
3020
|
+
/**
|
|
3021
|
+
* Whether or not objects contained in this namespace need feature resolution.
|
|
3022
|
+
* @type {boolean}
|
|
3023
|
+
* @protected
|
|
3024
|
+
*/
|
|
3025
|
+
this._needsRecursiveFeatureResolution = true;
|
|
3010
3026
|
}
|
|
3011
3027
|
|
|
3012
3028
|
function clearCache(namespace) {
|
|
3013
3029
|
namespace._nestedArray = null;
|
|
3030
|
+
namespace._lookupCache = {};
|
|
3031
|
+
|
|
3032
|
+
// Also clear parent caches, since they include nested lookups.
|
|
3033
|
+
var parent = namespace;
|
|
3034
|
+
while(parent = parent.parent) {
|
|
3035
|
+
parent._lookupCache = {};
|
|
3036
|
+
}
|
|
3014
3037
|
return namespace;
|
|
3015
3038
|
}
|
|
3016
3039
|
|
|
@@ -3148,6 +3171,14 @@ Namespace.prototype.add = function add(object) {
|
|
|
3148
3171
|
}
|
|
3149
3172
|
}
|
|
3150
3173
|
|
|
3174
|
+
this._needsRecursiveFeatureResolution = true;
|
|
3175
|
+
|
|
3176
|
+
// Also clear parent caches, since they need to recurse down.
|
|
3177
|
+
var parent = this;
|
|
3178
|
+
while(parent = parent.parent) {
|
|
3179
|
+
parent._needsRecursiveFeatureResolution = true;
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3151
3182
|
object.onAdd(this);
|
|
3152
3183
|
return clearCache(this);
|
|
3153
3184
|
};
|
|
@@ -3223,6 +3254,9 @@ Namespace.prototype.resolveAll = function resolveAll() {
|
|
|
3223
3254
|
* @override
|
|
3224
3255
|
*/
|
|
3225
3256
|
Namespace.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
3257
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
3258
|
+
this._needsRecursiveFeatureResolution = false;
|
|
3259
|
+
|
|
3226
3260
|
edition = this._edition || edition;
|
|
3227
3261
|
|
|
3228
3262
|
ReflectionObject.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
@@ -3240,7 +3274,6 @@ Namespace.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursi
|
|
|
3240
3274
|
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
3241
3275
|
*/
|
|
3242
3276
|
Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) {
|
|
3243
|
-
|
|
3244
3277
|
/* istanbul ignore next */
|
|
3245
3278
|
if (typeof filterTypes === "boolean") {
|
|
3246
3279
|
parentAlreadyChecked = filterTypes;
|
|
@@ -3259,25 +3292,48 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
3259
3292
|
if (path[0] === "")
|
|
3260
3293
|
return this.root.lookup(path.slice(1), filterTypes);
|
|
3261
3294
|
|
|
3295
|
+
var found = this._lookupImpl(path);
|
|
3296
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3297
|
+
return found;
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
// If there hasn't been a match, try again at the parent
|
|
3301
|
+
if (this.parent === null || parentAlreadyChecked)
|
|
3302
|
+
return null;
|
|
3303
|
+
return this.parent.lookup(path, filterTypes);
|
|
3304
|
+
};
|
|
3305
|
+
|
|
3306
|
+
/**
|
|
3307
|
+
* Internal helper for lookup that handles searching just at this namespace and below along with caching.
|
|
3308
|
+
* @param {string[]} path Path to look up
|
|
3309
|
+
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
3310
|
+
* @private
|
|
3311
|
+
*/
|
|
3312
|
+
Namespace.prototype._lookupImpl = function lookup(path) {
|
|
3313
|
+
var flatPath = path.join(".");
|
|
3314
|
+
if(Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) {
|
|
3315
|
+
return this._lookupCache[flatPath];
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3262
3318
|
// Test if the first part matches any nested object, and if so, traverse if path contains more
|
|
3263
3319
|
var found = this.get(path[0]);
|
|
3320
|
+
var exact = null;
|
|
3264
3321
|
if (found) {
|
|
3265
3322
|
if (path.length === 1) {
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
return found;
|
|
3323
|
+
exact = found;
|
|
3324
|
+
} else if (found instanceof Namespace && (found = found._lookupImpl(path.slice(1))))
|
|
3325
|
+
exact = found;
|
|
3270
3326
|
|
|
3271
3327
|
// Otherwise try each nested namespace
|
|
3272
|
-
} else
|
|
3328
|
+
} else {
|
|
3273
3329
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
3274
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].
|
|
3275
|
-
|
|
3330
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path)))
|
|
3331
|
+
exact = found;
|
|
3332
|
+
}
|
|
3276
3333
|
|
|
3277
|
-
//
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
return this.parent.lookup(path, filterTypes);
|
|
3334
|
+
// Set this even when null, so that when we walk up the tree we can quickly bail on repeated checks back down.
|
|
3335
|
+
this._lookupCache[flatPath] = exact;
|
|
3336
|
+
return exact;
|
|
3281
3337
|
};
|
|
3282
3338
|
|
|
3283
3339
|
/**
|
|
@@ -3427,7 +3483,7 @@ function ReflectionObject(name, options) {
|
|
|
3427
3483
|
/**
|
|
3428
3484
|
* Whether or not features have been resolved.
|
|
3429
3485
|
* @type {boolean}
|
|
3430
|
-
|
|
3486
|
+
*/
|
|
3431
3487
|
this._featuresResolved = false;
|
|
3432
3488
|
|
|
3433
3489
|
/**
|
|
@@ -3535,9 +3591,8 @@ ReflectionObject.prototype.onRemove = function onRemove(parent) {
|
|
|
3535
3591
|
ReflectionObject.prototype.resolve = function resolve() {
|
|
3536
3592
|
if (this.resolved)
|
|
3537
3593
|
return this;
|
|
3538
|
-
if (this instanceof Root)
|
|
3539
|
-
this.resolved = true;
|
|
3540
|
-
}
|
|
3594
|
+
if (this.root instanceof Root)
|
|
3595
|
+
this.resolved = true; // only if part of a root
|
|
3541
3596
|
return this;
|
|
3542
3597
|
};
|
|
3543
3598
|
|
|
@@ -5139,6 +5194,8 @@ Service.prototype.resolveAll = function resolveAll() {
|
|
|
5139
5194
|
* @override
|
|
5140
5195
|
*/
|
|
5141
5196
|
Service.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
5197
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
5198
|
+
|
|
5142
5199
|
edition = this._edition || edition;
|
|
5143
5200
|
|
|
5144
5201
|
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
@@ -5522,6 +5579,8 @@ Type.prototype.resolveAll = function resolveAll() {
|
|
|
5522
5579
|
* @override
|
|
5523
5580
|
*/
|
|
5524
5581
|
Type.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
5582
|
+
if (!this._needsRecursiveFeatureResolution) return this;
|
|
5583
|
+
|
|
5525
5584
|
edition = this._edition || edition;
|
|
5526
5585
|
|
|
5527
5586
|
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|