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.
Files changed (52) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +2 -2
  3. package/cli/node_modules/os-tmpdir/index.js +25 -0
  4. package/cli/node_modules/os-tmpdir/license +21 -0
  5. package/cli/node_modules/os-tmpdir/readme.md +32 -0
  6. package/cli/node_modules/tmp/LICENSE +21 -0
  7. package/cli/node_modules/tmp/README.md +314 -0
  8. package/cli/node_modules/tmp/lib/tmp.js +611 -0
  9. package/cli/pbjs.d.ts +1 -1
  10. package/cli/pbjs.js +11 -1
  11. package/cli/pbts.d.ts +1 -1
  12. package/cli/pbts.js +36 -7
  13. package/cli/targets/proto.js +1 -1
  14. package/cli/targets/static.js +3 -6
  15. package/dist/light/protobuf.js +143 -64
  16. package/dist/light/protobuf.js.map +1 -1
  17. package/dist/light/protobuf.min.js +3 -3
  18. package/dist/light/protobuf.min.js.map +1 -1
  19. package/dist/minimal/protobuf.js +23 -14
  20. package/dist/minimal/protobuf.js.map +1 -1
  21. package/dist/minimal/protobuf.min.js +3 -3
  22. package/dist/minimal/protobuf.min.js.map +1 -1
  23. package/dist/protobuf.js +268 -90
  24. package/dist/protobuf.js.map +1 -1
  25. package/dist/protobuf.min.js +3 -3
  26. package/dist/protobuf.min.js.map +1 -1
  27. package/ext/descriptor/index.d.ts +0 -1
  28. package/ext/descriptor/index.js +3 -0
  29. package/index.d.ts +57 -16
  30. package/package-lock.json +4579 -3191
  31. package/package.json +122 -125
  32. package/src/common.js +22 -1
  33. package/src/converter.js +9 -3
  34. package/src/enum.js +17 -5
  35. package/src/field.js +17 -4
  36. package/src/index-light.js +2 -2
  37. package/src/index-minimal.js +1 -1
  38. package/src/mapfield.js +9 -5
  39. package/src/message.js +1 -1
  40. package/src/method.js +14 -4
  41. package/src/namespace.js +14 -10
  42. package/src/object.js +1 -0
  43. package/src/oneof.js +14 -4
  44. package/src/parse.js +11 -3
  45. package/src/reader.js +2 -4
  46. package/src/root.js +3 -2
  47. package/src/service.js +8 -4
  48. package/src/tokenize.js +92 -22
  49. package/src/type.js +10 -5
  50. package/src/util/minimal.js +11 -2
  51. package/google/protobuf/field_mask.json +0 -21
  52. package/google/protobuf/field_mask.proto +0 -7
@@ -1,15 +1,15 @@
1
1
  /*!
2
- * protobuf.js v6.8.4 (c) 2016, daniel wirtz
3
- * compiled thu, 04 jan 2018 21:51:39 utc
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(global,undefined){"use strict";(function prelude(modules, cache, entries) {
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 unified `global` and a minification-friendly `undefined` var plus a global
12
- // "use strict" directive so that minification can remove the directives of each module.
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
- var protobuf = global.protobuf = $require(entries[0]);
24
+ protobuf.util.global.protobuf = protobuf;
23
25
 
24
26
  // Be nice to AMD
25
27
  if (typeof define === "function" && define.amd)
@@ -1353,9 +1355,15 @@ converter.toObject = function toObject(mtype) {
1353
1355
  ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
1354
1356
  ("}else")
1355
1357
  ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
1356
- else if (field.bytes) gen
1357
- ("d%s=o.bytes===String?%j:%s", prop, String.fromCharCode.apply(String, field.typeDefault), "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]");
1358
- else gen
1358
+ else if (field.bytes) {
1359
+ var arrayDefault = "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]";
1360
+ gen
1361
+ ("if(o.bytes===String)d%s=%j", prop, String.fromCharCode.apply(String, field.typeDefault))
1362
+ ("else{")
1363
+ ("d%s=%s", prop, arrayDefault)
1364
+ ("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop)
1365
+ ("}");
1366
+ } else gen
1359
1367
  ("d%s=%j", prop, field.typeDefault); // also messages (=null)
1360
1368
  } gen
1361
1369
  ("}");
@@ -1623,8 +1631,10 @@ var Namespace = require(21),
1623
1631
  * @param {string} name Unique name within its namespace
1624
1632
  * @param {Object.<string,number>} [values] Enum values as an object, by name
1625
1633
  * @param {Object.<string,*>} [options] Declared options
1634
+ * @param {string} [comment] The comment for this enum
1635
+ * @param {Object.<string,string>} [comments] The value comments for this enum
1626
1636
  */
1627
- function Enum(name, values, options) {
1637
+ function Enum(name, values, options, comment, comments) {
1628
1638
  ReflectionObject.call(this, name, options);
1629
1639
 
1630
1640
  if (values && typeof values !== "object")
@@ -1642,11 +1652,17 @@ function Enum(name, values, options) {
1642
1652
  */
1643
1653
  this.values = Object.create(this.valuesById); // toJSON, marker
1644
1654
 
1655
+ /**
1656
+ * Enum comment text.
1657
+ * @type {string|null}
1658
+ */
1659
+ this.comment = comment;
1660
+
1645
1661
  /**
1646
1662
  * Value comment texts, if any.
1647
1663
  * @type {Object.<string,string>}
1648
1664
  */
1649
- this.comments = {};
1665
+ this.comments = comments || {};
1650
1666
 
1651
1667
  /**
1652
1668
  * Reserved ranges, if any.
@@ -1679,20 +1695,24 @@ function Enum(name, values, options) {
1679
1695
  * @throws {TypeError} If arguments are invalid
1680
1696
  */
1681
1697
  Enum.fromJSON = function fromJSON(name, json) {
1682
- var enm = new Enum(name, json.values, json.options);
1698
+ var enm = new Enum(name, json.values, json.options, json.comment, json.comments);
1683
1699
  enm.reserved = json.reserved;
1684
1700
  return enm;
1685
1701
  };
1686
1702
 
1687
1703
  /**
1688
1704
  * Converts this enum to an enum descriptor.
1705
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
1689
1706
  * @returns {IEnum} Enum descriptor
1690
1707
  */
1691
- Enum.prototype.toJSON = function toJSON() {
1708
+ Enum.prototype.toJSON = function toJSON(toJSONOptions) {
1709
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
1692
1710
  return util.toObject([
1693
1711
  "options" , this.options,
1694
1712
  "values" , this.values,
1695
- "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined
1713
+ "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
1714
+ "comment" , keepComments ? this.comment : undefined,
1715
+ "comments" , keepComments ? this.comments : undefined
1696
1716
  ]);
1697
1717
  };
1698
1718
 
@@ -1813,7 +1833,7 @@ var ruleRe = /^required|optional|repeated$/;
1813
1833
  * @throws {TypeError} If arguments are invalid
1814
1834
  */
1815
1835
  Field.fromJSON = function fromJSON(name, json) {
1816
- return new Field(name, json.id, json.type, json.rule, json.extend, json.options);
1836
+ return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment);
1817
1837
  };
1818
1838
 
1819
1839
  /**
@@ -1828,13 +1848,16 @@ Field.fromJSON = function fromJSON(name, json) {
1828
1848
  * @param {string|Object.<string,*>} [rule="optional"] Field rule
1829
1849
  * @param {string|Object.<string,*>} [extend] Extended type if different from parent
1830
1850
  * @param {Object.<string,*>} [options] Declared options
1851
+ * @param {string} [comment] Comment associated with this field
1831
1852
  */
1832
- function Field(name, id, type, rule, extend, options) {
1853
+ function Field(name, id, type, rule, extend, options, comment) {
1833
1854
 
1834
1855
  if (util.isObject(rule)) {
1856
+ comment = extend;
1835
1857
  options = rule;
1836
1858
  rule = extend = undefined;
1837
1859
  } else if (util.isObject(extend)) {
1860
+ comment = options;
1838
1861
  options = extend;
1839
1862
  extend = undefined;
1840
1863
  }
@@ -1961,6 +1984,12 @@ function Field(name, id, type, rule, extend, options) {
1961
1984
  * @private
1962
1985
  */
1963
1986
  this._packed = null;
1987
+
1988
+ /**
1989
+ * Comment for this field.
1990
+ * @type {string|null}
1991
+ */
1992
+ this.comment = comment;
1964
1993
  }
1965
1994
 
1966
1995
  /**
@@ -2005,15 +2034,18 @@ Field.prototype.setOption = function setOption(name, value, ifNotSet) {
2005
2034
 
2006
2035
  /**
2007
2036
  * Converts this field to a field descriptor.
2037
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
2008
2038
  * @returns {IField} Field descriptor
2009
2039
  */
2010
- Field.prototype.toJSON = function toJSON() {
2040
+ Field.prototype.toJSON = function toJSON(toJSONOptions) {
2041
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
2011
2042
  return util.toObject([
2012
2043
  "rule" , this.rule !== "optional" && this.rule || undefined,
2013
2044
  "type" , this.type,
2014
2045
  "id" , this.id,
2015
2046
  "extend" , this.extend,
2016
- "options" , this.options
2047
+ "options" , this.options,
2048
+ "comment" , keepComments ? this.comment : undefined
2017
2049
  ]);
2018
2050
  };
2019
2051
 
@@ -2131,6 +2163,7 @@ Field.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) {
2131
2163
  */
2132
2164
  // like Field.d but without a default value
2133
2165
 
2166
+ // Sets up cyclic dependencies (called in index-light)
2134
2167
  Field._configure = function configure(Type_) {
2135
2168
  Type = Type_;
2136
2169
  };
@@ -2235,9 +2268,9 @@ protobuf.wrappers = require(37);
2235
2268
  protobuf.types = require(32);
2236
2269
  protobuf.util = require(33);
2237
2270
 
2238
- // Configure reflection
2271
+ // Set up possibly cyclic reflection dependencies
2239
2272
  protobuf.ReflectionObject._configure(protobuf.Root);
2240
- protobuf.Namespace._configure(protobuf.Type, protobuf.Service);
2273
+ protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);
2241
2274
  protobuf.Root._configure(protobuf.Type);
2242
2275
  protobuf.Field._configure(protobuf.Type);
2243
2276
 
@@ -2275,7 +2308,7 @@ function configure() {
2275
2308
  protobuf.util._configure();
2276
2309
  }
2277
2310
 
2278
- // Configure serialization
2311
+ // Set up buffer utility according to the environment
2279
2312
  protobuf.Writer._configure(protobuf.BufferWriter);
2280
2313
  configure();
2281
2314
 
@@ -2300,9 +2333,10 @@ var types = require(32),
2300
2333
  * @param {string} keyType Key type
2301
2334
  * @param {string} type Value type
2302
2335
  * @param {Object.<string,*>} [options] Declared options
2336
+ * @param {string} [comment] Comment associated with this field
2303
2337
  */
2304
- function MapField(name, id, keyType, type, options) {
2305
- Field.call(this, name, id, type, options);
2338
+ function MapField(name, id, keyType, type, options, comment) {
2339
+ Field.call(this, name, id, type, undefined, undefined, options, comment);
2306
2340
 
2307
2341
  /* istanbul ignore if */
2308
2342
  if (!util.isString(keyType))
@@ -2346,20 +2380,23 @@ function MapField(name, id, keyType, type, options) {
2346
2380
  * @throws {TypeError} If arguments are invalid
2347
2381
  */
2348
2382
  MapField.fromJSON = function fromJSON(name, json) {
2349
- return new MapField(name, json.id, json.keyType, json.type, json.options);
2383
+ return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment);
2350
2384
  };
2351
2385
 
2352
2386
  /**
2353
2387
  * Converts this map field to a map field descriptor.
2388
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
2354
2389
  * @returns {IMapField} Map field descriptor
2355
2390
  */
2356
- MapField.prototype.toJSON = function toJSON() {
2391
+ MapField.prototype.toJSON = function toJSON(toJSONOptions) {
2392
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
2357
2393
  return util.toObject([
2358
2394
  "keyType" , this.keyType,
2359
2395
  "type" , this.type,
2360
2396
  "id" , this.id,
2361
2397
  "extend" , this.extend,
2362
- "options" , this.options
2398
+ "options" , this.options,
2399
+ "comment" , keepComments ? this.comment : undefined
2363
2400
  ]);
2364
2401
  };
2365
2402
 
@@ -2414,7 +2451,7 @@ var util = require(35);
2414
2451
  * @classdesc Abstract runtime message.
2415
2452
  * @constructor
2416
2453
  * @param {Properties<T>} [properties] Properties to set
2417
- * @template T extends object
2454
+ * @template T extends object = object
2418
2455
  */
2419
2456
  function Message(properties) {
2420
2457
  // not used internally
@@ -2565,8 +2602,9 @@ var util = require(33);
2565
2602
  * @param {boolean|Object.<string,*>} [requestStream] Whether the request is streamed
2566
2603
  * @param {boolean|Object.<string,*>} [responseStream] Whether the response is streamed
2567
2604
  * @param {Object.<string,*>} [options] Declared options
2605
+ * @param {string} [comment] The comment for this method
2568
2606
  */
2569
- function Method(name, type, requestType, responseType, requestStream, responseStream, options) {
2607
+ function Method(name, type, requestType, responseType, requestStream, responseStream, options, comment) {
2570
2608
 
2571
2609
  /* istanbul ignore next */
2572
2610
  if (util.isObject(requestStream)) {
@@ -2632,6 +2670,12 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
2632
2670
  * @type {Type|null}
2633
2671
  */
2634
2672
  this.resolvedResponseType = null;
2673
+
2674
+ /**
2675
+ * Comment for this method
2676
+ * @type {string|null}
2677
+ */
2678
+ this.comment = comment;
2635
2679
  }
2636
2680
 
2637
2681
  /**
@@ -2653,21 +2697,24 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
2653
2697
  * @throws {TypeError} If arguments are invalid
2654
2698
  */
2655
2699
  Method.fromJSON = function fromJSON(name, json) {
2656
- return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options);
2700
+ return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment);
2657
2701
  };
2658
2702
 
2659
2703
  /**
2660
2704
  * Converts this method to a method descriptor.
2705
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
2661
2706
  * @returns {IMethod} Method descriptor
2662
2707
  */
2663
- Method.prototype.toJSON = function toJSON() {
2708
+ Method.prototype.toJSON = function toJSON(toJSONOptions) {
2709
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
2664
2710
  return util.toObject([
2665
2711
  "type" , this.type !== "rpc" && /* istanbul ignore next */ this.type || undefined,
2666
2712
  "requestType" , this.requestType,
2667
2713
  "requestStream" , this.requestStream,
2668
2714
  "responseType" , this.responseType,
2669
2715
  "responseStream" , this.responseStream,
2670
- "options" , this.options
2716
+ "options" , this.options,
2717
+ "comment" , keepComments ? this.comment : undefined
2671
2718
  ]);
2672
2719
  };
2673
2720
 
@@ -2694,12 +2741,12 @@ module.exports = Namespace;
2694
2741
  var ReflectionObject = require(22);
2695
2742
  ((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
2696
2743
 
2697
- var Enum = require(14),
2698
- Field = require(15),
2744
+ var Field = require(15),
2699
2745
  util = require(33);
2700
2746
 
2701
2747
  var Type, // cyclic
2702
- Service; // "
2748
+ Service,
2749
+ Enum;
2703
2750
 
2704
2751
  /**
2705
2752
  * Constructs a new namespace instance.
@@ -2728,14 +2775,15 @@ Namespace.fromJSON = function fromJSON(name, json) {
2728
2775
  * Converts an array of reflection objects to JSON.
2729
2776
  * @memberof Namespace
2730
2777
  * @param {ReflectionObject[]} array Object array
2778
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
2731
2779
  * @returns {Object.<string,*>|undefined} JSON object or `undefined` when array is empty
2732
2780
  */
2733
- function arrayToJSON(array) {
2781
+ function arrayToJSON(array, toJSONOptions) {
2734
2782
  if (!(array && array.length))
2735
2783
  return undefined;
2736
2784
  var obj = {};
2737
2785
  for (var i = 0; i < array.length; ++i)
2738
- obj[array[i].name] = array[i].toJSON();
2786
+ obj[array[i].name] = array[i].toJSON(toJSONOptions);
2739
2787
  return obj;
2740
2788
  }
2741
2789
 
@@ -2836,12 +2884,13 @@ Object.defineProperty(Namespace.prototype, "nestedArray", {
2836
2884
 
2837
2885
  /**
2838
2886
  * Converts this namespace to a namespace descriptor.
2887
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
2839
2888
  * @returns {INamespace} Namespace descriptor
2840
2889
  */
2841
- Namespace.prototype.toJSON = function toJSON() {
2890
+ Namespace.prototype.toJSON = function toJSON(toJSONOptions) {
2842
2891
  return util.toObject([
2843
2892
  "options" , this.options,
2844
- "nested" , arrayToJSON(this.nestedArray)
2893
+ "nested" , arrayToJSON(this.nestedArray, toJSONOptions)
2845
2894
  ]);
2846
2895
  };
2847
2896
 
@@ -2892,7 +2941,7 @@ Namespace.prototype.get = function get(name) {
2892
2941
  Namespace.prototype.getEnum = function getEnum(name) {
2893
2942
  if (this.nested && this.nested[name] instanceof Enum)
2894
2943
  return this.nested[name].values;
2895
- throw Error("no such enum");
2944
+ throw Error("no such enum: " + name);
2896
2945
  };
2897
2946
 
2898
2947
  /**
@@ -3066,7 +3115,7 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
3066
3115
  Namespace.prototype.lookupType = function lookupType(path) {
3067
3116
  var found = this.lookup(path, [ Type ]);
3068
3117
  if (!found)
3069
- throw Error("no such type");
3118
+ throw Error("no such type: " + path);
3070
3119
  return found;
3071
3120
  };
3072
3121
 
@@ -3112,12 +3161,14 @@ Namespace.prototype.lookupService = function lookupService(path) {
3112
3161
  return found;
3113
3162
  };
3114
3163
 
3115
- Namespace._configure = function(Type_, Service_) {
3164
+ // Sets up cyclic dependencies (called in index-light)
3165
+ Namespace._configure = function(Type_, Service_, Enum_) {
3116
3166
  Type = Type_;
3117
3167
  Service = Service_;
3168
+ Enum = Enum_;
3118
3169
  };
3119
3170
 
3120
- },{"14":14,"15":15,"22":22,"33":33}],22:[function(require,module,exports){
3171
+ },{"15":15,"22":22,"33":33}],22:[function(require,module,exports){
3121
3172
  "use strict";
3122
3173
  module.exports = ReflectionObject;
3123
3174
 
@@ -3314,6 +3365,7 @@ ReflectionObject.prototype.toString = function toString() {
3314
3365
  return className;
3315
3366
  };
3316
3367
 
3368
+ // Sets up cyclic dependencies (called in index-light)
3317
3369
  ReflectionObject._configure = function(Root_) {
3318
3370
  Root = Root_;
3319
3371
  };
@@ -3337,8 +3389,9 @@ var Field = require(15),
3337
3389
  * @param {string} name Oneof name
3338
3390
  * @param {string[]|Object.<string,*>} [fieldNames] Field names
3339
3391
  * @param {Object.<string,*>} [options] Declared options
3392
+ * @param {string} [comment] Comment associated with this field
3340
3393
  */
3341
- function OneOf(name, fieldNames, options) {
3394
+ function OneOf(name, fieldNames, options, comment) {
3342
3395
  if (!Array.isArray(fieldNames)) {
3343
3396
  options = fieldNames;
3344
3397
  fieldNames = undefined;
@@ -3361,6 +3414,12 @@ function OneOf(name, fieldNames, options) {
3361
3414
  * @readonly
3362
3415
  */
3363
3416
  this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent
3417
+
3418
+ /**
3419
+ * Comment for this field.
3420
+ * @type {string|null}
3421
+ */
3422
+ this.comment = comment;
3364
3423
  }
3365
3424
 
3366
3425
  /**
@@ -3378,17 +3437,20 @@ function OneOf(name, fieldNames, options) {
3378
3437
  * @throws {TypeError} If arguments are invalid
3379
3438
  */
3380
3439
  OneOf.fromJSON = function fromJSON(name, json) {
3381
- return new OneOf(name, json.oneof, json.options);
3440
+ return new OneOf(name, json.oneof, json.options, json.comment);
3382
3441
  };
3383
3442
 
3384
3443
  /**
3385
3444
  * Converts this oneof to a oneof descriptor.
3445
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
3386
3446
  * @returns {IOneOf} Oneof descriptor
3387
3447
  */
3388
- OneOf.prototype.toJSON = function toJSON() {
3448
+ OneOf.prototype.toJSON = function toJSON(toJSONOptions) {
3449
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
3389
3450
  return util.toObject([
3390
3451
  "options" , this.options,
3391
- "oneof" , this.oneof
3452
+ "oneof" , this.oneof,
3453
+ "comment" , keepComments ? this.comment : undefined
3392
3454
  ]);
3393
3455
  };
3394
3456
 
@@ -3876,11 +3938,9 @@ Reader.prototype.skipType = function(wireType) {
3876
3938
  this.skip(this.uint32());
3877
3939
  break;
3878
3940
  case 3:
3879
- do { // eslint-disable-line no-constant-condition
3880
- if ((wireType = this.uint32() & 7) === 4)
3881
- break;
3941
+ while ((wireType = this.uint32() & 7) !== 4) {
3882
3942
  this.skipType(wireType);
3883
- } while (true);
3943
+ }
3884
3944
  break;
3885
3945
  case 5:
3886
3946
  this.skip(4);
@@ -4314,9 +4374,10 @@ Root.prototype._handleRemove = function _handleRemove(object) {
4314
4374
  }
4315
4375
  };
4316
4376
 
4377
+ // Sets up cyclic dependencies (called in index-light)
4317
4378
  Root._configure = function(Type_, parse_, common_) {
4318
- Type = Type_;
4319
- parse = parse_;
4379
+ Type = Type_;
4380
+ parse = parse_;
4320
4381
  common = common_;
4321
4382
  };
4322
4383
 
@@ -4582,19 +4643,23 @@ Service.fromJSON = function fromJSON(name, json) {
4582
4643
  service.add(Method.fromJSON(names[i], json.methods[names[i]]));
4583
4644
  if (json.nested)
4584
4645
  service.addJSON(json.nested);
4646
+ service.comment = json.comment;
4585
4647
  return service;
4586
4648
  };
4587
4649
 
4588
4650
  /**
4589
4651
  * Converts this service to a service descriptor.
4652
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
4590
4653
  * @returns {IService} Service descriptor
4591
4654
  */
4592
- Service.prototype.toJSON = function toJSON() {
4593
- var inherited = Namespace.prototype.toJSON.call(this);
4655
+ Service.prototype.toJSON = function toJSON(toJSONOptions) {
4656
+ var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
4657
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
4594
4658
  return util.toObject([
4595
4659
  "options" , inherited && inherited.options || undefined,
4596
- "methods" , Namespace.arrayToJSON(this.methodsArray) || /* istanbul ignore next */ {},
4597
- "nested" , inherited && inherited.nested || undefined
4660
+ "methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {},
4661
+ "nested" , inherited && inherited.nested || undefined,
4662
+ "comment" , keepComments ? this.comment : undefined
4598
4663
  ]);
4599
4664
  };
4600
4665
 
@@ -4960,23 +5025,28 @@ Type.fromJSON = function fromJSON(name, json) {
4960
5025
  type.reserved = json.reserved;
4961
5026
  if (json.group)
4962
5027
  type.group = true;
5028
+ if (json.comment)
5029
+ type.comment = json.comment;
4963
5030
  return type;
4964
5031
  };
4965
5032
 
4966
5033
  /**
4967
5034
  * Converts this message type to a message type descriptor.
5035
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
4968
5036
  * @returns {IType} Message type descriptor
4969
5037
  */
4970
- Type.prototype.toJSON = function toJSON() {
4971
- var inherited = Namespace.prototype.toJSON.call(this);
5038
+ Type.prototype.toJSON = function toJSON(toJSONOptions) {
5039
+ var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
5040
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
4972
5041
  return util.toObject([
4973
5042
  "options" , inherited && inherited.options || undefined,
4974
- "oneofs" , Namespace.arrayToJSON(this.oneofsArray),
4975
- "fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; })) || {},
5043
+ "oneofs" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions),
5044
+ "fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {},
4976
5045
  "extensions" , this.extensions && this.extensions.length ? this.extensions : undefined,
4977
5046
  "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
4978
5047
  "group" , this.group || undefined,
4979
- "nested" , inherited && inherited.nested || undefined
5048
+ "nested" , inherited && inherited.nested || undefined,
5049
+ "comment" , keepComments ? this.comment : undefined
4980
5050
  ]);
4981
5051
  };
4982
5052
 
@@ -5881,6 +5951,12 @@ util.pool = require(9);
5881
5951
  // utility to work with the low and high bits of a 64 bit value
5882
5952
  util.LongBits = require(34);
5883
5953
 
5954
+ // global object reference
5955
+ util.global = typeof window !== "undefined" && window
5956
+ || typeof global !== "undefined" && global
5957
+ || typeof self !== "undefined" && self
5958
+ || this; // eslint-disable-line no-invalid-this
5959
+
5884
5960
  /**
5885
5961
  * An immuable empty array.
5886
5962
  * @memberof util
@@ -5902,7 +5978,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next *
5902
5978
  * @type {boolean}
5903
5979
  * @const
5904
5980
  */
5905
- util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node);
5981
+ util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node);
5906
5982
 
5907
5983
  /**
5908
5984
  * Tests if the specified value is an integer.
@@ -6020,7 +6096,9 @@ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore n
6020
6096
  * Long.js's Long class if available.
6021
6097
  * @type {Constructor<Long>}
6022
6098
  */
6023
- util.Long = /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long || util.inquire("long");
6099
+ util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
6100
+ || /* istanbul ignore next */ util.global.Long
6101
+ || util.inquire("long");
6024
6102
 
6025
6103
  /**
6026
6104
  * Regular expression used to verify 2 bit (`bool`) map keys.
@@ -6239,6 +6317,7 @@ util.toJSONOptions = {
6239
6317
  json: true
6240
6318
  };
6241
6319
 
6320
+ // Sets up buffer utility according to the environment (called in index-minimal)
6242
6321
  util._configure = function() {
6243
6322
  var Buffer = util.Buffer;
6244
6323
  /* istanbul ignore if */
@@ -7069,5 +7148,5 @@ BufferWriter.prototype.string = function write_string_buffer(value) {
7069
7148
 
7070
7149
  },{"35":35,"38":38}]},{},[16])
7071
7150
 
7072
- })(typeof window==="object"&&window||typeof self==="object"&&self||this);
7151
+ })();
7073
7152
  //# sourceMappingURL=protobuf.js.map