protobufjs 6.9.0 → 6.10.0
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/CHANGELOG.md +20 -0
- package/cli/package.json +7 -1
- package/cli/pbjs.js +2 -3
- package/dist/light/protobuf.js +149 -24
- 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 +4 -4
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +201 -44
- 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 +32 -0
- package/package-lock.json +649 -233
- package/package.json +7 -7
- package/src/decoder.js +37 -15
- package/src/object.js +43 -0
- package/src/parse.js +37 -11
- package/src/root.js +11 -1
- package/src/tokenize.js +15 -9
- package/src/util/minimal.js +2 -2
- package/src/util.js +31 -0
- package/src/wrappers.js +23 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [6.10.0](https://www.github.com/protobufjs/protobuf.js/compare/v6.9.0...v6.10.0) (2020-07-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add configurable Root.prototype.fetch ([ad3cffd](https://www.github.com/protobufjs/protobuf.js/commit/ad3cffdc5a54a7c94830674270d3386e1a2b58fc))
|
|
9
|
+
* better comment parse ([#1419](https://www.github.com/protobufjs/protobuf.js/issues/1419)) ([7fd2e18](https://www.github.com/protobufjs/protobuf.js/commit/7fd2e182150c9b6be9ba21e6450b6e4668ad9f82))
|
|
10
|
+
* parsed options ([#1256](https://www.github.com/protobufjs/protobuf.js/issues/1256)) ([7a25398](https://www.github.com/protobufjs/protobuf.js/commit/7a2539843055b6daecb9f369c67a6cf588dbb54c))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* allow Windows unc paths to be resolved and normalized ([#1351](https://www.github.com/protobufjs/protobuf.js/issues/1351)) ([cd4aeda](https://www.github.com/protobufjs/protobuf.js/commit/cd4aeda8036f80cfa3b9f1db4096d856b2fd05fb))
|
|
16
|
+
* do not fail if no process ([#1440](https://www.github.com/protobufjs/protobuf.js/issues/1440)) ([f2faa8c](https://www.github.com/protobufjs/protobuf.js/commit/f2faa8c32e918b3b843005f0419608b8e158998d))
|
|
17
|
+
* fix util.global ([#1441](https://www.github.com/protobufjs/protobuf.js/issues/1441)) ([742b8dc](https://www.github.com/protobufjs/protobuf.js/commit/742b8dcbc750f9c2659088cbd88ea61fd11b24a7))
|
|
18
|
+
* google.protobuf.Any type_url fixes ([#1068](https://www.github.com/protobufjs/protobuf.js/issues/1068)) ([192f5f1](https://www.github.com/protobufjs/protobuf.js/commit/192f5f12d071fa534ac625290d4666c839a46a9e))
|
|
19
|
+
* handling of map entries with omitted key or value ([#1348](https://www.github.com/protobufjs/protobuf.js/issues/1348)) ([b950877](https://www.github.com/protobufjs/protobuf.js/commit/b950877c86676399674821fca4cf444f046b5acb))
|
|
20
|
+
* properly parse empty messages in options ([#1429](https://www.github.com/protobufjs/protobuf.js/issues/1429)) ([7fbc79f](https://www.github.com/protobufjs/protobuf.js/commit/7fbc79f11d89b263dafc8f332ccba59a8d181fca))
|
|
21
|
+
* updated isNode check ([#1221](https://www.github.com/protobufjs/protobuf.js/issues/1221)) ([#1363](https://www.github.com/protobufjs/protobuf.js/issues/1363)) ([5564e7b](https://www.github.com/protobufjs/protobuf.js/commit/5564e7b5f07d3eab99762528e8ce88507af5a5a3))
|
|
22
|
+
|
|
3
23
|
## [6.9.0](https://www.github.com/protobufjs/protobuf.js/compare/6.8.8...v6.9.0) (2020-04-17)
|
|
4
24
|
|
|
5
25
|
|
package/cli/package.json
CHANGED
package/cli/pbjs.js
CHANGED
|
@@ -194,9 +194,8 @@ exports.main = function main(args, callback) {
|
|
|
194
194
|
return resolved;
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
-
//
|
|
198
|
-
if (argv.wrap === "es6"
|
|
199
|
-
argv.wrap = "es6";
|
|
197
|
+
// `--wrap es6` implies `--es6` but not the other way around. You can still use e.g. `--es6 --wrap commonjs`
|
|
198
|
+
if (argv.wrap === "es6") {
|
|
200
199
|
argv.es6 = true;
|
|
201
200
|
}
|
|
202
201
|
|
package/dist/light/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v6.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v6.9.0 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled mon, 13 jul 2020 22:57:44 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -1425,7 +1425,7 @@ function decoder(mtype) {
|
|
|
1425
1425
|
var gen = util.codegen(["r", "l"], mtype.name + "$decode")
|
|
1426
1426
|
("if(!(r instanceof Reader))")
|
|
1427
1427
|
("r=Reader.create(r)")
|
|
1428
|
-
("var c=l===undefined?r.len:r.pos+l,m=new this.ctor" + (mtype.fieldsArray.filter(function(field) { return field.map; }).length ? ",k" : ""))
|
|
1428
|
+
("var c=l===undefined?r.len:r.pos+l,m=new this.ctor" + (mtype.fieldsArray.filter(function(field) { return field.map; }).length ? ",k,value" : ""))
|
|
1429
1429
|
("while(r.pos<c){")
|
|
1430
1430
|
("var t=r.uint32()");
|
|
1431
1431
|
if (mtype.group) gen
|
|
@@ -1443,22 +1443,44 @@ function decoder(mtype) {
|
|
|
1443
1443
|
|
|
1444
1444
|
// Map fields
|
|
1445
1445
|
if (field.map) { gen
|
|
1446
|
-
("r.skip().pos++") // assumes id 1 + key wireType
|
|
1447
1446
|
("if(%s===util.emptyObject)", ref)
|
|
1448
1447
|
("%s={}", ref)
|
|
1449
|
-
("
|
|
1450
|
-
|
|
1451
|
-
if (types.
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1448
|
+
("var c2 = r.uint32()+r.pos");
|
|
1449
|
+
|
|
1450
|
+
if (types.defaults[field.keyType] !== undefined) gen
|
|
1451
|
+
("k=%j", types.defaults[field.keyType]);
|
|
1452
|
+
else gen
|
|
1453
|
+
("k=null");
|
|
1454
|
+
|
|
1455
|
+
if (types.defaults[type] !== undefined) gen
|
|
1456
|
+
("value=%j", types.defaults[type]);
|
|
1457
|
+
else gen
|
|
1458
|
+
("value=null");
|
|
1459
|
+
|
|
1460
|
+
gen
|
|
1461
|
+
("while(r.pos<c2){")
|
|
1462
|
+
("var tag2=r.uint32()")
|
|
1463
|
+
("switch(tag2>>>3){")
|
|
1464
|
+
("case 1: k=r.%s(); break", field.keyType)
|
|
1465
|
+
("case 2:");
|
|
1466
|
+
|
|
1467
|
+
if (types.basic[type] === undefined) gen
|
|
1468
|
+
("value=types[%i].decode(r,r.uint32())", i); // can't be groups
|
|
1469
|
+
else gen
|
|
1470
|
+
("value=r.%s()", type);
|
|
1471
|
+
|
|
1472
|
+
gen
|
|
1473
|
+
("break")
|
|
1474
|
+
("default:")
|
|
1475
|
+
("r.skipType(tag2&7)")
|
|
1476
|
+
("break")
|
|
1477
|
+
("}")
|
|
1478
|
+
("}");
|
|
1479
|
+
|
|
1480
|
+
if (types.long[field.keyType] !== undefined) gen
|
|
1481
|
+
("%s[typeof k===\"object\"?util.longToHash(k):k]=value", ref);
|
|
1482
|
+
else gen
|
|
1483
|
+
("%s[k]=value", ref);
|
|
1462
1484
|
|
|
1463
1485
|
// Repeated fields
|
|
1464
1486
|
} else if (field.repeated) { gen
|
|
@@ -3201,6 +3223,12 @@ function ReflectionObject(name, options) {
|
|
|
3201
3223
|
*/
|
|
3202
3224
|
this.options = options; // toJSON
|
|
3203
3225
|
|
|
3226
|
+
/**
|
|
3227
|
+
* Parsed Options.
|
|
3228
|
+
* @type {Array.<Object.<string,*>>|undefined}
|
|
3229
|
+
*/
|
|
3230
|
+
this.parsedOptions = null;
|
|
3231
|
+
|
|
3204
3232
|
/**
|
|
3205
3233
|
* Unique name within its namespace.
|
|
3206
3234
|
* @type {string}
|
|
@@ -3341,6 +3369,43 @@ ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet)
|
|
|
3341
3369
|
return this;
|
|
3342
3370
|
};
|
|
3343
3371
|
|
|
3372
|
+
/**
|
|
3373
|
+
* Sets a parsed option.
|
|
3374
|
+
* @param {string} name parsed Option name
|
|
3375
|
+
* @param {*} value Option value
|
|
3376
|
+
* @param {string} propName dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value
|
|
3377
|
+
* @returns {ReflectionObject} `this`
|
|
3378
|
+
*/
|
|
3379
|
+
ReflectionObject.prototype.setParsedOption = function setParsedOption(name, value, propName) {
|
|
3380
|
+
if (!this.parsedOptions) {
|
|
3381
|
+
this.parsedOptions = [];
|
|
3382
|
+
}
|
|
3383
|
+
var parsedOptions = this.parsedOptions;
|
|
3384
|
+
if (propName) {
|
|
3385
|
+
// If setting a sub property of an option then try to merge it
|
|
3386
|
+
// with an existing option
|
|
3387
|
+
var opt = parsedOptions.find(function (opt) {
|
|
3388
|
+
return Object.prototype.hasOwnProperty.call(opt, name);
|
|
3389
|
+
});
|
|
3390
|
+
if (opt) {
|
|
3391
|
+
// If we found an existing option - just merge the property value
|
|
3392
|
+
var newValue = opt[name];
|
|
3393
|
+
util.setProperty(newValue, propName, value);
|
|
3394
|
+
} else {
|
|
3395
|
+
// otherwise, create a new option, set it's property and add it to the list
|
|
3396
|
+
opt = {};
|
|
3397
|
+
opt[name] = util.setProperty({}, propName, value);
|
|
3398
|
+
parsedOptions.push(opt);
|
|
3399
|
+
}
|
|
3400
|
+
} else {
|
|
3401
|
+
// Always create a new option when setting the value of the option itself
|
|
3402
|
+
var newOpt = {};
|
|
3403
|
+
newOpt[name] = value;
|
|
3404
|
+
parsedOptions.push(newOpt);
|
|
3405
|
+
}
|
|
3406
|
+
return this;
|
|
3407
|
+
};
|
|
3408
|
+
|
|
3344
3409
|
/**
|
|
3345
3410
|
* Sets multiple options.
|
|
3346
3411
|
* @param {Object.<string,*>} options Options to set
|
|
@@ -4106,6 +4171,16 @@ Root.fromJSON = function fromJSON(json, root) {
|
|
|
4106
4171
|
*/
|
|
4107
4172
|
Root.prototype.resolvePath = util.path.resolve;
|
|
4108
4173
|
|
|
4174
|
+
/**
|
|
4175
|
+
* Fetch content from file path or url
|
|
4176
|
+
* This method exists so you can override it with your own logic.
|
|
4177
|
+
* @function
|
|
4178
|
+
* @param {string} path File path or url
|
|
4179
|
+
* @param {FetchCallback} callback Callback function
|
|
4180
|
+
* @returns {undefined}
|
|
4181
|
+
*/
|
|
4182
|
+
Root.prototype.fetch = util.fetch;
|
|
4183
|
+
|
|
4109
4184
|
// A symbol-like function to safely signal synchronous loading
|
|
4110
4185
|
/* istanbul ignore next */
|
|
4111
4186
|
function SYNC() {} // eslint-disable-line no-empty-function
|
|
@@ -4213,7 +4288,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
4213
4288
|
process(filename, source);
|
|
4214
4289
|
} else {
|
|
4215
4290
|
++queued;
|
|
4216
|
-
|
|
4291
|
+
self.fetch(filename, function(err, source) {
|
|
4217
4292
|
--queued;
|
|
4218
4293
|
/* istanbul ignore if */
|
|
4219
4294
|
if (!callback)
|
|
@@ -5725,6 +5800,37 @@ util.decorateEnum = function decorateEnum(object) {
|
|
|
5725
5800
|
return enm;
|
|
5726
5801
|
};
|
|
5727
5802
|
|
|
5803
|
+
|
|
5804
|
+
/**
|
|
5805
|
+
* Sets the value of a property by property path. If a value already exists, it is turned to an array
|
|
5806
|
+
* @param {Object.<string,*>} dst Destination object
|
|
5807
|
+
* @param {string} path dot '.' delimited path of the property to set
|
|
5808
|
+
* @param {Object} value the value to set
|
|
5809
|
+
* @returns {Object.<string,*>} Destination object
|
|
5810
|
+
*/
|
|
5811
|
+
util.setProperty = function setProperty(dst, path, value) {
|
|
5812
|
+
function setProp(dst, path, value) {
|
|
5813
|
+
var part = path.shift();
|
|
5814
|
+
if (path.length > 0) {
|
|
5815
|
+
dst[part] = setProp(dst[part] || {}, path, value);
|
|
5816
|
+
} else {
|
|
5817
|
+
var prevValue = dst[part];
|
|
5818
|
+
if (prevValue)
|
|
5819
|
+
value = [].concat(prevValue).concat(value);
|
|
5820
|
+
dst[part] = value;
|
|
5821
|
+
}
|
|
5822
|
+
return dst;
|
|
5823
|
+
}
|
|
5824
|
+
|
|
5825
|
+
if (typeof dst !== "object")
|
|
5826
|
+
throw TypeError("dst must be an object");
|
|
5827
|
+
if (!path)
|
|
5828
|
+
throw TypeError("path must be specified");
|
|
5829
|
+
|
|
5830
|
+
path = path.split(".");
|
|
5831
|
+
return setProp(dst, path, value);
|
|
5832
|
+
};
|
|
5833
|
+
|
|
5728
5834
|
/**
|
|
5729
5835
|
* Decorator root (TypeScript).
|
|
5730
5836
|
* @name util.decorateRoot
|
|
@@ -5968,8 +6074,8 @@ util.pool = require(9);
|
|
|
5968
6074
|
util.LongBits = require(34);
|
|
5969
6075
|
|
|
5970
6076
|
// global object reference
|
|
5971
|
-
util.global = typeof
|
|
5972
|
-
|| typeof
|
|
6077
|
+
util.global = typeof global !== "undefined" && Object.prototype.toString.call(global) === "[object global]" && global
|
|
6078
|
+
|| typeof window !== "undefined" && window
|
|
5973
6079
|
|| typeof self !== "undefined" && self
|
|
5974
6080
|
|| this; // eslint-disable-line no-invalid-this
|
|
5975
6081
|
|
|
@@ -6578,15 +6684,20 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
6578
6684
|
|
|
6579
6685
|
// unwrap value type if mapped
|
|
6580
6686
|
if (object && object["@type"]) {
|
|
6581
|
-
|
|
6687
|
+
// Only use fully qualified type name after the last '/'
|
|
6688
|
+
var name = object["@type"].substring(object["@type"].lastIndexOf("/") + 1);
|
|
6689
|
+
var type = this.lookup(name);
|
|
6582
6690
|
/* istanbul ignore else */
|
|
6583
6691
|
if (type) {
|
|
6584
6692
|
// type_url does not accept leading "."
|
|
6585
6693
|
var type_url = object["@type"].charAt(0) === "." ?
|
|
6586
6694
|
object["@type"].substr(1) : object["@type"];
|
|
6587
6695
|
// type_url prefix is optional, but path seperator is required
|
|
6696
|
+
if (type_url.indexOf("/") === -1) {
|
|
6697
|
+
type_url = "/" + type_url;
|
|
6698
|
+
}
|
|
6588
6699
|
return this.create({
|
|
6589
|
-
type_url:
|
|
6700
|
+
type_url: type_url,
|
|
6590
6701
|
value: type.encode(type.fromObject(object)).finish()
|
|
6591
6702
|
});
|
|
6592
6703
|
}
|
|
@@ -6597,10 +6708,17 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
6597
6708
|
|
|
6598
6709
|
toObject: function(message, options) {
|
|
6599
6710
|
|
|
6711
|
+
// Default prefix
|
|
6712
|
+
var googleApi = "type.googleapis.com/";
|
|
6713
|
+
var prefix = "";
|
|
6714
|
+
var name = "";
|
|
6715
|
+
|
|
6600
6716
|
// decode value if requested and unmapped
|
|
6601
6717
|
if (options && options.json && message.type_url && message.value) {
|
|
6602
6718
|
// Only use fully qualified type name after the last '/'
|
|
6603
|
-
|
|
6719
|
+
name = message.type_url.substring(message.type_url.lastIndexOf("/") + 1);
|
|
6720
|
+
// Separate the prefix used
|
|
6721
|
+
prefix = message.type_url.substring(0, message.type_url.lastIndexOf("/") + 1);
|
|
6604
6722
|
var type = this.lookup(name);
|
|
6605
6723
|
/* istanbul ignore else */
|
|
6606
6724
|
if (type)
|
|
@@ -6610,7 +6728,14 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
6610
6728
|
// wrap value if unmapped
|
|
6611
6729
|
if (!(message instanceof this.ctor) && message instanceof Message) {
|
|
6612
6730
|
var object = message.$type.toObject(message, options);
|
|
6613
|
-
|
|
6731
|
+
var messageName = message.$type.fullName[0] === "." ?
|
|
6732
|
+
message.$type.fullName.substr(1) : message.$type.fullName;
|
|
6733
|
+
// Default to type.googleapis.com prefix if no prefix is used
|
|
6734
|
+
if (prefix === "") {
|
|
6735
|
+
prefix = googleApi;
|
|
6736
|
+
}
|
|
6737
|
+
name = prefix + messageName;
|
|
6738
|
+
object["@type"] = name;
|
|
6614
6739
|
return object;
|
|
6615
6740
|
}
|
|
6616
6741
|
|