protobufjs 7.0.0 → 7.1.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/dist/light/protobuf.js +39 -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 +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +56 -17
- 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 +8 -3
- package/package.json +5 -5
- package/src/converter.js +9 -3
- package/src/enum.js +24 -7
- package/src/namespace.js +3 -2
- package/src/parse.js +17 -2
- package/tsconfig.json +2 -1
- package/dist/README.md +0 -31
- package/dist/light/README.md +0 -31
- package/dist/minimal/README.md +0 -31
package/dist/light/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js
|
|
3
|
-
* compiled fri,
|
|
2
|
+
* protobuf.js v7.1.0 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled fri, 26 aug 2022 21:49:00 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -1134,8 +1134,14 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
|
1134
1134
|
if (field.resolvedType instanceof Enum) { gen
|
|
1135
1135
|
("switch(d%s){", prop);
|
|
1136
1136
|
for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
|
|
1137
|
-
|
|
1138
|
-
(
|
|
1137
|
+
// enum unknown values passthrough
|
|
1138
|
+
if (values[keys[i]] === field.typeDefault) { gen
|
|
1139
|
+
("default:")
|
|
1140
|
+
("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
|
|
1141
|
+
if (!field.repeated) gen // fallback to default value only for
|
|
1142
|
+
// arrays, to avoid leaving holes.
|
|
1143
|
+
("break"); // for non-repeated fields, just ignore
|
|
1144
|
+
}
|
|
1139
1145
|
gen
|
|
1140
1146
|
("case%j:", keys[i])
|
|
1141
1147
|
("case %i:", values[keys[i]])
|
|
@@ -1267,7 +1273,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
|
|
|
1267
1273
|
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
|
|
1268
1274
|
if (field.resolvedType) {
|
|
1269
1275
|
if (field.resolvedType instanceof Enum) gen
|
|
1270
|
-
("d%s=o.enums===String?types[%i].values[m%s]:m%s", prop, fieldIndex, prop, prop);
|
|
1276
|
+
("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s", prop, fieldIndex, prop, prop, fieldIndex, prop, prop);
|
|
1271
1277
|
else gen
|
|
1272
1278
|
("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
|
|
1273
1279
|
} else {
|
|
@@ -1657,8 +1663,9 @@ var Namespace = require(21),
|
|
|
1657
1663
|
* @param {Object.<string,*>} [options] Declared options
|
|
1658
1664
|
* @param {string} [comment] The comment for this enum
|
|
1659
1665
|
* @param {Object.<string,string>} [comments] The value comments for this enum
|
|
1666
|
+
* @param {Object.<string,Object<string,*>>|undefined} [valuesOptions] The value options for this enum
|
|
1660
1667
|
*/
|
|
1661
|
-
function Enum(name, values, options, comment, comments) {
|
|
1668
|
+
function Enum(name, values, options, comment, comments, valuesOptions) {
|
|
1662
1669
|
ReflectionObject.call(this, name, options);
|
|
1663
1670
|
|
|
1664
1671
|
if (values && typeof values !== "object")
|
|
@@ -1688,6 +1695,12 @@ function Enum(name, values, options, comment, comments) {
|
|
|
1688
1695
|
*/
|
|
1689
1696
|
this.comments = comments || {};
|
|
1690
1697
|
|
|
1698
|
+
/**
|
|
1699
|
+
* Values options, if any
|
|
1700
|
+
* @type {Object<string, Object<string, *>>|undefined}
|
|
1701
|
+
*/
|
|
1702
|
+
this.valuesOptions = valuesOptions;
|
|
1703
|
+
|
|
1691
1704
|
/**
|
|
1692
1705
|
* Reserved ranges, if any.
|
|
1693
1706
|
* @type {Array.<number[]|string>}
|
|
@@ -1732,11 +1745,12 @@ Enum.fromJSON = function fromJSON(name, json) {
|
|
|
1732
1745
|
Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
1733
1746
|
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
1734
1747
|
return util.toObject([
|
|
1735
|
-
"options"
|
|
1736
|
-
"
|
|
1737
|
-
"
|
|
1738
|
-
"
|
|
1739
|
-
"
|
|
1748
|
+
"options" , this.options,
|
|
1749
|
+
"valuesOptions" , this.valuesOptions,
|
|
1750
|
+
"values" , this.values,
|
|
1751
|
+
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
1752
|
+
"comment" , keepComments ? this.comment : undefined,
|
|
1753
|
+
"comments" , keepComments ? this.comments : undefined
|
|
1740
1754
|
]);
|
|
1741
1755
|
};
|
|
1742
1756
|
|
|
@@ -1745,11 +1759,12 @@ Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
1745
1759
|
* @param {string} name Value name
|
|
1746
1760
|
* @param {number} id Value id
|
|
1747
1761
|
* @param {string} [comment] Comment, if any
|
|
1762
|
+
* @param {Object.<string, *>|undefined} [options] Options, if any
|
|
1748
1763
|
* @returns {Enum} `this`
|
|
1749
1764
|
* @throws {TypeError} If arguments are invalid
|
|
1750
1765
|
* @throws {Error} If there is already a value with this name or id
|
|
1751
1766
|
*/
|
|
1752
|
-
Enum.prototype.add = function add(name, id, comment) {
|
|
1767
|
+
Enum.prototype.add = function add(name, id, comment, options) {
|
|
1753
1768
|
// utilized by the parser but not by .fromJSON
|
|
1754
1769
|
|
|
1755
1770
|
if (!util.isString(name))
|
|
@@ -1774,6 +1789,12 @@ Enum.prototype.add = function add(name, id, comment) {
|
|
|
1774
1789
|
} else
|
|
1775
1790
|
this.valuesById[this.values[name] = id] = name;
|
|
1776
1791
|
|
|
1792
|
+
if (options) {
|
|
1793
|
+
if (this.valuesOptions === undefined)
|
|
1794
|
+
this.valuesOptions = {};
|
|
1795
|
+
this.valuesOptions[name] = options || null;
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1777
1798
|
this.comments[name] = comment || null;
|
|
1778
1799
|
return this;
|
|
1779
1800
|
};
|
|
@@ -1797,6 +1818,8 @@ Enum.prototype.remove = function remove(name) {
|
|
|
1797
1818
|
delete this.valuesById[val];
|
|
1798
1819
|
delete this.values[name];
|
|
1799
1820
|
delete this.comments[name];
|
|
1821
|
+
if (this.valuesOptions)
|
|
1822
|
+
delete this.valuesOptions[name];
|
|
1800
1823
|
|
|
1801
1824
|
return this;
|
|
1802
1825
|
};
|
|
@@ -2781,7 +2804,8 @@ var ReflectionObject = require(22);
|
|
|
2781
2804
|
((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
|
|
2782
2805
|
|
|
2783
2806
|
var Field = require(15),
|
|
2784
|
-
util = require(33)
|
|
2807
|
+
util = require(33),
|
|
2808
|
+
OneOf = require(23);
|
|
2785
2809
|
|
|
2786
2810
|
var Type, // cyclic
|
|
2787
2811
|
Service,
|
|
@@ -2992,7 +3016,7 @@ Namespace.prototype.getEnum = function getEnum(name) {
|
|
|
2992
3016
|
*/
|
|
2993
3017
|
Namespace.prototype.add = function add(object) {
|
|
2994
3018
|
|
|
2995
|
-
if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace))
|
|
3019
|
+
if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof OneOf || object instanceof Enum || object instanceof Service || object instanceof Namespace))
|
|
2996
3020
|
throw TypeError("object must be a valid nested object");
|
|
2997
3021
|
|
|
2998
3022
|
if (!this.nested)
|
|
@@ -3207,7 +3231,7 @@ Namespace._configure = function(Type_, Service_, Enum_) {
|
|
|
3207
3231
|
Enum = Enum_;
|
|
3208
3232
|
};
|
|
3209
3233
|
|
|
3210
|
-
},{"15":15,"22":22,"33":33}],22:[function(require,module,exports){
|
|
3234
|
+
},{"15":15,"22":22,"23":23,"33":33}],22:[function(require,module,exports){
|
|
3211
3235
|
"use strict";
|
|
3212
3236
|
module.exports = ReflectionObject;
|
|
3213
3237
|
|