protobufjs 8.1.2-experimental → 8.1.3-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 +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 +79 -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/parse.js +4 -0
- package/src/root.js +24 -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.3-experimental (c) 2016, daniel wirtz
|
|
3
|
+
* compiled mon, 12 may 2025 03:50:28 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -3023,6 +3023,13 @@ function Namespace(name, options) {
|
|
|
3023
3023
|
* @protected
|
|
3024
3024
|
*/
|
|
3025
3025
|
this._needsRecursiveFeatureResolution = true;
|
|
3026
|
+
|
|
3027
|
+
/**
|
|
3028
|
+
* Whether or not objects contained in this namespace need a resolve.
|
|
3029
|
+
* @type {boolean}
|
|
3030
|
+
* @protected
|
|
3031
|
+
*/
|
|
3032
|
+
this._needsRecursiveResolve = true;
|
|
3026
3033
|
}
|
|
3027
3034
|
|
|
3028
3035
|
function clearCache(namespace) {
|
|
@@ -3172,11 +3179,13 @@ Namespace.prototype.add = function add(object) {
|
|
|
3172
3179
|
}
|
|
3173
3180
|
|
|
3174
3181
|
this._needsRecursiveFeatureResolution = true;
|
|
3182
|
+
this._needsRecursiveResolve = true;
|
|
3175
3183
|
|
|
3176
3184
|
// Also clear parent caches, since they need to recurse down.
|
|
3177
3185
|
var parent = this;
|
|
3178
3186
|
while(parent = parent.parent) {
|
|
3179
3187
|
parent._needsRecursiveFeatureResolution = true;
|
|
3188
|
+
parent._needsRecursiveResolve = true;
|
|
3180
3189
|
}
|
|
3181
3190
|
|
|
3182
3191
|
object.onAdd(this);
|
|
@@ -3240,6 +3249,8 @@ Namespace.prototype.define = function define(path, json) {
|
|
|
3240
3249
|
* @returns {Namespace} `this`
|
|
3241
3250
|
*/
|
|
3242
3251
|
Namespace.prototype.resolveAll = function resolveAll() {
|
|
3252
|
+
if (!this._needsRecursiveResolve) return this;
|
|
3253
|
+
|
|
3243
3254
|
var nested = this.nestedArray, i = 0;
|
|
3244
3255
|
this.resolve();
|
|
3245
3256
|
while (i < nested.length)
|
|
@@ -3247,6 +3258,7 @@ Namespace.prototype.resolveAll = function resolveAll() {
|
|
|
3247
3258
|
nested[i++].resolveAll();
|
|
3248
3259
|
else
|
|
3249
3260
|
nested[i++].resolve();
|
|
3261
|
+
this._needsRecursiveResolve = false;
|
|
3250
3262
|
return this;
|
|
3251
3263
|
};
|
|
3252
3264
|
|
|
@@ -3288,29 +3300,47 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
3288
3300
|
} else if (!path.length)
|
|
3289
3301
|
return this;
|
|
3290
3302
|
|
|
3303
|
+
var flatPath = path.join(".");
|
|
3304
|
+
|
|
3291
3305
|
// Start at root if path is absolute
|
|
3292
3306
|
if (path[0] === "")
|
|
3293
3307
|
return this.root.lookup(path.slice(1), filterTypes);
|
|
3294
3308
|
|
|
3295
|
-
|
|
3309
|
+
// Early bailout for objects with matching absolute paths
|
|
3310
|
+
var found = this.root._fullyQualifiedObjects["." + flatPath];
|
|
3311
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3312
|
+
return found;
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
// Do a regular lookup at this namespace and below
|
|
3316
|
+
found = this._lookupImpl(path, flatPath);
|
|
3296
3317
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3297
3318
|
return found;
|
|
3298
3319
|
}
|
|
3299
3320
|
|
|
3300
|
-
|
|
3301
|
-
if (this.parent === null || parentAlreadyChecked)
|
|
3321
|
+
if (parentAlreadyChecked)
|
|
3302
3322
|
return null;
|
|
3303
|
-
|
|
3323
|
+
|
|
3324
|
+
// If there hasn't been a match, walk up the tree and look more broadly
|
|
3325
|
+
var current = this;
|
|
3326
|
+
while (current.parent) {
|
|
3327
|
+
found = current.parent._lookupImpl(path, flatPath);
|
|
3328
|
+
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
3329
|
+
return found;
|
|
3330
|
+
}
|
|
3331
|
+
current = current.parent;
|
|
3332
|
+
}
|
|
3333
|
+
return null;
|
|
3304
3334
|
};
|
|
3305
3335
|
|
|
3306
3336
|
/**
|
|
3307
3337
|
* Internal helper for lookup that handles searching just at this namespace and below along with caching.
|
|
3308
3338
|
* @param {string[]} path Path to look up
|
|
3339
|
+
* @param {string} flatPath Flattened version of the path to use as a cache key
|
|
3309
3340
|
* @returns {ReflectionObject|null} Looked up object or `null` if none could be found
|
|
3310
3341
|
* @private
|
|
3311
3342
|
*/
|
|
3312
|
-
Namespace.prototype._lookupImpl = function lookup(path) {
|
|
3313
|
-
var flatPath = path.join(".");
|
|
3343
|
+
Namespace.prototype._lookupImpl = function lookup(path, flatPath) {
|
|
3314
3344
|
if(Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) {
|
|
3315
3345
|
return this._lookupCache[flatPath];
|
|
3316
3346
|
}
|
|
@@ -3321,13 +3351,15 @@ Namespace.prototype._lookupImpl = function lookup(path) {
|
|
|
3321
3351
|
if (found) {
|
|
3322
3352
|
if (path.length === 1) {
|
|
3323
3353
|
exact = found;
|
|
3324
|
-
} else if (found instanceof Namespace
|
|
3325
|
-
|
|
3354
|
+
} else if (found instanceof Namespace) {
|
|
3355
|
+
path = path.slice(1);
|
|
3356
|
+
exact = found._lookupImpl(path, path.join("."));
|
|
3357
|
+
}
|
|
3326
3358
|
|
|
3327
3359
|
// Otherwise try each nested namespace
|
|
3328
3360
|
} else {
|
|
3329
3361
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
3330
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path)))
|
|
3362
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath)))
|
|
3331
3363
|
exact = found;
|
|
3332
3364
|
}
|
|
3333
3365
|
|
|
@@ -3464,6 +3496,7 @@ function ReflectionObject(name, options) {
|
|
|
3464
3496
|
/**
|
|
3465
3497
|
* The edition specified for this object. Only relevant for top-level objects.
|
|
3466
3498
|
* @type {string}
|
|
3499
|
+
* @private
|
|
3467
3500
|
*/
|
|
3468
3501
|
this._edition = null;
|
|
3469
3502
|
|
|
@@ -3471,18 +3504,21 @@ function ReflectionObject(name, options) {
|
|
|
3471
3504
|
* The default edition to use for this object if none is specified. For legacy reasons,
|
|
3472
3505
|
* this is proto2 except in the JSON parsing case where it was proto3.
|
|
3473
3506
|
* @type {string}
|
|
3507
|
+
* @private
|
|
3474
3508
|
*/
|
|
3475
3509
|
this._defaultEdition = "proto2";
|
|
3476
3510
|
|
|
3477
3511
|
/**
|
|
3478
3512
|
* Resolved Features.
|
|
3479
3513
|
* @type {object}
|
|
3514
|
+
* @private
|
|
3480
3515
|
*/
|
|
3481
3516
|
this._features = {};
|
|
3482
3517
|
|
|
3483
3518
|
/**
|
|
3484
3519
|
* Whether or not features have been resolved.
|
|
3485
3520
|
* @type {boolean}
|
|
3521
|
+
* @private
|
|
3486
3522
|
*/
|
|
3487
3523
|
this._featuresResolved = false;
|
|
3488
3524
|
|
|
@@ -4520,8 +4556,19 @@ function Root(options) {
|
|
|
4520
4556
|
*/
|
|
4521
4557
|
this.files = [];
|
|
4522
4558
|
|
|
4523
|
-
|
|
4559
|
+
/**
|
|
4560
|
+
* Edition, defaults to proto2 if unspecified.
|
|
4561
|
+
* @type {string}
|
|
4562
|
+
* @private
|
|
4563
|
+
*/
|
|
4524
4564
|
this._edition = "proto2";
|
|
4565
|
+
|
|
4566
|
+
/**
|
|
4567
|
+
* Global lookup cache of fully qualified names.
|
|
4568
|
+
* @type {Object.<string,ReflectionObject>}
|
|
4569
|
+
* @private
|
|
4570
|
+
*/
|
|
4571
|
+
this._fullyQualifiedObjects = {};
|
|
4525
4572
|
}
|
|
4526
4573
|
|
|
4527
4574
|
/**
|
|
@@ -4535,7 +4582,7 @@ Root.fromJSON = function fromJSON(json, root) {
|
|
|
4535
4582
|
root = new Root();
|
|
4536
4583
|
if (json.options)
|
|
4537
4584
|
root.setOptions(json.options);
|
|
4538
|
-
return root.addJSON(json.nested).
|
|
4585
|
+
return root.addJSON(json.nested).resolveAll();
|
|
4539
4586
|
};
|
|
4540
4587
|
|
|
4541
4588
|
/**
|
|
@@ -4584,7 +4631,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
4584
4631
|
// Finishes loading by calling the callback (exactly once)
|
|
4585
4632
|
function finish(err, root) {
|
|
4586
4633
|
if (root) {
|
|
4587
|
-
root.
|
|
4634
|
+
root.resolveAll();
|
|
4588
4635
|
}
|
|
4589
4636
|
/* istanbul ignore if */
|
|
4590
4637
|
if (!callback) {
|
|
@@ -4703,7 +4750,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
4703
4750
|
if (resolved = self.resolvePath("", filename[i]))
|
|
4704
4751
|
fetch(resolved);
|
|
4705
4752
|
if (sync) {
|
|
4706
|
-
self.
|
|
4753
|
+
self.resolveAll();
|
|
4707
4754
|
return self;
|
|
4708
4755
|
}
|
|
4709
4756
|
if (!queued) {
|
|
@@ -4752,6 +4799,8 @@ Root.prototype.loadSync = function loadSync(filename, options) {
|
|
|
4752
4799
|
* @override
|
|
4753
4800
|
*/
|
|
4754
4801
|
Root.prototype.resolveAll = function resolveAll() {
|
|
4802
|
+
if (!this._needsRecursiveResolve) return this;
|
|
4803
|
+
|
|
4755
4804
|
if (this.deferred.length)
|
|
4756
4805
|
throw Error("unresolvable extensions: " + this.deferred.map(function(field) {
|
|
4757
4806
|
return "'extend " + field.extend + "' in " + field.parent.fullName;
|
|
@@ -4819,6 +4868,11 @@ Root.prototype._handleAdd = function _handleAdd(object) {
|
|
|
4819
4868
|
object.parent[object.name] = object; // expose namespace as property of its parent
|
|
4820
4869
|
}
|
|
4821
4870
|
|
|
4871
|
+
if (object instanceof Type || object instanceof Enum) {
|
|
4872
|
+
// Only store types and enums for quick lookup during resolve.
|
|
4873
|
+
this._fullyQualifiedObjects[object.fullName] = object;
|
|
4874
|
+
}
|
|
4875
|
+
|
|
4822
4876
|
// The above also adds uppercased (and thus conflict-free) nested types, services and enums as
|
|
4823
4877
|
// properties of namespaces just like static code does. This allows using a .d.ts generated for
|
|
4824
4878
|
// a static module with reflection-based solutions where the condition is met.
|
|
@@ -4859,6 +4913,8 @@ Root.prototype._handleRemove = function _handleRemove(object) {
|
|
|
4859
4913
|
delete object.parent[object.name]; // unexpose namespaces
|
|
4860
4914
|
|
|
4861
4915
|
}
|
|
4916
|
+
|
|
4917
|
+
delete this._fullyQualifiedObjects[object.fullName];
|
|
4862
4918
|
};
|
|
4863
4919
|
|
|
4864
4920
|
// Sets up cyclic dependencies (called in index-light)
|
|
@@ -5183,6 +5239,8 @@ Service.prototype.get = function get(name) {
|
|
|
5183
5239
|
* @override
|
|
5184
5240
|
*/
|
|
5185
5241
|
Service.prototype.resolveAll = function resolveAll() {
|
|
5242
|
+
if (!this._needsRecursiveResolve) return this;
|
|
5243
|
+
|
|
5186
5244
|
Namespace.prototype.resolve.call(this);
|
|
5187
5245
|
var methods = this.methodsArray;
|
|
5188
5246
|
for (var i = 0; i < methods.length; ++i)
|
|
@@ -5565,6 +5623,8 @@ Type.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
5565
5623
|
* @override
|
|
5566
5624
|
*/
|
|
5567
5625
|
Type.prototype.resolveAll = function resolveAll() {
|
|
5626
|
+
if (!this._needsRecursiveResolve) return this;
|
|
5627
|
+
|
|
5568
5628
|
Namespace.prototype.resolveAll.call(this);
|
|
5569
5629
|
var oneofs = this.oneofsArray; i = 0;
|
|
5570
5630
|
while (i < oneofs.length)
|