protobufjs 6.8.4 → 6.8.8
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 +46 -0
- package/README.md +2 -2
- package/cli/node_modules/os-tmpdir/index.js +25 -0
- package/cli/node_modules/os-tmpdir/license +21 -0
- package/cli/node_modules/os-tmpdir/readme.md +32 -0
- package/cli/node_modules/tmp/LICENSE +21 -0
- package/cli/node_modules/tmp/README.md +314 -0
- package/cli/node_modules/tmp/lib/tmp.js +611 -0
- package/cli/pbjs.d.ts +1 -1
- package/cli/pbjs.js +11 -1
- package/cli/pbts.d.ts +1 -1
- package/cli/pbts.js +36 -7
- package/cli/targets/proto.js +1 -1
- package/cli/targets/static.js +3 -6
- package/dist/light/protobuf.js +143 -64
- 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 +23 -14
- 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 +268 -90
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/descriptor/index.d.ts +0 -1
- package/ext/descriptor/index.js +3 -0
- package/index.d.ts +57 -16
- package/package-lock.json +4579 -3191
- package/package.json +122 -125
- package/src/common.js +22 -1
- package/src/converter.js +9 -3
- package/src/enum.js +17 -5
- package/src/field.js +17 -4
- package/src/index-light.js +2 -2
- package/src/index-minimal.js +1 -1
- package/src/mapfield.js +9 -5
- package/src/message.js +1 -1
- package/src/method.js +14 -4
- package/src/namespace.js +14 -10
- package/src/object.js +1 -0
- package/src/oneof.js +14 -4
- package/src/parse.js +11 -3
- package/src/reader.js +2 -4
- package/src/root.js +3 -2
- package/src/service.js +8 -4
- package/src/tokenize.js +92 -22
- package/src/type.js +10 -5
- package/src/util/minimal.js +11 -2
- package/google/protobuf/field_mask.json +0 -21
- package/google/protobuf/field_mask.proto +0 -7
package/dist/protobuf.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v6.8.
|
|
3
|
-
* compiled thu,
|
|
2
|
+
* protobuf.js v6.8.8 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 19 jul 2018 00:33:25 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
7
|
-
(function(
|
|
7
|
+
(function(undefined){"use strict";(function prelude(modules, cache, entries) {
|
|
8
8
|
|
|
9
9
|
// This is the prelude used to bundle protobuf.js for the browser. Wraps up the CommonJS
|
|
10
10
|
// sources through a conflict-free require shim and is again wrapped within an iife that
|
|
11
|
-
// provides a
|
|
12
|
-
//
|
|
11
|
+
// provides a minification-friendly `undefined` var plus a global "use strict" directive
|
|
12
|
+
// so that minification can remove the directives of each module.
|
|
13
13
|
|
|
14
14
|
function $require(name) {
|
|
15
15
|
var $module = cache[name];
|
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
return $module.exports;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
var protobuf = $require(entries[0]);
|
|
22
|
+
|
|
21
23
|
// Expose globally
|
|
22
|
-
|
|
24
|
+
protobuf.util.global.protobuf = protobuf;
|
|
23
25
|
|
|
24
26
|
// Be nice to AMD
|
|
25
27
|
if (typeof define === "function" && define.amd)
|
|
@@ -1121,6 +1123,7 @@ var commonRe = /\/|\./;
|
|
|
1121
1123
|
* @property {INamespace} google/protobuf/any.proto Any
|
|
1122
1124
|
* @property {INamespace} google/protobuf/duration.proto Duration
|
|
1123
1125
|
* @property {INamespace} google/protobuf/empty.proto Empty
|
|
1126
|
+
* @property {INamespace} google/protobuf/field_mask.proto FieldMask
|
|
1124
1127
|
* @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue
|
|
1125
1128
|
* @property {INamespace} google/protobuf/timestamp.proto Timestamp
|
|
1126
1129
|
* @property {INamespace} google/protobuf/wrappers.proto Wrappers
|
|
@@ -1142,7 +1145,6 @@ function common(name, json) {
|
|
|
1142
1145
|
// Not provided because of limited use (feel free to discuss or to provide yourself):
|
|
1143
1146
|
//
|
|
1144
1147
|
// google/protobuf/descriptor.proto
|
|
1145
|
-
// google/protobuf/field_mask.proto
|
|
1146
1148
|
// google/protobuf/source_context.proto
|
|
1147
1149
|
// google/protobuf/type.proto
|
|
1148
1150
|
//
|
|
@@ -1468,6 +1470,26 @@ common("wrappers", {
|
|
|
1468
1470
|
}
|
|
1469
1471
|
});
|
|
1470
1472
|
|
|
1473
|
+
common("field_mask", {
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* Properties of a google.protobuf.FieldMask message.
|
|
1477
|
+
* @interface IDoubleValue
|
|
1478
|
+
* @type {Object}
|
|
1479
|
+
* @property {number} [value]
|
|
1480
|
+
* @memberof common
|
|
1481
|
+
*/
|
|
1482
|
+
FieldMask: {
|
|
1483
|
+
fields: {
|
|
1484
|
+
paths: {
|
|
1485
|
+
rule: "repeated",
|
|
1486
|
+
type: "string",
|
|
1487
|
+
id: 1
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
|
|
1471
1493
|
/**
|
|
1472
1494
|
* Gets the root definition of the specified common proto file.
|
|
1473
1495
|
*
|
|
@@ -1475,6 +1497,7 @@ common("wrappers", {
|
|
|
1475
1497
|
* - google/protobuf/any.proto
|
|
1476
1498
|
* - google/protobuf/duration.proto
|
|
1477
1499
|
* - google/protobuf/empty.proto
|
|
1500
|
+
* - google/protobuf/field_mask.proto
|
|
1478
1501
|
* - google/protobuf/struct.proto
|
|
1479
1502
|
* - google/protobuf/timestamp.proto
|
|
1480
1503
|
* - google/protobuf/wrappers.proto
|
|
@@ -1733,9 +1756,15 @@ converter.toObject = function toObject(mtype) {
|
|
|
1733
1756
|
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
|
|
1734
1757
|
("}else")
|
|
1735
1758
|
("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
|
|
1736
|
-
else if (field.bytes)
|
|
1737
|
-
|
|
1738
|
-
|
|
1759
|
+
else if (field.bytes) {
|
|
1760
|
+
var arrayDefault = "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]";
|
|
1761
|
+
gen
|
|
1762
|
+
("if(o.bytes===String)d%s=%j", prop, String.fromCharCode.apply(String, field.typeDefault))
|
|
1763
|
+
("else{")
|
|
1764
|
+
("d%s=%s", prop, arrayDefault)
|
|
1765
|
+
("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop)
|
|
1766
|
+
("}");
|
|
1767
|
+
} else gen
|
|
1739
1768
|
("d%s=%j", prop, field.typeDefault); // also messages (=null)
|
|
1740
1769
|
} gen
|
|
1741
1770
|
("}");
|
|
@@ -2003,8 +2032,10 @@ var Namespace = require(23),
|
|
|
2003
2032
|
* @param {string} name Unique name within its namespace
|
|
2004
2033
|
* @param {Object.<string,number>} [values] Enum values as an object, by name
|
|
2005
2034
|
* @param {Object.<string,*>} [options] Declared options
|
|
2035
|
+
* @param {string} [comment] The comment for this enum
|
|
2036
|
+
* @param {Object.<string,string>} [comments] The value comments for this enum
|
|
2006
2037
|
*/
|
|
2007
|
-
function Enum(name, values, options) {
|
|
2038
|
+
function Enum(name, values, options, comment, comments) {
|
|
2008
2039
|
ReflectionObject.call(this, name, options);
|
|
2009
2040
|
|
|
2010
2041
|
if (values && typeof values !== "object")
|
|
@@ -2022,11 +2053,17 @@ function Enum(name, values, options) {
|
|
|
2022
2053
|
*/
|
|
2023
2054
|
this.values = Object.create(this.valuesById); // toJSON, marker
|
|
2024
2055
|
|
|
2056
|
+
/**
|
|
2057
|
+
* Enum comment text.
|
|
2058
|
+
* @type {string|null}
|
|
2059
|
+
*/
|
|
2060
|
+
this.comment = comment;
|
|
2061
|
+
|
|
2025
2062
|
/**
|
|
2026
2063
|
* Value comment texts, if any.
|
|
2027
2064
|
* @type {Object.<string,string>}
|
|
2028
2065
|
*/
|
|
2029
|
-
this.comments = {};
|
|
2066
|
+
this.comments = comments || {};
|
|
2030
2067
|
|
|
2031
2068
|
/**
|
|
2032
2069
|
* Reserved ranges, if any.
|
|
@@ -2059,20 +2096,24 @@ function Enum(name, values, options) {
|
|
|
2059
2096
|
* @throws {TypeError} If arguments are invalid
|
|
2060
2097
|
*/
|
|
2061
2098
|
Enum.fromJSON = function fromJSON(name, json) {
|
|
2062
|
-
var enm = new Enum(name, json.values, json.options);
|
|
2099
|
+
var enm = new Enum(name, json.values, json.options, json.comment, json.comments);
|
|
2063
2100
|
enm.reserved = json.reserved;
|
|
2064
2101
|
return enm;
|
|
2065
2102
|
};
|
|
2066
2103
|
|
|
2067
2104
|
/**
|
|
2068
2105
|
* Converts this enum to an enum descriptor.
|
|
2106
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
2069
2107
|
* @returns {IEnum} Enum descriptor
|
|
2070
2108
|
*/
|
|
2071
|
-
Enum.prototype.toJSON = function toJSON() {
|
|
2109
|
+
Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
2110
|
+
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
2072
2111
|
return util.toObject([
|
|
2073
2112
|
"options" , this.options,
|
|
2074
2113
|
"values" , this.values,
|
|
2075
|
-
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined
|
|
2114
|
+
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
2115
|
+
"comment" , keepComments ? this.comment : undefined,
|
|
2116
|
+
"comments" , keepComments ? this.comments : undefined
|
|
2076
2117
|
]);
|
|
2077
2118
|
};
|
|
2078
2119
|
|
|
@@ -2193,7 +2234,7 @@ var ruleRe = /^required|optional|repeated$/;
|
|
|
2193
2234
|
* @throws {TypeError} If arguments are invalid
|
|
2194
2235
|
*/
|
|
2195
2236
|
Field.fromJSON = function fromJSON(name, json) {
|
|
2196
|
-
return new Field(name, json.id, json.type, json.rule, json.extend, json.options);
|
|
2237
|
+
return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment);
|
|
2197
2238
|
};
|
|
2198
2239
|
|
|
2199
2240
|
/**
|
|
@@ -2208,13 +2249,16 @@ Field.fromJSON = function fromJSON(name, json) {
|
|
|
2208
2249
|
* @param {string|Object.<string,*>} [rule="optional"] Field rule
|
|
2209
2250
|
* @param {string|Object.<string,*>} [extend] Extended type if different from parent
|
|
2210
2251
|
* @param {Object.<string,*>} [options] Declared options
|
|
2252
|
+
* @param {string} [comment] Comment associated with this field
|
|
2211
2253
|
*/
|
|
2212
|
-
function Field(name, id, type, rule, extend, options) {
|
|
2254
|
+
function Field(name, id, type, rule, extend, options, comment) {
|
|
2213
2255
|
|
|
2214
2256
|
if (util.isObject(rule)) {
|
|
2257
|
+
comment = extend;
|
|
2215
2258
|
options = rule;
|
|
2216
2259
|
rule = extend = undefined;
|
|
2217
2260
|
} else if (util.isObject(extend)) {
|
|
2261
|
+
comment = options;
|
|
2218
2262
|
options = extend;
|
|
2219
2263
|
extend = undefined;
|
|
2220
2264
|
}
|
|
@@ -2341,6 +2385,12 @@ function Field(name, id, type, rule, extend, options) {
|
|
|
2341
2385
|
* @private
|
|
2342
2386
|
*/
|
|
2343
2387
|
this._packed = null;
|
|
2388
|
+
|
|
2389
|
+
/**
|
|
2390
|
+
* Comment for this field.
|
|
2391
|
+
* @type {string|null}
|
|
2392
|
+
*/
|
|
2393
|
+
this.comment = comment;
|
|
2344
2394
|
}
|
|
2345
2395
|
|
|
2346
2396
|
/**
|
|
@@ -2385,15 +2435,18 @@ Field.prototype.setOption = function setOption(name, value, ifNotSet) {
|
|
|
2385
2435
|
|
|
2386
2436
|
/**
|
|
2387
2437
|
* Converts this field to a field descriptor.
|
|
2438
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
2388
2439
|
* @returns {IField} Field descriptor
|
|
2389
2440
|
*/
|
|
2390
|
-
Field.prototype.toJSON = function toJSON() {
|
|
2441
|
+
Field.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
2442
|
+
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
2391
2443
|
return util.toObject([
|
|
2392
2444
|
"rule" , this.rule !== "optional" && this.rule || undefined,
|
|
2393
2445
|
"type" , this.type,
|
|
2394
2446
|
"id" , this.id,
|
|
2395
2447
|
"extend" , this.extend,
|
|
2396
|
-
"options" , this.options
|
|
2448
|
+
"options" , this.options,
|
|
2449
|
+
"comment" , keepComments ? this.comment : undefined
|
|
2397
2450
|
]);
|
|
2398
2451
|
};
|
|
2399
2452
|
|
|
@@ -2511,6 +2564,7 @@ Field.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) {
|
|
|
2511
2564
|
*/
|
|
2512
2565
|
// like Field.d but without a default value
|
|
2513
2566
|
|
|
2567
|
+
// Sets up cyclic dependencies (called in index-light)
|
|
2514
2568
|
Field._configure = function configure(Type_) {
|
|
2515
2569
|
Type = Type_;
|
|
2516
2570
|
};
|
|
@@ -2615,9 +2669,9 @@ protobuf.wrappers = require(41);
|
|
|
2615
2669
|
protobuf.types = require(36);
|
|
2616
2670
|
protobuf.util = require(37);
|
|
2617
2671
|
|
|
2618
|
-
//
|
|
2672
|
+
// Set up possibly cyclic reflection dependencies
|
|
2619
2673
|
protobuf.ReflectionObject._configure(protobuf.Root);
|
|
2620
|
-
protobuf.Namespace._configure(protobuf.Type, protobuf.Service);
|
|
2674
|
+
protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);
|
|
2621
2675
|
protobuf.Root._configure(protobuf.Type);
|
|
2622
2676
|
protobuf.Field._configure(protobuf.Type);
|
|
2623
2677
|
|
|
@@ -2655,7 +2709,7 @@ function configure() {
|
|
|
2655
2709
|
protobuf.util._configure();
|
|
2656
2710
|
}
|
|
2657
2711
|
|
|
2658
|
-
//
|
|
2712
|
+
// Set up buffer utility according to the environment
|
|
2659
2713
|
protobuf.Writer._configure(protobuf.BufferWriter);
|
|
2660
2714
|
configure();
|
|
2661
2715
|
|
|
@@ -2694,9 +2748,10 @@ var types = require(36),
|
|
|
2694
2748
|
* @param {string} keyType Key type
|
|
2695
2749
|
* @param {string} type Value type
|
|
2696
2750
|
* @param {Object.<string,*>} [options] Declared options
|
|
2751
|
+
* @param {string} [comment] Comment associated with this field
|
|
2697
2752
|
*/
|
|
2698
|
-
function MapField(name, id, keyType, type, options) {
|
|
2699
|
-
Field.call(this, name, id, type, options);
|
|
2753
|
+
function MapField(name, id, keyType, type, options, comment) {
|
|
2754
|
+
Field.call(this, name, id, type, undefined, undefined, options, comment);
|
|
2700
2755
|
|
|
2701
2756
|
/* istanbul ignore if */
|
|
2702
2757
|
if (!util.isString(keyType))
|
|
@@ -2740,20 +2795,23 @@ function MapField(name, id, keyType, type, options) {
|
|
|
2740
2795
|
* @throws {TypeError} If arguments are invalid
|
|
2741
2796
|
*/
|
|
2742
2797
|
MapField.fromJSON = function fromJSON(name, json) {
|
|
2743
|
-
return new MapField(name, json.id, json.keyType, json.type, json.options);
|
|
2798
|
+
return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment);
|
|
2744
2799
|
};
|
|
2745
2800
|
|
|
2746
2801
|
/**
|
|
2747
2802
|
* Converts this map field to a map field descriptor.
|
|
2803
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
2748
2804
|
* @returns {IMapField} Map field descriptor
|
|
2749
2805
|
*/
|
|
2750
|
-
MapField.prototype.toJSON = function toJSON() {
|
|
2806
|
+
MapField.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
2807
|
+
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
2751
2808
|
return util.toObject([
|
|
2752
2809
|
"keyType" , this.keyType,
|
|
2753
2810
|
"type" , this.type,
|
|
2754
2811
|
"id" , this.id,
|
|
2755
2812
|
"extend" , this.extend,
|
|
2756
|
-
"options" , this.options
|
|
2813
|
+
"options" , this.options,
|
|
2814
|
+
"comment" , keepComments ? this.comment : undefined
|
|
2757
2815
|
]);
|
|
2758
2816
|
};
|
|
2759
2817
|
|
|
@@ -2808,7 +2866,7 @@ var util = require(39);
|
|
|
2808
2866
|
* @classdesc Abstract runtime message.
|
|
2809
2867
|
* @constructor
|
|
2810
2868
|
* @param {Properties<T>} [properties] Properties to set
|
|
2811
|
-
* @template T extends object
|
|
2869
|
+
* @template T extends object = object
|
|
2812
2870
|
*/
|
|
2813
2871
|
function Message(properties) {
|
|
2814
2872
|
// not used internally
|
|
@@ -2959,8 +3017,9 @@ var util = require(37);
|
|
|
2959
3017
|
* @param {boolean|Object.<string,*>} [requestStream] Whether the request is streamed
|
|
2960
3018
|
* @param {boolean|Object.<string,*>} [responseStream] Whether the response is streamed
|
|
2961
3019
|
* @param {Object.<string,*>} [options] Declared options
|
|
3020
|
+
* @param {string} [comment] The comment for this method
|
|
2962
3021
|
*/
|
|
2963
|
-
function Method(name, type, requestType, responseType, requestStream, responseStream, options) {
|
|
3022
|
+
function Method(name, type, requestType, responseType, requestStream, responseStream, options, comment) {
|
|
2964
3023
|
|
|
2965
3024
|
/* istanbul ignore next */
|
|
2966
3025
|
if (util.isObject(requestStream)) {
|
|
@@ -3026,6 +3085,12 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
|
|
|
3026
3085
|
* @type {Type|null}
|
|
3027
3086
|
*/
|
|
3028
3087
|
this.resolvedResponseType = null;
|
|
3088
|
+
|
|
3089
|
+
/**
|
|
3090
|
+
* Comment for this method
|
|
3091
|
+
* @type {string|null}
|
|
3092
|
+
*/
|
|
3093
|
+
this.comment = comment;
|
|
3029
3094
|
}
|
|
3030
3095
|
|
|
3031
3096
|
/**
|
|
@@ -3047,21 +3112,24 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
|
|
|
3047
3112
|
* @throws {TypeError} If arguments are invalid
|
|
3048
3113
|
*/
|
|
3049
3114
|
Method.fromJSON = function fromJSON(name, json) {
|
|
3050
|
-
return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options);
|
|
3115
|
+
return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment);
|
|
3051
3116
|
};
|
|
3052
3117
|
|
|
3053
3118
|
/**
|
|
3054
3119
|
* Converts this method to a method descriptor.
|
|
3120
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
3055
3121
|
* @returns {IMethod} Method descriptor
|
|
3056
3122
|
*/
|
|
3057
|
-
Method.prototype.toJSON = function toJSON() {
|
|
3123
|
+
Method.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
3124
|
+
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
3058
3125
|
return util.toObject([
|
|
3059
3126
|
"type" , this.type !== "rpc" && /* istanbul ignore next */ this.type || undefined,
|
|
3060
3127
|
"requestType" , this.requestType,
|
|
3061
3128
|
"requestStream" , this.requestStream,
|
|
3062
3129
|
"responseType" , this.responseType,
|
|
3063
3130
|
"responseStream" , this.responseStream,
|
|
3064
|
-
"options" , this.options
|
|
3131
|
+
"options" , this.options,
|
|
3132
|
+
"comment" , keepComments ? this.comment : undefined
|
|
3065
3133
|
]);
|
|
3066
3134
|
};
|
|
3067
3135
|
|
|
@@ -3088,12 +3156,12 @@ module.exports = Namespace;
|
|
|
3088
3156
|
var ReflectionObject = require(24);
|
|
3089
3157
|
((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
|
|
3090
3158
|
|
|
3091
|
-
var
|
|
3092
|
-
Field = require(16),
|
|
3159
|
+
var Field = require(16),
|
|
3093
3160
|
util = require(37);
|
|
3094
3161
|
|
|
3095
3162
|
var Type, // cyclic
|
|
3096
|
-
Service
|
|
3163
|
+
Service,
|
|
3164
|
+
Enum;
|
|
3097
3165
|
|
|
3098
3166
|
/**
|
|
3099
3167
|
* Constructs a new namespace instance.
|
|
@@ -3122,14 +3190,15 @@ Namespace.fromJSON = function fromJSON(name, json) {
|
|
|
3122
3190
|
* Converts an array of reflection objects to JSON.
|
|
3123
3191
|
* @memberof Namespace
|
|
3124
3192
|
* @param {ReflectionObject[]} array Object array
|
|
3193
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
3125
3194
|
* @returns {Object.<string,*>|undefined} JSON object or `undefined` when array is empty
|
|
3126
3195
|
*/
|
|
3127
|
-
function arrayToJSON(array) {
|
|
3196
|
+
function arrayToJSON(array, toJSONOptions) {
|
|
3128
3197
|
if (!(array && array.length))
|
|
3129
3198
|
return undefined;
|
|
3130
3199
|
var obj = {};
|
|
3131
3200
|
for (var i = 0; i < array.length; ++i)
|
|
3132
|
-
obj[array[i].name] = array[i].toJSON();
|
|
3201
|
+
obj[array[i].name] = array[i].toJSON(toJSONOptions);
|
|
3133
3202
|
return obj;
|
|
3134
3203
|
}
|
|
3135
3204
|
|
|
@@ -3230,12 +3299,13 @@ Object.defineProperty(Namespace.prototype, "nestedArray", {
|
|
|
3230
3299
|
|
|
3231
3300
|
/**
|
|
3232
3301
|
* Converts this namespace to a namespace descriptor.
|
|
3302
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
3233
3303
|
* @returns {INamespace} Namespace descriptor
|
|
3234
3304
|
*/
|
|
3235
|
-
Namespace.prototype.toJSON = function toJSON() {
|
|
3305
|
+
Namespace.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
3236
3306
|
return util.toObject([
|
|
3237
3307
|
"options" , this.options,
|
|
3238
|
-
"nested" , arrayToJSON(this.nestedArray)
|
|
3308
|
+
"nested" , arrayToJSON(this.nestedArray, toJSONOptions)
|
|
3239
3309
|
]);
|
|
3240
3310
|
};
|
|
3241
3311
|
|
|
@@ -3286,7 +3356,7 @@ Namespace.prototype.get = function get(name) {
|
|
|
3286
3356
|
Namespace.prototype.getEnum = function getEnum(name) {
|
|
3287
3357
|
if (this.nested && this.nested[name] instanceof Enum)
|
|
3288
3358
|
return this.nested[name].values;
|
|
3289
|
-
throw Error("no such enum");
|
|
3359
|
+
throw Error("no such enum: " + name);
|
|
3290
3360
|
};
|
|
3291
3361
|
|
|
3292
3362
|
/**
|
|
@@ -3460,7 +3530,7 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
|
|
|
3460
3530
|
Namespace.prototype.lookupType = function lookupType(path) {
|
|
3461
3531
|
var found = this.lookup(path, [ Type ]);
|
|
3462
3532
|
if (!found)
|
|
3463
|
-
throw Error("no such type");
|
|
3533
|
+
throw Error("no such type: " + path);
|
|
3464
3534
|
return found;
|
|
3465
3535
|
};
|
|
3466
3536
|
|
|
@@ -3506,12 +3576,14 @@ Namespace.prototype.lookupService = function lookupService(path) {
|
|
|
3506
3576
|
return found;
|
|
3507
3577
|
};
|
|
3508
3578
|
|
|
3509
|
-
|
|
3579
|
+
// Sets up cyclic dependencies (called in index-light)
|
|
3580
|
+
Namespace._configure = function(Type_, Service_, Enum_) {
|
|
3510
3581
|
Type = Type_;
|
|
3511
3582
|
Service = Service_;
|
|
3583
|
+
Enum = Enum_;
|
|
3512
3584
|
};
|
|
3513
3585
|
|
|
3514
|
-
},{"
|
|
3586
|
+
},{"16":16,"24":24,"37":37}],24:[function(require,module,exports){
|
|
3515
3587
|
"use strict";
|
|
3516
3588
|
module.exports = ReflectionObject;
|
|
3517
3589
|
|
|
@@ -3708,6 +3780,7 @@ ReflectionObject.prototype.toString = function toString() {
|
|
|
3708
3780
|
return className;
|
|
3709
3781
|
};
|
|
3710
3782
|
|
|
3783
|
+
// Sets up cyclic dependencies (called in index-light)
|
|
3711
3784
|
ReflectionObject._configure = function(Root_) {
|
|
3712
3785
|
Root = Root_;
|
|
3713
3786
|
};
|
|
@@ -3731,8 +3804,9 @@ var Field = require(16),
|
|
|
3731
3804
|
* @param {string} name Oneof name
|
|
3732
3805
|
* @param {string[]|Object.<string,*>} [fieldNames] Field names
|
|
3733
3806
|
* @param {Object.<string,*>} [options] Declared options
|
|
3807
|
+
* @param {string} [comment] Comment associated with this field
|
|
3734
3808
|
*/
|
|
3735
|
-
function OneOf(name, fieldNames, options) {
|
|
3809
|
+
function OneOf(name, fieldNames, options, comment) {
|
|
3736
3810
|
if (!Array.isArray(fieldNames)) {
|
|
3737
3811
|
options = fieldNames;
|
|
3738
3812
|
fieldNames = undefined;
|
|
@@ -3755,6 +3829,12 @@ function OneOf(name, fieldNames, options) {
|
|
|
3755
3829
|
* @readonly
|
|
3756
3830
|
*/
|
|
3757
3831
|
this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent
|
|
3832
|
+
|
|
3833
|
+
/**
|
|
3834
|
+
* Comment for this field.
|
|
3835
|
+
* @type {string|null}
|
|
3836
|
+
*/
|
|
3837
|
+
this.comment = comment;
|
|
3758
3838
|
}
|
|
3759
3839
|
|
|
3760
3840
|
/**
|
|
@@ -3772,17 +3852,20 @@ function OneOf(name, fieldNames, options) {
|
|
|
3772
3852
|
* @throws {TypeError} If arguments are invalid
|
|
3773
3853
|
*/
|
|
3774
3854
|
OneOf.fromJSON = function fromJSON(name, json) {
|
|
3775
|
-
return new OneOf(name, json.oneof, json.options);
|
|
3855
|
+
return new OneOf(name, json.oneof, json.options, json.comment);
|
|
3776
3856
|
};
|
|
3777
3857
|
|
|
3778
3858
|
/**
|
|
3779
3859
|
* Converts this oneof to a oneof descriptor.
|
|
3860
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
3780
3861
|
* @returns {IOneOf} Oneof descriptor
|
|
3781
3862
|
*/
|
|
3782
|
-
OneOf.prototype.toJSON = function toJSON() {
|
|
3863
|
+
OneOf.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
3864
|
+
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
3783
3865
|
return util.toObject([
|
|
3784
3866
|
"options" , this.options,
|
|
3785
|
-
"oneof" , this.oneof
|
|
3867
|
+
"oneof" , this.oneof,
|
|
3868
|
+
"comment" , keepComments ? this.comment : undefined
|
|
3786
3869
|
]);
|
|
3787
3870
|
};
|
|
3788
3871
|
|
|
@@ -3934,8 +4017,8 @@ var base10Re = /^[1-9][0-9]*$/,
|
|
|
3934
4017
|
base8NegRe = /^-?0[0-7]+$/,
|
|
3935
4018
|
numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,
|
|
3936
4019
|
nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
|
|
3937
|
-
typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)
|
|
3938
|
-
fqTypeRefRe = /^(?:\.[a-zA-
|
|
4020
|
+
typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,
|
|
4021
|
+
fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;
|
|
3939
4022
|
|
|
3940
4023
|
/**
|
|
3941
4024
|
* Result object returned from {@link parse}.
|
|
@@ -3951,6 +4034,13 @@ var base10Re = /^[1-9][0-9]*$/,
|
|
|
3951
4034
|
* Options modifying the behavior of {@link parse}.
|
|
3952
4035
|
* @interface IParseOptions
|
|
3953
4036
|
* @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case
|
|
4037
|
+
* @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.
|
|
4038
|
+
*/
|
|
4039
|
+
|
|
4040
|
+
/**
|
|
4041
|
+
* Options modifying the behavior of JSON serialization.
|
|
4042
|
+
* @interface IToJSONOptions
|
|
4043
|
+
* @property {boolean} [keepComments=false] Serializes comments.
|
|
3954
4044
|
*/
|
|
3955
4045
|
|
|
3956
4046
|
/**
|
|
@@ -3971,7 +4061,7 @@ function parse(source, root, options) {
|
|
|
3971
4061
|
if (!options)
|
|
3972
4062
|
options = parse.defaults;
|
|
3973
4063
|
|
|
3974
|
-
var tn = tokenize(source),
|
|
4064
|
+
var tn = tokenize(source, options.alternateCommentMode || false),
|
|
3975
4065
|
next = tn.next,
|
|
3976
4066
|
push = tn.push,
|
|
3977
4067
|
peek = tn.peek,
|
|
@@ -4470,6 +4560,7 @@ function parse(source, root, options) {
|
|
|
4470
4560
|
else
|
|
4471
4561
|
setOption(parent, name + "." + token, readValue(true));
|
|
4472
4562
|
}
|
|
4563
|
+
skip(",", true);
|
|
4473
4564
|
} while (!skip("}", true));
|
|
4474
4565
|
} else
|
|
4475
4566
|
setOption(parent, name, readValue(true));
|
|
@@ -5022,11 +5113,9 @@ Reader.prototype.skipType = function(wireType) {
|
|
|
5022
5113
|
this.skip(this.uint32());
|
|
5023
5114
|
break;
|
|
5024
5115
|
case 3:
|
|
5025
|
-
|
|
5026
|
-
if ((wireType = this.uint32() & 7) === 4)
|
|
5027
|
-
break;
|
|
5116
|
+
while ((wireType = this.uint32() & 7) !== 4) {
|
|
5028
5117
|
this.skipType(wireType);
|
|
5029
|
-
}
|
|
5118
|
+
}
|
|
5030
5119
|
break;
|
|
5031
5120
|
case 5:
|
|
5032
5121
|
this.skip(4);
|
|
@@ -5460,9 +5549,10 @@ Root.prototype._handleRemove = function _handleRemove(object) {
|
|
|
5460
5549
|
}
|
|
5461
5550
|
};
|
|
5462
5551
|
|
|
5552
|
+
// Sets up cyclic dependencies (called in index-light)
|
|
5463
5553
|
Root._configure = function(Type_, parse_, common_) {
|
|
5464
|
-
Type
|
|
5465
|
-
parse
|
|
5554
|
+
Type = Type_;
|
|
5555
|
+
parse = parse_;
|
|
5466
5556
|
common = common_;
|
|
5467
5557
|
};
|
|
5468
5558
|
|
|
@@ -5728,19 +5818,23 @@ Service.fromJSON = function fromJSON(name, json) {
|
|
|
5728
5818
|
service.add(Method.fromJSON(names[i], json.methods[names[i]]));
|
|
5729
5819
|
if (json.nested)
|
|
5730
5820
|
service.addJSON(json.nested);
|
|
5821
|
+
service.comment = json.comment;
|
|
5731
5822
|
return service;
|
|
5732
5823
|
};
|
|
5733
5824
|
|
|
5734
5825
|
/**
|
|
5735
5826
|
* Converts this service to a service descriptor.
|
|
5827
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
5736
5828
|
* @returns {IService} Service descriptor
|
|
5737
5829
|
*/
|
|
5738
|
-
Service.prototype.toJSON = function toJSON() {
|
|
5739
|
-
var inherited = Namespace.prototype.toJSON.call(this);
|
|
5830
|
+
Service.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
5831
|
+
var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
|
|
5832
|
+
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
5740
5833
|
return util.toObject([
|
|
5741
5834
|
"options" , inherited && inherited.options || undefined,
|
|
5742
|
-
"methods" , Namespace.arrayToJSON(this.methodsArray) || /* istanbul ignore next */ {},
|
|
5743
|
-
"nested" , inherited && inherited.nested || undefined
|
|
5835
|
+
"methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {},
|
|
5836
|
+
"nested" , inherited && inherited.nested || undefined,
|
|
5837
|
+
"comment" , keepComments ? this.comment : undefined
|
|
5744
5838
|
]);
|
|
5745
5839
|
};
|
|
5746
5840
|
|
|
@@ -5842,6 +5936,7 @@ var delimRe = /[\s{}=;:[\],'"()<>]/g,
|
|
|
5842
5936
|
stringSingleRe = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g;
|
|
5843
5937
|
|
|
5844
5938
|
var setCommentRe = /^ *[*/]+ */,
|
|
5939
|
+
setCommentAltRe = /^\s*\*?\/*/,
|
|
5845
5940
|
setCommentSplitRe = /\n/g,
|
|
5846
5941
|
whitespaceRe = /\s/,
|
|
5847
5942
|
unescapeRe = /\\(.?)/g;
|
|
@@ -5928,9 +6023,10 @@ tokenize.unescape = unescape;
|
|
|
5928
6023
|
/**
|
|
5929
6024
|
* Tokenizes the given .proto source and returns an object with useful utility functions.
|
|
5930
6025
|
* @param {string} source Source contents
|
|
6026
|
+
* @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode.
|
|
5931
6027
|
* @returns {ITokenizerHandle} Tokenizer handle
|
|
5932
6028
|
*/
|
|
5933
|
-
function tokenize(source) {
|
|
6029
|
+
function tokenize(source, alternateCommentMode) {
|
|
5934
6030
|
/* eslint-disable callback-return */
|
|
5935
6031
|
source = source.toString();
|
|
5936
6032
|
|
|
@@ -5995,10 +6091,17 @@ function tokenize(source) {
|
|
|
5995
6091
|
commentType = source.charAt(start++);
|
|
5996
6092
|
commentLine = line;
|
|
5997
6093
|
commentLineEmpty = false;
|
|
5998
|
-
var
|
|
6094
|
+
var lookback;
|
|
6095
|
+
if (alternateCommentMode) {
|
|
6096
|
+
lookback = 2; // alternate comment parsing: "//" or "/*"
|
|
6097
|
+
} else {
|
|
6098
|
+
lookback = 3; // "///" or "/**"
|
|
6099
|
+
}
|
|
6100
|
+
var commentOffset = start - lookback,
|
|
5999
6101
|
c;
|
|
6000
6102
|
do {
|
|
6001
|
-
if (--
|
|
6103
|
+
if (--commentOffset < 0 ||
|
|
6104
|
+
(c = source.charAt(commentOffset)) === "\n") {
|
|
6002
6105
|
commentLineEmpty = true;
|
|
6003
6106
|
break;
|
|
6004
6107
|
}
|
|
@@ -6007,12 +6110,34 @@ function tokenize(source) {
|
|
|
6007
6110
|
.substring(start, end)
|
|
6008
6111
|
.split(setCommentSplitRe);
|
|
6009
6112
|
for (var i = 0; i < lines.length; ++i)
|
|
6010
|
-
lines[i] = lines[i]
|
|
6113
|
+
lines[i] = lines[i]
|
|
6114
|
+
.replace(alternateCommentMode ? setCommentAltRe : setCommentRe, "")
|
|
6115
|
+
.trim();
|
|
6011
6116
|
commentText = lines
|
|
6012
6117
|
.join("\n")
|
|
6013
6118
|
.trim();
|
|
6014
6119
|
}
|
|
6015
6120
|
|
|
6121
|
+
function isDoubleSlashCommentLine(startOffset) {
|
|
6122
|
+
var endOffset = findEndOfLine(startOffset);
|
|
6123
|
+
|
|
6124
|
+
// see if remaining line matches comment pattern
|
|
6125
|
+
var lineText = source.substring(startOffset, endOffset);
|
|
6126
|
+
// look for 1 or 2 slashes since startOffset would already point past
|
|
6127
|
+
// the first slash that started the comment.
|
|
6128
|
+
var isComment = /^\s*\/{1,2}/.test(lineText);
|
|
6129
|
+
return isComment;
|
|
6130
|
+
}
|
|
6131
|
+
|
|
6132
|
+
function findEndOfLine(cursor) {
|
|
6133
|
+
// find end of cursor's line
|
|
6134
|
+
var endOffset = cursor;
|
|
6135
|
+
while (endOffset < length && charAt(endOffset) !== "\n") {
|
|
6136
|
+
endOffset++;
|
|
6137
|
+
}
|
|
6138
|
+
return endOffset;
|
|
6139
|
+
}
|
|
6140
|
+
|
|
6016
6141
|
/**
|
|
6017
6142
|
* Obtains the next token.
|
|
6018
6143
|
* @returns {string|null} Next token or `null` on eof
|
|
@@ -6038,35 +6163,71 @@ function tokenize(source) {
|
|
|
6038
6163
|
if (++offset === length)
|
|
6039
6164
|
return null;
|
|
6040
6165
|
}
|
|
6166
|
+
|
|
6041
6167
|
if (charAt(offset) === "/") {
|
|
6042
|
-
if (++offset === length)
|
|
6168
|
+
if (++offset === length) {
|
|
6043
6169
|
throw illegal("comment");
|
|
6170
|
+
}
|
|
6044
6171
|
if (charAt(offset) === "/") { // Line
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6172
|
+
if (!alternateCommentMode) {
|
|
6173
|
+
// check for triple-slash comment
|
|
6174
|
+
isDoc = charAt(start = offset + 1) === "/";
|
|
6175
|
+
|
|
6176
|
+
while (charAt(++offset) !== "\n") {
|
|
6177
|
+
if (offset === length) {
|
|
6178
|
+
return null;
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
++offset;
|
|
6182
|
+
if (isDoc) {
|
|
6183
|
+
setComment(start, offset - 1);
|
|
6184
|
+
}
|
|
6185
|
+
++line;
|
|
6186
|
+
repeat = true;
|
|
6187
|
+
} else {
|
|
6188
|
+
// check for double-slash comments, consolidating consecutive lines
|
|
6189
|
+
start = offset;
|
|
6190
|
+
isDoc = false;
|
|
6191
|
+
if (isDoubleSlashCommentLine(offset)) {
|
|
6192
|
+
isDoc = true;
|
|
6193
|
+
do {
|
|
6194
|
+
offset = findEndOfLine(offset);
|
|
6195
|
+
if (offset === length) {
|
|
6196
|
+
break;
|
|
6197
|
+
}
|
|
6198
|
+
offset++;
|
|
6199
|
+
} while (isDoubleSlashCommentLine(offset));
|
|
6200
|
+
} else {
|
|
6201
|
+
offset = Math.min(length, findEndOfLine(offset) + 1);
|
|
6202
|
+
}
|
|
6203
|
+
if (isDoc) {
|
|
6204
|
+
setComment(start, offset);
|
|
6205
|
+
}
|
|
6206
|
+
line++;
|
|
6207
|
+
repeat = true;
|
|
6208
|
+
}
|
|
6054
6209
|
} else if ((curr = charAt(offset)) === "*") { /* Block */
|
|
6055
|
-
|
|
6210
|
+
// check for /** (regular comment mode) or /* (alternate comment mode)
|
|
6211
|
+
start = offset + 1;
|
|
6212
|
+
isDoc = alternateCommentMode || charAt(start) === "*";
|
|
6056
6213
|
do {
|
|
6057
|
-
if (curr === "\n")
|
|
6214
|
+
if (curr === "\n") {
|
|
6058
6215
|
++line;
|
|
6059
|
-
|
|
6216
|
+
}
|
|
6217
|
+
if (++offset === length) {
|
|
6060
6218
|
throw illegal("comment");
|
|
6219
|
+
}
|
|
6061
6220
|
prev = curr;
|
|
6062
6221
|
curr = charAt(offset);
|
|
6063
6222
|
} while (prev !== "*" || curr !== "/");
|
|
6064
6223
|
++offset;
|
|
6065
|
-
if (isDoc)
|
|
6224
|
+
if (isDoc) {
|
|
6066
6225
|
setComment(start, offset - 2);
|
|
6226
|
+
}
|
|
6067
6227
|
repeat = true;
|
|
6068
|
-
} else
|
|
6228
|
+
} else {
|
|
6069
6229
|
return "/";
|
|
6230
|
+
}
|
|
6070
6231
|
}
|
|
6071
6232
|
} while (repeat);
|
|
6072
6233
|
|
|
@@ -6138,14 +6299,17 @@ function tokenize(source) {
|
|
|
6138
6299
|
function cmnt(trailingLine) {
|
|
6139
6300
|
var ret = null;
|
|
6140
6301
|
if (trailingLine === undefined) {
|
|
6141
|
-
if (commentLine === line - 1 && (commentType === "*" || commentLineEmpty))
|
|
6302
|
+
if (commentLine === line - 1 && (alternateCommentMode || commentType === "*" || commentLineEmpty)) {
|
|
6142
6303
|
ret = commentText;
|
|
6304
|
+
}
|
|
6143
6305
|
} else {
|
|
6144
6306
|
/* istanbul ignore else */
|
|
6145
|
-
if (commentLine < trailingLine)
|
|
6307
|
+
if (commentLine < trailingLine) {
|
|
6146
6308
|
peek();
|
|
6147
|
-
|
|
6309
|
+
}
|
|
6310
|
+
if (commentLine === trailingLine && !commentLineEmpty && (alternateCommentMode || commentType === "/")) {
|
|
6148
6311
|
ret = commentText;
|
|
6312
|
+
}
|
|
6149
6313
|
}
|
|
6150
6314
|
return ret;
|
|
6151
6315
|
}
|
|
@@ -6435,23 +6599,28 @@ Type.fromJSON = function fromJSON(name, json) {
|
|
|
6435
6599
|
type.reserved = json.reserved;
|
|
6436
6600
|
if (json.group)
|
|
6437
6601
|
type.group = true;
|
|
6602
|
+
if (json.comment)
|
|
6603
|
+
type.comment = json.comment;
|
|
6438
6604
|
return type;
|
|
6439
6605
|
};
|
|
6440
6606
|
|
|
6441
6607
|
/**
|
|
6442
6608
|
* Converts this message type to a message type descriptor.
|
|
6609
|
+
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
6443
6610
|
* @returns {IType} Message type descriptor
|
|
6444
6611
|
*/
|
|
6445
|
-
Type.prototype.toJSON = function toJSON() {
|
|
6446
|
-
var inherited = Namespace.prototype.toJSON.call(this);
|
|
6612
|
+
Type.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
6613
|
+
var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
|
|
6614
|
+
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
6447
6615
|
return util.toObject([
|
|
6448
6616
|
"options" , inherited && inherited.options || undefined,
|
|
6449
|
-
"oneofs" , Namespace.arrayToJSON(this.oneofsArray),
|
|
6450
|
-
"fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; })) || {},
|
|
6617
|
+
"oneofs" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions),
|
|
6618
|
+
"fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {},
|
|
6451
6619
|
"extensions" , this.extensions && this.extensions.length ? this.extensions : undefined,
|
|
6452
6620
|
"reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
|
|
6453
6621
|
"group" , this.group || undefined,
|
|
6454
|
-
"nested" , inherited && inherited.nested || undefined
|
|
6622
|
+
"nested" , inherited && inherited.nested || undefined,
|
|
6623
|
+
"comment" , keepComments ? this.comment : undefined
|
|
6455
6624
|
]);
|
|
6456
6625
|
};
|
|
6457
6626
|
|
|
@@ -7356,6 +7525,12 @@ util.pool = require(9);
|
|
|
7356
7525
|
// utility to work with the low and high bits of a 64 bit value
|
|
7357
7526
|
util.LongBits = require(38);
|
|
7358
7527
|
|
|
7528
|
+
// global object reference
|
|
7529
|
+
util.global = typeof window !== "undefined" && window
|
|
7530
|
+
|| typeof global !== "undefined" && global
|
|
7531
|
+
|| typeof self !== "undefined" && self
|
|
7532
|
+
|| this; // eslint-disable-line no-invalid-this
|
|
7533
|
+
|
|
7359
7534
|
/**
|
|
7360
7535
|
* An immuable empty array.
|
|
7361
7536
|
* @memberof util
|
|
@@ -7377,7 +7552,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next *
|
|
|
7377
7552
|
* @type {boolean}
|
|
7378
7553
|
* @const
|
|
7379
7554
|
*/
|
|
7380
|
-
util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node);
|
|
7555
|
+
util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node);
|
|
7381
7556
|
|
|
7382
7557
|
/**
|
|
7383
7558
|
* Tests if the specified value is an integer.
|
|
@@ -7495,7 +7670,9 @@ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore n
|
|
|
7495
7670
|
* Long.js's Long class if available.
|
|
7496
7671
|
* @type {Constructor<Long>}
|
|
7497
7672
|
*/
|
|
7498
|
-
util.Long = /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long
|
|
7673
|
+
util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
|
|
7674
|
+
|| /* istanbul ignore next */ util.global.Long
|
|
7675
|
+
|| util.inquire("long");
|
|
7499
7676
|
|
|
7500
7677
|
/**
|
|
7501
7678
|
* Regular expression used to verify 2 bit (`bool`) map keys.
|
|
@@ -7714,6 +7891,7 @@ util.toJSONOptions = {
|
|
|
7714
7891
|
json: true
|
|
7715
7892
|
};
|
|
7716
7893
|
|
|
7894
|
+
// Sets up buffer utility according to the environment (called in index-minimal)
|
|
7717
7895
|
util._configure = function() {
|
|
7718
7896
|
var Buffer = util.Buffer;
|
|
7719
7897
|
/* istanbul ignore if */
|
|
@@ -8544,5 +8722,5 @@ BufferWriter.prototype.string = function write_string_buffer(value) {
|
|
|
8544
8722
|
|
|
8545
8723
|
},{"39":39,"42":42}]},{},[19])
|
|
8546
8724
|
|
|
8547
|
-
})(
|
|
8725
|
+
})();
|
|
8548
8726
|
//# sourceMappingURL=protobuf.js.map
|