protobufjs
Advanced tools
Comparing version
/*! | ||
* protobuf.js v7.5.1 (c) 2016, daniel wirtz | ||
* compiled thu, 08 may 2025 17:34:56 utc | ||
* protobuf.js v7.5.2 (c) 2016, daniel wirtz | ||
* compiled wed, 14 may 2025 19:25:30 utc | ||
* licensed under the bsd-3-clause license | ||
@@ -5,0 +5,0 @@ * see: https://github.com/dcodeio/protobuf.js for details |
{ | ||
"name": "protobufjs", | ||
"version": "7.5.1", | ||
"version": "7.5.2", | ||
"versionScheme": "~", | ||
@@ -5,0 +5,0 @@ "description": "Protocol Buffers for JavaScript (& TypeScript).", |
@@ -127,2 +127,9 @@ "use strict"; | ||
this._needsRecursiveFeatureResolution = true; | ||
/** | ||
* Whether or not objects contained in this namespace need a resolve. | ||
* @type {boolean} | ||
* @protected | ||
*/ | ||
this._needsRecursiveResolve = true; | ||
} | ||
@@ -277,2 +284,3 @@ | ||
this._needsRecursiveFeatureResolution = true; | ||
this._needsRecursiveResolve = true; | ||
@@ -283,2 +291,3 @@ // Also clear parent caches, since they need to recurse down. | ||
parent._needsRecursiveFeatureResolution = true; | ||
parent._needsRecursiveResolve = true; | ||
} | ||
@@ -347,2 +356,4 @@ | ||
Namespace.prototype.resolveAll = function resolveAll() { | ||
if (!this._needsRecursiveResolve) return this; | ||
var nested = this.nestedArray, i = 0; | ||
@@ -355,2 +366,3 @@ this.resolve(); | ||
nested[i++].resolve(); | ||
this._needsRecursiveResolve = false; | ||
return this; | ||
@@ -397,2 +409,4 @@ }; | ||
var flatPath = path.join("."); | ||
// Start at root if path is absolute | ||
@@ -402,3 +416,4 @@ if (path[0] === "") | ||
var found = this._lookupImpl(path); | ||
// Early bailout for objects with matching absolute paths | ||
var found = this.root._fullyQualifiedObjects["." + flatPath]; | ||
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) { | ||
@@ -408,6 +423,21 @@ return found; | ||
// If there hasn't been a match, try again at the parent | ||
if (this.parent === null || parentAlreadyChecked) | ||
// Do a regular lookup at this namespace and below | ||
found = this._lookupImpl(path, flatPath); | ||
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) { | ||
return found; | ||
} | ||
if (parentAlreadyChecked) | ||
return null; | ||
return this.parent.lookup(path, filterTypes); | ||
// If there hasn't been a match, walk up the tree and look more broadly | ||
var current = this; | ||
while (current.parent) { | ||
found = current.parent._lookupImpl(path, flatPath); | ||
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) { | ||
return found; | ||
} | ||
current = current.parent; | ||
} | ||
return null; | ||
}; | ||
@@ -418,7 +448,7 @@ | ||
* @param {string[]} path Path to look up | ||
* @param {string} flatPath Flattened version of the path to use as a cache key | ||
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found | ||
* @private | ||
*/ | ||
Namespace.prototype._lookupImpl = function lookup(path) { | ||
var flatPath = path.join("."); | ||
Namespace.prototype._lookupImpl = function lookup(path, flatPath) { | ||
if(Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) { | ||
@@ -434,4 +464,6 @@ return this._lookupCache[flatPath]; | ||
exact = found; | ||
} else if (found instanceof Namespace && (found = found._lookupImpl(path.slice(1)))) | ||
exact = found; | ||
} else if (found instanceof Namespace) { | ||
path = path.slice(1); | ||
exact = found._lookupImpl(path, path.join(".")); | ||
} | ||
@@ -441,3 +473,3 @@ // Otherwise try each nested namespace | ||
for (var i = 0; i < this.nestedArray.length; ++i) | ||
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path))) | ||
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath))) | ||
exact = found; | ||
@@ -444,0 +476,0 @@ } |
@@ -54,2 +54,3 @@ "use strict"; | ||
* @type {string} | ||
* @private | ||
*/ | ||
@@ -62,2 +63,3 @@ this._edition = null; | ||
* @type {string} | ||
* @private | ||
*/ | ||
@@ -69,2 +71,3 @@ this._defaultEdition = "proto2"; | ||
* @type {object} | ||
* @private | ||
*/ | ||
@@ -76,2 +79,3 @@ this._features = {}; | ||
* @type {boolean} | ||
* @private | ||
*/ | ||
@@ -78,0 +82,0 @@ this._featuresResolved = false; |
@@ -39,4 +39,15 @@ "use strict"; | ||
// Default to proto2 if unspecified. | ||
/** | ||
* Edition, defaults to proto2 if unspecified. | ||
* @type {string} | ||
* @private | ||
*/ | ||
this._edition = "proto2"; | ||
/** | ||
* Global lookup cache of fully qualified names. | ||
* @type {Object.<string,ReflectionObject>} | ||
* @private | ||
*/ | ||
this._fullyQualifiedObjects = {}; | ||
} | ||
@@ -55,3 +66,3 @@ | ||
root.setOptions(json.options); | ||
return root.addJSON(json.nested)._resolveFeaturesRecursive(); | ||
return root.addJSON(json.nested).resolveAll(); | ||
}; | ||
@@ -105,3 +116,3 @@ | ||
if (root) { | ||
root._resolveFeaturesRecursive(); | ||
root.resolveAll(); | ||
} | ||
@@ -225,3 +236,3 @@ /* istanbul ignore if */ | ||
if (sync) { | ||
self._resolveFeaturesRecursive(); | ||
self.resolveAll(); | ||
return self; | ||
@@ -275,2 +286,4 @@ } | ||
Root.prototype.resolveAll = function resolveAll() { | ||
if (!this._needsRecursiveResolve) return this; | ||
if (this.deferred.length) | ||
@@ -343,2 +356,7 @@ throw Error("unresolvable extensions: " + this.deferred.map(function(field) { | ||
if (object instanceof Type || object instanceof Enum || object instanceof Field) { | ||
// Only store types and enums for quick lookup during resolve. | ||
this._fullyQualifiedObjects[object.fullName] = object; | ||
} | ||
// The above also adds uppercased (and thus conflict-free) nested types, services and enums as | ||
@@ -384,2 +402,4 @@ // properties of namespaces just like static code does. This allows using a .d.ts generated for | ||
} | ||
delete this._fullyQualifiedObjects[object.fullName]; | ||
}; | ||
@@ -386,0 +406,0 @@ |
@@ -113,2 +113,4 @@ "use strict"; | ||
Service.prototype.resolveAll = function resolveAll() { | ||
if (!this._needsRecursiveResolve) return this; | ||
Namespace.prototype.resolve.call(this); | ||
@@ -115,0 +117,0 @@ var methods = this.methodsArray; |
@@ -306,2 +306,4 @@ "use strict"; | ||
Type.prototype.resolveAll = function resolveAll() { | ||
if (!this._needsRecursiveResolve) return this; | ||
Namespace.prototype.resolveAll.call(this); | ||
@@ -308,0 +310,0 @@ var oneofs = this.oneofsArray; i = 0; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
2915654
0.51%30716
0.46%